feat(info): show the install reason and drop the indentation
N? and `info PKG` now print three lines, none indented:
PKG: <description>
reason: explicitly installed | installed as a dependency | unknown | not installed
required by: <installed dependents, comma separated> | nothing
The reason comes from a new <be>_reason backend function: apt-mark
showauto / showmanual (dpkg decides for a package in neither list), the
Install Reason of pacman -Qi, dnf repoquery --installed %{reason} (dnf4
and dnf5 words) and the Installed line of zypper info (rpm plus libzypp's
AutoInstalled when zypper is locked). A row whose old version is "-" is
not installed and the backend is not asked. The "(installed)" qualifier
moves to --help, README and DESIGN.
The rpm E2E fixture and e2e_reset now also mark su-dummy-a and su-dummy-c
as user-installed on dnf, which records plain rpm installs as "unknown",
so 1? and 2? show both reasons on all 12 distros. The verified commands
are recorded in discovery/{apt,pacman,rpm}.md.
This commit is contained in:
1 parent
1354db6c39
commit
71d7f87aa3
21 files changed
+589
-48
No files matched your search
@@ -31,7 +31,10 @@
|
||||
# so it is a pre-existing unneeded package (dnf repoquery --unneeded / zypper packages --unneeded).
|
||||
#
|
||||
# Optional (SU_FIXTURE_B_AUTO=1): su-dummy-b counts as installed as a dependency (dnf: `dnf mark
|
||||
# remove`, zypper: /var/lib/zypp/AutoInstalled), like the pacman fixture's --asdeps.
|
||||
# remove`, zypper: /var/lib/zypp/AutoInstalled), like the pacman fixture's --asdeps; on dnf
|
||||
# su-dummy-a and su-dummy-c also count as installed by the user (`dnf mark install`): dnf4 reports
|
||||
# packages installed with plain rpm as reason "unknown" (dnf5: "External User"). zypper needs
|
||||
# nothing for them: a package that is not in AutoInstalled is user-installed.
|
||||
#
|
||||
# Re-runnable: re-running resets everything to the "1.0 installed, 2.0 available" state.
|
||||
#
|
||||
@@ -198,7 +201,11 @@ fi
|
||||
if [ "${SU_FIXTURE_B_AUTO:-0}" = 1 ]; then
|
||||
case $BACKEND in
|
||||
zypper) grep -qx su-dummy-b /var/lib/zypp/AutoInstalled 2>/dev/null || echo su-dummy-b >>/var/lib/zypp/AutoInstalled ;;
|
||||
dnf|yum) "$BACKEND" -q mark remove su-dummy-b >/dev/null ;;
|
||||
dnf|yum)
|
||||
# dnf4 spelling first, then dnf5's (which asks for confirmation)
|
||||
"$BACKEND" -q mark remove su-dummy-b >/dev/null 2>&1 || "$BACKEND" -q -y mark dependency su-dummy-b >/dev/null
|
||||
"$BACKEND" -q mark install su-dummy-a su-dummy-c >/dev/null 2>&1 || "$BACKEND" -q -y mark user su-dummy-a su-dummy-c >/dev/null
|
||||
;;
|
||||
esac
|
||||
log "su-dummy-b marked as installed as a dependency"
|
||||
fi
|
||||
|
||||
@@ -132,10 +132,14 @@ e2e_reset() {
|
||||
rpm -Uvh --oldpackage --replacepkgs /var/tmp/su-fixture/RPMS/*/su-dummy-[abc]-1.0-1.*.rpm >/dev/null 2>&1
|
||||
;;
|
||||
esac
|
||||
# su-dummy-b is a dependency of su-dummy-a (installed as such), on every backend
|
||||
# su-dummy-b is a dependency of su-dummy-a (installed as such), on every backend; su-dummy-a and
|
||||
# su-dummy-c were installed by the user (dnf records plain rpm installs as reason unknown)
|
||||
case $BE in
|
||||
apt) apt-mark auto su-dummy-orphan su-dummy-b >/dev/null ;;
|
||||
dnf) dnf -q mark remove su-dummy-b >/dev/null 2>&1 ;;
|
||||
dnf)
|
||||
dnf -q mark remove su-dummy-b >/dev/null 2>&1 || dnf -q -y mark dependency su-dummy-b >/dev/null 2>&1
|
||||
dnf -q mark install su-dummy-a su-dummy-c >/dev/null 2>&1 || dnf -q -y mark user su-dummy-a su-dummy-c >/dev/null 2>&1
|
||||
;;
|
||||
zypper) grep -qx su-dummy-b /var/lib/zypp/AutoInstalled 2>/dev/null || echo su-dummy-b >>/var/lib/zypp/AutoInstalled ;;
|
||||
esac
|
||||
[[ $(versions) == "a=1.0 b=1.0 c=1.0" && $(pkg_ver su-dummy-orphan) == 1.0 ]] || {
|
||||
|
||||
@@ -32,14 +32,27 @@ zypper_verb() { case $(. /etc/os-release && printf '%s' "$ID") in opensuse-tumbl
|
||||
refute_line --regexp '^.\[4\]'
|
||||
}
|
||||
|
||||
@test "N? prints the description; su-dummy-b is required by su-dummy-a" {
|
||||
@test "N? prints the description, the install reason and who requires it" {
|
||||
local -a lines_=()
|
||||
local i a=-1 b=-1
|
||||
run skeptical-updater --no-refresh <<<$'1?\n2?\nq'
|
||||
assert_success
|
||||
assert_line --regexp '^su-dummy-a: .*([Dd]ummy|skeptical-updater).*$'
|
||||
assert_line --regexp '^su-dummy-b: .*([Dd]ummy|skeptical-updater).*$'
|
||||
# [1] su-dummy-a has no installed reverse dependency, [2] su-dummy-b is needed by su-dummy-a
|
||||
assert_line ' required by (installed): nothing'
|
||||
assert_line ' required by (installed): su-dummy-a'
|
||||
# [1] su-dummy-a was installed explicitly and nothing needs it; [2] su-dummy-b was installed as
|
||||
# a dependency of su-dummy-a - the two lines right under each description, no indentation
|
||||
mapfile -t lines_ <<<"$output"
|
||||
for i in "${!lines_[@]}"; do
|
||||
case ${lines_[i]} in
|
||||
'su-dummy-a: '*) a=$i ;;
|
||||
'su-dummy-b: '*) b=$i ;;
|
||||
esac
|
||||
done
|
||||
[[ ${lines_[a + 1]} == 'reason: explicitly installed' && ${lines_[a + 2]} == 'required by: nothing' ]] ||
|
||||
fail "1? (su-dummy-a): got '${lines_[a + 1]}' / '${lines_[a + 2]}'"
|
||||
[[ ${lines_[b + 1]} == 'reason: installed as a dependency' && ${lines_[b + 2]} == 'required by: su-dummy-a' ]] ||
|
||||
fail "2? (su-dummy-b): got '${lines_[b + 1]}' / '${lines_[b + 2]}'"
|
||||
refute_output --partial 'required by (installed)'
|
||||
assert_line 'Quit: nothing was upgraded.'
|
||||
}
|
||||
|
||||
@@ -250,7 +263,11 @@ zypper_verb() { case $(. /etc/os-release && printf '%s' "$ID") in opensuse-tumbl
|
||||
assert_line --partial "$BE"$'\t'"su-dummy-c"$'\t'"user"
|
||||
run asuser skeptical-updater info su-dummy-b
|
||||
assert_success
|
||||
assert_line ' required by (installed): su-dummy-a'
|
||||
assert_line 'reason: installed as a dependency'
|
||||
assert_line 'required by: su-dummy-a'
|
||||
run asuser skeptical-updater info su-dummy-a
|
||||
assert_success
|
||||
assert_line 'reason: explicitly installed'
|
||||
run asuser skeptical-updater --dry-run --no-refresh <<<''
|
||||
assert_success
|
||||
assert_line --regexp "$(native_upgrade_regex)"
|
||||
|
||||
Reference in new issue
Block a user