wip
This commit is contained in:
parent
f7801c918a
commit
61957873b9
1 changed files with 126 additions and 60 deletions
186
distros.sh
186
distros.sh
|
@ -96,8 +96,8 @@ echo_pkg() {
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
case "$1" in
|
case "$1" in
|
||||||
deps)
|
deps | dep | dependencies)
|
||||||
echo "${BOLD}${BRIGHT_RED}${PACKAGE:-PKG}-dependencies:${BRIGHT_YELLOW} $2 ${NC}"
|
echo "${BOLD}${BRIGHT_RED}${PACKAGE:-PKG}-${pkger:-dependencies}:${BRIGHT_YELLOW} $2 ${NC}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "${BOLD}${BRIGHT_RED}${PACKAGE:-PKG}-$1:${NC}${BRIGHT_YELLOW} $2 ${NC}"
|
echo "${BOLD}${BRIGHT_RED}${PACKAGE:-PKG}-$1:${NC}${BRIGHT_YELLOW} $2 ${NC}"
|
||||||
|
@ -205,21 +205,56 @@ check_env() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# CAUTION:
|
||||||
|
# ╭─────────────────────────────────────────────────────────────────────╮
|
||||||
|
# │ This can break really quickly, since the _remove() function removes │
|
||||||
|
# │ without confirmation! use with CAUTION!! │
|
||||||
|
# ╰─────────────────────────────────────────────────────────────────────╯
|
||||||
_setup() {
|
_setup() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
debian | ubuntu)
|
debian | ubuntu)
|
||||||
_install() { $_sudo apt-get install --assume-yes "$@"; }
|
_install() {
|
||||||
|
# $_sudo apt-get install --assume-yes "$@"
|
||||||
|
if command_exists nala; then
|
||||||
|
pkger=nala
|
||||||
|
# echo_pkg "Using paru"
|
||||||
|
$_sudo nala install --assume-yes "$@"
|
||||||
|
else
|
||||||
|
pkger=apt-get
|
||||||
|
# echo_pkg "Using pacman"
|
||||||
|
$_sudo apt-get install --assume-yes "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# CAUTION:
|
||||||
_remove() {
|
_remove() {
|
||||||
$_sudo apt-get remove --assume-yes "$@"
|
if command_exists nala; then
|
||||||
$_sudo apt-get autoremove --assume-yes
|
pkger=nala
|
||||||
|
# echo_pkg "Using paru"
|
||||||
|
$_sudo nala remove --assume-yes "$@"
|
||||||
|
$_sudo nala autoremove --assume-yes
|
||||||
|
$_sudo nala autopurge --assume-yes
|
||||||
|
else
|
||||||
|
pkger=apt-get
|
||||||
|
# echo_pkg "Using pacman"
|
||||||
|
$_sudo apt-get remove --assume-yes "$@"
|
||||||
|
$_sudo apt-get autoremove --assume-yes
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
;;
|
;;
|
||||||
fedora)
|
fedora)
|
||||||
_install() { $_sudo dnf -y install "$@"; }
|
_install() {
|
||||||
_remove() { $_sudo dnf -y remove "$@"; }
|
pkger=dnf
|
||||||
|
$_sudo dnf -y install "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# CAUTION:
|
||||||
|
_remove() {
|
||||||
|
pkger=dnf
|
||||||
|
$_sudo dnf -y remove "$@"
|
||||||
|
}
|
||||||
;;
|
;;
|
||||||
arch)
|
arch)
|
||||||
|
|
||||||
checkAUR() {
|
checkAUR() {
|
||||||
if ! command_exists yay && ! command_exists paru; then
|
if ! command_exists yay && ! command_exists paru; then
|
||||||
return 69
|
return 69
|
||||||
|
@ -230,42 +265,109 @@ _setup() {
|
||||||
|
|
||||||
_install() {
|
_install() {
|
||||||
if command_exists paru; then
|
if command_exists paru; then
|
||||||
echo_pkg "Using paru"
|
pkger=paru
|
||||||
|
# echo_pkg "Using paru"
|
||||||
paru -S --color always --noconfirm --needed "$@"
|
paru -S --color always --noconfirm --needed "$@"
|
||||||
elif command_exists yay; then
|
elif command_exists yay; then
|
||||||
echo_pkg "Using yay"
|
pkger=yay
|
||||||
|
# echo_pkg "Using yay"
|
||||||
yay -S --color always --noconfirm --needed "$@"
|
yay -S --color always --noconfirm --needed "$@"
|
||||||
else
|
else
|
||||||
echo_pkg "Using pacman"
|
pkger=pacman
|
||||||
|
# echo_pkg "Using pacman"
|
||||||
$_sudo pacman -S --color always --noconfirm --needed "$@"
|
$_sudo pacman -S --color always --noconfirm --needed "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# CAUTION:
|
||||||
_remove() {
|
_remove() {
|
||||||
if command_exists paru; then
|
if command_exists paru; then
|
||||||
echo_info "Using paru"
|
pkger=paru
|
||||||
|
# echo_info "Using paru"
|
||||||
paru -R --color always --noconfirm "$@"
|
paru -R --color always --noconfirm "$@"
|
||||||
elif command_exists yay; then
|
elif command_exists yay; then
|
||||||
echo_info "Using yay"
|
pkger=yay
|
||||||
|
# echo_info "Using yay"
|
||||||
yay -R --color always --noconfirm "$@"
|
yay -R --color always --noconfirm "$@"
|
||||||
else
|
else
|
||||||
echo_warning "Using pacman"
|
pkger=pacman
|
||||||
|
# echo_warning "Using pacman"
|
||||||
$_sudo pacman -R --color always --noconfirm "$@"
|
$_sudo pacman -R --color always --noconfirm "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
;;
|
;;
|
||||||
opensuse)
|
opensuse)
|
||||||
_install() { $_sudo zypper in "$@"; }
|
_install() {
|
||||||
_remove() { $_sudo zypper rem "$@"; }
|
pkger=zypper
|
||||||
|
$_sudo zypper in "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# CAUTION:
|
||||||
|
_remove() {
|
||||||
|
pkger=zypper
|
||||||
|
$_sudo zypper rem "$@"
|
||||||
|
}
|
||||||
;;
|
;;
|
||||||
alpine)
|
alpine)
|
||||||
_install() { apk add "$@"; }
|
_install() {
|
||||||
_remove() { apk remove "$@"; }
|
pkger=apk
|
||||||
|
apk add "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# CAUTION:
|
||||||
|
_remove() {
|
||||||
|
pkger=apk
|
||||||
|
apk remove "$@"
|
||||||
|
}
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─< Distribution detection and installation >────────────────────────────────────────
|
# ─< Distribution detection and installation >────────────────────────────────────────
|
||||||
get_packager() {
|
get_packager() {
|
||||||
|
fallback() {
|
||||||
|
# ─────────────────────────────────────< get packager >─────────────────────────────────────
|
||||||
|
local pkger=""
|
||||||
|
for pkg in apt-get dnf pacman apk zypper; do
|
||||||
|
if command_exists $pkg; then
|
||||||
|
printf "Using ${RED}${pkg}${NC} method.."
|
||||||
|
pkger="$pkg"
|
||||||
|
|
||||||
|
# break
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
case "$pkger" in
|
||||||
|
apt-get)
|
||||||
|
ubuntu="true"
|
||||||
|
debian="true"
|
||||||
|
distro="debian"
|
||||||
|
;;
|
||||||
|
dnf)
|
||||||
|
fedora="true"
|
||||||
|
distro="fedora"
|
||||||
|
;;
|
||||||
|
apk)
|
||||||
|
alpine="true"
|
||||||
|
distro="alpine"
|
||||||
|
;;
|
||||||
|
pacman)
|
||||||
|
arch="true"
|
||||||
|
distro="arch"
|
||||||
|
;;
|
||||||
|
zypper)
|
||||||
|
opensuse="true"
|
||||||
|
distro="opensuse"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo_error "Can not detect distribution correctly!"
|
||||||
|
# echo_error "DEBUG:: $pkger ::"
|
||||||
|
return 69
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
if [ -e /etc/os-release ]; then
|
if [ -e /etc/os-release ]; then
|
||||||
echo_info "Detecting distribution..."
|
echo_info "Detecting distribution..."
|
||||||
. /etc/os-release
|
. /etc/os-release
|
||||||
|
@ -317,54 +419,18 @@ get_packager() {
|
||||||
distro="opensuse"
|
distro="opensuse"
|
||||||
else
|
else
|
||||||
echo_error "Unsupported distribution: $ID"
|
echo_error "Unsupported distribution: $ID"
|
||||||
exit 1
|
echo_warning "Trying fallback.."
|
||||||
|
fallback
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
echo_warning "Unable to detect distribution /etc/os-release not found."
|
echo_warning "Unable to detect distribution - /etc/os-release not found."
|
||||||
echo_note "Trying other methods.."
|
echo_note "Trying other methods.."
|
||||||
|
|
||||||
# ─────────────────────────────────────< get packager >─────────────────────────────────────
|
sleep 3
|
||||||
pkger=""
|
|
||||||
for pkg in apt-get dnf pacman apk zypper; do
|
|
||||||
if command_exists $pkg; then
|
|
||||||
printf "Using ${RED}${pkg}${NC} method.."
|
|
||||||
pkger="$pkg"
|
|
||||||
|
|
||||||
# break
|
fallback
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
case "$pkger" in
|
|
||||||
apt-get)
|
|
||||||
ubuntu="true"
|
|
||||||
debian="true"
|
|
||||||
distro="debian"
|
|
||||||
;;
|
|
||||||
dnf)
|
|
||||||
fedora="true"
|
|
||||||
distro="fedora"
|
|
||||||
;;
|
|
||||||
apk)
|
|
||||||
alpine="true"
|
|
||||||
distro="alpine"
|
|
||||||
;;
|
|
||||||
pacman)
|
|
||||||
arch="true"
|
|
||||||
distro="arch"
|
|
||||||
;;
|
|
||||||
zypper)
|
|
||||||
opensuse="true"
|
|
||||||
distro="opensuse"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo_error "Can not detect distribution correctly!"
|
|
||||||
# echo_error "DEBUG:: $pkger ::"
|
|
||||||
return 69
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,7 +501,7 @@ update_package_list() {
|
||||||
$_sudo mkdir -p "$paruBuildDir"
|
$_sudo mkdir -p "$paruBuildDir"
|
||||||
# if ! command_exists paru; then
|
# if ! command_exists paru; then
|
||||||
echo "${YELLOW}Installing paru as AUR helper...${NC}"
|
echo "${YELLOW}Installing paru as AUR helper...${NC}"
|
||||||
$_sudo pacman -S --needed --noconfirm base-devel git
|
run $_sudo pacman -S --needed --noconfirm base-devel git
|
||||||
cd "$paruBuildDir" && $_sudo git clone https://aur.archlinux.org/paru-bin.git paru
|
cd "$paruBuildDir" && $_sudo git clone https://aur.archlinux.org/paru-bin.git paru
|
||||||
$_sudo chown -R "$USER": "$paruBuildDir/paru"
|
$_sudo chown -R "$USER": "$paruBuildDir/paru"
|
||||||
cd "$paruBuildDir/paru" && makepkg --noconfirm -si
|
cd "$paruBuildDir/paru" && makepkg --noconfirm -si
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue