In software installation tutorials, they always have a long list of dependencies. How do they find those dependencies?
For example, I'm starting on a fresh Ubuntu server, following directions to install rvm. They provide something like:
sudo apt-get install git-core libreadline5 libncurses5-dev libreadline5-dev build-essential zlib1g-dev libssl-dev libpcre3-dev libxml2-dev libxslt-dev;
I just want to understand how they find all of those dependencies. Copy and pasting works, but I think it's more important to understand it.
Each package comes with a list of its own dependencies. For debs, which Ubuntu uses, you can do:-
The dependencies for a package are specified when the package is built. Some of them are specified manually by the package maintainer (the person who's responsible for building the package), and some are automatically determined when the package is built. If you download a Debian source package, and look in the
debian/control
file, you'll see a number of lines likeDepends:
,Conflicts:
,Replaces:
, etc.So, back to the example -
git-core
depends on only one package, which isgit
.git
is probably a metapackage of some sort, which in turn has a whole raft of dependencies, to make sure all the packages neccessary to run git are installed - not just to satisfy the dependencies of one package. If we look at thegit
package:-...you'll see that
git
itself has further dependencies. To complicate things further, there's different kinds of dependency other than just requiring another package to be installed...git
conflicts withgit-core
. On my box here, thegit-core
package is marked as obsolete, which is probably why this is listed here.stgit
andstgit-contrib
packages will be considered broken oncegit
is installed.git-core
package shows up again here.There are also 'soft' dependency types, such as Recommends and Suggests, which aren't required by the package you're installing, but are recommended or suggested, as the name suggests. Once again, looking at the example, the suggested and recommended packages are add-ons to git, or tools not directly related that will make using it easier.
Putting all this together, the package manager you use will start off with the package (or packages) you've asked it to install, and will look up the dependencies for it, and then any dependencies for those packages, and so on. It will also check for packages which conflict, break or replace the requested packages or their dependencies. Once it's happy that it's found a way it can satisfy your original request, it'll then go ahead with the install.
Different package managers have different ways of doing this dependency resolution.
apt-get
,aptitude
anddselect
, for example, all essentially do the same thing but the way they make their decision differs. You may find thataptitude
anddselect
will happily present you with a way to install a package whereasapt-get
can't.If you're interested in knowing more about Debian packages, have a look at the Debian New Maintainers' Guide, which goes over some of the guts of debs.
usually apt will do that for you. if you try to install a binary package that has unmet dependencies, apt will tell you which ones are missing and ask you for permission to install them as well.
most source distributions tell you in a README file what the -dev dependencies are.