scripts/checkdeps: cleanup

Replace "which" with "command -v", which is part of POSIX.

Make offering to install packages contingent on having the sudo command.
Not every distro uses sudo. It is optional in Gentoo, for example.

Signed-off-by: Ian Leonard <antonlacon@gmail.com>
This commit is contained in:
Ian Leonard 2018-10-04 07:24:55 +00:00
parent df1cffa51e
commit ef93ecf54b

View File

@ -132,12 +132,13 @@ if [ "${#need[@]}" -gt 0 ]; then
done
echo "**** You seem to use a $DISTRO system ****"
if command -v sudo >/dev/null; then
case "$DISTRO" in
ubuntu|debian|linuxmint|\"elementary\")
get_yes_no && sudo apt-get install "${need_pkg[@]}"
;;
fedora|centos|rhel)
if [ $(which dnf) ]; then YUM=dnf; else YUM=yum; fi
command -v dnf >/dev/null && YUM=dnf || YUM=yum
get_yes_no && sudo $YUM install "${need_pkg[@]}"
;;
gentoo)
@ -160,6 +161,9 @@ if [ "${#need[@]}" -gt 0 ]; then
exit 1
;;
esac
else
echo "The command 'sudo' was not found. Please install necessary packages manually."
fi
fi
get_deps