Commit a2c2ad64 authored by TNE's avatar TNE
Browse files

Refactor garuda-update, auto replace python-xdg with python-pyxdg

parent 7be38058
......@@ -3,19 +3,21 @@
pkgname=garuda-update
pkgdesc="The Garuda Linux update command, in a separate package to allow separate updating"
pkgver=2.1.2
pkgver=2.2.0
pkgrel=1
arch=('any')
license=('GPL')
depends=('coreutils' 'sed' 'awk' 'pacman' 'wget')
source=("garuda-update" "pre-update-routines" "auto-pacman")
sha512sums=('69a523cae22797ade231d9921f258bb17d60a60245263f4ed77cbe01be0e9083546549c034581dad2a412beb8aac8f13f11fb5564f23f25b78d3a71d051059fd'
'c78bd7003450686a7c2d74b7c8f227b321bd2439f9b03e3023ea1ff151140fb732b278f24ec107fa2a1d63ad3e39ade331bef3e5e0281f0569d1007ac99610a3'
'3cfd84d81efbda393c39761a6014ddd346091f8a44b0944df0ce7e635d0e297481591e5c9546009683999e40c43ca94c57827e1984a8b08ecc86114f5abda98c')
source=("garuda-update" "update-helper-scripts" "auto-pacman" "main-update")
sha512sums=('8c30b6f296d2c3ce3d09d4b3c902b2db1fedb71e4e077404604ecfac4864ab0fa300967bc422702cd750f260ea6bb5fdcb54dba971faa533a53908e286a8253f'
'a1c84b4052602f5a8802ea541ca0541b5525cf86561fc3ebf910bf9b3a26889a4faa35916c0b5dc2612640f31b39bc2ae86584cf299dcead1348ca8eb99647f8'
'9f75ce2b71bc1de52645ef2904b0725be044dbfae96c7caebe77b0b5907e70ae10b89b09a5e2130988207481f4e2465bd062e07cd915514816a439c42a2a4622'
'057dc539b87c88c8f481348e5cfc94acd1fc089a81c72ddf9763ba40db2d53052feebde30c7a548dffcf6f1a46f278e93287bb53bfd29f78300a1f4b9d35864c')
package() {
install -Dm755 garuda-update $pkgdir/usr/bin/garuda-update
ln -s /usr/bin/garuda-update $pkgdir/usr/bin/update
install -Dm755 pre-update-routines $pkgdir/usr/lib/garuda/garuda-update/pre-update-routines
install -Dm755 update-helper-scripts $pkgdir/usr/lib/garuda/garuda-update/update-helper-scripts
install -Dm755 main-update $pkgdir/usr/lib/garuda/garuda-update/main-update
install -Dm755 auto-pacman $pkgdir/usr/lib/garuda/garuda-update/auto-pacman
}
......@@ -4,6 +4,7 @@ if {![exp_debug]} {trap {exit 1} {SIGINT SIGTERM}}
array set auto_replace_conflicts {
sweet-cursor-theme-git xcursor-sweet
python-pyxdg python-xdg
}
proc parseConflicts {text} {
......
#!/bin/bash
set -e
update_keyrings() {
local packages=("archlinux-keyring" "chaotic-keyring" "garuda-hotfixes")
if $PACMAN -Qq blackarch-keyring &> /dev/null; then
packages+=("blackarch-keyring")
fi
if [ ! -z "$($PACMAN -Qu ${packages[@]} 2>&1)" ]; then
echo -e "\n\033[1;33m-->\033[1;34m Applying keyring updates before starting full system update..\033[0m"
SNAP_PAC_SKIP=y SKIP_AUTOSNAP= $PACMAN -S --needed --noconfirm ${packages[@]} || false
fi
}
self_update() {
# Let the update script self update
if [ -z "$GARUDA_UPDATE_SELFUPDATE" ]; then
......@@ -22,14 +11,6 @@ self_update() {
fi
}
show_changelog() {
# Show update notices if the notices file exists
if [ -e "/var/lib/garuda/tmp/update_notices" ]; then
echo -e "\033[1;32mUpdate notices:\n\033[1;34m$(cut -f2 /var/lib/garuda/tmp/update_notices)\n\033[0m"
rm /var/lib/garuda/tmp/update_notices
fi
}
# Some funny stuff with reflector makes it not exit on sigint, we set up our own sigint handler for that
INT=true
trap "INT=false" INT
......@@ -51,105 +32,10 @@ else
PACMAN="pacman"
fi
DATABASE_UPDATED=false
self_update "$@"
if [ -f /etc/garuda/garuda-update/config ]; then
source /etc/garuda/garuda-update/config
fi
# Parse CLI options
PARSED_OPTIONS=$(getopt --options="a" --longoptions="aur,skip-mirrorlist" --name "$0" -- "$@")
if [[ $? -ne 0 ]]; then
echo -e "\033[1;31m\nFailed to parse CLI options\n\033[0m"
fi
eval set -- "$PARSED_OPTIONS"
while true; do
case "$1" in
-a|--aur)
UPDATE_AUR=1
shift
;;
--skip-mirrorlist)
SKIP_MIRRORLIST=1
shift
;;
--)
shift
break
;;
*)
echo "Programming error"
exit 3
;;
esac
done
export PACMAN
if [[ ! -v SKIP_MIRRORLIST ]]; then
# Refresh mirrorlists
if [ -x /usr/bin/rate-mirrors ]; then
echo -e "\n\033[1;33m-->\033[1;34m Refreshing mirrorlists using rate-mirrors, please be patient..\033[0m"
MIRRORLIST_TEMP="$(mktemp)" && rate-mirrors --allow-root --save=$MIRRORLIST_TEMP arch --max-delay=21600 &> /dev/null \
&& chmod 644 /etc/pacman.d/mirrorlist $MIRRORLIST_TEMP && \mv $MIRRORLIST_TEMP /etc/pacman.d/mirrorlist && $PACMAN -Syy && DATABASE_UPDATED=true || { echo -e "\033[1;31m\nFailed to update mirrorlist\033[0m"; }
$INT
elif [ -x /usr/bin/reflector ]; then
echo -e "\n\033[1;33m-->\033[1;34m Refreshing mirrorlists using reflector, please be patient..\033[0m"
reflector --latest 5 --age 2 --fastest 5 --protocol https --sort rate --save /etc/pacman.d/mirrorlist \
&& $INT && cat /etc/pacman.d/mirrorlist && echo "" \
&& $PACMAN -Syy && DATABASE_UPDATED=true || { echo -e "\033[1;31m\nFailed to update mirrorlist\n\033[0m"; }
$INT
fi
fi
DATABASE_UPDATED=false
self_update "$@"
update_keyrings
# Run pre-update routines and hotfixes
/usr/lib/garuda/garuda-update/pre-update-routines
pacman_args=("-Su")
if [ "$DATABASE_UPDATED" == false ]; then pacman_args+=("-y"); fi
if [ -x /usr/bin/expect ]; then
LANG=C /usr/lib/garuda/garuda-update/auto-pacman $PACMAN "${pacman_args[@]}" || { [ "$?" != "134" ] && false; }
else
$PACMAN "${pacman_args[@]}"
fi
if [[ -v UPDATE_AUR ]]; then
# Check for AUR helper
if [ -x /usr/bin/paru ] && [[ ! -z "$SUDO_UID" ]]; then
echo -e "\n\033[1;33m-->\033[1;34m Updating AUR packages with paru..\033[0m"
sudo -u "#$SUDO_UID" paru -Sua || { echo -e "\033[1;31m\nParu exited with error code $?\n\033[0m"; }
elif [ -x /usr/bin/yay ] && [[ ! -z "$SUDO_UID" ]]; then
echo -e "\n\033[1;33m-->\033[1;34m Updating AUR packages with yay..\033[0m"
sudo -u "#$SUDO_UID" yay -Sua || { echo -e "\033[1;31m\nYay exited with error code $?\n\033[0m"; }
else
echo -e "\n\033[1;33m--> UPDATE_AUR specified but no supported AUR helper found\033[0m"
fi
$INT
fi
# Update mlocate index in the background
if [ -x /usr/bin/locate ]; then
systemctl start updatedb.service
fi
# Update fish completions
if [ -x /usr/bin/fish ] && [ ! -z "$SUDO_UID" ]; then
echo ""
sudo -u "#$SUDO_UID" fish -c fish_update_completions
fi
# Update micro plugins
if [ -x /usr/bin/micro ] && [ ! -z "$SUDO_UID" ]; then
echo ""
sudo -u "#$SUDO_UID" micro -plugin update
fi
echo -e "\n\033[1;32mSystem updated! 🐧\n\033[0m"
show_changelog
source /usr/lib/garuda/garuda-update/main-update
#!/bin/bash
set -e
show_changelog() {
# Show update notices if the notices file exists
if [ -e "/var/lib/garuda/tmp/update_notices" ]; then
echo -e "\033[1;32mUpdate notices:\n\033[1;34m$(cut -f2 /var/lib/garuda/tmp/update_notices)\n\033[0m"
rm /var/lib/garuda/tmp/update_notices
fi
}
if [ -f /etc/garuda/garuda-update/config ]; then
source /etc/garuda/garuda-update/config
fi
# Parse CLI options
PARSED_OPTIONS=$(getopt --options="a" --longoptions="aur,skip-mirrorlist" --name "$0" -- "$@")
if [[ $? -ne 0 ]]; then
echo -e "\033[1;31m\nFailed to parse CLI options\n\033[0m"
fi
eval set -- "$PARSED_OPTIONS"
while true; do
case "$1" in
-a|--aur)
UPDATE_AUR=1
shift
;;
--skip-mirrorlist)
SKIP_MIRRORLIST=1
shift
;;
--)
shift
break
;;
*)
echo "Programming error"
exit 3
;;
esac
done
if [[ ! -v SKIP_MIRRORLIST ]]; then
# Refresh mirrorlists
if [ -x /usr/bin/rate-mirrors ]; then
echo -e "\n\033[1;33m-->\033[1;34m Refreshing mirrorlists using rate-mirrors, please be patient..\033[0m"
MIRRORLIST_TEMP="$(mktemp)" && rate-mirrors --allow-root --save=$MIRRORLIST_TEMP arch --max-delay=21600 &> /dev/null \
&& chmod 644 /etc/pacman.d/mirrorlist $MIRRORLIST_TEMP && \mv $MIRRORLIST_TEMP /etc/pacman.d/mirrorlist && $PACMAN -Syy && DATABASE_UPDATED=true || { echo -e "\033[1;31m\nFailed to update mirrorlist\033[0m"; }
$INT
elif [ -x /usr/bin/reflector ]; then
echo -e "\n\033[1;33m-->\033[1;34m Refreshing mirrorlists using reflector, please be patient..\033[0m"
reflector --latest 5 --age 2 --fastest 5 --protocol https --sort rate --save /etc/pacman.d/mirrorlist \
&& $INT && cat /etc/pacman.d/mirrorlist && echo "" \
&& $PACMAN -Syy && DATABASE_UPDATED=true || { echo -e "\033[1;31m\nFailed to update mirrorlist\n\033[0m"; }
$INT
fi
fi
self_update "$@"
# Run pre-update routines and hotfixes
/usr/lib/garuda/garuda-update/update-helper-scripts pre-update-routines
pacman_args=("-Su")
if [ "$DATABASE_UPDATED" == false ]; then pacman_args+=("-y"); fi
while IFS= read -r line ; do
pacman_args+=("$line")
done < <(/usr/lib/garuda/garuda-update/update-helper-scripts package-replaces)
if [ -x /usr/bin/expect ]; then
LANG=C /usr/lib/garuda/garuda-update/auto-pacman $PACMAN "${pacman_args[@]}" || { [ "$?" != "134" ] && false; }
else
$PACMAN "${pacman_args[@]}"
fi
if [[ -v UPDATE_AUR ]]; then
# Check for AUR helper
if [ -x /usr/bin/paru ] && [[ ! -z "$SUDO_UID" ]]; then
echo -e "\n\033[1;33m-->\033[1;34m Updating AUR packages with paru..\033[0m"
sudo -u "#$SUDO_UID" paru -Sua || { echo -e "\033[1;31m\nParu exited with error code $?\n\033[0m"; }
elif [ -x /usr/bin/yay ] && [[ ! -z "$SUDO_UID" ]]; then
echo -e "\n\033[1;33m-->\033[1;34m Updating AUR packages with yay..\033[0m"
sudo -u "#$SUDO_UID" yay -Sua || { echo -e "\033[1;31m\nYay exited with error code $?\n\033[0m"; }
else
echo -e "\n\033[1;33m--> UPDATE_AUR specified but no supported AUR helper found\033[0m"
fi
$INT
fi
# Update mlocate index in the background
if [ -x /usr/bin/locate ]; then
systemctl start updatedb.service
fi
# Update fish completions
if [ -x /usr/bin/fish ] && [ ! -z "$SUDO_UID" ]; then
echo ""
sudo -u "#$SUDO_UID" fish -c fish_update_completions
fi
# Update micro plugins
if [ -x /usr/bin/micro ] && [ ! -z "$SUDO_UID" ]; then
echo ""
sudo -u "#$SUDO_UID" micro -plugin update
fi
echo -e "\n\033[1;32mSystem updated! 🐧\n\033[0m"
show_changelog
#!/bin/bash
set -e
update_keyrings() {
local packages=("archlinux-keyring" "chaotic-keyring" "garuda-hotfixes")
if $PACMAN -Qq blackarch-keyring &> /dev/null; then
packages+=("blackarch-keyring")
fi
if [ ! -z "$($PACMAN -Qu ${packages[@]} 2>&1)" ]; then
echo -e "\n\033[1;33m-->\033[1;34m Applying keyring updates before starting full system update..\033[0m"
SNAP_PAC_SKIP=y SKIP_AUTOSNAP= $PACMAN -S --needed --noconfirm ${packages[@]} || false
fi
}
fix_jack2_confilict() {
if [ -e /usr/bin/pw-jack ]; then
local jack2=false
local jack2_dbus=false
local lib32_jack=false
pacman -Qq jack2 &> /dev/null && jack2=true
pacman -Qq jack2-dbus &> /dev/null && jack2=true
pacman -Qq lib32-jack2 &> /dev/null && lib32_jack=true
$PACMAN -Qq jack2 &> /dev/null && jack2=true
$PACMAN -Qq jack2-dbus &> /dev/null && jack2=true
$PACMAN -Qq lib32-jack2 &> /dev/null && lib32_jack=true
if [ "$jack2" == true ] || [ "$jack2_dbus" == true ]; then
echo -e "\n\033[1;33m-->\033[1;34m Addressing jack2 conflict..\033[0m"
fi
if [ "$jack2_dbus" == true ]; then
pacman -R jack2-dbus --noconfirm
$PACMAN -R jack2-dbus --noconfirm
fi
if [ "$jack2" == true ]; then
pacman -Rdd jack2 --noconfirm
$PACMAN -Rdd jack2 --noconfirm
fi
if [ "$lib32_jack" == true ]; then
# Most hacky thing I've ever done
# Goal: Get pacman to properly install lib32-pipewire-jack next system update
SNAP_PAC_SKIP=y SKIP_AUTOSNAP= pacman --dbonly -U https://archive.archlinux.org/repos/2021/12/31/multilib/os/x86_64/lib32-pipewire-jack-1%3A0.3.42-2-x86_64.pkg.tar.zst --noconfirm
pacman -Rdd lib32-jack2 --noconfirm
SNAP_PAC_SKIP=y SKIP_AUTOSNAP= $PACMAN --dbonly -U https://archive.archlinux.org/repos/2021/12/31/multilib/os/x86_64/lib32-pipewire-jack-1%3A0.3.42-2-x86_64.pkg.tar.zst --noconfirm
$PACMAN -Rdd lib32-jack2 --noconfirm
fi
fi
}
......@@ -30,10 +41,24 @@ fix_jack2_confilict() {
fix_wireplumber_conflict() {
if [ -e /usr/bin/wireplumber ] && [ -e /usr/bin/pipewire-media-session ]; then
echo -e "\n\033[1;33m-->\033[1;34m Addressing pipewire-media-session/wireplumber conflict..\033[0m"
pacman -Rdd wireplumber --noconfirm
$PACMAN -Rdd wireplumber --noconfirm
fi
}
fix_wireplumber_conflict
fix_jack2_confilict
# Anything printed by this script into stdout will be added as a pacman parameter to pacman -Syu
package-replaces() {
# We replace python-xdg with python-pyxdg from community
# This is not done automatically for some reason
if [ "$($PACMAN -Qq python-xdg || true)" == "python-xdg" ] &> /dev/null; then
echo python-pyxdg
fi
}
pre-update-routines() {
update_keyrings
fix_wireplumber_conflict
fix_jack2_confilict
}
"$@"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment