🐛 fix(dh): refactor dependencies_install function

 feat(dh): add support for multiple package managers
The dependencies_install function has been refactored to use separate functions for each package manager. This makes it easier to add support for new package managers in the future. Support for apt, pacman, xbps, and dnf has been added. This improves the flexibility of the script as it can now be used on a wider range of systems.
This commit is contained in:
zenobit 2023-04-12 01:18:19 +02:00
parent 16b193dee3
commit 7fb5c35af1
1 changed files with 26 additions and 21 deletions

47
dh
View File

@ -194,24 +194,14 @@ EOF
function dependencies_install() {
# Find the current distribution and install dependecies
if [ -f /etc/os-release ]; then
if grep -q arch /etc/os-release; then
sudo pacman -S cdrtools coreutils edk2-ovmf grep jq procps python3 qemu-full sed socat spice-gtk swtpm usbutils util-linux wget xdg-user-dirs xorg-xrandr zsync getext yad fzf
elif [[ -f /etc/debian_version ]]; then
sudo apt install qemu bash coreutils ovmf grep jq lsb procps python3 genisoimage usbutils util-linux sed spice-client-gtk swtpm wget xdg-user-dirs zsync unzip yad fzf
elif grep -q void /etc/os-release; then
sudo xbps-install -S qemu bash coreutils grep jq procps-ng python3 util-linux sed spice-gtk swtpm usbutils wget xdg-user-dirs xrandr unzip zsync socat yad fzf
elif grep -q fedora /etc/os-release; then
sudo dnf install qemu bash coreutils edk2-tools grep jq lsb procps python3 genisoimage usbutils util-linux sed spice-gtk-tools swtpm wget xdg-user-dirs xrandr unzip yad fzf
elif grep -q nix /etc/os-release; then
echo "#TODO"
elif grep -q openSUSE /etc/os-release; then
# openSUSE supports dnf, but the default is zypper
if hash dnf 2>/dev/null; then
sudo dnf install qemu bash coreutils edk2-tools grep jq lsb procps python3 genisoimage usbutils util-linux sed spice-gtk-tools swtpm wget xdg-user-dirs xrandr unzip yad fzf
else
echo "$MSG_ERROR: $MSG_NO_DISTRO"
exit 1
fi
if [ -f "$PATH_PREFIX/pacman" ]; then
install_needed_pacman
elif [ -f "$PATH_PREFIX/apt" ]; then
install_needed_apt
elif [ -f "$PATH_PREFIX/xbps-install" ]; then
install_needed_xbps
elif [ -f "$PATH_PREFIX/dnf" ]; then
install_needed_dnf
else
echo "$MSG_ERROR: $MSG_NO_DISTRO"
exit 1
@ -219,6 +209,22 @@ EOF
fi
}
function install_needed_atp() {
sudo apt install qemu bash coreutils ovmf grep jq lsb procps python3 genisoimage usbutils util-linux sed spice-client-gtk swtpm wget xdg-user-dirs zsync unzip yad fzf
}
function install_needed_pacman() {
sudo pacman -S cdrtools coreutils edk2-ovmf grep jq procps python3 qemu-full sed socat spice-gtk swtpm usbutils util-linux wget xdg-user-dirs xorg-xrandr zsync getext yad fzf
}
function install_needed_xbps() {
sudo xbps-install -S qemu bash coreutils grep jq procps-ng python3 util-linux sed spice-gtk swtpm usbutils wget xdg-user-dirs xrandr unzip zsync socat yad fzf
}
function install_needed_dnf() {
sudo dnf install qemu bash coreutils edk2-tools grep jq lsb procps python3 genisoimage usbutils util-linux sed spice-gtk-tools swtpm wget xdg-user-dirs xrandr unzip yad fzf
}
function distrohopper_install() {
cp dh quickget quickemu macrecovery windowskey "$PATH_PREFIX" >/dev/null 2>&1 || sudo cp dh quickget quickemu macrecovery windowskey "$PATH_PREFIX"
# quickget also to config directory for adding new distros...
@ -234,13 +240,12 @@ EOF
function installation_process() {
dependencies_check_tui
dependencies_check_gui
#check_quickemu_dependencies
echo "$MSG_NEEDED"
dependencies_install
echo "$MSG_STRUCTURE" \
&& directory_structure_create \
&& echo "$MSG_SETTINGUP" \
&& virtual_machines_directory_choose \
&& echo "$MSG_NEEDED" \
&& dependencies_install \
&& echo "$MSG_INSTALLING" \
&& distrohopper_install \
&& echo "$MSG_C_ENTRY" \