5

e.g. if package specifies

Depends: www-browser

How does apt/dpkg decide which real package will be installed?

5

According to this answer on Ask Ubuntu, apt will first try to install any non-virtual packages listed as options instead:

Now, according to sources, apt tries first of satisfying the dependency before trying with virtual packages (i.e., if depends are firefox | www-browser, checks if any of the packages are installed, then try to install firefox if neither is).

If not, it will simply iterate over the list of packages that provide the virtual one, and install the first one that it can:

If the non-virtual package isn't available, it seems to just iterate over all packages which provides the virtual package, if no other dependencies are broken. Other comments evidence of this behavior are this which leads to GrpIterator::FindPreferredPkg function.

  • It is discouraged to use pure virtual dependencies, usually you'd give one real and one virtual package as in your example. For Build-Depends, this is required by policy as well, as "or" relationships are ignored by autobuilders. – Simon Richter Jan 1 at 5:06
  • @SimonRichter Yes, it makes sense to discourage purely virtual dependencies because apt will just install any package that provides it, which is rarely what you'd want. – Nonny Moose Jan 1 at 14:39

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.