wip
This commit is contained in:
parent
882ee78d07
commit
75e32097ae
1 changed files with 102 additions and 62 deletions
164
distros.sh
164
distros.sh
|
@ -91,6 +91,56 @@ check_root() {
|
|||
fi
|
||||
}
|
||||
|
||||
_setup() {
|
||||
case "$1" in
|
||||
debian | ubuntu)
|
||||
_install() { $_sudo apt-get install --assume-yes "$@"; }
|
||||
_remove() {
|
||||
$_sudo apt-get remove --assume-yes "$@"
|
||||
$_sudo apt-get autoremove --assume-yes
|
||||
}
|
||||
;;
|
||||
fedora)
|
||||
_install() { $_sudo dnf -y install "$@"; }
|
||||
_remove() { $_sudo dnf -y remove "$@"; }
|
||||
;;
|
||||
arch)
|
||||
_install() {
|
||||
if command_exists paru; then
|
||||
echo_info "Using paru"
|
||||
paru -S --color always --noconfirm --needed "$@"
|
||||
elif command_exists yay; then
|
||||
echo_info "Using yay"
|
||||
yay -S --color always --noconfirm --needed "$@"
|
||||
else
|
||||
echo_warning "Using pacman"
|
||||
$_sudo pacman -S --color always --noconfirm --needed "$@"
|
||||
fi
|
||||
}
|
||||
_remove() {
|
||||
if command_exists paru; then
|
||||
echo_info "Using paru"
|
||||
paru -R --color always --noconfirm "$@"
|
||||
elif command_exists yay; then
|
||||
echo_info "Using yay"
|
||||
yay -R --color always --noconfirm "$@"
|
||||
else
|
||||
echo_warning "Using pacman"
|
||||
$_sudo pacman -R --color always --noconfirm "$@"
|
||||
fi
|
||||
}
|
||||
;;
|
||||
opensuse)
|
||||
_install() { $_sudo zypper in "$@"; }
|
||||
_remove() { $_sudo zypper rem "$@"; }
|
||||
;;
|
||||
alpine)
|
||||
_install() { apk add "$@"; }
|
||||
_remove() { apk remove "$@"; }
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# ─< Distribution detection and installation >────────────────────────────────────────
|
||||
get_packager() {
|
||||
if [ -e /etc/os-release ]; then
|
||||
|
@ -105,86 +155,43 @@ get_packager() {
|
|||
ubuntu | pop | zorin | kubuntu | linuxmintubuntu)
|
||||
ubuntu="true"
|
||||
distro="ubuntu"
|
||||
_install() { $_sudo apt-get install --assume-yes "$@"; }
|
||||
# Codename support
|
||||
case "$VERSION_CODENAME" in
|
||||
noble) noble=true ;;
|
||||
jammy) jammy=true ;;
|
||||
focal) focal=true ;;
|
||||
bionic) bionic=true ;;
|
||||
esac
|
||||
;;
|
||||
debian | kali | linuxmint | elementary | neon | kdeneon | deepin)
|
||||
debian="true"
|
||||
distro="debian"
|
||||
_install() { $_sudo apt-get install --assume-yes "$@"; }
|
||||
case "$VERSION_CODENAME" in
|
||||
trixie) trixie=true ;;
|
||||
bookworm) bookworm=true ;;
|
||||
bullseye) bullseye=true ;;
|
||||
buster) buster=true ;;
|
||||
esac
|
||||
;;
|
||||
fedora | centos | rhel | rocky | almalinux)
|
||||
fedora="true"
|
||||
distro="fedora"
|
||||
_install() { $_sudo dnf install -y "$@"; }
|
||||
# Add version-specific var like: fedora_40=true
|
||||
fedora_version="fedora_${VERSION_ID//./_}"
|
||||
eval "$fedora_version=true"
|
||||
;;
|
||||
alpine)
|
||||
alpine="true"
|
||||
distro="alpine"
|
||||
_install() { $_sudo apk add "$@"; }
|
||||
;;
|
||||
arch | manjaro | garuda | endeavour)
|
||||
arch="true"
|
||||
distro="arch"
|
||||
if command_exists yay || command_exists paru; then
|
||||
aur=true
|
||||
else
|
||||
aur=false
|
||||
fi
|
||||
_install() {
|
||||
if command_exists paru; then
|
||||
echo_info "Using paru"
|
||||
paru -S --color always --noconfirm --needed "$@"
|
||||
elif command_exists yay; then
|
||||
echo_info "Using yay"
|
||||
yay -S --color always --noconfirm --needed "$@"
|
||||
else
|
||||
echo_warning "Using pacman"
|
||||
$_sudo pacman -S --color always --noconfirm --needed "$@"
|
||||
fi
|
||||
}
|
||||
;;
|
||||
opensuse*)
|
||||
opensuse="true"
|
||||
distro="opensuse"
|
||||
_install() { $_sudo zypper in "$@"; }
|
||||
;;
|
||||
*)
|
||||
if [ "${ID_LIKE#*debian}" != "$ID_LIKE" ]; then
|
||||
debian="true"
|
||||
distro="debian"
|
||||
_install() { $_sudo apt-get install --assume-yes "$@"; }
|
||||
elif [ "${ID_LIKE#*ubuntu}" != "$ID_LIKE" ]; then
|
||||
ubuntu="true"
|
||||
distro="ubuntu"
|
||||
_install() { $_sudo apt-get install --assume-yes "$@"; }
|
||||
elif [ "${ID_LIKE#*arch}" != "$ID_LIKE" ]; then
|
||||
arch="true"
|
||||
distro="arch"
|
||||
_install() { $_sudo pacman -S --noconfirm "$@"; }
|
||||
elif [ "${ID_LIKE#*fedora}" != "$ID_LIKE" ]; then
|
||||
fedora="true"
|
||||
distro="fedora"
|
||||
_install() { $_sudo dnf install -y "$@"; }
|
||||
elif [ "${ID_LIKE#*suse}" != "$ID_LIKE" ]; then
|
||||
opensuse="true"
|
||||
distro="opensuse"
|
||||
_install() { $_sudo zypper in "$@"; }
|
||||
else
|
||||
echo_error "Unsupported distribution: $ID"
|
||||
exit 1
|
||||
|
@ -212,38 +219,22 @@ get_packager() {
|
|||
ubuntu="true"
|
||||
debian="true"
|
||||
distro="debian"
|
||||
_install() { $_sudo apt-get install --assume-yes "$@"; }
|
||||
;;
|
||||
dnf)
|
||||
fedora="true"
|
||||
distro="fedora"
|
||||
_install() { $_sudo dnf install -y "$@"; }
|
||||
;;
|
||||
apk)
|
||||
alpine="true"
|
||||
distro="alpine"
|
||||
_install() { $_sudo apk add "$@"; }
|
||||
;;
|
||||
pacman)
|
||||
arch="true"
|
||||
distro="arch"
|
||||
_install() {
|
||||
if command_exists paru; then
|
||||
echo_info "Using paru"
|
||||
paru -S --color always --noconfirm --needed "$@"
|
||||
elif command_exists yay; then
|
||||
echo_info "Using yay"
|
||||
yay -S --color always --noconfirm --needed "$@"
|
||||
else
|
||||
echo_warning "Using pacman"
|
||||
$_sudo pacman -S --color always --noconfirm --needed "$@"
|
||||
fi
|
||||
}
|
||||
;;
|
||||
zypper)
|
||||
opensuse="true"
|
||||
distro="opensuse"
|
||||
_install() { $_sudo zypper in "$@"; }
|
||||
;;
|
||||
*)
|
||||
echo_error "Can not detect distribution correctly!"
|
||||
|
@ -259,6 +250,55 @@ get_packager() {
|
|||
# │ Automated setup for refreshing repositories and overall getting the variables to setup │
|
||||
# ╰────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
|
||||
dist_setup() {
|
||||
case "$distro" in
|
||||
debian)
|
||||
_setup debian
|
||||
# Codename support
|
||||
if [ -n $VERSION_CODENAME ]; then
|
||||
case "$VERSION_CODENAME" in
|
||||
trixie) trixie=true ;;
|
||||
bookworm) bookworm=true ;;
|
||||
bullseye) bullseye=true ;;
|
||||
buster) buster=true ;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
ubuntu)
|
||||
_setup ubuntu
|
||||
# Codename support
|
||||
if [ -n $VERSION_CODENAME ]; then
|
||||
case "$VERSION_CODENAME" in
|
||||
noble) noble=true ;;
|
||||
jammy) jammy=true ;;
|
||||
focal) focal=true ;;
|
||||
bionic) bionic=true ;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
fedora)
|
||||
_setup fedora
|
||||
# Add version-specific var like: fedora_40=true
|
||||
fedora_version="fedora_${VERSION_ID//./_}"
|
||||
eval "$fedora_version=true"
|
||||
;;
|
||||
arch)
|
||||
_setup arch
|
||||
if command_exists yay || command_exists paru; then
|
||||
aur=true
|
||||
else
|
||||
aur=false
|
||||
fi
|
||||
;;
|
||||
alpine)
|
||||
_setup alpine
|
||||
;;
|
||||
opensuse)
|
||||
_setup opensuse
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
update_package_list() {
|
||||
echo_note "Refreshing repositories.."
|
||||
case "$distro" in
|
||||
|
@ -280,7 +320,7 @@ update_package_list() {
|
|||
}
|
||||
|
||||
if check_root; then
|
||||
get_packager &&
|
||||
update_package_list
|
||||
|
||||
get_packager
|
||||
dist_setup
|
||||
update_package_list
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue