3

I want to know ahead of time how many extra packages need to be installed for a given package. I know I get something like this when I do an apt install -s package | grep ^Inst, but can I get the same info using the apt-cache command without needing to grep the output of the simulated apt install command?

I know I can show a list of dependencies for a package with the command:

apt-cache depends package-name

and I know I can limit that list to only those dependencies that I have already installed on my system with:

apt-cache depends -installed package-name

but how can I list only the dependencies that I don't yet have installed on my system? Something akin to:

apt-cache depends -uninstalled package-name
1
  • The tricky thing here is that if a (direct) dependency is installed, then you know all of its sub-dependencies must also be installed. However if a (direct) dependency isn't installed, you don't know which other sub-dependencies may be required without recursively traversing all the way down. Aug 12 at 17:37
2

In layman's terms :)

You can find dependencies, recommends and suggests for a package like so:

apt-cache depends package-name

You can limit it to dependencies only like so:

apt-cache depends package-name | awk '/Depends:/ {print $2}'

You can check installation status of these dependencies like so:

apt-cache depends package-name | awk '/Depends:/ {print $2}' | xargs apt list

You can print only uninstalled dependencies for a package like so:

apt-cache depends package-name | awk '/Depends:/ {print $2}' | xargs apt list | awk '!/installed/ {print}'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.