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.
44 lines
1.2 KiB
Bash
Executable File
44 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
# Copyright (C) 2026 Bryan Joshua Pedini
|
|
|
|
# fake dpkg-query (unit tests): the dpkg database dump used for dependency closures, and
|
|
# `-W -f '${db:Status-Abbrev}' NAME` (the status of one package; purged = unknown to dpkg)
|
|
# shellcheck source=../fakelib.bash
|
|
. "${BASH_SOURCE[0]%/*}/../fakelib.bash"
|
|
fake_log "$@"
|
|
# FAKE_STATE_APPEND / FAKE_STATE_SED: simulate another process writing the statefile meanwhile
|
|
st=${SKEPTICAL_UPDATER_STATE_DIR:-}/trusted.tsv
|
|
if [[ -n ${FAKE_STATE_APPEND:-} ]]; then printf '%s\n' "$FAKE_STATE_APPEND" >>"$st"; fi
|
|
if [[ -n ${FAKE_STATE_SED:-} ]]; then sed -i "$FAKE_STATE_SED" "$st"; fi
|
|
args=" $* "
|
|
names=()
|
|
while (($#)); do
|
|
case $1 in
|
|
-f) shift ;;
|
|
-*) ;;
|
|
*) names+=("$1") ;;
|
|
esac
|
|
shift
|
|
done
|
|
if ((${#names[@]})); then
|
|
rc=0
|
|
for n in "${names[@]}"; do
|
|
st=$(awk -F'\t' -v n="${n%:amd64}" '$2 == n { print $1; exit }' "$FAKE_DATA/apt/dpkg-status.tsv")
|
|
if [[ -z $st ]] || fake_purged "${n%:amd64}"; then
|
|
echo "dpkg-query: no packages found matching $n" >&2
|
|
rc=1
|
|
continue
|
|
fi
|
|
printf '%s' "$st"
|
|
done
|
|
exit "$rc"
|
|
fi
|
|
case $args in
|
|
*' -W '*) cat "$FAKE_DATA/apt/dpkg-status.tsv" ;;
|
|
*)
|
|
echo "fake dpkg-query: unhandled: $*" >&2
|
|
exit 99
|
|
;;
|
|
esac
|