[dev] improve Package Manager detection mechenism
improve Package Manager detection on linux in scripts/dev_setup.sh
port from
MODIFY
scripts/dev_setup.sh
scripts/dev_setup.sh
@@ -822,8 +822,26 @@ if [ "$(whoami)" != 'root' ]; then
PRE_COMMAND=(sudo)
fi
-PACKAGE_MANAGER=
if [[ "$(uname)" == "Linux" ]]; then
+ # check for default package manager for linux
+ if [[ -f /etc/redhat-release ]]; then
+ # use yum by default
+ if command -v yum &>/dev/null; then
+ PACKAGE_MANAGER="yum"
+ elif command -v dnf &>/dev/null; then
+ # dnf is the updated default since Red Hat Enterprise Linux 8, CentOS 8, Fedora 22, and any distros based on these
+ echo "WARNING: dnf package manager support is experimental"
+ PACKAGE_MANAGER="dnf"
+ fi
+ elif [[ -f /etc/debian_version ]] && command -v apt-get &>/dev/null; then
+ PACKAGE_MANAGER="apt-get"
+ elif [[ -f /etc/arch-release ]] && command -v pacman &>/dev/null; then
+ PACKAGE_MANAGER="pacman"
+ elif [[ -f /etc/alpine-release ]] && command -v apk &>/dev/null; then
+ PACKAGE_MANAGER="apk"
+ fi
+ # if no default PACKAGE_MANAGER detected, pick one that's installed, this is usually useless
+ if [[ $PACKAGE_MANAGER == "" ]]; then
if command -v yum &>/dev/null; then
PACKAGE_MANAGER="yum"
elif command -v apt-get &>/dev/null; then
@@ -839,6 +857,7 @@ if [[ "$(uname)" == "Linux" ]]; then
echo "Unable to find supported package manager (yum, apt-get, dnf, or pacman). Abort"
exit 1
fi
+ fi
elif [[ "$(uname)" == "Darwin" ]]; then
if command -v brew &>/dev/null; then
PACKAGE_MANAGER="brew"

[dev] improve Package Manager detection mechenism (#3412)

improve Package Manager detection on linux in scripts/dev_setup.sh
port from https://github.com/move-language/move/pull/146