What's the difference between garuda-update and pacman -Syu

Give them your little finger, and they will rip your arm off. :smiley:


Reich ihnen den kleinen Finger und sie werden dir den Arm abreißen. :smiley:

This may help keep you arm, but you will miss a finger as there is 2 errors I don't know how to fix.
Keep your arm! Feel free to use and change as anyone would like.

Benefits:

  • Added -c|--country and -s to command line
  • Added Variable COUNTRY
  • Added source of variables to $HOME/.config/garuda/garuda-update.conf
  • Prioritize the use of reflector over rate-mirrors

Errors:

  • Will not use source from $HOME/.config/garuda/garuda-update.conf
  • When using --country Stuck in loop if disable lines 87-90. Will not pass the country if not disabled.
garuda-update
#!/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
        [ "$DATABASE_UPDATED" != "true" ] && $PACMAN -Sy && DATABASE_UPDATED=true || true
        $PACMAN -Qu garuda-update &> /dev/null && SNAP_PAC_SKIP=y SKIP_AUTOSNAP= $PACMAN -S garuda-update --needed --noconfirm && GARUDA_UPDATE_SELFUPDATE=1 exec /usr/bin/garuda-update "$1" || true # whatever, it is how it is
        # Check if we have received sigint and should exit
        $INT
    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

# Elevate once and stop asking for the password constantly
if [[ $EUID -ne 0 ]]; then
    exec sudo --preserve-env="SKIP_MIRRORLIST,UPDATE_AUR,PACMAN_EXE,HOME" /usr/bin/garuda-update "[email protected]"
    exit 1
fi

# Run the "I'm too lazy to fix it myself all in one" script
if [ "$1" == "remote" ]; then
    exec bash -c "VERSION=5 . <(wget -qO- https://gitlab.com/garuda-linux/themes-and-settings/settings/garuda-common-settings/-/snippets/2147440/raw/main/remote-update) \"$2\" \"$3\""
fi

if [ ! -z "$PACMAN_EXE" ]; then
    PACMAN="$PACMAN_EXE"
else
    PACMAN="pacman"
fi

DATABASE_UPDATED=false

self_update "[email protected]"

if [ -f /etc/garuda/garuda-update/config ]; then
    source /etc/garuda/garuda-update/config
fi

if [ -f $HOME/.config/garuda/garuda-update.conf ]; then
    source $HOME/.config/garuda/garuda-update.conf
fi

# Parse CLI options
PARSED_OPTIONS=$(getopt --options="a,s,c" --longoptions="aur,skip-mirrorlist,country" --name "$0" -- "[email protected]")
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
            ;;
        -s|--skip-mirrorlist)
            SKIP_MIRRORLIST=1
            shift
            ;;
        -c|--country)
            shift
            COUNTRY=${@:2}
            eval set -- "$PARSED_OPTIONS"
            shift
            ;;
        --)
            shift
            break
            ;;
        *)
            echo "Programming error"
            exit 3
            ;;
    esac
done

if [[ ! -v SKIP_MIRRORLIST ]]; then
    # Refresh mirrorlists
    if [ -x /usr/bin/reflector ]; then
        if [[ $COUNTRY ]]; then
            echo -e "\n\033[1;33m-->\033[1;34m Refreshing mirrorlists using reflector for $COUNTRY, please be patient..\033[0m"
            reflector --latest 5 --age 2 --fastest 5 --protocol https --sort rate --country $COUNTRY --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
        else
            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
    elif [ -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
    fi
fi

self_update "[email protected]"

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

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.