I've got several Debian servers, and I want to ensure that an X server never gets installed on them. Sometimes when I'm installing a package, it has dependencies that include X. Is there any good way to make sure that the X server never gets installed? I'd prefer that the X11 libraries not get installed either, since X forwarding should never be enabled.
Putting a package on hold does not work (very well) to achieve this. It does not cover all tools in a satisfactory manner. For example aptitude on command-line completely ignores the previous invocation of
aptitude hold somepackage, installing a package also installs the dependencies even if they are on hold.
The best way in my opinion is to create a fake package (named for example "unwanted-pkg") that conflicts with all the packages that you don't want and to install it (with
dpkg -i). And then you put this package on hold to avoid its removal.
You can use a tool like "equivs" to create the fake package easily. See
equivs-build. A conflicts field look like this:
Conflicts: xserver-xorg-video-2, xserver-xorg-core
You can conflict with the low-level dependencies common to all unwanted packages to avoid listing each individual package (or use virtual package like xserver-xorg-video-2).
Note that pinning does not work to solve this problem. If you do
aptitude install xorg it will install many xserver-xorg-* packages despite the negative pinning. BTW, for the pinning to be recognized by apt (check with
apt-cache policy <package>) you have to use a syntax like this one:
$ cat /etc/apt/preferences Package: xserver-xorg-video-vga Pin: version * Pin-Priority: -100 $ LANG=C apt-cache policy xserver-xorg-video-vga xserver-xorg-video-vga: Installed: (none) Candidate: 1:4.1.0-8 Package pin: 1:4.1.0-8 Version table: 1:4.1.0-8 -100 500 http://localhost lenny/main Packages
Using a regexp in the Package field does not work (except for "*" alone, in which case you have some other requirements in the Pin field).
See section 7.12, "How do I put a package on hold?"
If you 'hold' a currently uninstalled package, it will never be installed.