This commit is contained in:
Jeevitha Kannan K S 2024-11-08 05:35:44 +05:30 committed by GitHub
commit 15acd61d2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,83 +5,85 @@
fastUpdate() { fastUpdate() {
case "$PACKAGER" in case "$PACKAGER" in
pacman) pacman)
"$AUR_HELPER" -S --needed --noconfirm rate-mirrors-bin
$AUR_HELPER -S --needed --noconfirm rate-mirrors-bin
printf "%b\n" "${YELLOW}Generating a new list of mirrors using rate-mirrors. This process may take a few seconds...${RC}" printf "%b\n" "${YELLOW}Generating a new list of mirrors using rate-mirrors. This process may take a few seconds...${RC}"
if [ -s /etc/pacman.d/mirrorlist ]; then if [ -s "/etc/pacman.d/mirrorlist" ]; then
"$ESCALATION_TOOL" cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak "$ESCALATION_TOOL" cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
fi fi
# If for some reason DTYPE is still unknown use always arch so the rate-mirrors does not fail # If for some reason DTYPE is still unknown use always arch so the rate-mirrors does not fail
dtype_local=${DTYPE} dtype_local="$DTYPE"
if [ "${DTYPE}" = "unknown" ]; then if [ "$dtype_local" = "unknown" ]; then
dtype_local="arch" dtype_local="arch"
fi fi
"$ESCALATION_TOOL" rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root ${dtype_local} if ! "$ESCALATION_TOOL" rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root "$dtype_local" > /dev/null || [ ! -s "/etc/pacman.d/mirrorlist" ]; then
if [ $? -ne 0 ] || [ ! -s /etc/pacman.d/mirrorlist ]; then
printf "%b\n" "${RED}Rate-mirrors failed, restoring backup.${RC}" printf "%b\n" "${RED}Rate-mirrors failed, restoring backup.${RC}"
"$ESCALATION_TOOL" cp /etc/pacman.d/mirrorlist.bak /etc/pacman.d/mirrorlist "$ESCALATION_TOOL" cp /etc/pacman.d/mirrorlist.bak /etc/pacman.d/mirrorlist
fi fi
;; ;;
apt-get|nala) apt-get|nala)
"$ESCALATION_TOOL" apt-get update if [ "$PACKAGER" = "apt-get" ]; then
if ! command_exists nala; then printf "%b\n" "${YELLOW}Installing nala for faster updates.${RC}"
"$ESCALATION_TOOL" apt-get install -y nala || { printf "%b\n" "${YELLOW}Falling back to apt-get${RC}"; PACKAGER="apt-get"; } "$ESCALATION_TOOL" "$PACKAGER" update
if "$ESCALATION_TOOL" "$PACKAGER" install -y nala; then
PACKAGER="nala";
printf "%b\n" "${CYAN}Using $PACKAGER as package manager${RC}"
else
printf "%b\n" "${RED}Nala installation failed.${RC}"
printf "%b\n" "${YELLOW}Falling back to apt-get.${RC}"
fi
fi fi
if [ "$PACKAGER" = "nala" ]; then if [ "$PACKAGER" = "nala" ]; then
"$ESCALATION_TOOL" cp /etc/apt/sources.list /etc/apt/sources.list.bak if [ -f "/etc/apt/sources.list.d/nala-sources.list" ]; then
"$ESCALATION_TOOL" nala update "$ESCALATION_TOOL" cp /etc/apt/sources.list.d/nala-sources.list /etc/apt/sources.list.d/nala-sources.list.bak
PACKAGER="nala" fi
if ! "$ESCALATION_TOOL" nala fetch --auto -y || [ ! -s "/etc/apt/sources.list.d/nala-sources.list" ]; then
printf "%b\n" "${RED}Nala fetch failed, restoring backup.${RC}"
"$ESCALATION_TOOL" cp /etc/apt/sources.list.d/nala-sources.list.bak /etc/apt/sources.list.d/nala-sources.list
fi
fi fi
"$ESCALATION_TOOL" "$PACKAGER" upgrade -y
;; ;;
dnf) dnf)
"$ESCALATION_TOOL" "$PACKAGER" update -y "$ESCALATION_TOOL" "$PACKAGER" update -y
;; ;;
zypper) zypper)
"$ESCALATION_TOOL" "$PACKAGER" ref "$ESCALATION_TOOL" "$PACKAGER" ref
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive dup
;; ;;
apk) apk)
"$ESCALATION_TOOL" "$PACKAGER" update "$ESCALATION_TOOL" "$PACKAGER" update
;; ;;
*) *)
printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}" printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}"
exit 1 exit 1
;; ;;
esac esac
} }
updateSystem() { updateSystem() {
printf "%b\n" "${GREEN}Updating system${RC}" printf "%b\n" "${YELLOW}Updating system packages.${RC}"
case "$PACKAGER" in case "$PACKAGER" in
apt-get|nala) apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" "$PACKAGER" upgrade -y "$ESCALATION_TOOL" "$PACKAGER" upgrade -y
;; ;;
dnf) dnf)
"$ESCALATION_TOOL" "$PACKAGER" update -y
"$ESCALATION_TOOL" "$PACKAGER" upgrade -y "$ESCALATION_TOOL" "$PACKAGER" upgrade -y
;; ;;
pacman) pacman)
"$ESCALATION_TOOL" "$PACKAGER" -Sy --noconfirm --needed archlinux-keyring "$ESCALATION_TOOL" "$PACKAGER" -Sy --noconfirm --needed archlinux-keyring
"$ESCALATION_TOOL" "$PACKAGER" -Su --noconfirm "$AUR_HELPER" -Su --noconfirm
;; ;;
zypper) zypper)
"$ESCALATION_TOOL" "$PACKAGER" ref
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive dup "$ESCALATION_TOOL" "$PACKAGER" --non-interactive dup
;; ;;
apk) apk)
"$ESCALATION_TOOL" "$PACKAGER" upgrade "$ESCALATION_TOOL" "$PACKAGER" upgrade
;; ;;
*) *)
printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}" printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}"
exit 1 exit 1
;; ;;
esac esac
@ -89,18 +91,8 @@ updateSystem() {
updateFlatpaks() { updateFlatpaks() {
if command_exists flatpak; then if command_exists flatpak; then
printf "%b\n" "${YELLOW}Updating installed Flathub apps...${RC}" printf "%b\n" "${YELLOW}Updating flatpak packages.${RC}"
installed_apps=$(flatpak list --app --columns=application) flatpak update -y
if [ -z "$installed_apps" ]; then
printf "%b\n" "${RED}No Flathub apps are installed.${RC}"
return
fi
for app in $installed_apps; do
printf "%b\n" "${YELLOW}Updating $app...${RC}"
flatpak update -y "$app"
done
fi fi
} }