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

refactor(postscripts): share RPM package manager discovery

Signed-off-by: Vinícius Ferrão <2031761+viniciusferrao@users.noreply.github.com>
This commit is contained in:
Vinícius Ferrão
2026-08-30 19:19:20 -03:00
parent a5ad2f7b26
commit 4317b5ec75
3 changed files with 14 additions and 10 deletions
+1 -5
View File
@@ -910,11 +910,7 @@ elif ( pmatch "$OSVER" "ubuntu*" ); then
fi
else
#check if yum or dnf is installed
if [ -x /usr/bin/dnf ]; then
yumcmd="dnf"
elif [ -x /usr/bin/yum ]; then
yumcmd="yum"
else
if ! yumcmd=$(xcat_find_rpm_package_manager); then
echo "Please install yum or dnf on $NODE."
exit 1;
fi
+1 -5
View File
@@ -509,12 +509,8 @@ else
result=`rpm --version 2>/dev/null`
if [ $? -eq 0 ]; then
hasrpm=1
if [ -x /usr/bin/dnf ]; then
if yumcmd=$(xcat_find_rpm_package_manager); then
hasyum=1
yumcmd="dnf"
elif [ -x /usr/bin/yum ]; then
hasyum=1
yumcmd="yum"
else
result=`rpm -q zypper`
if [ "$?" = "0" ]; then
+12
View File
@@ -2,6 +2,18 @@
# EPL license http://www.eclipse.org/legal/epl-v10.html
# Shared POSIX shell helpers for the ospkgs and otherpkgs postscripts.
xcat_find_rpm_package_manager()
{
if [ -x "${1:-/usr/bin}/dnf" ]; then
printf '%s\n' dnf
elif [ -x "${1:-/usr/bin}/yum" ]; then
printf '%s\n' yum
else
return 1
fi
}
# Keep the marker assignment last so callers know the whole library loaded.
# shellcheck disable=SC2034
XCATPKGUTILS_LOADED=1