mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-19 04:49:13 +08:00
core: 重构软件包安装
This commit is contained in:
parent
4024bb346f
commit
246743f04f
38
reinstall.sh
38
reinstall.sh
@ -464,34 +464,32 @@ install_pkg() {
|
|||||||
fi
|
fi
|
||||||
# cmds to pkgs
|
# cmds to pkgs
|
||||||
for cmd in $cmds; do
|
for cmd in $cmds; do
|
||||||
|
pkg=
|
||||||
case $cmd in
|
case $cmd in
|
||||||
unsquashfs) pkg=squashfs-tools ;;
|
unsquashfs) command -v zypper && pkg=squashfs || pkg=squashfs-tools ;;
|
||||||
lsmem) pkg=util-linux ;;
|
lsmem) pkg=util-linux ;;
|
||||||
nslookup | dig)
|
nslookup | dig)
|
||||||
if is_in_alpine; then
|
(command -v apk && pkg="bind-tools") ||
|
||||||
pkg="bind-tools"
|
(command -v apt && pkg="bind9-dnsutils") ||
|
||||||
elif is_in_arch; then
|
(command -v pacmcn && pkg="bind") ||
|
||||||
pkg="bind"
|
(command -v yum dnf zypper && pkg="bind-utils")
|
||||||
elif command -v yum || command -v dnf; then
|
|
||||||
pkg="bind-utils"
|
|
||||||
elif command -v apt; then
|
|
||||||
pkg="bind9-dnsutils"
|
|
||||||
else
|
|
||||||
error "Can't install nslookup / dig"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
*) pkg=$cmd ;;
|
*) pkg=$cmd ;;
|
||||||
esac
|
esac
|
||||||
pkgs+=" $pkg"
|
pkgs+=" $pkg"
|
||||||
done
|
done
|
||||||
{
|
|
||||||
apt_install $pkgs ||
|
# command -v 有先后顺序,dnf放yum前面
|
||||||
dnf install -y --setopt=install_weak_deps=False $pkgs ||
|
pkg_mgr=$(command -v dnf yum apt pacman zypper apk | head -1 | awk -F/ '{print $NF}')
|
||||||
yum install -y $pkgs ||
|
case $pkg_mgr in
|
||||||
zypper install -y $pkgs ||
|
dnf) dnf install -y --setopt=install_weak_deps=False $pkgs ;;
|
||||||
pacman -Syu --noconfirm $pkgs ||
|
yum) yum install -y $pkgs ;;
|
||||||
apk add $pkgs
|
apk) apk add $pkgs ;;
|
||||||
} 2>/dev/null
|
apt) apt_install $pkgs ;;
|
||||||
|
pacman) pacman -Syu --noconfirm --needed $pkgs ;;
|
||||||
|
zypper) zypper install -y $pkgs ;;
|
||||||
|
*) error_and_exit "Unexpected package manager: $pkg_mgr" ;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user