Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a059e37564 | ||
|
|
6da4312f5c |
No files matched your search
@@ -146,7 +146,9 @@ other command suffixes.
|
|||||||
| `N-` | exclude from this run (toggle; `N-` again re-includes); shown with a `-` marker |
|
| `N-` | exclude from this run (toggle; `N-` again re-includes); shown with a `-` marker |
|
||||||
| `Nx` | purge now, with its now-unneeded dependencies: the purge is simulated first and the prompt lists everything it removes (`Purge su-dummy-a now? This also removes: su-dummy-b [y/N]`); the answer is read from the same stdin; the rows of every removed package leave the list. `x` refuses when other installed packages depend on the target, like `pacman -Rns`; purge the dependents first (`not purged: su-dummy-b is required by: su-dummy-a - purge the dependents first`). Rows with old version `-` (new dependencies, not installed) cannot be purged |
|
| `Nx` | purge now, with its now-unneeded dependencies: the purge is simulated first and the prompt lists everything it removes (`Purge su-dummy-a now? This also removes: su-dummy-b [y/N]`); the answer is read from the same stdin; the rows of every removed package leave the list. `x` refuses when other installed packages depend on the target, like `pacman -Rns`; purge the dependents first (`not purged: su-dummy-b is required by: su-dummy-a - purge the dependents first`). Rows with old version `-` (new dependencies, not installed) cannot be purged |
|
||||||
| `N+` | trust forever: write it and its installed dependency closure to the statefile; the row leaves the list. Rows this hides are re-included if they were excluded (a trusted package is upgraded) |
|
| `N+` | trust forever: write it and its installed dependency closure to the statefile; the row leaves the list. Rows this hides are re-included if they were excluded (a trusted package is upgraded) |
|
||||||
|
| `N++` | follow installed dependents recursively and trust each topmost package and its installed dependencies, even when a topmost package is not in the update list |
|
||||||
| `*+` / `*-` | `+` / `-` for every listed package (`*-` is an all-or-nothing toggle: when all are excluded it re-includes them) |
|
| `*+` / `*-` | `+` / `-` for every listed package (`*-` is an all-or-nothing toggle: when all are excluded it re-includes them) |
|
||||||
|
| `a` | show packages trusted during this session again, marked with `=`; packages already trusted before the session remain hidden |
|
||||||
| `l` | redraw the list |
|
| `l` | redraw the list |
|
||||||
| `q` | quit without upgrading (exit 0) |
|
| `q` | quit without upgrading (exit 0) |
|
||||||
| `h`, `?` | help |
|
| `h`, `?` | help |
|
||||||
|
|||||||
+86
-6
@@ -6,7 +6,7 @@
|
|||||||
# and zypper: list what would be upgraded, interrogate every package, remember the
|
# and zypper: list what would be upgraded, interrogate every package, remember the
|
||||||
# ones you trust, then run the native upgrade (with per-run exclusions).
|
# ones you trust, then run the native upgrade (with per-run exclusions).
|
||||||
#
|
#
|
||||||
# Version: 0.4.0
|
# Version: 0.6.0
|
||||||
#
|
#
|
||||||
# Specification: docs/DESIGN.md. Single file, bash >= 4.3, no runtime dependency
|
# Specification: docs/DESIGN.md. Single file, bash >= 4.3, no runtime dependency
|
||||||
# beyond the distro's package manager and coreutils/sed/grep (awk only on the apt
|
# beyond the distro's package manager and coreutils/sed/grep (awk only on the apt
|
||||||
@@ -23,7 +23,7 @@ export LC_ALL=C DEBIAN_FRONTEND=noninteractive
|
|||||||
# never read from or written to a file (no HISTFILE; `history -r`/`-w`/`-a` are never used).
|
# never read from or written to a file (no HISTFILE; `history -r`/`-w`/`-a` are never used).
|
||||||
unset HISTFILE
|
unset HISTFILE
|
||||||
|
|
||||||
readonly SU_VERSION=0.4.0
|
readonly SU_VERSION=0.6.0
|
||||||
readonly SU_PROG=skeptical-updater
|
readonly SU_PROG=skeptical-updater
|
||||||
readonly SU_STATE_HEADER='# skeptical-updater trusted packages. Columns: backend package reason added(UTC ISO-8601)'
|
readonly SU_STATE_HEADER='# skeptical-updater trusted packages. Columns: backend package reason added(UTC ISO-8601)'
|
||||||
readonly SU_PROMPT_HELP='<enter> upgrade | N? what is it | N?? full info | N- exclude this run | Nx purge now | N+ trust forever'
|
readonly SU_PROMPT_HELP='<enter> upgrade | N? what is it | N?? full info | N- exclude this run | Nx purge now | N+ trust forever'
|
||||||
@@ -120,7 +120,9 @@ interactive commands (one line, whitespace-separated tokens, N = number in brack
|
|||||||
when other installed packages depend on it, like pacman -Rns
|
when other installed packages depend on it, like pacman -Rns
|
||||||
consecutive Nx commands are purged together after one confirmation
|
consecutive Nx commands are purged together after one confirmation
|
||||||
N+ trust it forever (with its installed dependency closure)
|
N+ trust it forever (with its installed dependency closure)
|
||||||
|
N++ trust the topmost installed dependents and their dependency closures
|
||||||
*+ / *- apply + / - to every listed package
|
*+ / *- apply + / - to every listed package
|
||||||
|
a show packages trusted during this session again
|
||||||
l redraw the list
|
l redraw the list
|
||||||
q quit without upgrading (exit 0)
|
q quit without upgrading (exit 0)
|
||||||
h, ? this help
|
h, ? this help
|
||||||
@@ -147,7 +149,9 @@ session_help() {
|
|||||||
pacman -Rns; purge the dependents first
|
pacman -Rns; purge the dependents first
|
||||||
consecutive Nx commands are purged together after one confirmation
|
consecutive Nx commands are purged together after one confirmation
|
||||||
N+ trust N (and its installed dependencies) forever
|
N+ trust N (and its installed dependencies) forever
|
||||||
|
N++ trust the topmost installed dependents of N and their dependencies
|
||||||
*+ *- trust / exclude every listed package (*- again re-includes them)
|
*+ *- trust / exclude every listed package (*- again re-includes them)
|
||||||
|
a show packages trusted during this session again
|
||||||
l redraw the list (a '*' after the number marks an AUR package)
|
l redraw the list (a '*' after the number marks an AUR package)
|
||||||
q quit without upgrading
|
q quit without upgrading
|
||||||
h ? this help
|
h ? this help
|
||||||
@@ -2232,6 +2236,8 @@ maybe_refresh() { if ((opt_refresh)); then be refresh || true; fi; }
|
|||||||
R_NAME=() R_OLD=() R_NEW=() R_REPO=() R_FLAGS=() R_AUR=() R_NUM=() R_GONE=() R_EXCL=() R_NOTES=()
|
R_NAME=() R_OLD=() R_NEW=() R_REPO=() R_FLAGS=() R_AUR=() R_NUM=() R_GONE=() R_EXCL=() R_NOTES=()
|
||||||
N_IDX=() # number -> row index
|
N_IDX=() # number -> row index
|
||||||
N_MAX=0
|
N_MAX=0
|
||||||
|
SESSION_SHOW_TRUSTED=0
|
||||||
|
declare -A SESSION_TRUSTED=()
|
||||||
|
|
||||||
load_rows() {
|
load_rows() {
|
||||||
local out rc=0 line name old new repo flags i n=0 w aur shown
|
local out rc=0 line name old new repo flags i n=0 w aur shown
|
||||||
@@ -2279,7 +2285,7 @@ rows_left() { # number of rows not purged
|
|||||||
row_visible() { # row_visible IDX
|
row_visible() { # row_visible IDX
|
||||||
local i=$1
|
local i=$1
|
||||||
((R_GONE[i] == 0 && R_NUM[i] > 0)) || return 1
|
((R_GONE[i] == 0 && R_NUM[i] > 0)) || return 1
|
||||||
((opt_all)) || ! is_trusted "${R_NAME[i]}"
|
((opt_all)) || ! is_trusted "${R_NAME[i]}" || { ((SESSION_SHOW_TRUSTED)) && [[ -n ${SESSION_TRUSTED[${R_NAME[i]}]+x} ]]; }
|
||||||
}
|
}
|
||||||
|
|
||||||
print_list() {
|
print_list() {
|
||||||
@@ -2296,6 +2302,8 @@ print_list() {
|
|||||||
done
|
done
|
||||||
if ((opt_all)); then
|
if ((opt_all)); then
|
||||||
say "$total upgradable, $trusted trusted (marked with =), $review to review:"
|
say "$total upgradable, $trusted trusted (marked with =), $review to review:"
|
||||||
|
elif ((SESSION_SHOW_TRUSTED)); then
|
||||||
|
say "$total upgradable, $trusted trusted (session trusted marked with =), $review to review:"
|
||||||
else
|
else
|
||||||
say "$total upgradable, $trusted trusted (hidden, use --all to show), $review to review:"
|
say "$total upgradable, $trusted trusted (hidden, use --all to show), $review to review:"
|
||||||
fi
|
fi
|
||||||
@@ -2779,9 +2787,17 @@ session_trust() { # session_trust IDX...
|
|||||||
trust_pkg "${R_NAME[i]}" "$now"
|
trust_pkg "${R_NAME[i]}" "$now"
|
||||||
R_EXCL[i]=0
|
R_EXCL[i]=0
|
||||||
done
|
done
|
||||||
|
session_finish_trust
|
||||||
|
}
|
||||||
|
|
||||||
|
session_finish_trust() {
|
||||||
|
local i
|
||||||
|
for ((i = 0; i < ${#R_NAME[@]}; i++)); do
|
||||||
|
if ((R_NUM[i] > 0 && !R_GONE[i])) && is_trusted "${R_NAME[i]}"; then SESSION_TRUSTED[${R_NAME[i]}]=1; fi
|
||||||
|
done
|
||||||
# a row this trust hides must not stay excluded behind the user's back
|
# a row this trust hides must not stay excluded behind the user's back
|
||||||
for ((i = 0; i < ${#R_NAME[@]}; i++)); do
|
for ((i = 0; i < ${#R_NAME[@]}; i++)); do
|
||||||
if ((R_EXCL[i] && !R_GONE[i] && !opt_all)) && is_trusted "${R_NAME[i]}"; then
|
if ((R_EXCL[i] && !R_GONE[i])) && is_trusted "${R_NAME[i]}" && ! row_visible "$i"; then
|
||||||
R_EXCL[i]=0
|
R_EXCL[i]=0
|
||||||
say " (${R_NAME[i]} is trusted now: no longer excluded from this run)"
|
say " (${R_NAME[i]} is trusted now: no longer excluded from this run)"
|
||||||
fi
|
fi
|
||||||
@@ -2789,6 +2805,62 @@ session_trust() { # session_trust IDX...
|
|||||||
state_save
|
state_save
|
||||||
}
|
}
|
||||||
|
|
||||||
|
session_trust_dependents() {
|
||||||
|
local i=$1 node dep out root other candidate now head blocked
|
||||||
|
local -a queue=() nodes=() roots=() walk=() deps=()
|
||||||
|
local -A seen=() edges=() reach=() visited=()
|
||||||
|
if [[ ${R_OLD[i]} == - ]]; then
|
||||||
|
say "${R_NAME[i]} is not installed: cannot find installed dependents."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
queue=("${R_NAME[i]}")
|
||||||
|
seen[${R_NAME[i]}]=1
|
||||||
|
for ((head = 0; head < ${#queue[@]}; head++)); do
|
||||||
|
node=${queue[head]}
|
||||||
|
nodes+=("$node")
|
||||||
|
if ! out=$(be rdepends "$node"); then
|
||||||
|
err "cannot find installed dependents of $node; nothing was trusted"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
while IFS= read -r dep; do
|
||||||
|
[[ -n $dep ]] || continue
|
||||||
|
edges[$node]+=" $dep"
|
||||||
|
if [[ -z ${seen[$dep]+x} ]]; then seen[$dep]=1; queue+=("$dep"); fi
|
||||||
|
done <<<"$out"
|
||||||
|
done
|
||||||
|
for root in "${nodes[@]}"; do
|
||||||
|
walk=("$root")
|
||||||
|
visited=(["$root"]=1)
|
||||||
|
for ((head = 0; head < ${#walk[@]}; head++)); do
|
||||||
|
node=${walk[head]}
|
||||||
|
read -r -a deps <<<"${edges[$node]-}"
|
||||||
|
for dep in "${deps[@]}"; do
|
||||||
|
[[ -z ${visited[$dep]+x} ]] || continue
|
||||||
|
visited[$dep]=1
|
||||||
|
walk+=("$dep")
|
||||||
|
done
|
||||||
|
done
|
||||||
|
for node in "${walk[@]}"; do reach["$root,$node"]=1; done
|
||||||
|
done
|
||||||
|
mapfile -t nodes < <(printf '%s\n' "${nodes[@]}" | sort -u)
|
||||||
|
for root in "${nodes[@]}"; do
|
||||||
|
blocked=0
|
||||||
|
for other in "${nodes[@]}"; do
|
||||||
|
[[ $root != "$other" && -n ${reach[$root,$other]+x} ]] || continue
|
||||||
|
if [[ -z ${reach[$other,$root]+x} || $other < $root ]]; then blocked=1; break; fi
|
||||||
|
done
|
||||||
|
((blocked)) || roots+=("$root")
|
||||||
|
done
|
||||||
|
now=$(now_utc)
|
||||||
|
for candidate in "${roots[@]}"; do
|
||||||
|
trust_pkg "$candidate" "$now"
|
||||||
|
for ((i = 0; i < ${#R_NAME[@]}; i++)); do
|
||||||
|
[[ ${R_NAME[i]} != "$candidate" ]] || R_EXCL[i]=0
|
||||||
|
done
|
||||||
|
done
|
||||||
|
session_finish_trust
|
||||||
|
}
|
||||||
|
|
||||||
session_toggle_all() {
|
session_toggle_all() {
|
||||||
local i all=1
|
local i all=1
|
||||||
local -a idx=()
|
local -a idx=()
|
||||||
@@ -2824,7 +2896,7 @@ session_line() {
|
|||||||
local tok n op i name
|
local tok n op i name
|
||||||
local -a toks=() batch=() purge_batch=()
|
local -a toks=() batch=() purge_batch=()
|
||||||
local -A initial=() named=()
|
local -A initial=() named=()
|
||||||
local re='^([0-9]{1,6})(\?\?|\?|-|x|\+)$'
|
local re='^([0-9]{1,6})(\?\?|\?|-|x|\+\+|\+)$'
|
||||||
local name_re='^([A-Za-z0-9_+@][A-Za-z0-9_+.@:~-]*)(\?\?|\?)$'
|
local name_re='^([A-Za-z0-9_+@][A-Za-z0-9_+.@:~-]*)(\?\?|\?)$'
|
||||||
read -r -a toks <<<"$1" || true
|
read -r -a toks <<<"$1" || true
|
||||||
if ((${#toks[@]} == 0)); then
|
if ((${#toks[@]} == 0)); then
|
||||||
@@ -2834,7 +2906,7 @@ session_line() {
|
|||||||
for tok in "${toks[@]}"; do
|
for tok in "${toks[@]}"; do
|
||||||
if [[ ! $tok =~ $re && ! $tok =~ $name_re ]]; then
|
if [[ ! $tok =~ $re && ! $tok =~ $name_re ]]; then
|
||||||
case $tok in
|
case $tok in
|
||||||
'*+' | '*-' | l | q | h | '?') ;;
|
'*+' | '*-' | a | l | q | h | '?') ;;
|
||||||
*)
|
*)
|
||||||
err "unknown command '$tok' (h for help)"
|
err "unknown command '$tok' (h for help)"
|
||||||
return 0
|
return 0
|
||||||
@@ -2884,6 +2956,7 @@ session_line() {
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
case $op in
|
case $op in
|
||||||
|
'++') session_trust_dependents "$i" ;;
|
||||||
'?') print_info "${R_NAME[i]}" "${R_OLD[i]}" || true ;;
|
'?') print_info "${R_NAME[i]}" "${R_OLD[i]}" || true ;;
|
||||||
'??') print_full_info "${R_NAME[i]}" "${R_OLD[i]}" || true ;;
|
'??') print_full_info "${R_NAME[i]}" "${R_OLD[i]}" || true ;;
|
||||||
-)
|
-)
|
||||||
@@ -2919,6 +2992,13 @@ session_line() {
|
|||||||
if ((${#idx[@]})); then session_trust "${idx[@]}"; else say "nothing to trust"; fi
|
if ((${#idx[@]})); then session_trust "${idx[@]}"; else say "nothing to trust"; fi
|
||||||
;;
|
;;
|
||||||
'*-') session_toggle_all ;;
|
'*-') session_toggle_all ;;
|
||||||
|
a)
|
||||||
|
SESSION_SHOW_TRUSTED=1
|
||||||
|
for ((n = 1; n <= N_MAX; n++)); do
|
||||||
|
if num_row "$n"; then initial[$n]=$REPLY; named[${R_NAME[REPLY]}]=$REPLY; fi
|
||||||
|
done
|
||||||
|
print_list
|
||||||
|
;;
|
||||||
l) print_list ;;
|
l) print_list ;;
|
||||||
q)
|
q)
|
||||||
say "Quit: nothing was upgraded."
|
say "Quit: nothing was upgraded."
|
||||||
|
|||||||
@@ -536,3 +536,66 @@ UPGRADE='apt-get -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--forc
|
|||||||
assert_output --partial 'would also remove su-dummy-c'
|
assert_output --partial 'would also remove su-dummy-c'
|
||||||
log_lacks '^apt-get -y purge'
|
log_lacks '^apt-get -y purge'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "a shows session trusted rows without exposing previously trusted rows" {
|
||||||
|
write_state "$HEADER" "apt${T}su-dummy-c${T}user${T}2026-01-01T00:00:00Z"
|
||||||
|
run skup --no-refresh <<<$'1+\na\n2?\nq'
|
||||||
|
assert_success
|
||||||
|
assert_line '=[1] su-dummy-a 1.0 -> 2.0 su-fixture:su-repo'
|
||||||
|
assert_line '=[2] su-dummy-b 1.0 -> 2.0 su-fixture:su-repo'
|
||||||
|
refute_output --partial '=[3] su-dummy-c'
|
||||||
|
assert_line 'su-dummy-b: dummy package su-dummy-b for skeptical-updater tests'
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a works on the same line as trust and keeps removed rows hidden" {
|
||||||
|
run skup --no-refresh <<<$'3x\ny\n1+ a 2?\nq'
|
||||||
|
assert_success
|
||||||
|
assert_line 'purged: su-dummy-c'
|
||||||
|
assert_line '=[1] su-dummy-a 1.0 -> 2.0 su-fixture:su-repo'
|
||||||
|
assert_line 'su-dummy-b: dummy package su-dummy-b for skeptical-updater tests'
|
||||||
|
refute_output --partial '=[3] su-dummy-c'
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "N++ trusts the topmost installed dependent and its dependencies" {
|
||||||
|
run skup --no-refresh <<<$'2++\nq'
|
||||||
|
assert_success
|
||||||
|
assert_line 'trusted su-dummy-a (+1 dependency: su-dummy-b)'
|
||||||
|
run cut -f2,3 "$STATE_FILE"
|
||||||
|
assert_line "su-dummy-a${T}user"
|
||||||
|
assert_line "su-dummy-b${T}dep:su-dummy-a"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "N++ trusts all topmost branches including packages outside the list" {
|
||||||
|
local fixture_data="$BATS_TEST_TMPDIR/data"
|
||||||
|
cp -R "$FAKE_DATA" "$fixture_data"
|
||||||
|
printf 'su-dummy-b\nReverse Depends:\n su-dummy-a\n su-dummy-c\n' >"$fixture_data/apt/rdepends/su-dummy-b"
|
||||||
|
printf 'su-dummy-a\nReverse Depends:\n su-dummy-w\n' >"$fixture_data/apt/rdepends/su-dummy-a"
|
||||||
|
sed -i 's/su-virtual | su-dummy-alt/su-dummy-a/; s/^ii \(.*su-dummy-c\)\t\t\t\t/ii \1\t\tsu-dummy-b\t/' "$fixture_data/apt/dpkg-status.tsv"
|
||||||
|
FAKE_DATA="$fixture_data" run skup --no-refresh <<<$'2++\nq'
|
||||||
|
assert_success
|
||||||
|
assert_output --partial 'trusted su-dummy-c'
|
||||||
|
assert_output --partial 'trusted su-dummy-w'
|
||||||
|
run cut -f2,3 "$STATE_FILE"
|
||||||
|
assert_line "su-dummy-c${T}user"
|
||||||
|
assert_line "su-dummy-w${T}user"
|
||||||
|
assert_line "su-dummy-a${T}dep:su-dummy-w"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "N++ terminates on a dependency cycle and chooses one root" {
|
||||||
|
local fixture_data="$BATS_TEST_TMPDIR/data"
|
||||||
|
cp -R "$FAKE_DATA" "$fixture_data"
|
||||||
|
printf 'su-dummy-a\nReverse Depends:\n su-dummy-b\n' >"$fixture_data/apt/rdepends/su-dummy-a"
|
||||||
|
sed -i 's/^ii \(.*su-dummy-b\)\t\t\t\t/ii \1\t\tsu-dummy-a\t/' "$fixture_data/apt/dpkg-status.tsv"
|
||||||
|
FAKE_DATA="$fixture_data" run skup --no-refresh <<<$'2++\nq'
|
||||||
|
assert_success
|
||||||
|
assert_output --partial 'trusted su-dummy-a'
|
||||||
|
run cut -f2,3 "$STATE_FILE"
|
||||||
|
assert_line "su-dummy-a${T}user"
|
||||||
|
assert_line "su-dummy-b${T}dep:su-dummy-a"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "N++ trusts the package itself when it has no installed dependents" {
|
||||||
|
run skup --no-refresh <<<$'3++\nq'
|
||||||
|
assert_success
|
||||||
|
assert_line 'trusted su-dummy-c'
|
||||||
|
}
|
||||||
Reference in new issue
Block a user