Skip to content
Merged
2 changes: 1 addition & 1 deletion hack/build-image
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ PACKAGES_FROM = {
DEFAULT: "",
NIGHTLY: "samba-nightly",
DEVBUILDS: "devbuilds",
CUSTOM: "custom-repo"
CUSTOM: "custom-repos"
}

# SOURCE_DIRS - image source paths
Expand Down
6 changes: 2 additions & 4 deletions images/server/Containerfile.centos
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ ARG INSTALL_PACKAGES_FROM=default
ARG SAMBA_VERSION_SUFFIX=""
ARG SAMBACC_VERSION_SUFFIX=""
ARG SAMBA_SPECIFICS=daemon_cli_debug_output,ctdb_leader_admin_command
ARG INSTALL_CUSTOM_REPO=
ARG INSTALL_CUSTOM_REPOS=
ARG PACKAGE_SELECTION=
ARG CUSTOM_REPOS=

MAINTAINER John Mulligan <[email protected]>

Expand All @@ -20,8 +19,7 @@ COPY install-packages.sh /usr/local/bin/install-packages.sh
RUN /usr/local/bin/install-packages.sh \
"--install-packages-from=${INSTALL_PACKAGES_FROM}" \
"--samba-version-suffix=${SAMBA_VERSION_SUFFIX}" \
"--install-custom-repo=${INSTALL_CUSTOM_REPO}" \
"--custom-repos=${CUSTOM_REPOS}" \
"--install-custom-repos=${INSTALL_CUSTOM_REPOS}" \
"--package-selection=${PACKAGE_SELECTION}"

# If you want to install a custom version of sambacc into this image mount
Expand Down
73 changes: 39 additions & 34 deletions images/server/install-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,30 @@ need_curl() {
dnf install --setopt=install_weak_deps=False -y /usr/bin/curl
}

get_custom_repo() {
url="$1"
fname="$(basename "$url")"
dest="/etc/yum.repos.d/${fname}"
while [ -e "$dest" ]; do
u="$(echo "${url}" | sha256sum | head -c12)"
if [ -z "$u" ]; then
echo "failed to uniquify repo file name"
exit 2
get_custom_repos() {
if [[ -n $1 ]]; then
urls=$1
need_curl
if [[ $ceph_from_custom -ne 1 ]]; then
get_distro_ceph_repo
fi
dest="/etc/yum.repos.d/${u}-${fname}"
done
need_curl
curl -L "$url" -o "$dest"
for url in $urls; do
fname="$(basename "$url")"
dest="/etc/yum.repos.d/${fname}"
if [ -e "$dest" ]; then
u="$(echo "${url}" | sha256sum | head -c12)"
if [ -z "$u" ]; then
echo "failed to uniquify repo file name"
exit 2
fi
dest="/etc/yum.repos.d/${u}-${fname}"
if [ -e "$dest" ]; then
continue
fi
fi
curl -L "$url" -o "$dest"
done
fi
}

generate_repo_from_shaman() {
Expand All @@ -49,7 +59,7 @@ EOF
}

get_samba_nightly_repo() {
get_custom_repo "https://artifacts.ci.centos.org/samba/pkgs/master/${OS_BASE}/samba-nightly-master.repo"
get_custom_repos "https://artifacts.ci.centos.org/samba/pkgs/master/${OS_BASE}/samba-nightly-master.repo"
}

get_sig_samba_repo() {
Expand All @@ -72,6 +82,12 @@ get_epel_repo_if_needed() {
fi
}

get_glusterfs_repo_if_needed() {
if [[ "${OS_BASE}" = centos ]]; then
dnf install --setopt=install_weak_deps=False -y centos-release-gluster
fi
}

get_ceph_shaman_repo() {
ceph_ref="${CEPH_REPO_REF:-main}"
ceph_sha="${CEPH_REPO_SHA:-latest}"
Expand All @@ -87,12 +103,9 @@ if [[ "$1" =~ ^--.+$ ]]; then
case "$arg" in
--install-packages-from=*) install_packages_from="${arg/*=/}" ;;
--samba-version-suffix=*) samba_version_suffix="${arg/*=/}" ;;
--install-custom-repo=*) install_custom_repo="${arg/*=/}" ;;
--install-custom-repos=*) install_custom_repos="${arg/*=/}" ;;
--package-selection=*) package_selection="${arg/*=/}" ;;
--custom-repos=*)
IFS=' ' read -ra custom_repos <<< "${arg/*=/}"
for x in "${custom_repos[@]}"; do echo custom repo: "$x"; done
;;
--ceph-from-custom) ceph_from_custom=1 ;;
*)
echo "error: unexpected argument: ${arg}"
exit 2
Expand All @@ -103,14 +116,15 @@ else
# legacy positional only
install_packages_from="$1"
samba_version_suffix="$2"
install_custom_repo="$3"
install_custom_repos="$3"
package_selection="$4"
fi

# shellcheck disable=SC1091
OS_BASE="$(. /etc/os-release && echo "${ID}")"

get_epel_repo_if_needed
get_glusterfs_repo_if_needed

case "${install_packages_from}" in
samba-nightly)
Expand All @@ -124,20 +138,12 @@ case "${install_packages_from}" in
get_ceph_shaman_repo
package_selection=${package_selection:-devbuilds}
;;
custom-repo)
get_custom_repo "${install_custom_repo}"
customized=0
for crepo in "${custom_repos[@]}" ; do
get_custom_repo "${crepo}"
customized=1
done
if [ $customized != 1 ]; then
get_distro_ceph_repo
fi
package_selection=${package_selection:-custom}
custom-repos)
get_custom_repos "${install_custom_repos}"
package_selection=${package_selection:-custom-repos-devbuilds}
;;
custom-devbuilds)
get_custom_repo "${install_custom_repo}"
get_custom_repos "${install_custom_repos}"
get_ceph_shaman_repo
package_selection=${package_selection:-custom-devbuilds}
;;
Expand Down Expand Up @@ -182,8 +188,7 @@ case "${package_selection}-${OS_BASE}" in
# Fall through to next case
;&
nightly-centos|default-centos)
dnf_cmd+=(--enablerepo=epel)
samba_packages+=(samba-vfs-cephfs ctdb-ceph-mutex)
samba_packages+=(samba-vfs-cephfs samba-vfs-glusterfs ctdb-ceph-mutex)
# these packages should be installed as deps. of sambacc extras
# however, the sambacc builds do not enable the extras on centos atm.
# Once this is fixed this line ought to be removed.
Expand Down