In the Debian Policy Manual, Chapter 7 - Declaring relationships between packages you can read
In the Depends, Recommends, Suggests, Pre-Depends, Build-Depends and
Build-Depends-Indep control fields of the package, which declare
dependencies on other packages, the package names listed may also
include lists of alternative package names, separated by vertical bar
(pipe) symbols |. In such a case, if any one of the alternative
packages is installed, that part of the dependency is considered to be
satisfied.
I cannot find any other useful information about list of alternatives in the whole document, so I should conclude that, in case none of the packages in the list is already installed, the first one in the list would be chosen. But be aware that this is only my interpretation.
Either I am gravely mistaken, or there's something fundamentally wrong with apt
having 302 dependencies + sub-dependencies. How can any distribution claim to lightweight if it depends on apt
, then? At least, in my laptop, reinstalling apt
doesn't mention any dependencies at all, so I am not sure where you got that figure from. I cooked up a script to check. On Ubuntu 14.04, I get 24 dependencies:
dpkg gcc-4.8-base gcc-4.9-base gnupg gpgv install-info libacl1 libapt-pkg4.12 libattr1 libbz2-1.0 libc6 libgcc1 liblzma5 libpcre3 libreadline6 libselinux1 libstdc++6 libtinfo5 libusb-0.1-4 multiarch-support readline-common tar ubuntu-keyring zlib1g
I then learned about apt-rdepends
: http://xmodulo.com/2013/07/how-to-check-package-dependencies-on-ubuntu-or-debian.html
I installed and ran it, filtered the dependencies, sorted and compared to find the same list I got with the script. So I can safely conclude that these are all the packages you need to install apt
. I think one of those gcc-4.[89]
can be ignored depending on which one you want to install. Note that this list has trimmed down from Ubuntu 12.04, on which running this script (on a server) gave me 28 dependencies:
coreutils debconf dpkg gcc-4.6-base gnupg gpgv install-info libacl1 libapt-pkg4.12 libattr1 libbz2-1.0 libc6 libc-bin libgcc1 liblzma5 libreadline6 libselinux1 libstdc++6 libtinfo5 libusb-0.1-4 multiarch-support perl-base readline-common tar tzdata ubuntu-keyring xz-utils zlib1g
Presumably the packages have been trimmed down. The lack of dependency on coreutils
and debconf
is startling, I must say.
On a side note, I agree with this bug given in apt-rdepends
man page:
apt-rdepends exists. This functionality should really reside in apt-
cache itself.
The apt-cache
tool provides four relevant commands that Braiam, unorthodox-grammar and I have discussed:
depends
: List the (forward) dependencies. This also includes all the packages that are recommended, and also includes packages in the Breaks, Conflicts and Replaces sections. We just need to look at the Depends and Pre-Depends packages.
rdepends
: There's an unfortunate naming clash with apt-rdepends
. Both apt-rdepends
and my aforementioned script check for dependencies recursively, whereas the apt-cache
command is looking for reverse dependencies - packages which depend on the package in consideration. Use this command to check for potentially breakages caused by a package depending on a specific version of the one you are going got change.
showsrc
: This command gives information about the source package that was use to build a package. A single source package can be used to build multiple binary packages - each of which may or may not depend on the others. apt
, for example, depends on libapt-pkg
, but not on libapt-inst
, both of which are provided by the apt
source package. Use this command to gain some insight into other packages you should install, which may not be dependencies, but which may be needed for greater utility,
showpkg
: This command, among other things, lists both reverse and forward dependencies. The reverse dependencies are listed in a straightforward list, but the forward ones are a bit of a jumble - I still am not sure what the numbers mean. In any case, the individual commands depends
and rdepends
are clearer.
Thus, if we need to look at all the packages that a package might depend on directly or indirectly, apt-rdepends
is what we need.
Best Answer
Dependencies should be installed by default with apt-get. You might also want to read the answers for this question: Installing suggested/recommended packages?.