2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-05 04:27:55 +00:00

refactor(postscripts): share modular package directory predicate

This commit is contained in:
Vinícius Ferrão
2026-08-25 15:01:07 -03:00
parent 50257ff136
commit d2fec89988
3 changed files with 19 additions and 40 deletions
+2 -20
View File
@@ -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
+2 -20
View File
@@ -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
+15
View File
@@ -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