scripts: install-deps.sh: Fix distribution detection
Relying on the installed package manager to detect the distribution is not reliable since it's possible to install multiple package managers at the same time. As such, lets simply use the information in the os-release files. Change-Id: I285c6cd94932f84bb9133b39d282c39d9a25b301
This commit is contained in:
parent
4e094b9a18
commit
69d6cbae25
@ -19,9 +19,9 @@ CHECK_CMD_PKGS=(
|
|||||||
wget
|
wget
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check zypper before apt-get in case zypper-aptitude
|
source /etc/os-release || source /usr/lib/os-release
|
||||||
# is installed
|
case ${ID,,} in
|
||||||
if [ -x '/usr/bin/zypper' ]; then
|
*suse)
|
||||||
OS_FAMILY="Suse"
|
OS_FAMILY="Suse"
|
||||||
INSTALLER_CMD="sudo -H -E zypper install -y --no-recommends"
|
INSTALLER_CMD="sudo -H -E zypper install -y --no-recommends"
|
||||||
CHECK_CMD="zypper search --match-exact --installed"
|
CHECK_CMD="zypper search --match-exact --installed"
|
||||||
@ -43,7 +43,9 @@ if [ -x '/usr/bin/zypper' ]; then
|
|||||||
if $(${CHECK_CMD} patterns-openSUSE-minimal_base-conflicts &> /dev/null); then
|
if $(${CHECK_CMD} patterns-openSUSE-minimal_base-conflicts &> /dev/null); then
|
||||||
sudo -H zypper remove -y patterns-openSUSE-minimal_base-conflicts
|
sudo -H zypper remove -y patterns-openSUSE-minimal_base-conflicts
|
||||||
fi
|
fi
|
||||||
elif [ -x '/usr/bin/apt-get' ]; then
|
;;
|
||||||
|
|
||||||
|
ubuntu|debian)
|
||||||
OS_FAMILY="Debian"
|
OS_FAMILY="Debian"
|
||||||
INSTALLER_CMD="sudo -H -E apt-get -y install"
|
INSTALLER_CMD="sudo -H -E apt-get -y install"
|
||||||
CHECK_CMD="dpkg -l"
|
CHECK_CMD="dpkg -l"
|
||||||
@ -60,7 +62,9 @@ elif [ -x '/usr/bin/apt-get' ]; then
|
|||||||
[wget]=wget
|
[wget]=wget
|
||||||
)
|
)
|
||||||
EXTRA_PKG_DEPS=()
|
EXTRA_PKG_DEPS=()
|
||||||
elif [ -x '/usr/bin/dnf' ] || [ -x '/usr/bin/yum' ]; then
|
;;
|
||||||
|
|
||||||
|
rhel|fedora|centos)
|
||||||
OS_FAMILY="RedHat"
|
OS_FAMILY="RedHat"
|
||||||
PKG_MANAGER=$(which dnf || which yum)
|
PKG_MANAGER=$(which dnf || which yum)
|
||||||
INSTALLER_CMD="sudo -H -E ${PKG_MANAGER} -y install"
|
INSTALLER_CMD="sudo -H -E ${PKG_MANAGER} -y install"
|
||||||
@ -78,9 +82,10 @@ elif [ -x '/usr/bin/dnf' ] || [ -x '/usr/bin/yum' ]; then
|
|||||||
[wget]=wget
|
[wget]=wget
|
||||||
)
|
)
|
||||||
EXTRA_PKG_DEPS=()
|
EXTRA_PKG_DEPS=()
|
||||||
else
|
;;
|
||||||
echo "ERROR: Supported package manager not found. Supported: apt, dnf, yum, zypper"
|
|
||||||
fi
|
*) echo "ERROR: Supported package manager not found. Supported: apt, dnf, yum, zypper"; exit 1;;
|
||||||
|
esac
|
||||||
|
|
||||||
# if running in OpenStack CI, then make sure epel is enabled
|
# if running in OpenStack CI, then make sure epel is enabled
|
||||||
# since it may already be present (but disabled) on the host
|
# since it may already be present (but disabled) on the host
|
||||||
|
Loading…
Reference in New Issue
Block a user