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
@@ -10,6 +10,7 @@
|
||||
# FAKE_PACMAN_STDERR=TEXT: -Sl and -Qu also print TEXT on stderr (an unreadable database).
|
||||
# -Rs --print: FAKE_PACMAN_RS_REFUSE=1 makes pacman refuse ("breaks dependency");
|
||||
# FAKE_PACMAN_RS_EXTRA="pkg:other" adds other to the plan of pkg.
|
||||
# FAKE_PACMAN_REASON="pkg=text" replaces the "Install Reason" of pkg in -Qi (empty text: no such line).
|
||||
# FAKE_PACMAN_QU=fixture|real|none selects the -Qu sample,
|
||||
# FAKE_PACMAN_SL=empty makes -Sl print nothing, FAKE_PACMAN_SUP_EXTRA="a b" adds packages that
|
||||
# only -Sup (the real transaction) shows. Every -Q*/-S[il] call records its COLUMNS value, every
|
||||
@@ -107,7 +108,19 @@ case $op in
|
||||
[[ -z ${FAKE_PACMAN_STDERR:-} ]] || echo "$FAKE_PACMAN_STDERR" >&2
|
||||
[[ ${FAKE_PACMAN_SL:-} == empty ]] || cat "$D/Sl.txt"
|
||||
;;
|
||||
-Qi) blocks "$D/Qi.txt" "${targets[@]}" ;;
|
||||
-Qi)
|
||||
if [[ -z ${FAKE_PACMAN_REASON:-} ]]; then
|
||||
blocks "$D/Qi.txt" "${targets[@]}"
|
||||
exit
|
||||
fi
|
||||
rc=0
|
||||
out=$(blocks "$D/Qi.txt" "${targets[@]}") || rc=$?
|
||||
awk -v n="${FAKE_PACMAN_REASON%%=*}" -v r="${FAKE_PACMAN_REASON#*=}" '
|
||||
/^Name +: / { cur = $0; sub(/^Name +: /, "", cur) }
|
||||
/^Install Reason +: / && cur == n { if (r != "") print "Install Reason : " r; next }
|
||||
{ print }' <<<"$out"
|
||||
exit "$rc"
|
||||
;;
|
||||
-Si)
|
||||
t=()
|
||||
for a in "${targets[@]}"; do t+=("${a#*/}"); done
|
||||
|
||||
Reference in new issue
Block a user