Skip to content

Commit 57eee95

Browse files
images: automate enabling copr repos when installing sambacc
Update the install-sambacc-common.sh script so that setting up and using COPR repos is eaiser. Make some small cleanups and updates to use the new sambacc-extras-deps repository. Signed-off-by: John Mulligan <[email protected]>
1 parent b0c31fe commit 57eee95

File tree

1 file changed

+43
-15
lines changed

1 file changed

+43
-15
lines changed

images/common/install-sambacc-common.sh

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
#!/bin/bash
22

3+
SAMBACC_DEPS_COPR="phlogistonjohn/sambacc-extras-deps"
4+
SAMBACC_COPR="phlogistonjohn/sambacc"
5+
6+
ensure_copr() {
7+
if ! rpm -q --whatprovides 'dnf-command(copr)' >/dev/null; then
8+
dnf install -y 'dnf-command(copr)'
9+
fi
10+
}
11+
12+
enable_copr() {
13+
if [ "$1" = "--centos9only" ]; then
14+
if [ "$OS_BASE" != "centos" ]; then return 0; fi
15+
shift
16+
fi
17+
ensure_copr
18+
19+
cmd=(dnf copr enable -y "$1")
20+
if [ "${CHROOT}" ]; then
21+
# force/override automatically selected chroot
22+
cmd+=("${CHROOT}")
23+
elif [ "$OS_BASE" = centos ]; then
24+
# centos needs a little help determining what repository
25+
# within the copr to use. By default it only wants
26+
# to add `epel-9-$arch`.
27+
chroot="centos-stream+epel-next-9-$(uname -p)"
28+
cmd+=("${chroot}")
29+
fi
30+
"${cmd[@]}"
31+
}
32+
33+
dnf_install() {
34+
dnf install -y "${@}"
35+
}
36+
337
install_sambacc() {
438
local distdir="$1"
539
local sambacc_version_suffix="$2"
@@ -71,37 +105,31 @@ install_sambacc() {
71105
exit 1
72106
fi
73107

108+
# shellcheck disable=SC1091
109+
OS_BASE="$(. /etc/os-release && echo "${ID}")"
110+
74111
case $action in
75112
install-wheel)
76113
pip install "${wheels[0]}"
77114
container_json_file="/usr/local/share/sambacc/examples/${DEFAULT_JSON_FILE}"
78115
;;
79116
install-rpm)
80-
dnf install -y "${rpmfiles[0]}" "${rpmextras[@]}"
117+
dnf_install "${rpmfiles[0]}" "${rpmextras[@]}"
81118
dnf clean all
82119
container_json_file="/usr/share/sambacc/examples/${DEFAULT_JSON_FILE}"
83120
;;
84121
install-from-repo)
85122
local tgt="${repofiles[0]}"
86123
cp "${tgt}" /etc/yum.repos.d/"$(basename "${tgt}")"
87-
dnf install -y "python3-sambacc${sambacc_version_suffix}"
124+
enable_copr --centos9only "$SAMBACC_DEPS_COPR"
125+
dnf_install "python3-sambacc${sambacc_version_suffix}"
88126
dnf clean all
89127
container_json_file="/usr/share/sambacc/examples/${DEFAULT_JSON_FILE}"
90128
;;
91129
install-from-copr-repo)
92-
# shellcheck disable=SC1091
93-
OS_BASE="$(. /etc/os-release && echo "${ID}")"
94-
dnf install -y 'dnf-command(copr)'
95-
96-
copr_args=("phlogistonjohn/sambacc")
97-
if [ "$OS_BASE" = centos ]; then
98-
# centos needs a little help determining what repository
99-
# within the copr to use. By default it only wants
100-
# to add `epel-9-$arch`.
101-
copr_args+=("centos-stream+epel-next-9-$(uname -p)")
102-
fi
103-
dnf copr enable -y "${copr_args[@]}"
104-
dnf install -y "python3-sambacc${sambacc_version_suffix}"
130+
enable_copr --centos9only "$SAMBACC_DEPS_COPR"
131+
enable_copr "$SAMBACC_COPR"
132+
dnf_install "python3-sambacc${sambacc_version_suffix}"
105133
dnf clean all
106134
container_json_file="/usr/share/sambacc/examples/${DEFAULT_JSON_FILE}"
107135
;;

0 commit comments

Comments
 (0)