Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 43 additions & 15 deletions images/common/install-sambacc-common.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
#!/bin/bash

SAMBACC_DEPS_COPR="phlogistonjohn/sambacc-extras-deps"
SAMBACC_COPR="phlogistonjohn/sambacc"

ensure_copr() {
if ! rpm -q --whatprovides 'dnf-command(copr)' >/dev/null; then
dnf install -y 'dnf-command(copr)'
fi
}

enable_copr() {
if [ "$1" = "--centos9only" ]; then
if [ "$OS_BASE" != "centos" ]; then return 0; fi
shift
fi
ensure_copr

cmd=(dnf copr enable -y "$1")
if [ "${CHROOT}" ]; then
# force/override automatically selected chroot
cmd+=("${CHROOT}")
elif [ "$OS_BASE" = centos ]; then
# centos needs a little help determining what repository
# within the copr to use. By default it only wants
# to add `epel-9-$arch`.
chroot="centos-stream+epel-next-9-$(uname -p)"
cmd+=("${chroot}")
fi
"${cmd[@]}"
}

dnf_install() {
dnf install -y "${@}"
}

install_sambacc() {
local distdir="$1"
local sambacc_version_suffix="$2"
Expand Down Expand Up @@ -71,37 +105,31 @@ install_sambacc() {
exit 1
fi

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

case $action in
install-wheel)
pip install "${wheels[0]}"
container_json_file="/usr/local/share/sambacc/examples/${DEFAULT_JSON_FILE}"
;;
install-rpm)
dnf install -y "${rpmfiles[0]}" "${rpmextras[@]}"
dnf_install "${rpmfiles[0]}" "${rpmextras[@]}"
dnf clean all
container_json_file="/usr/share/sambacc/examples/${DEFAULT_JSON_FILE}"
;;
install-from-repo)
local tgt="${repofiles[0]}"
cp "${tgt}" /etc/yum.repos.d/"$(basename "${tgt}")"
dnf install -y "python3-sambacc${sambacc_version_suffix}"
enable_copr --centos9only "$SAMBACC_DEPS_COPR"
dnf_install "python3-sambacc${sambacc_version_suffix}"
dnf clean all
container_json_file="/usr/share/sambacc/examples/${DEFAULT_JSON_FILE}"
;;
install-from-copr-repo)
# shellcheck disable=SC1091
OS_BASE="$(. /etc/os-release && echo "${ID}")"
dnf install -y 'dnf-command(copr)'

copr_args=("phlogistonjohn/sambacc")
if [ "$OS_BASE" = centos ]; then
# centos needs a little help determining what repository
# within the copr to use. By default it only wants
# to add `epel-9-$arch`.
copr_args+=("centos-stream+epel-next-9-$(uname -p)")
fi
dnf copr enable -y "${copr_args[@]}"
dnf install -y "python3-sambacc${sambacc_version_suffix}"
enable_copr --centos9only "$SAMBACC_DEPS_COPR"
enable_copr "$SAMBACC_COPR"
dnf_install "python3-sambacc${sambacc_version_suffix}"
dnf clean all
container_json_file="/usr/share/sambacc/examples/${DEFAULT_JSON_FILE}"
;;
Expand Down