commit 9f0baf05f6420f0cf894a9034395ccd3579da613
parent 2ca0d30202871b6bcb96a98ccf922e9b660baf1a
Author: Jacob R. Edwards <n/a>
Date: Tue, 1 Mar 2022 21:53:42 -0800
Show every package in pkg_root's walk
Diffstat:
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/local/bin/bin/pkg_root b/local/bin/bin/pkg_root
@@ -2,20 +2,27 @@
# Copyright 2021 Jacob R. Edwards
# License: GPLv3
#
-# pkg_root -- List manually installed OpenBSD packages with the given dependancy
+# pkg_root -- Reverse dependancy tree
-pkg_info -Iq "$@" | awk 'function walk(pkg, file)
+pkg_info -Iq "$@" | awk 'function walk(pkg, depth, file)
{
+ pkgs[depth] = pkg;
+
file = "/var/db/pkg/" pkg "/+REQUIRED_BY";
while ((r = getline < file) > 0)
- walk($0);
+ walk($0, depth + 1);
close(file);
- if (r == -1 && !pkgs[pkg])
- print pkg;
- pkgs[pkg] = 1;
+ if (r == -1 && !reqs[pkgs[depth]]) {
+ for (i = depth; i >= 0; --i) {
+ for (j = 0; j < depth - i; ++j)
+ printf " ";
+ print pkgs[i];
+ }
+ }
+ reqs[pkgs[depth]] = 1;
}
{
- walk($0);
+ walk($0, 0);
}'