mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-24 11:16:51 +00:00
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:
parent
df1cffa51e
commit
ef93ecf54b
@ -41,7 +41,7 @@ get_deps() {
|
||||
get_yes_no()
|
||||
{
|
||||
local ans
|
||||
read -p "Would you like to install the needed tools ? (y/n) " ans
|
||||
read -p "Would you like to install the needed tools? (y/n) " ans
|
||||
[ "${ans,,}" = "y" ] && return 0
|
||||
[ "${ans,,}" = "yes" ] && return 0
|
||||
return 1
|
||||
@ -132,34 +132,38 @@ if [ "${#need[@]}" -gt 0 ]; then
|
||||
done
|
||||
echo "**** You seem to use a $DISTRO system ****"
|
||||
|
||||
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
|
||||
get_yes_no && sudo $YUM install "${need_pkg[@]}"
|
||||
;;
|
||||
gentoo)
|
||||
get_yes_no && sudo emerge --ask --deep "${need_pkg[@]}"
|
||||
;;
|
||||
sabayon)
|
||||
get_yes_no && sudo equo install --ask "${need_pkg[@]}"
|
||||
;;
|
||||
mageia)
|
||||
get_yes_no && sudo urpmi "${need_pkg[@]}"
|
||||
;;
|
||||
arch)
|
||||
get_yes_no && sudo pacman -Sy "${need_pkg[@]}"
|
||||
;;
|
||||
opensuse)
|
||||
get_yes_no && sudo zypper install -y --no-recommends "${need_pkg[@]}"
|
||||
;;
|
||||
*)
|
||||
echo "**** unsupported distro $DISTRO ****"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
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)
|
||||
command -v dnf >/dev/null && YUM=dnf || YUM=yum
|
||||
get_yes_no && sudo $YUM install "${need_pkg[@]}"
|
||||
;;
|
||||
gentoo)
|
||||
get_yes_no && sudo emerge --ask --deep "${need_pkg[@]}"
|
||||
;;
|
||||
sabayon)
|
||||
get_yes_no && sudo equo install --ask "${need_pkg[@]}"
|
||||
;;
|
||||
mageia)
|
||||
get_yes_no && sudo urpmi "${need_pkg[@]}"
|
||||
;;
|
||||
arch)
|
||||
get_yes_no && sudo pacman -Sy "${need_pkg[@]}"
|
||||
;;
|
||||
opensuse)
|
||||
get_yes_no && sudo zypper install -y --no-recommends "${need_pkg[@]}"
|
||||
;;
|
||||
*)
|
||||
echo "**** unsupported distro $DISTRO ****"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "The command 'sudo' was not found. Please install necessary packages manually."
|
||||
fi
|
||||
fi
|
||||
|
||||
get_deps
|
||||
|
Loading…
x
Reference in New Issue
Block a user