Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # shellcheck disable=SC2015
- set -e
- minimal_pacman_conf() {
- local TEMP_CONF
- TEMP_CONF=$(mktemp)
- echo -e "[chaotic-aur]\nServer = https://garudalinux.org/os/garuda-update/backuprepo/x86_64" >"$TEMP_CONF"
- echo "$TEMP_CONF"
- }
- self_update() {
- # Let the update script self update
- local EXTRA_PARAMS=()
- if [ "$DATABASE_UPDATED" == "force" ]; then
- $PACMAN -Syy && DATABASE_UPDATED=true || true
- elif [ "$DATABASE_UPDATED" != "true" ]; then
- $PACMAN -Sy && DATABASE_UPDATED=true || true
- fi
- [ "$DATABASE_UPDATED" != "true" ] && local MIN_PACMAN_CONF && MIN_PACMAN_CONF="$(minimal_pacman_conf)" && $PACMAN --config "$MIN_PACMAN_CONF" -Syy && EXTRA_PARAMS=("--config" "$MIN_PACMAN_CONF") || true
- $INT
- if $PACMAN "${EXTRA_PARAMS[@]}" -Qu garuda-update &>/dev/null; then
- local success=true
- if ! SNAP_PAC_SKIP=y SKIP_AUTOSNAP='' $PACMAN "${EXTRA_PARAMS[@]}" -Sdd garuda-update --needed --noconfirm; then
- $INT
- # Create unshare'd mount namespace and mount an empty tmpfs on /usr/share/libalpm/hooks and /var/cache/pacman/pkg if it exists
- unshare -m bash -c 'mount -t tmpfs tmpfs /usr/share/libalpm/hooks && { [ ! -d /var/cache/pacman/pkg ] || mount -t tmpfs tmpfs /var/cache/pacman/pkg; } && eval "$@"' -- SNAP_PAC_SKIP=y SKIP_AUTOSNAP='' "$PACMAN" "${EXTRA_PARAMS[@]}" --hookdir "/usr/share/libalpm/hooks" -Sdd garuda-update --needed --noconfirm || success=false
- fi
- $INT
- if [ "$success" == "true" ]; then
- GARUDA_UPDATE_SELFUPDATE=2 exec /usr/bin/garuda-update "$@"
- fi
- fi
- # Check if we have received sigint and should exit
- $INT
- }
- # 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
- # Show a help text in case it was requested
- if [ "$1" == "-h" ] || [ "$1" == "--help" ] || [ "$1" == "help" ]; then
- # shellcheck source=./help
- source /usr/lib/garuda/garuda-update/help
- fi
- # Elevate once and stop asking for the password constantly
- if [[ $EUID -ne 0 ]]; then
- exec sudo --preserve-env="SKIP_MIRRORLIST,UPDATE_AUR,PACMAN_EXE,GARUDA_SNAPSHOT_PACMAN,PACMAN_EXTRA_OPTS" /usr/bin/garuda-update "$@"
- 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=6 . <(wget -qO- https://garudalinux.org/os/garuda-update/remote-update) \"\$@\"" remote-update "${@:2}"
- fi
- if [ -n "$PACMAN_EXE" ]; then
- PACMAN="$PACMAN_EXE"
- else
- PACMAN="pacman"
- fi
- export PACMAN
- DATABASE_UPDATED=false
- if [ -n "$GARUDA_UPDATE_SELFUPDATE" ]; then
- DATABASE_UPDATED=true
- fi
- self_update "$@"
- # shellcheck source=./main-update
- source /usr/lib/garuda/garuda-update/main-update
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement