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
@@ -7,6 +7,10 @@
|
||||
# FAKE_APT_MARK_UNHOLD_SIGNAL=SIG: send SIG to the applet before an unhold (a second Ctrl-C).
|
||||
# FAKE_APT_MARK_UNHOLD_RC=N: unhold fails (nothing released). FAKE_APT_MARK_FAIL_MSG: the message a
|
||||
# failing hold prints. Every unhold logs whether $STATE_DIR/holds.lock is held by someone.
|
||||
# showauto/showmanual: installed = the "?i" rows of data/apt/dpkg-status.tsv (not purged), auto = those
|
||||
# listed in data/apt/auto.txt, manual = the others; FAKE_APT_MARK_NEITHER="pkg ..." are in neither
|
||||
# list, FAKE_APT_MARK_SHOW_RC=N makes both fail. Like the real ones they print only the named
|
||||
# packages (all of them without a name), native packages without their ":arch" qualifier.
|
||||
# shellcheck source=../fakelib.bash
|
||||
. "${BASH_SOURCE[0]%/*}/../fakelib.bash"
|
||||
fake_log "$@"
|
||||
@@ -27,8 +31,30 @@ case $verb in hold | unhold)
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
# show_marked auto|manual NAME...
|
||||
show_marked() {
|
||||
local want=$1 n st name mark
|
||||
shift
|
||||
local -A pick=()
|
||||
for n in "$@"; do pick[${n%:all}]=1; done
|
||||
if [[ -n ${FAKE_APT_MARK_SHOW_RC:-} ]]; then
|
||||
echo "E: Unable to determine the package states" >&2
|
||||
exit "$FAKE_APT_MARK_SHOW_RC"
|
||||
fi
|
||||
while IFS=$'\t' read -r st name _; do
|
||||
[[ $st == ?i* ]] || continue
|
||||
fake_purged "$name" && continue
|
||||
[[ " ${FAKE_APT_MARK_NEITHER:-} " == *" $name "* ]] && continue
|
||||
if grep -qxF -- "$name" "$FAKE_DATA/apt/auto.txt"; then mark=auto; else mark=manual; fi
|
||||
[[ $mark == "$want" ]] || continue
|
||||
if (($# == 0)) || [[ -n ${pick[$name]:-} || -n ${pick[$name:amd64]:-} ]]; then printf '%s\n' "$name"; fi
|
||||
done <"$FAKE_DATA/apt/dpkg-status.tsv" | sort
|
||||
}
|
||||
|
||||
case $verb in
|
||||
showhold) sort "$h" ;;
|
||||
showauto) show_marked auto "$@" ;;
|
||||
showmanual) show_marked manual "$@" ;;
|
||||
hold)
|
||||
for p in "$@"; do
|
||||
if grep -qxF -- "$p" "$h"; then echo "$p was already set on hold."; else
|
||||
|
||||
Reference in new issue
Block a user