Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
vim (2:8.2.2434-3+deb11u1) Vi IMproved - enhanced vi editor
- vim-common (= 2:8.2.2434-3+deb11u1) Vi IMproved - Common files
- xxd tool to make (or reverse) a hex dump
- vim-runtime (= 2:8.2.2434-3+deb11u1) Vi IMproved - Runtime files
If you compare that with "apt depends vim" or the online package page the differences are hopefully apparent.
Am I overlooking a tool that already provides something like that, or is it something I need to go build myself?
I would like a way to see 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 is:
* only dependencies (no recommends/suggests/enhances/etc)
* if a package is not already installed, show child dependencies
* 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
vim (2:8.2.2434-3+deb11u1) Vi IMproved - enhanced vi editor
- vim-common (= 2:8.2.2434-3+deb11u1) Vi IMproved - Common files
- xxd tool to make (or reverse) a hex dump
- vim-runtime (= 2:8.2.2434-3+deb11u1) Vi IMproved - Runtime files
If you compare that with "apt depends vim" or the online package page the differences are hopefully apparent.
Am I overlooking a tool that already provides something like that, or is it something I need to go build myself?
Nothing I know of. such a tree would be useful for some maintainers, developers, and a few system admins. Normal users would never need it.
If you make such a thing, let me know because I would love to see the code.
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:
Originally Posted by wpeckham
Nothing I know of. such a tree would be useful for some maintainers, developers, and a few system admins. Normal users would never need it.
If you make such a thing, let me know because I would love to see the code.
I never claim to be normal, but my motivation was that of a user. I wanted to switch my Cinnamon desktop to Plasma; not wanting all the software that the tasksel method would have installed, I started looking at the packages involved, and realised there should be an easier way to see what brings in what.
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.
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
vim Vi IMproved - enhanced vi editor [editors] (7)
├─vim-common Vi IMproved - Common files [editors] (1)
│ └─xxd tool to make (or reverse) a hex dump [editors] (1)
└─vim-runtime Vi IMproved - Runtime files [editors] (1)
Code:
$ ./pkgtree.sh --maxdepth=2 task-kde-desktop
task-kde-desktop KDE Plasma [tasks] (4)
├─tasksel tool for selecting tasks for installation on Debian systems [admin] (5)
├─task-desktop Debian desktop environment [tasks] (5)
├─kde-standard KDE Plasma Desktop and standard set of applications [metapackages] (23)
│ ├─akregator RSS/Atom feed aggregator [web] (55)
│ ├─ark archive utility [utils] (32)
│ ├─dragonplayer simple video player [video] (26)
│ ├─gwenview image viewer [graphics] (49)
│ ├─juk music jukebox / music player [sound] (34)
│ ├─kaddressbook address book and contact data manager [utils] (48)
│ ├─kate powerful text editor [editors] (47)
│ ├─kcalc simple and scientific calculator [math] (19)
│ ├─kde-plasma-desktop KDE Plasma Desktop and minimal set of applications [metapackages] (5)
│ ├─kde-spectacle Screenshot capture utility [graphics] (38)
│ ├─kmail full featured graphical email client [mail] (114)
│ ├─knotes sticky notes application [kde] (65)
│ ├─korganizer calendar and personal organizer [kde] (76)
│ ├─kwalletmanager secure password wallet manager [utils] (27)
│ ├─okular universal document viewer [graphics] (50)
│ ├─plasma-dataengines-addons additional data engines for Plasma [kde] (21)
│ ├─plasma-pa Plasma 5 Volume controller [kde] (26)
│ ├─plasma-runners-addons additional runners for Plasma 5 and Krunner [kde] (17)
│ ├─plasma-wallpapers-addons additional wallpaper plugins for Plasma 5 [kde] (2)
│ ├─plasma-widgets-addons additional widgets for Plasma 5 [kde] (47)
│ ├─polkit-kde-agent-1 KDE dialogs for PolicyKit [kde] (15)
│ └─sweeper history and temporary file cleaner [utils] (19)
└─sddm modern display manager for X11 [kde] (19)
├─adduser add and remove users and groups [admin] (2)
├─xauth X authentication utility [x11] (5)
├─x11-common X Window System (X.Org) infrastructure [x11] (1)
├─xserver-xorg X.Org X server [x11] (5)
└─debconf Debian configuration management system [admin] (1)
Thanks, I've just setup an AlmaLinux VM to test. Needed to add a "$1" on the penultimate line.
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:
I'd also replace apt-cache show ...|awk ... in getPackageInfo() with
Code:
grep-aptavail -dnsDescription,Section,Pre-Depends,Depends -\!XFArchitecture i386 -aXP "$1"|
sed "2a$Status"
That's also taking about half a second for a single record.
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 :/
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.
Yeah. I think doing this with dnf/yum would be impractical. At least, dnf and repoquery can recurse:
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
I see. And dropping -X/--exact-match from grep-aptavail doesn't help either. Looks like apt-cache is the fastest option.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.