`pactree -r` but only show a partial tree if the last node is an explicitly installed package ? (Equivalent of `aptitude why`)
On Debian systems I very much like the command aptitude why <package> which lets me know exactly why a given package was installed on my system with regards to the commands I manually typed myself, by showing me a reverse dependency chain up to an explicitly installed package.
The best equivalent I found on Arch is pactree -r, which itself prints a full reverse dependency tree for the package.
It's cool, but you rapidly end up with a huge tree, and have to analyze the tree yourself to find packages you know you explicitly installed in order to get the same information as with aptitude why, which is:
"Why/how did this package get installed on my systemd?"
I read the full manpage for pactree in vain.
I was wondering if some of you had found a more efficient solution than I currently have.
Edited 12 Nov 2020. We only hold this version.
About this post
- Posted
- Archived
- Edited
- Score
- 35 · 93% up
- Kind
- Text
- ID
- jsvvif
12 comments
EDIT: /u/Moizac pointed out how to shorten a command.
You could try this command:
It takes a list of all reverse dependencies of
YOURPACKAGEand keeps only those which are explicitely installed.
In more detail:
List all explicitely installed packages without version number.
List all reverse dependencies of the package without tree structure and don't repeat.
Put both command inside parentheses so they can be piped together into the sort command. sort and uniq is used to only show packages which are explicitely installed and a dependency.
EDIT:
You can go one step further to look inside /var/log/pacman.log for when the packages were installed:
EDIT2: Looking through the wiki I found that it already suggest the program
whoneedsfrom pkgtools (AUR) which apparently does the same thing as my first suggested solution.This can be shortened to
pacman -Qqeorpacman -Q --explicit --quietThanks for pointing that out, I'll edit this above.
Please put this in Wiki.
I just found out that the wiki already has some information on using
whoneedsfrompkgtoolswhich does basically the same thing: https://wiki.archlinux.org/index.php/Pacman#PactreeThanks a lot! feel kinda dumb that I didn't think about comparing with
Pacman -Qe, but your way of achieving the goal it is very smart. If I was alone, I believe I would have gone with a rather sizable script entangling everything when you've done it in a one-liner :D, thanks to that clever use ofsortanduniq.Then, the shortest way to type this becomes:
Yep, also have a look at my second edit.
Furthermore I noticed that
--uniqueimplies--linearfor pactree, so you can skip that, too.i did't understood really well but you can just use pacman -Qi packagename to get which packages needs it
There is a package installed on their machine.
They know they didn't install it.
They want to know what package they installed (explicitly) either directly or indirectly lead to that package being installed.
For example: I didn't install Egg, but I installed Cake. Cake depends on Cake Batter and Cake Batter depends on Egg.
They want a way to determine that Cake was the installation responsible for installing Egg.
See that Egg is required by Cake Batter.
See that Cake Batter is required by Cake. If you don't remember installing Cake explicitly, you can check that by running: