#!/usr/bin/env bash # SPDX-License-Identifier: GPL-2.0-or-later # Copyright (C) 2026 Bryan Joshua Pedini # Fake paru for the AUR E2E tests (tests/e2e/aur.bats installs it as /usr/local/bin/paru on the # pacman backend): emulates paru 2.1.0 (discovery/pacman.md section 15) for su-dummy-aur, the # foreign package of the fixture (FIXTURE_AUR=1), whose 2.0 "AUR build" is # /srv/su-aur/su-dummy-aur-2.0-1-any.pkg.tar.zst. No network. # -Qua "su-dummy-aur 1.0-1 -> 2.0-1" (+ " [ignored]" when IgnorePkg names it) while an # older version is installed; otherwise nothing, exit 1 # -Sia NAME paru's AUR record of su-dummy-aur 2.0-1 (pacman-style "Key : Value" lines) # -Sua [--noconfirm] [--ignore a,b] # installs the 2.0 package with `sudo pacman -U --noconfirm`, unless su-dummy-aur is # ignored or up to date; refuses to run as root like paru ("can't install AUR package # as root") # Every call is appended to /tmp/su-aur-paru.log as " HOME= PWD= "; -Sua # also logs the installed su-dummy-a then (the repository step must have upgraded it before). set -uo pipefail LOG=/tmp/su-aur-paru.log PKG=su-dummy-aur NEW=2.0-1 FILE=/srv/su-aur/su-dummy-aur-2.0-1-any.pkg.tar.zst printf '%s HOME=%s PWD=%s %s\n' "$(id -un)" "${HOME-}" "$PWD" "$*" >>"$LOG" installed() { pacman -Q "$PKG" 2>/dev/null | cut -d' ' -f2; } ignored_by_conf() { pacman-conf IgnorePkg 2>/dev/null | grep -qx "$PKG"; } case ${1:-} in -Qua) v=$(installed) [[ -n $v && $v != "$NEW" ]] || exit 1 if ignored_by_conf; then echo "$PKG $v -> $NEW [ignored]"; else echo "$PKG $v -> $NEW"; fi ;; -Sia) if [[ ${2:-} != "$PKG" ]]; then echo "error: package '${2:-}' was not found" >&2 exit 1 fi cat </dev/null))" >>"$LOG" echo ':: Looking for devel upgrades...' if ((EUID == 0)); then echo ':: Resolving dependencies...' echo "error: can't install AUR package as root" >&2 exit 1 fi v=$(installed) if [[ ,$ign, == *,"$PKG",* ]] || ignored_by_conf; then echo " there is nothing to do" echo "warning: $PKG: ignoring package upgrade ($v => $NEW)" >&2 exit 0 fi if [[ -z $v || $v == "$NEW" ]]; then echo " there is nothing to do" exit 0 fi printf '\nAur (1) Old Version New Version Make Only\naur/%s %s %s No\n\n' "$PKG" "$v" "$NEW" sudo pacman -U --noconfirm "$FILE" ;; *) echo "fake paru: unhandled: $*" >&2 exit 99 ;; esac