How can I determine why apt-get will install a package?
Solution 1:
What you really seem to be asking is "How do I diagram dependencies?" so you can see which packages pull in which dependencies.
You get both text and diagrammed dependencies from the apt-cache
command (included in the apt package, part of the default install).
Here's an example of apt-cache for listing dependencies of the 'hello' package in text format. Text output will always be only one level.
$ apt-cache depends hello
hello
Depends: libc6
|Depends: dpkg
Depends: install-info
You can read the diagram using any dotfile viewer, such as dotty
(included in the graphviz package, also part of the default install)
Here's an example of getting the full dependency tree in graphical format, then displaying it. Graphical output will always be the full tree.
$ apt-cache dotty hello > dotfile
$ dotty dotfile
Looking it over, you can see that the 'hello' package pulls in a ton of Perl packages...and which dependency does it.
Solution 2:
apt-rdepends
does this, without installing 50+ libraries of cruft like ubuntu-dev-tools
.
durr@scraper:~$ apt-rdepends mercurial
Reading package lists... Done
Building dependency tree
Reading state information... Done
mercurial
Depends: libc6 (>= 2.14)
Depends: mercurial-common (= 2.8.2-1ubuntu1)
Depends: python (<< 2.8)
Depends: ucf (>= 2.0020)
libc6
Depends: libgcc1
libgcc1
Depends: gcc-4.9-base (= 4.9-20140406-0ubuntu1)
Depends: libc6 (>= 2.14)
PreDepends: multiarch-support
gcc-4.9-base
multiarch-support
Depends: libc6 (>= 2.3.6-2)
mercurial-common
Depends: python (<< 2.8)
Depends: python:any (>= 2.7.1-0ubuntu2)
python
Depends: libpython-stdlib (= 2.7.5-5ubuntu3)
Depends: python-minimal (= 2.7.5-5ubuntu3)
Depends: python2.7 (>= 2.7.5-1~)
libpython-stdlib
Depends: libpython2.7-stdlib (>= 2.7.5-1~)
libpython2.7-stdlib
Depends: libbz2-1.0
Depends: libc6 (>= 2.15)
Depends: libdb5.3
Depends: libexpat1 (>= 2.1~beta3)
Depends: libffi6 (>= 3.0.4)
Depends: libncursesw5 (>= 5.6+20070908)
Depends: libpython2.7-minimal (= 2.7.6-8)
Depends: libreadline6 (>= 6.0)
Depends: libsqlite3-0 (>= 3.5.9)
Depends: libssl1.0.0 (>= 1.0.0)
Depends: libtinfo5
Depends: mime-support
libbz2-1.0
Depends: libc6 (>= 2.4)
PreDepends: multiarch-support
libdb5.3
Depends: libc6 (>= 2.17)
PreDepends: multiarch-support
libexpat1
Depends: libc6 (>= 2.14)
PreDepends: multiarch-support
libffi6
Depends: libc6 (>= 2.14)
PreDepends: multiarch-support
libncursesw5
Depends: libc6 (>= 2.15)
Depends: libtinfo5 (= 5.9+20140118-1ubuntu1)
PreDepends: multiarch-support
libtinfo5
Depends: libc6 (>= 2.15)
PreDepends: multiarch-support
libpython2.7-minimal
libreadline6
Depends: libc6 (>= 2.15)
Depends: libtinfo5
Depends: readline-common
PreDepends: multiarch-support
readline-common
Depends: dpkg (>= 1.15.4)
Depends: install-info
dpkg
PreDepends: libbz2-1.0
PreDepends: libc6 (>= 2.14)
PreDepends: liblzma5 (>= 5.1.1alpha+20120614)
PreDepends: libselinux1 (>= 2.1.0)
PreDepends: tar (>= 1.23)
PreDepends: zlib1g (>= 1:1.1.4)
liblzma5
Depends: libc6 (>= 2.14)
PreDepends: multiarch-support
libselinux1
Depends: libc6 (>= 2.14)
Depends: libpcre3
PreDepends: multiarch-support
libpcre3
Depends: libc6 (>= 2.14)
PreDepends: multiarch-support
tar
PreDepends: libacl1 (>= 2.2.51-8)
PreDepends: libc6 (>= 2.17)
PreDepends: libselinux1 (>= 1.32)
libacl1
Depends: libattr1 (>= 1:2.4.46-8)
Depends: libc6 (>= 2.14)
PreDepends: multiarch-support
libattr1
Depends: libc6 (>= 2.4)
PreDepends: multiarch-support
zlib1g
Depends: libc6 (>= 2.14)
PreDepends: multiarch-support
install-info
Depends: libc6 (>= 2.14)
PreDepends: dpkg (>= 1.16.1)
libsqlite3-0
Depends: libc6 (>= 2.14)
PreDepends: multiarch-support
libssl1.0.0
Depends: debconf (>= 0.5)
Depends: debconf-2.0
Depends: libc6 (>= 2.14)
PreDepends: multiarch-support
debconf
PreDepends: perl-base (>= 5.6.1-4)
perl-base
PreDepends: dpkg (>= 1.14.20)
PreDepends: libc6 (>= 2.14)
debconf-2.0
mime-support
python-minimal
Depends: dpkg (>= 1.13.20)
Depends: python2.7-minimal (>= 2.7.5-1~)
python2.7-minimal
Depends: libpython2.7-minimal (= 2.7.6-8)
Depends: zlib1g (>= 1:1.2.0)
PreDepends: libc6 (>= 2.15)
python2.7
Depends: libpython2.7-stdlib (= 2.7.6-8)
Depends: mime-support
Depends: python2.7-minimal (= 2.7.6-8)
python:any
ucf
Depends: coreutils (>= 5.91)
Depends: debconf (>= 1.5.19)
coreutils
PreDepends: libacl1 (>= 2.2.51-8)
PreDepends: libattr1 (>= 1:2.4.46-8)
PreDepends: libc6 (>= 2.17)
PreDepends: libselinux1 (>= 1.32)
On my clean ubuntu server install, apt-rdepends
only required libapt-pkg-perl
for installation. It's much lighter then ubuntu-dev-tools
, and yet is still recursive, so you get all the dependencies, rather then just the first-order dependencies, like apt-cache depends
returns.