From d2fec89988d4318e4c3552a81ed1a64a5fe090b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Tue, 25 Aug 2026 15:01:07 -0300 Subject: [PATCH] refactor(postscripts): share modular package directory predicate --- xCAT/postscripts/ospkgs | 22 ++-------------------- xCAT/postscripts/otherpkgs | 22 ++-------------------- xCAT/postscripts/xcatpkgutils.sh | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 40 deletions(-) diff --git a/xCAT/postscripts/ospkgs b/xCAT/postscripts/ospkgs index e50b3c4da..20ece81c6 100755 --- a/xCAT/postscripts/ospkgs +++ b/xCAT/postscripts/ospkgs @@ -261,24 +261,6 @@ array_ospkgdirs=($OSPKGDIR) array_empty os_path -is_el_modular_pkgdir() -{ - pmatch "$OSVER" "rhel[89]*" || - pmatch "$OSVER" "rhel1[0-9]*" || - pmatch "$OSVER" "rhels[89]*" || - pmatch "$OSVER" "rhels1[0-9]*" || - pmatch "$OSVER" "centos[89]*" || - pmatch "$OSVER" "centos1[0-9]*" || - pmatch "$OSVER" "rocky[89]*" || - pmatch "$OSVER" "rocky1[0-9]*" || - pmatch "$OSVER" "alma[89]*" || - pmatch "$OSVER" "alma1[0-9]*" || - pmatch "$OSVER" "almalinux[89]*" || - pmatch "$OSVER" "almalinux1[0-9]*" || - pmatch "$OSVER" "ol[89]*" || - pmatch "$OSVER" "ol1[0-9]*" -} - index=0 for dir in ${array_ospkgdirs[@]} do @@ -308,7 +290,7 @@ do ospkgdir="$ospkgdir/SL" fi fi - if ! is_el_modular_pkgdir || \ + if ! xcat_is_el_modular_pkgdir "$OSVER" || \ { [ "$dir" != "$default_pkgdir" ] && [ "$dir" != "$default_pkgdir/" ]; }; then # For EL8+ modular distros, only the base OS pkgdir expands to subrepos. array_set_element os_path $index $ospkgdir @@ -376,7 +358,7 @@ do array_set_element os_path $index $ospkgdir_ok done fi # x86_64 - elif is_el_modular_pkgdir; then + elif xcat_is_el_modular_pkgdir "$OSVER"; then # for EL8+ modular distros the repodata is in ./BaseOS and ./AppStream, not in ./ for arg in "BaseOS" "AppStream" do diff --git a/xCAT/postscripts/otherpkgs b/xCAT/postscripts/otherpkgs index 6dbc9707a..8815e69ca 100755 --- a/xCAT/postscripts/otherpkgs +++ b/xCAT/postscripts/otherpkgs @@ -341,24 +341,6 @@ fi IFS=$OIFS array_empty os_path - is_el_modular_pkgdir() - { - pmatch "$OSVER" "rhel[89]*" || - pmatch "$OSVER" "rhel1[0-9]*" || - pmatch "$OSVER" "rhels[89]*" || - pmatch "$OSVER" "rhels1[0-9]*" || - pmatch "$OSVER" "centos[89]*" || - pmatch "$OSVER" "centos1[0-9]*" || - pmatch "$OSVER" "rocky[89]*" || - pmatch "$OSVER" "rocky1[0-9]*" || - pmatch "$OSVER" "alma[89]*" || - pmatch "$OSVER" "alma1[0-9]*" || - pmatch "$OSVER" "almalinux[89]*" || - pmatch "$OSVER" "almalinux1[0-9]*" || - pmatch "$OSVER" "ol[89]*" || - pmatch "$OSVER" "ol1[0-9]*" - } - is_el_yum_distro() { pmatch "$OSVER" "rhel*" || @@ -398,7 +380,7 @@ fi ospkgdir="$ospkgdir/SL" fi fi - if ! is_el_modular_pkgdir || \ + if ! xcat_is_el_modular_pkgdir "$OSVER" || \ { [ "$dir" != "$default_pkgdir" ] && [ "$dir" != "$default_pkgdir/" ]; }; then # For EL8+ modular distros, only the base OS pkgdir expands to subrepos. array_set_element os_path $index $ospkgdir @@ -441,7 +423,7 @@ fi array_set_element os_path $index $ospkgdir_ok done fi # x86_64 - elif is_el_modular_pkgdir; then + elif xcat_is_el_modular_pkgdir "$OSVER"; then # for EL8+ modular distros the repodata is in ./BaseOS and ./AppStream, not in ./ for arg in "BaseOS" "AppStream" do diff --git a/xCAT/postscripts/xcatpkgutils.sh b/xCAT/postscripts/xcatpkgutils.sh index 8c91b5239..857b1b586 100755 --- a/xCAT/postscripts/xcatpkgutils.sh +++ b/xCAT/postscripts/xcatpkgutils.sh @@ -3,5 +3,20 @@ # Shared POSIX shell helpers for the ospkgs and otherpkgs postscripts. # Keep the marker assignment last so callers know the whole library loaded. + +xcat_is_el_modular_pkgdir() +{ + case "$1" in + rhel[89]*|rhel1[0-9]*|rhels[89]*|rhels1[0-9]*|\ + centos[89]*|centos1[0-9]*|rocky[89]*|rocky1[0-9]*|\ + alma[89]*|alma1[0-9]*|almalinux[89]*|almalinux1[0-9]*|\ + ol[89]*|ol1[0-9]*) + return 0 + ;; + esac + + return 1 +} + # shellcheck disable=SC2034 XCATPKGUTILS_LOADED=1