Skip to content

Commit bc7f139

Browse files
phlogistonjohnmergify[bot]
authored andcommitted
images: support a package selection distinct from package sources
Previously, you could set a package source such as 'default' or 'nightly' and, along with the distro, it would enable repos and install a certain packages based on those vars. However, there are times when having the package selection separate from what repos are being enabled is handy. This change adds a new variable, that is unused by default, to directly pick what packages are selected for install. However, by default, this is still derived from the package source variable. Signed-off-by: John Mulligan <[email protected]>
1 parent e3a0a39 commit bc7f139

File tree

2 files changed

+57
-27
lines changed

2 files changed

+57
-27
lines changed

images/ad-server/install-packages.sh

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ get_custom_repo() {
1313
install_packages_from="$1"
1414
samba_version_suffix="$2"
1515
install_custom_repo="$3"
16+
# reserve package_selection. keep args consistent with server image script.
17+
# unused for ad image (for now)
18+
# package_selection="$4"
1619

1720
# shellcheck disable=SC1091
1821
OS_BASE="$(. /etc/os-release && echo "${ID}")"
@@ -26,24 +29,37 @@ case "${install_packages_from}" in
2629
;;
2730
esac
2831

29-
dnf_cmd=(dnf)
30-
if [[ "${OS_BASE}" = centos ]]; then
31-
dnf install -y epel-next-release
32-
dnf_cmd+=(--enablerepo=crb)
33-
fi
3432

35-
packages=(\
33+
# Assorted packages that must be installed in the container image to
34+
# support the functioning of the container
35+
support_packages=(\
3636
findutils \
3737
python-pip \
3838
python3-samba \
3939
python3-pyxattr \
4040
tdb-tools \
41-
"samba-dc${samba_version_suffix}" \
4241
procps-ng \
4342
/usr/bin/smbclient)
43+
# Packages belonging to the samba install. If a samba_version_suffix is given
44+
# all the samba_packages must share that version
45+
samba_packages=(samba-dc)
46+
47+
# Assign version suffix to samba packages
48+
samba_versioned_packages=()
49+
for p in "${samba_packages[@]}"; do
50+
samba_versioned_packages+=("${p}${samba_version_suffix}")
51+
done
52+
53+
dnf_cmd=(dnf)
54+
if [[ "${OS_BASE}" = centos ]]; then
55+
dnf install -y epel-next-release
56+
dnf_cmd+=(--enablerepo=crb)
57+
fi
58+
4459
"${dnf_cmd[@]}" \
4560
install --setopt=install_weak_deps=False -y \
46-
"${packages[@]}"
61+
"${support_packages[@]}" \
62+
"${samba_versioned_packages[@]}"
4763
dnf clean all
4864

4965
rm -rf /etc/samba/smb.conf

images/server/install-packages.sh

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,60 @@ get_custom_repo() {
1313
install_packages_from="$1"
1414
samba_version_suffix="$2"
1515
install_custom_repo="$3"
16+
package_selection="$4"
1617

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

2021
case "${install_packages_from}" in
2122
samba-nightly)
2223
get_custom_repo "https://artifacts.ci.centos.org/samba/pkgs/master/${OS_BASE}/samba-nightly-master.repo"
24+
package_selection=${package_selection:-nightly}
2325
;;
2426
custom-repo)
2527
get_custom_repo "${install_custom_repo}"
2628
;;
2729
esac
2830

2931

30-
dnf_cmd=(dnf)
31-
if [[ "${OS_BASE}" = centos ]]; then
32-
dnf_cmd+=(--enablerepo=crb --enablerepo=resilientstorage)
33-
fi
34-
35-
packages=(\
32+
# Assorted packages that must be installed in the container image to
33+
# support the functioning of the container
34+
support_packages=(\
3635
findutils \
3736
python-pip \
3837
python3-samba \
3938
python3-pyxattr \
40-
"samba${samba_version_suffix}" \
41-
"samba-client${samba_version_suffix}" \
42-
"samba-winbind${samba_version_suffix}" \
43-
"samba-winbind-clients${samba_version_suffix}" \
44-
"samba-vfs-iouring${samba_version_suffix}" \
45-
tdb-tools \
46-
"ctdb${samba_version_suffix}")
47-
if [[ "${OS_BASE}" = fedora ]]; then
48-
packages+=(\
49-
"samba-vfs-cephfs${samba_version_suffix}" \
50-
"samba-vfs-glusterfs${samba_version_suffix}" \
51-
)
39+
tdb-tools)
40+
# Packages belonging to the samba install. If a samba_version_suffix is given
41+
# all the samba_packages must share that version
42+
samba_packages=(\
43+
samba \
44+
samba-client \
45+
samba-winbind \
46+
samba-winbind-clients \
47+
samba-vfs-iouring \
48+
ctdb)
49+
case "${package_selection}-${OS_BASE}" in
50+
*-fedora|allvfs-*)
51+
samba_packages+=(samba-vfs-cephfs samba-vfs-glusterfs)
52+
;;
53+
esac
54+
55+
# Assign version suffix to samba packages
56+
samba_versioned_packages=()
57+
for p in "${samba_packages[@]}"; do
58+
samba_versioned_packages+=("${p}${samba_version_suffix}")
59+
done
60+
61+
dnf_cmd=(dnf)
62+
if [[ "${OS_BASE}" = centos ]]; then
63+
dnf_cmd+=(--enablerepo=crb --enablerepo=resilientstorage)
5264
fi
65+
5366
"${dnf_cmd[@]}" \
5467
install --setopt=install_weak_deps=False -y \
55-
"${packages[@]}"
68+
"${support_packages[@]}" \
69+
"${samba_versioned_packages[@]}"
5670
dnf clean all
5771

5872
cp --preserve=all /etc/ctdb/functions /usr/share/ctdb/functions

0 commit comments

Comments
 (0)