[H-GEN] Apt pinning - Is there a guru in the house?

Anthony Towns aj at erisian.com.au
Wed Jul 1 12:17:16 EDT 2009

On Wed, Jul 01, 2009 at 12:20:52PM +1000, Gary Curtis wrote:
> I was playing with apt pinning on one of my systems and can't
> seem to get things to work the way I planned. [...]

> My goal is to use apt pinning to exclude a set of packages from
> ever being installed on the system. The man pages and howtos
> say this is possible by using a pin priority less than zero, thus...
> In /etc/apt/preferences  (this is the entire file contents)
> Package: mono-*
> Pin: version *
> Pin-Priority: -1
> As wildcards are valid for both Package and Pin I expected this
> config to exclude any version of any mono-* package.  It does not.

> What am I missing here?

Globs aren't supported in the Package: field, just package names or "*". So:

    Package: *
    Pin: release o=Ubuntu
    Pin-Priority: -1

would stop you from installing anything from Ubuntu sources, and afaict:

    Package: mono-common
    Pin: version *
    Pin-Priority: -1

should stop you from installing mono-common, but in reality doesn't seem
to actually do anything useful at all. If it did, something like:

     echo Package: $(apt-cache search mono-|grep ^mono-|cut -d\  -f1)
     echo Pin: version *
     echo Pin-Priority: -1001
    ) >/etc/apt/preferences

would probably be as close as you could get to what you asked for.

Another approach is a "fake" package that conflicts with all the mono stuff:

    $ sudo apt-get install equivs
    $ mkdir i-hate-mono
    $ cd i-hate-mono
    $ vi ./i-hate-mono.control
    $ equivs-build ./i-hate-mono.control
    $ sudo dpkg -i ./i-hate-mono_*.deb

(see attached)

That has the advantage that dpkg will complain as well as apt if someone tries
installing mono, though apt will be a bit too helpful in offering to remove it.

The "Essential: yes" flag finishes the job:

    $ sudo apt-get install mono-jit   
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following extra packages will be installed:
    The following packages will be REMOVED:
    The following NEW packages will be installed:
      mono-common mono-jit
    WARNING: The following essential packages will be removed.
    This should NOT be done unless you know exactly what you are doing!
    0 upgraded, 2 newly installed, 1 to remove and 601 not upgraded.
    Need to get 997kB/1118kB of archives.
    After this operation, 3244kB of additional disk space will be used.
    You are about to do something potentially harmful.
    To continue type in the phrase 'Yes, do as I say!'

But sadly stock-standard equivs doesn't support adding the Essential
field. Upside is it's just a perl script, so extra fields are easy to add
(above the "Pre-Depends" line in write_control_file to be precise).


-------------- next part --------------
Suite: i-hate
Section: misc
Priority: required

Package: i-hate-mono
Version: 20090702-1
Maintainer: Gary Curtis <gazilla at gmail.com>
Essential: yes
Conflicts: mono-1.0-devel, mono-1.0-gac, mono-1.0-runtime, mono-1.0-service, mono-2.0-devel, mono-2.0-gac, mono-2.0-runtime, mono-2.0-service, mono-apache-server, mono-apache-server2, mono-basic-dbg, mono-common, mono-complete, mono-csharp-shell, mono-dbg, mono-debugger, mono-devel, mono-fastcgi-server, mono-fastcgi-server2, mono-gac, mono-gmcs, mono-jay, mono-jit, mono-jit-dbg, mono-mcs, mono-mjs, mono-profiler, mono-runtime, mono-runtime-dbg, mono-smcs, mono-tools-devel, mono-tools-gui, mono-utils, mono-vbnc, mono-xbuild, mono-xsp, mono-xsp-base, mono-xsp2, mono-xsp2-base
Description: No goddamn Mono on Gary's machines
 It's a disease, dammit!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: i-hate-mono_20090702-1_all.deb
Type: application/x-debian-package
Size: 2442 bytes
Desc: not available
URL: <http://lists.humbug.org.au/pipermail/general/attachments/20090702/d87924e4/attachment.deb>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: Digital signature
URL: <http://lists.humbug.org.au/pipermail/general/attachments/20090702/d87924e4/attachment.sig>

More information about the General mailing list