APT Pinning fails when Default-Release set

Jurjen Bokma

February 2013

Abstract

APT Pinning fails when the Default-Release is set in APT config. But without that setting, pinning can be used to give imported PPAs a lower priority.


We use apt-mirror to mirror many PPAs on our own server. Our customers are allowed to do package management, and should be able to install from these mirrors. But we do not want all of our PCs to recklessly install all of these PPA packages. So we de-prioritize these PPA packages by pinning them in /etc/apt/preferences.d/*.

The use of /etc/apt/preferences/* is somewhat documented. But it is important to also read Carlo Wood's errata and especially Roderick Schertler's Using APT with more than 2 sources.

[Warning]Warning

When I set /etc/apt/apt.conf.d/80version to:

APT::Default-Release "precise";
      

then APT pinning fails to work! The pinning stops having any effect at all.

Procedure 8.  Down-prioritizing packages from PPAs
  1. apprentice@pc:~$ls /var/lib/apt/lists/*_Release

  2. apprentice@pc:~$ head -10 /var/lib/apt/lists/mirror.mydomain.com_ppa_mirror_ppa.launchpad.net_texlive-backports_ppa_ubuntu_dists_precise_Release
    Origin: LP-PPA-texlive-backports
    Label: TeX Live Backports PPA
    Suite: precise
    Version: 12.04
    Codename: precise
    Date: Tue, 04 Dec 2012 19:43:57 UTC
    Architectures: amd64 armel armhf i386 powerpc
    Components: main
    Description: Ubuntu Precise 12.04
    MD5Sum:

    Note that Origin is LP-PPA-texlive-backports.

  3. In /etc/apt/preferences.d/LP-PPA-texlive-backports_underpin.pref, put:

    Package: *
    Pin: release o=LP-PPA-texlive-backports
    Pin-Priority: 400
    	

    and see the result of your work:

    apprentice@pc:~$apt-cache policy texlive-science
    texlive-science:
      Installed: 2009-10ubuntu1
      Candidate: 2009-10ubuntu1
      Version table:
         2012.20120611-1~ubuntu12.04.1 0
            400 http://mirror.mydomain.com/ppa/mirror/ppa.launchpad.net/texlive-backports/ppa/ubuntu/ precise/main amd64 Packages
     *** 2009-10ubuntu1 0
            500 http://osmirror.rug.nl/ubuntu/ precise/main amd64 Packages
            100 /var/lib/dpkg/status

  4. apprentice@pc:~$sudo apt-get install -s texlive-science

  5. apprentice@pc:~$ sudo apt-get install -s texlive-science -t o=LP-PPA-texlive-backports

    	

[Note]Note

One could also down-pin all other sources than Ubuntu/Canonical in a single file, like this:

Package: *
Pin-priority: 400

Package: *
Pin: release o=Ubuntu
Pin-priority: 900

Package: *
Pin: release o=Canonical
Pin-priority: 900