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
|
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 >────────────────────────────────────────
|
# ─< Distribution detection and installation >────────────────────────────────────────
|
||||||
get_packager() {
|
get_packager() {
|
||||||
if [ -e /etc/os-release ]; then
|
if [ -e /etc/os-release ]; then
|
||||||
|
@ -105,86 +155,43 @@ get_packager() {
|
||||||
ubuntu | pop | zorin | kubuntu | linuxmintubuntu)
|
ubuntu | pop | zorin | kubuntu | linuxmintubuntu)
|
||||||
ubuntu="true"
|
ubuntu="true"
|
||||||
distro="ubuntu"
|
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 | kali | linuxmint | elementary | neon | kdeneon | deepin)
|
||||||
debian="true"
|
debian="true"
|
||||||
distro="debian"
|
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 | centos | rhel | rocky | almalinux)
|
||||||
fedora="true"
|
fedora="true"
|
||||||
distro="fedora"
|
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)
|
||||||
alpine="true"
|
alpine="true"
|
||||||
distro="alpine"
|
distro="alpine"
|
||||||
_install() { $_sudo apk add "$@"; }
|
|
||||||
;;
|
;;
|
||||||
arch | manjaro | garuda | endeavour)
|
arch | manjaro | garuda | endeavour)
|
||||||
arch="true"
|
arch="true"
|
||||||
distro="arch"
|
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*)
|
||||||
opensuse="true"
|
opensuse="true"
|
||||||
distro="opensuse"
|
distro="opensuse"
|
||||||
_install() { $_sudo zypper in "$@"; }
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [ "${ID_LIKE#*debian}" != "$ID_LIKE" ]; then
|
if [ "${ID_LIKE#*debian}" != "$ID_LIKE" ]; then
|
||||||
debian="true"
|
debian="true"
|
||||||
distro="debian"
|
distro="debian"
|
||||||
_install() { $_sudo apt-get install --assume-yes "$@"; }
|
|
||||||
elif [ "${ID_LIKE#*ubuntu}" != "$ID_LIKE" ]; then
|
elif [ "${ID_LIKE#*ubuntu}" != "$ID_LIKE" ]; then
|
||||||
ubuntu="true"
|
ubuntu="true"
|
||||||
distro="ubuntu"
|
distro="ubuntu"
|
||||||
_install() { $_sudo apt-get install --assume-yes "$@"; }
|
|
||||||
elif [ "${ID_LIKE#*arch}" != "$ID_LIKE" ]; then
|
elif [ "${ID_LIKE#*arch}" != "$ID_LIKE" ]; then
|
||||||
arch="true"
|
arch="true"
|
||||||
distro="arch"
|
distro="arch"
|
||||||
_install() { $_sudo pacman -S --noconfirm "$@"; }
|
|
||||||
elif [ "${ID_LIKE#*fedora}" != "$ID_LIKE" ]; then
|
elif [ "${ID_LIKE#*fedora}" != "$ID_LIKE" ]; then
|
||||||
fedora="true"
|
fedora="true"
|
||||||
distro="fedora"
|
distro="fedora"
|
||||||
_install() { $_sudo dnf install -y "$@"; }
|
|
||||||
elif [ "${ID_LIKE#*suse}" != "$ID_LIKE" ]; then
|
elif [ "${ID_LIKE#*suse}" != "$ID_LIKE" ]; then
|
||||||
opensuse="true"
|
opensuse="true"
|
||||||
distro="opensuse"
|
distro="opensuse"
|
||||||
_install() { $_sudo zypper in "$@"; }
|
|
||||||
else
|
else
|
||||||
echo_error "Unsupported distribution: $ID"
|
echo_error "Unsupported distribution: $ID"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -212,38 +219,22 @@ get_packager() {
|
||||||
ubuntu="true"
|
ubuntu="true"
|
||||||
debian="true"
|
debian="true"
|
||||||
distro="debian"
|
distro="debian"
|
||||||
_install() { $_sudo apt-get install --assume-yes "$@"; }
|
|
||||||
;;
|
;;
|
||||||
dnf)
|
dnf)
|
||||||
fedora="true"
|
fedora="true"
|
||||||
distro="fedora"
|
distro="fedora"
|
||||||
_install() { $_sudo dnf install -y "$@"; }
|
|
||||||
;;
|
;;
|
||||||
apk)
|
apk)
|
||||||
alpine="true"
|
alpine="true"
|
||||||
distro="alpine"
|
distro="alpine"
|
||||||
_install() { $_sudo apk add "$@"; }
|
|
||||||
;;
|
;;
|
||||||
pacman)
|
pacman)
|
||||||
arch="true"
|
arch="true"
|
||||||
distro="arch"
|
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)
|
zypper)
|
||||||
opensuse="true"
|
opensuse="true"
|
||||||
distro="opensuse"
|
distro="opensuse"
|
||||||
_install() { $_sudo zypper in "$@"; }
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo_error "Can not detect distribution correctly!"
|
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 │
|
# │ 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() {
|
update_package_list() {
|
||||||
echo_note "Refreshing repositories.."
|
echo_note "Refreshing repositories.."
|
||||||
case "$distro" in
|
case "$distro" in
|
||||||
|
@ -280,7 +320,7 @@ update_package_list() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if check_root; then
|
if check_root; then
|
||||||
get_packager &&
|
get_packager
|
||||||
update_package_list
|
dist_setup
|
||||||
|
update_package_list
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue