Running sudo apt-get install <PACKAGE>
will install the package, its dependencies, and any other recommended packages.
However, there does not seem to be a way to install only the dependencies of a package and exclude the package itself.
How would one go about doing this?
This will install all packages in the package's Depends and PreDepends field:
Basically you ask for all dependencies, filter out the (Pre)Depends, and format that output for apt-get.
One problem are dependencies like
or virtual packages like
So: use with care - it doesn't work in all cases!
If you don't mind copy/past, just simulate an apt-get install with
-s
. That way you will see which other packages will get installed and/or upgrade, then you just remove the package name you don't want to install from that list and voila.sudo apt-get install -s <package>
apt-get build-dep <package>
will do the trick.To list all dependencies of a given package not being installed, you could use
aptitude
To install the dependencies
Examples
List the dependencies
Show only the package name
Install the dependencies for, e.g.
mc
You can parse the output of an apt install simulation to do this, here's a bash function to do so for you:
Usage:
To install dependencies only, you can use
apt-cache show package | grep Depends
. This will give you a list of dependencies:then you can decide what package install with apt-get. There is also
aptitude
in the interactive mode, you look for the package select it and then install it's dependencies: