feat(aur): list and upgrade AUR packages through paru or yay on Arch
On the pacman backend, an installed AUR helper (paru, else yay;
--aur-helper=paru|yay|none, --no-aur) adds the AUR updates to the review
list. The helper never runs as root: when the tool is root through sudo it
runs as SUDO_USER (runuser -u, else sudo -u, with that user's HOME, from
that home); unprivileged it runs as is; a root login gets no AUR, with a
warning. The banner names the helper ("+ AUR via paru").
- listing: <helper> -Qua (also with --no-refresh), rows with repository
"aur"; [ignored] is shown [held]; a failing -Qua warns and the session
goes on with the repository rows
- every row has a marker column after the number: "*" for AUR rows, a
space otherwise (on every backend)
- N?? merges pacman -Qi with <helper> -Sia; N?, N+, Nx stay with pacman;
N- excludes through the helper's --ignore
- <enter>: the repository step exactly as before, then <helper> -Sua
--ignore <excluded> as the invoking user (--noconfirm only when stdin is
not a terminal); pacman is skipped when only AUR rows are left; a helper
failure is reported and its status returned; --dry-run prints it
- other backends never run a helper; --aur-helper is ignored with a warning
paru 2.1.0 and yay 13.0.1 formats verified in discovery/pacman.md section
15 (proof: discovery/pacman/aur.sh). Unit tests replay the recorded output
(fake paru, yay, runuser, getent); the archlinux E2E run installs the
foreign su-dummy-aur and drives a fake paru through a fake sudo built on
passwordless su for wheel.
This commit is contained in:
1 parent
875c8294bf
commit
def537af58
39 files changed
+1903
-115
No files matched your search
@@ -0,0 +1,180 @@
|
||||
#!/usr/bin/env bats
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2026 Bryan Joshua Pedini
|
||||
|
||||
# E2E: AUR packages. pacman backend (archlinux): su-dummy-aur 1.0 is a foreign package (fixture
|
||||
# FIXTURE_AUR=1), the fake paru (fixtures/fake-paru.sh) offers it at 2.0 and installs it through
|
||||
# the fake sudo (fixtures/fake-sudo.sh: su, passwordless for wheel). The applet runs either as the
|
||||
# test user su-tester, re-executing itself through that sudo, or as root with SUDO_USER=su-tester
|
||||
# (what the re-exec leaves behind). Rows: [1] su-dummy-a [2]* su-dummy-aur [3] su-dummy-b
|
||||
# [4] su-dummy-c. Other backends: the marker column is a space and no AUR helper ever runs.
|
||||
|
||||
load helpers
|
||||
|
||||
PARU_LOG=/tmp/su-aur-paru.log
|
||||
AUR_OLD=/srv/su-aur/su-dummy-aur-1.0-1-any.pkg.tar.zst
|
||||
|
||||
setup_file() {
|
||||
e2e_setup_file
|
||||
if [[ $BE == pacman ]]; then
|
||||
install -m 0755 "$BATS_TEST_DIRNAME/fixtures/fake-paru.sh" /usr/local/bin/paru
|
||||
install -m 0755 "$BATS_TEST_DIRNAME/fixtures/fake-sudo.sh" /usr/local/bin/sudo
|
||||
else
|
||||
# a paru that only records that it ran (it never may: AUR helpers are for pacman only)
|
||||
printf '#!/bin/sh\necho "$*" >>%s\n' "$PARU_LOG" >/usr/local/bin/paru
|
||||
chmod 0755 /usr/local/bin/paru
|
||||
fi
|
||||
}
|
||||
teardown_file() {
|
||||
rm -f /usr/local/bin/paru "$PARU_LOG"
|
||||
if [[ $BE == pacman ]]; then rm -f /usr/local/bin/sudo; fi
|
||||
}
|
||||
setup() {
|
||||
e2e_reset
|
||||
if [[ $BE == pacman ]]; then
|
||||
pacman -U --noconfirm "$AUR_OLD" >/dev/null 2>&1
|
||||
[[ $(pkg_ver su-dummy-aur) == 1.0 ]]
|
||||
fi
|
||||
: >"$PARU_LOG"
|
||||
chmod 0666 "$PARU_LOG"
|
||||
}
|
||||
|
||||
# as_tester ARGS...: run skeptical-updater as the unprivileged su-tester (its TMPDIR: the suite's
|
||||
# is root's); a run that needs root re-executes itself through the fake sudo
|
||||
as_tester() { runuser -u su-tester -- env TMPDIR=/tmp HOME=/home/su-tester skeptical-updater "$@"; }
|
||||
pacman_only() { [[ $BE == pacman ]] || skip "pacman backend only"; }
|
||||
|
||||
@test "AUR: the row is listed with * and repo aur; paru ran as the invoking user after the sudo re-exec" {
|
||||
pacman_only
|
||||
run as_tester list
|
||||
assert_success
|
||||
assert_line --index 0 "Backend: pacman ($(pretty_name)) + AUR via paru"
|
||||
assert_line 'Refreshing package lists... done.'
|
||||
assert_line '4 upgradable, 0 trusted (hidden, use --all to show), 4 to review:'
|
||||
assert_line ' [1] su-dummy-a 1.0-1 -> 2.0-1 su-dummy'
|
||||
assert_line ' [2]* su-dummy-aur 1.0-1 -> 2.0-1 aur'
|
||||
assert_line ' [3] su-dummy-b 1.0-1 -> 2.0-1 su-dummy'
|
||||
assert_line ' [4] su-dummy-c 1.0-1 -> 2.0-1 su-dummy'
|
||||
run cat "$PARU_LOG"
|
||||
assert_output 'su-tester HOME=/home/su-tester PWD=/home/su-tester -Qua'
|
||||
}
|
||||
|
||||
@test "AUR: N? and N?? on the AUR row (pacman -Qi; merged with paru -Sia)" {
|
||||
pacman_only
|
||||
SUDO_USER=su-tester run skeptical-updater --no-refresh <<<$'2?\n2??\nq'
|
||||
assert_success
|
||||
assert_output --partial "$(printf '%s\n' \
|
||||
'su-dummy-aur: Skeptical-updater dummy package AUR (foreign: in no repository)' \
|
||||
'reason: explicitly installed' \
|
||||
'required by: nothing')"
|
||||
assert_line '# lines starting with > come from the upstream candidate: a differing value, or a field the installed record lacks'
|
||||
assert_output --partial "$(printf '%s\n' 'Version : 1.0-1' '> Version : 2.0-1')"
|
||||
assert_line 'Install Reason : Explicitly installed'
|
||||
assert_line '> Repository : aur'
|
||||
assert_line '> Maintainer : su-fixture'
|
||||
assert_line '> AUR URL : https://aur.archlinux.org/packages/su-dummy-aur'
|
||||
run grep -c 'su-tester HOME=/home/su-tester PWD=/home/su-tester -Sia su-dummy-aur' "$PARU_LOG"
|
||||
assert_output 1
|
||||
}
|
||||
|
||||
@test "AUR: N- keeps su-dummy-aur at 1.0 while the repository packages upgrade; paru is not run" {
|
||||
pacman_only
|
||||
SUDO_USER=su-tester run skeptical-updater <<<$'2-\n'
|
||||
assert_success
|
||||
assert_line 'Excluded from this run: su-dummy-aur'
|
||||
assert_line 'Upgrade finished.'
|
||||
[[ $(versions) == "a=2.0 b=2.0 c=2.0" ]] || fail "versions after the run: $(versions)"
|
||||
[[ $(pkg_ver su-dummy-aur) == 1.0 ]] || fail "su-dummy-aur: $(pkg_ver su-dummy-aur)"
|
||||
run grep -c -- '-Sua' "$PARU_LOG"
|
||||
assert_output 0
|
||||
}
|
||||
|
||||
@test "AUR: a plain <enter> upgrades su-dummy-aur to 2.0 with paru, after the repository packages" {
|
||||
pacman_only
|
||||
run as_tester <<<''
|
||||
assert_success
|
||||
assert_line 'Excluded from this run: none'
|
||||
assert_line '+ runuser -u su-tester -- env HOME=/home/su-tester paru -Sua --noconfirm'
|
||||
assert_line 'Upgrade finished.'
|
||||
[[ $(versions) == "a=2.0 b=2.0 c=2.0" ]] || fail "versions after the run: $(versions)"
|
||||
[[ $(pkg_ver su-dummy-aur) == 2.0 ]] || fail "su-dummy-aur: $(pkg_ver su-dummy-aur)"
|
||||
# the repository step came first: su-dummy-a was 2.0 already when paru -Sua started
|
||||
run grep -A1 -- ' -Sua --noconfirm$' "$PARU_LOG"
|
||||
assert_line --index 0 'su-tester HOME=/home/su-tester PWD=/home/su-tester -Sua --noconfirm'
|
||||
assert_line --index 1 ' (at -Sua: su-dummy-a 2.0-1)'
|
||||
run skeptical-updater list --no-refresh --no-aur
|
||||
assert_output --partial 'Nothing to upgrade.'
|
||||
SUDO_USER=su-tester run skeptical-updater list --no-refresh
|
||||
assert_output --partial 'Nothing to upgrade.'
|
||||
}
|
||||
|
||||
@test "AUR: only the AUR row left to upgrade: pacman is not run, only paru" {
|
||||
pacman_only
|
||||
# (the files only: `..` changes with the db.lck of paru's pacman -U)
|
||||
before=$(ls -l --time-style=full-iso /var/lib/pacman/sync)
|
||||
SUDO_USER=su-tester run skeptical-updater <<<$'1- 3- 4-\n'
|
||||
assert_success
|
||||
assert_line 'No repository package to upgrade: pacman is not run, only paru.'
|
||||
assert_line '+ runuser -u su-tester -- env HOME=/home/su-tester paru -Sua --noconfirm --ignore su-dummy-a,su-dummy-b,su-dummy-c'
|
||||
refute_line --regexp '^\+ pacman '
|
||||
[[ $(versions) == "a=1.0 b=1.0 c=1.0" ]] || fail "versions after the run: $(versions)"
|
||||
[[ $(pkg_ver su-dummy-aur) == 2.0 ]] || fail "su-dummy-aur: $(pkg_ver su-dummy-aur)"
|
||||
[[ $(ls -l --time-style=full-iso /var/lib/pacman/sync) == "$before" ]] || fail "the sync database changed although pacman was not run"
|
||||
}
|
||||
|
||||
@test "AUR: --dry-run prints paru's command line (as the invoking user) and changes nothing" {
|
||||
pacman_only
|
||||
SUDO_USER=su-tester run skeptical-updater --dry-run --no-refresh <<<$'3-\n'
|
||||
assert_success
|
||||
assert_line '+ pacman -Su --noconfirm --ignore su-dummy-b'
|
||||
assert_line '+ runuser -u su-tester -- env HOME=/home/su-tester paru -Sua --noconfirm --ignore su-dummy-b'
|
||||
assert_line 'Dry run: nothing was changed.'
|
||||
[[ $(versions) == "a=1.0 b=1.0 c=1.0" && $(pkg_ver su-dummy-aur) == 1.0 ]]
|
||||
run grep -c -- '-Sua' "$PARU_LOG"
|
||||
assert_output 0
|
||||
}
|
||||
|
||||
@test "AUR: unprivileged list --no-refresh runs paru directly, as that user" {
|
||||
pacman_only
|
||||
run as_tester list --no-refresh
|
||||
assert_success
|
||||
assert_line ' [2]* su-dummy-aur 1.0-1 -> 2.0-1 aur'
|
||||
run cat "$PARU_LOG"
|
||||
assert_output --regexp '^su-tester HOME=/home/su-tester PWD=[^ ]+ -Qua$'
|
||||
}
|
||||
|
||||
@test "AUR: a root login (no SUDO_USER): skipped with a warning, the repository rows listed, paru never run" {
|
||||
pacman_only
|
||||
run skeptical-updater list --no-refresh
|
||||
assert_success
|
||||
assert_line --index 0 "Backend: pacman ($(pretty_name))"
|
||||
assert_line --index 1 'skeptical-updater: warning: aur: paru is never run as root and there is no invoking user (SUDO_USER is not set): AUR packages are neither listed nor upgraded (run skeptical-updater through sudo from your own account, or use --no-aur)'
|
||||
assert_line '3 upgradable, 0 trusted (hidden, use --all to show), 3 to review:'
|
||||
refute_output --partial 'su-dummy-aur'
|
||||
[[ ! -s $PARU_LOG ]]
|
||||
}
|
||||
|
||||
@test "AUR: --no-aur lists the repository rows only and never runs paru" {
|
||||
pacman_only
|
||||
run as_tester --no-aur list --no-refresh
|
||||
assert_success
|
||||
assert_line --index 0 "Backend: pacman ($(pretty_name))"
|
||||
assert_line ' [1] su-dummy-a 1.0-1 -> 2.0-1 su-dummy'
|
||||
refute_output --partial 'su-dummy-aur'
|
||||
[[ ! -s $PARU_LOG ]]
|
||||
}
|
||||
|
||||
@test "other backends: the marker column is a space; no AUR helper is ever run, --aur-helper is ignored" {
|
||||
[[ $BE != pacman ]] || skip "not the pacman backend"
|
||||
run skeptical-updater list --no-refresh
|
||||
assert_success
|
||||
assert_line --regexp '^ \[1\] su-dummy-a +1\.0(-1)? +-> +2\.0(-1)? +[^ ]+$'
|
||||
run skeptical-updater --aur-helper=paru list --no-refresh
|
||||
assert_success
|
||||
assert_line "skeptical-updater: warning: --aur-helper=paru is ignored: AUR helpers only apply to the pacman backend (Arch Linux and derivatives)"
|
||||
assert_line --regexp '^ \[3\] su-dummy-c '
|
||||
run skeptical-updater --dry-run --no-refresh <<<''
|
||||
assert_success
|
||||
refute_output --partial 'paru'
|
||||
[[ ! -s $PARU_LOG ]] || fail "paru ran: $(cat "$PARU_LOG")"
|
||||
}
|
||||
@@ -27,8 +27,9 @@ install -m 0755 skeptical-updater /usr/local/bin/skeptical-updater
|
||||
|
||||
if command -v pacman >/dev/null 2>&1; then
|
||||
family=pacman
|
||||
# FIXTURE_SYNC=1: a system whose sync database was synced once (--no-refresh lists from it)
|
||||
FIXTURE_ISOLATE=1 FIXTURE_ORPHAN=1 FIXTURE_SYNC=1 bash tests/e2e/fixtures/pacman.sh
|
||||
# FIXTURE_SYNC=1: a system whose sync database was synced once (--no-refresh lists from it);
|
||||
# FIXTURE_AUR=1: the foreign package su-dummy-aur and the user su-tester for tests/e2e/aur.bats
|
||||
FIXTURE_ISOLATE=1 FIXTURE_ORPHAN=1 FIXTURE_SYNC=1 FIXTURE_AUR=1 bash tests/e2e/fixtures/pacman.sh
|
||||
elif command -v apt-get >/dev/null 2>&1; then
|
||||
family=apt
|
||||
SU_FIXTURE_OFFLINE=1 SU_FIXTURE_ORPHAN=1 SU_FIXTURE_B_AUTO=1 bash tests/e2e/fixtures/apt.sh
|
||||
|
||||
Executable
+97
@@ -0,0 +1,97 @@
|
||||
#!/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 "<user> HOME=<home> PWD=<dir> <args>"; -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 <<REC
|
||||
Repository : aur
|
||||
Name : $PKG
|
||||
Version : $NEW
|
||||
Description : Skeptical-updater dummy package AUR (foreign: in no repository)
|
||||
URL : https://example.invalid/su-dummy
|
||||
AUR URL : https://aur.archlinux.org/packages/$PKG
|
||||
Groups : None
|
||||
Licenses : custom
|
||||
Provides : None
|
||||
Depends On : None
|
||||
Make Deps : None
|
||||
Check Deps : None
|
||||
Optional Deps : None
|
||||
Conflicts With : None
|
||||
Maintainer : su-fixture
|
||||
Votes : 7
|
||||
Popularity : 0.01
|
||||
First Submitted : Tue, 14 Nov 2023 22:13:20
|
||||
Last Modified : Tue, 14 Nov 2023 22:13:20
|
||||
Out Of Date : No
|
||||
|
||||
REC
|
||||
;;
|
||||
-Sua)
|
||||
shift
|
||||
ign=''
|
||||
while (($#)); do
|
||||
case $1 in
|
||||
--ignore)
|
||||
ign=${2:-}
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
echo " (at -Sua: $(pacman -Q su-dummy-a 2>/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
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2026 Bryan Joshua Pedini
|
||||
|
||||
# Fake sudo for the AUR E2E tests (tests/e2e/aur.bats installs it as /usr/local/bin/sudo on the
|
||||
# pacman backend): archlinux:latest has no sudo and the E2E run is offline. Runs
|
||||
# "sudo [--] COMMAND..." as root through su, which the fixture (FIXTURE_AUR=1) makes passwordless
|
||||
# for the members of wheel (pam_wheel trust), with the variables sudo sets for the command:
|
||||
# SUDO_USER, SUDO_UID and SUDO_GID. Used for the applet's own re-exec and by the fake paru.
|
||||
[[ ${1:-} != -- ]] || shift
|
||||
if (($# == 0)); then
|
||||
echo "usage: sudo [--] command..." >&2
|
||||
exit 1
|
||||
fi
|
||||
# shellcheck disable=SC2016 # $1... belong to the root shell started by su
|
||||
exec su -s /bin/bash root -c 'exec env SUDO_USER="$1" SUDO_UID="$2" SUDO_GID="$3" "${@:4}"' -- sudo "$(id -un)" "$(id -u)" "$(id -g)" "$@"
|
||||
@@ -3,8 +3,9 @@
|
||||
# Copyright (C) 2026 Bryan Joshua Pedini
|
||||
|
||||
# Deterministic pacman fixture for skeptical-updater E2E tests.
|
||||
# (tests/e2e/fixtures/pacman.sh: copy of discovery/pacman/fixture.sh plus the FIXTURE_ORPHAN
|
||||
# knob; tests/e2e/entrypoint.sh runs it with FIXTURE_ISOLATE=1 FIXTURE_ORPHAN=1.)
|
||||
# (tests/e2e/fixtures/pacman.sh: copy of discovery/pacman/fixture.sh plus the FIXTURE_ORPHAN and
|
||||
# FIXTURE_AUR knobs; tests/e2e/entrypoint.sh runs it with FIXTURE_ISOLATE=1 FIXTURE_ORPHAN=1
|
||||
# FIXTURE_SYNC=1 FIXTURE_AUR=1.)
|
||||
#
|
||||
# Creates three dummy packages installed at 1.0 and a local pacman repo
|
||||
# ([su-dummy], file:///srv/su-repo) that offers them at 2.0:
|
||||
@@ -37,6 +38,11 @@
|
||||
# IgnorePkg) while upgrading su-dummy-a fails with unsatisfied deps.
|
||||
# FIXTURE_ORPHAN 0 (default) | 1 -> also install su-dummy-orphan 1.0 --asdeps with nothing
|
||||
# requiring it (a pre-existing orphan, `pacman -Qdtq` lists it)
|
||||
# FIXTURE_AUR 0 (default) | 1 -> also install su-dummy-aur 1.0, a foreign package (in no
|
||||
# repository: `pacman -Qm` lists it), and keep its 2.0 package file in
|
||||
# /srv/su-aur for the fake paru of tests/e2e/aur.bats; create the user
|
||||
# su-tester (group wheel) and make `su` passwordless for wheel (pam_wheel
|
||||
# trust), which the fake sudo of those tests relies on (the image has no sudo)
|
||||
# FIXTURE_REPO repo directory (default /srv/su-repo)
|
||||
# FIXTURE_SYNC 0 (default) | 1 -> run `pacman -Sy` at the end
|
||||
#
|
||||
@@ -52,6 +58,7 @@ FIXTURE_STRICT_DEP=${FIXTURE_STRICT_DEP:-0}
|
||||
FIXTURE_REPO=${FIXTURE_REPO:-/srv/su-repo}
|
||||
FIXTURE_SYNC=${FIXTURE_SYNC:-0}
|
||||
FIXTURE_ORPHAN=${FIXTURE_ORPHAN:-0}
|
||||
FIXTURE_AUR=${FIXTURE_AUR:-0}
|
||||
FIXTURE_REPO_NAME=su-dummy
|
||||
FIXTURE_EPOCH=1700000000 # fixed build date => reproducible tarballs
|
||||
|
||||
@@ -208,7 +215,24 @@ fx_main() {
|
||||
fi
|
||||
rm -rf "$old"
|
||||
|
||||
if [ "$FIXTURE_AUR" = 1 ]; then
|
||||
mkdir -p /srv/su-aur
|
||||
[ "$FIXTURE_BUILDER" != makepkg ] || chown su-builder: /srv/su-aur
|
||||
fx_build /srv/su-aur su-dummy-aur 1.0 'Skeptical-updater dummy package AUR (foreign: in no repository)'
|
||||
fx_build /srv/su-aur su-dummy-aur 2.0 'Skeptical-updater dummy package AUR (foreign: in no repository)'
|
||||
chmod -R a+rX /srv/su-aur
|
||||
fx_pacman -U --noconfirm /srv/su-aur/su-dummy-aur-1.0-1-any.pkg.tar.zst
|
||||
id su-tester >/dev/null 2>&1 || useradd --create-home --groups wheel su-tester
|
||||
sed -i 's/^#\(auth[[:space:]]\+sufficient[[:space:]]\+pam_wheel\.so trust use_uid\)/\1/' /etc/pam.d/su
|
||||
grep -q '^auth[[:space:]]\+sufficient[[:space:]]\+pam_wheel\.so trust use_uid' /etc/pam.d/su ||
|
||||
fx_die "could not enable pam_wheel trust in /etc/pam.d/su"
|
||||
fi
|
||||
|
||||
if [ "$FIXTURE_SYNC" = 1 ]; then fx_pacman -Sy; fi
|
||||
if [ "$FIXTURE_AUR" = 1 ]; then
|
||||
pacman -Qmq | grep -qx su-dummy-aur || fx_die "su-dummy-aur is not a foreign package"
|
||||
fx_log "foreign (AUR) package: su-dummy-aur 1.0; user su-tester (wheel, passwordless su)"
|
||||
fi
|
||||
|
||||
fx_log "builder=$FIXTURE_BUILDER isolate=$FIXTURE_ISOLATE repo=$FIXTURE_REPO"
|
||||
fx_log "installed: $(pacman -Q su-dummy-a su-dummy-b su-dummy-c 2>/dev/null | tr '\n' ';')"
|
||||
|
||||
@@ -17,7 +17,7 @@ rpm) if command -v zypper >/dev/null 2>&1; then BE=zypper; else BE=dnf; fi ;;
|
||||
*) BE=unknown ;;
|
||||
esac
|
||||
export STATE_DIR STATE_FILE FAMILY BE
|
||||
unset SKEPTICAL_UPDATER_STATE_DIR NO_COLOR
|
||||
unset SKEPTICAL_UPDATER_STATE_DIR NO_COLOR SUDO_USER
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
pretty_name() { (. /etc/os-release && printf '%s' "$PRETTY_NAME"); }
|
||||
|
||||
@@ -26,9 +26,9 @@ zypper_verb() { case $(. /etc/os-release && printf '%s' "$ID") in opensuse-tumbl
|
||||
run skeptical-updater list --no-refresh
|
||||
assert_success
|
||||
assert_line "3 upgradable, 0 trusted (hidden, use --all to show), 3 to review:"
|
||||
assert_line --regexp '^ \[1\] su-dummy-a +1\.0(-1)? +-> +2\.0(-1)? +[^ ]+$'
|
||||
assert_line --regexp '^ \[2\] su-dummy-b +1\.0(-1)? +-> +2\.0(-1)? +[^ ]+$'
|
||||
assert_line --regexp '^ \[3\] su-dummy-c +1\.0(-1)? +-> +2\.0(-1)? +[^ ]+$'
|
||||
assert_line --regexp '^ \[1\] su-dummy-a +1\.0(-1)? +-> +2\.0(-1)? +[^ ]+$'
|
||||
assert_line --regexp '^ \[2\] su-dummy-b +1\.0(-1)? +-> +2\.0(-1)? +[^ ]+$'
|
||||
assert_line --regexp '^ \[3\] su-dummy-c +1\.0(-1)? +-> +2\.0(-1)? +[^ ]+$'
|
||||
refute_line --regexp '^.\[4\]'
|
||||
}
|
||||
|
||||
@@ -100,13 +100,13 @@ zypper_verb() { case $(. /etc/os-release && printf '%s' "$ID") in opensuse-tumbl
|
||||
assert_line "3 upgradable, 2 trusted (hidden, use --all to show), 1 to review:"
|
||||
refute_output --partial 'su-dummy-a'
|
||||
refute_output --partial 'su-dummy-b'
|
||||
assert_line --regexp '^ \[1\] su-dummy-c '
|
||||
assert_line --regexp '^ \[1\] su-dummy-c '
|
||||
run skeptical-updater list --no-refresh --all
|
||||
assert_success
|
||||
assert_line "3 upgradable, 2 trusted (marked with =), 1 to review:"
|
||||
assert_line --regexp '^=\[1\] su-dummy-a '
|
||||
assert_line --regexp '^=\[2\] su-dummy-b '
|
||||
assert_line --regexp '^ \[3\] su-dummy-c '
|
||||
assert_line --regexp '^=\[1\] su-dummy-a '
|
||||
assert_line --regexp '^=\[2\] su-dummy-b '
|
||||
assert_line --regexp '^ \[3\] su-dummy-c '
|
||||
}
|
||||
|
||||
@test "trust / trusted / refresh / untrust from the command line" {
|
||||
@@ -142,7 +142,7 @@ zypper_verb() { case $(. /etc/os-release && printf '%s' "$ID") in opensuse-tumbl
|
||||
[[ $(versions) == "a=2.0 b=1.0 c=2.0" ]] || fail "versions after the run: $(versions)"
|
||||
[[ $(holds_snapshot) == "$before" ]] || fail "hold/lock state changed: $(holds_snapshot)"
|
||||
run skeptical-updater list --no-refresh
|
||||
assert_line --regexp '^ \[1\] su-dummy-b +1\.0'
|
||||
assert_line --regexp '^ \[1\] su-dummy-b +1\.0'
|
||||
}
|
||||
|
||||
@test "a pre-existing hold/lock/IgnorePkg on su-dummy-c survives a run that excludes su-dummy-b" {
|
||||
@@ -150,7 +150,7 @@ zypper_verb() { case $(. /etc/os-release && printf '%s' "$ID") in opensuse-tumbl
|
||||
before=$(holds_snapshot)
|
||||
[[ -n $before ]]
|
||||
run skeptical-updater list --no-refresh
|
||||
assert_line --regexp '^ \[2\] su-dummy-b '
|
||||
assert_line --regexp '^ \[2\] su-dummy-b '
|
||||
run skeptical-updater <<<$'2-\n'
|
||||
assert_success
|
||||
assert_line 'Excluded from this run: su-dummy-b'
|
||||
@@ -193,7 +193,7 @@ zypper_verb() { case $(. /etc/os-release && printf '%s' "$ID") in opensuse-tumbl
|
||||
assert_success
|
||||
assert_line 'not purged: su-dummy-b is required by: su-dummy-a - purge the dependents first'
|
||||
refute_output --partial '[y/N]'
|
||||
[[ $(grep -c '^ \[2\] su-dummy-b ' <<<"$output") -eq 2 ]] || fail "row 2 left the list"
|
||||
[[ $(grep -c '^ \[2\] su-dummy-b ' <<<"$output") -eq 2 ]] || fail "row 2 left the list"
|
||||
[[ $(versions) == "a=1.0 b=1.0 c=1.0" ]] || fail "versions after the run: $(versions)"
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user