Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

3 Answers

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-control and 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).

share|improve this answer
    
I think you should file a bug report on aptitude. Either "aptitude hold" is not properly setting the selection for the package, or "aptitude install" is not honoring the selection. –  Sparr Jun 3 '09 at 20:00
    
There are lots of (old) bugreports open on this topic already, unfortunately the maintainer is busy and can only deal with so many bugs each month. See bugs.debian.org/aptitude and search "hold". –  Raphaël Hertzog Jun 5 '09 at 7:40
add comment

http://www.debian.org/doc/FAQ/ch-pkg_basics.en.html

See section 7.12, "How do I put a package on hold?"

If you 'hold' a currently uninstalled package, it will never be installed.

share|improve this answer
add comment

You can use apt pinning to prevent certain packages from being installed. Try putting this in /etc/apt/preferences:

Package: xserver-xorg*
Pin-Priority: -100

Should prevent installing all xserver-xorg* packages.

share|improve this answer
    
Yes, see this man page: man.cx/apt_preferences –  Bruno De Fraine Jun 2 '09 at 11:15
    
When did wildcards start working in package names in apt_preferences? –  derobert Jun 3 '09 at 5:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.