Show package dependencies as recursive tree
I would like a way to see package dependencies in a nested tree view, for Debian (apt/dpkg).
Like how pstree displays a tree of processes, but with a specified package instead. There's already "apt depends <packagename>" which shows dependencies (and related packages), but it doesn't do tree format (or provide descriptions). I also found debtree which can do graphs, but I don't want a graph. What I want: * only dependencies (no recommends/suggests/enhances/etc) * if a package is not already installed, show child dependencies in a tree (recursively) * output should include the same brief descriptions that packages.debian.org uses (first line of Description field?) * a status to indicate already installed/downloaded packages * for lib* packages, either a count or a single line (no dependencies/descriptions needed) Here's an example of the type of output I'd like: Code:
$ dependency_tree vim Am I overlooking a tool that already provides something like that, or is it something I need to go build myself? |
Quote:
If you make such a thing, let me know because I would love to see the code. |
Perhaps, apt-rdepends? It produces output similar to
Code:
apt -i --recurse -oAPT::Architectures=, \ Code:
apt-rdepends -p vim First level vim dependencies (packages vim directly depends on): Code:
aptitude search '~rnative~R^vim$' Code:
aptitude search '~rnative~R~R^vim$' Something you can achieve with apt-cache and dctrl-tools: Code:
apt-cache -i --recurse -oAPT::Architectures=, \ Code:
...|sed '1d;/^ /d'|sort|xargs -rn1 ... Code:
tbl-dctrl -Hd$'\t'|column -ts$'\t' To see what packages would be pulled in and installed automatically as dependencies of a package, I'd just use Code:
aptitude -sy install vim |
Thanks Shruggy, a lot of interesting+useful stuff there.
I had missed the --recurse option for apt/apt-cache before, but I think I need to do it manually to get the format I want anyway. Aptitude search is nice and flexible - there have definitely been times in the past where that would have been handy - but for scripting use it's painfully slow. Quote:
Anyhow, I've been playing around with Python, but may switch it to Bash depending on how it turns out; either way I'll post when I've got something worth showing. |
You could have a look at the Pacman Rosetta page. It doesn't have exactly what you ask (pactree was my first thought), but a few good hints.
|
Thanks - I bookmarked that page last time you/someone mentioned it, thinking "that'll come in useful", only to then not even think to look at it. :(
|
Not sure if and how they could fit in here, but I just remembered there are those dose3 and botch tools.
Code:
ls /var/lib/apt/lists/*Packages|sed 's#^#deb://#'| |
1 Attachment(s)
Here's the current version of script, but it's still a work in progress.
*sigh* LQ's stupid CloudFlare firewall blocked it, so get the attachment then "tar -xvf pkgtree.tgz.txt" to get the script. It works on Debian 11, but not Debian 10 because it currently relies on the tree-formatting functionality of bsdextrautils/column which wasn't present in the earlier bsdmainutils/column. (Wouldn't mind replacing that with something a bit better, but can't find if there's other similar tools because searching just brings up the annoyingly-named file-listing tree command, and not sure if it's worth the effort to write something.) There's also a function for Yum in there (disconnected and not tested), which might work with RHELv8/compatible (v7 has the older column command). Anyway, script is attached, here's a couple of quick examples... Code:
$ ./pkgtree.sh vim Code:
$ ./pkgtree.sh --maxdepth=2 task-kde-desktop |
Quote:
Code:
function getPackageInfoDnf() Code:
grep-aptavail -dnsDescription,Section,Pre-Depends,Depends -\!XFArchitecture i386 -aXP "$1"| |
Quote:
Annoyingly it takes about half a second per package, and the lack of any "section" field to filter on means it takes almost 4 minutes for "./pkgtree.sh vim-enhanced", because it iterates through over a hundred glibc langpack packages. Quote:
As does aptitude, pkcon, and even apt-cache if you use the "wrong" options - the first line of the awk is because "time apt-cache show perl" takes 0.08s whilst any option that gets it to return a single record makes it take over 0.52s :/ |
Quote:
Quote:
Code:
dnf -q rq --requires --resolve --recursive <package_name> Code:
repoquery -R --output ascii-tree <package_name> Quote:
|
All times are GMT -5. The time now is 03:34 PM. |