|
1 | 1 | #!/bin/bash
|
2 | 2 |
|
| 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 | + |
3 | 37 | install_sambacc() {
|
4 | 38 | local distdir="$1"
|
5 | 39 | local sambacc_version_suffix="$2"
|
@@ -71,37 +105,31 @@ install_sambacc() {
|
71 | 105 | exit 1
|
72 | 106 | fi
|
73 | 107 |
|
| 108 | + # shellcheck disable=SC1091 |
| 109 | + OS_BASE="$(. /etc/os-release && echo "${ID}")" |
| 110 | + |
74 | 111 | case $action in
|
75 | 112 | install-wheel)
|
76 | 113 | pip install "${wheels[0]}"
|
77 | 114 | container_json_file="/usr/local/share/sambacc/examples/${DEFAULT_JSON_FILE}"
|
78 | 115 | ;;
|
79 | 116 | install-rpm)
|
80 |
| - dnf install -y "${rpmfiles[0]}" "${rpmextras[@]}" |
| 117 | + dnf_install "${rpmfiles[0]}" "${rpmextras[@]}" |
81 | 118 | dnf clean all
|
82 | 119 | container_json_file="/usr/share/sambacc/examples/${DEFAULT_JSON_FILE}"
|
83 | 120 | ;;
|
84 | 121 | install-from-repo)
|
85 | 122 | local tgt="${repofiles[0]}"
|
86 | 123 | 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}" |
88 | 126 | dnf clean all
|
89 | 127 | container_json_file="/usr/share/sambacc/examples/${DEFAULT_JSON_FILE}"
|
90 | 128 | ;;
|
91 | 129 | 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}" |
105 | 133 | dnf clean all
|
106 | 134 | container_json_file="/usr/share/sambacc/examples/${DEFAULT_JSON_FILE}"
|
107 | 135 | ;;
|
|
0 commit comments