2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-26 04:12:17 +00:00

fix(xcat-core): go-xcat case cannot enable CodeReady Builder on RHEL

On a RHEL node, Red Hat Subscription Management owns the CodeReady
Builder repository, so dnf config-manager cannot enable it by the crb or
powertools id. The case also had no check on that command, so the
failure showed up later as a go-xcat dependency error.

enable_crb.sh now enables codeready-builder-for-rhel-<major>-<arch>-rpms
through subscription-manager when RHSM lists it. Otherwise it enables
crb, or powertools on EL8, through dnf. go_xcat_devel_from_repo checks
rc==0 on the command.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
Daniel Hilst
2026-10-07 13:47:43 -03:00
parent 60ffd5d4c0
commit b30b2718a5
2 changed files with 19 additions and 4 deletions
+2 -1
View File
@@ -25,8 +25,9 @@ cmd:if xdsh $$CN "grep \"Red Hat\|Rocky\|Alma\" /etc/*release >/dev/null"; then
cmd:if xdsh $$CN "grep \"Red Hat\|Rocky\|Alma\" /etc/*release >/dev/null"; then xdsh $$CN 'rpm -q epel-release || dnf -y install epel-release || dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(rpm -E %rhel).noarch.rpm'; fi
check:rc==0
#go-xcat requires CodeReady Builder, named crb on EL9 and later and PowerTools on EL8.
#go-xcat requires CodeReady Builder.
cmd:if xdsh $$CN "grep \"Red Hat\|Rocky\|Alma\" /etc/*release >/dev/null"; then xdsh $$CN -e /opt/xcat/share/xcat/tools/autotest/testcase/go_xcat/enable_crb.sh; fi
check:rc==0
#Install additional packages on Ubuntu
cmd:if xdsh $$CN "grep \"Ubuntu\" /etc/*release >/dev/null"; then xdsh $$CN "DEBIAN_FRONTEND=noninteractive apt-get install -y gnupg"; fi
@@ -4,9 +4,23 @@
enable_crb()
{
dnf config-manager --set-enabled crb ||
dnf config-manager --set-enabled powertools ||
dnf config-manager setopt crb.enabled=1
local major arch rhsm_repo dnf_repo
major=$(rpm -E %rhel)
arch=$(uname -m)
# On RHEL, RHSM owns the repository and dnf config-manager cannot enable it.
rhsm_repo="codeready-builder-for-rhel-${major}-${arch}-rpms"
if subscription-manager repos --list 2>/dev/null |
grep -Eq "^Repo ID:[[:space:]]+${rhsm_repo}[[:space:]]*\$"; then
subscription-manager repos --enable "$rhsm_repo"
return
fi
dnf_repo=crb
[ "$major" = 8 ] && dnf_repo=powertools
dnf config-manager --set-enabled "$dnf_repo" ||
dnf config-manager setopt "${dnf_repo}.enabled=1"
}
if [ "${BASH_SOURCE[0]}" = "$0" ]; then