I know I can disallow a particular package in Debian by appending /etc/apt/preferences with:

Package: *x11*
Pin: release
Pin-Priority: -1

But how can I do that for a virtual package like httpd? I'd like to disallow installation of all packages that provide this virtual httpd but the one selected by me. Is there a (simple) way to do this?

The reason: recently, an automatic apt-get dist-upgrade removed nginx and installed lighttpd instead, because some other package (phppgadmin AFAIR) depended on httpd and something nginx started depending on in that update was not installable. I'd really like the whole upgrade to fail in this case, rather than put the http service down. Also: is it possible to make a package "uninstallable"? That would be a good solution, too.


I'd rather build a tiny meta-package with equivs with according Conflicts and maybe Depends. That allows more fine-grained control over which package needs to be installed and which may not be installed.

Pinning is more for picking the right version of a package (and until very recently, virtual package couldn't have a version) and not to install one or another package -- although that should be possible in theory.

Another possibility is to use a tool which keeps all packages in a list installed or uninstalled, e.g. aptitude-robot. (There may be others, but aptitude-robot is what I use for that.) aptitude-robot though only applies your configured package lists when it is used to upgrade packages, it doesn't apply to normal aptitude or apt-get runs.

If you only use aptitude, a third possibility may be to use Aptitude's forbid-version (Shift-F) feature in a situation as in your example. This though won't apply if you later use apt-get again.

| improve this answer | |

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.