Debian – Understanding Apt Pinning Priority Restrictions

aptdebian

I need to downgrade some apt packages, that I had previously pinned to testing, having stable as default. This is the preferences file:

Package: *
Pin: release a=stable
Pin-Priority: 1001

Package: *
Pin: release a=testing
Pin-Priority: 500

Package: *
Pin: release a=unstable
Pin-Priority: 400

When I check the policy for one of the upgraded packages, I get:

apt-cache policy libstdc++5
libstdc++5:
  Installed: 1:3.3.6-28
  Candidate: 1:3.3.6-28
  Version table:
 *** 1:3.3.6-28 0
        500 http://mirror.hetzner.de/debian/packages/ testing/main amd64 Packages
        400 http://mirror.hetzner.de/debian/packages/ unstable/main amd64 Packages
        100 /var/lib/dpkg/status
     1:3.3.6-27.2 0
        990 http://mirror.hetzner.de/debian/packages/ stable/main amd64 Packages
        990 http://cdn.debian.net/debian/ stable/main amd64 Packages

Whenever I change the settings for testing and unstable, I see the changes in the priority reflected here. Though, the priority for the stable package won't change, whatever I tried so far. The idea is to set it >1000, to actually execute the downgrade. Any hints, how to actually change it?

This is the full output for apt-cache policy:

Package files:
 100 /var/lib/dpkg/status
     release a=now
 500 http://llvm.org/apt/jessie/ llvm-toolchain-jessie-3.7/main amd64 Packages
     release n=llvm-toolchain-jessie-3.7,c=main
     origin llvm.org
 990 http://security.debian.org/ stable/updates/non-free amd64 Packages
     release v=8,o=Debian,a=stable,n=jessie,l=Debian-Security,c=non-free
     origin security.debian.org
 990 http://security.debian.org/ stable/updates/contrib amd64 Packages
     release v=8,o=Debian,a=stable,n=jessie,l=Debian-Security,c=contrib
     origin security.debian.org
 990 http://security.debian.org/ stable/updates/main amd64 Packages
     release v=8,o=Debian,a=stable,n=jessie,l=Debian-Security,c=main
     origin security.debian.org
 990 http://cdn.debian.net/debian/ stable/contrib amd64 Packages
     release v=8.3,o=Debian,a=stable,n=jessie,l=Debian,c=contrib
     origin cdn.debian.net
 990 http://cdn.debian.net/debian/ stable/non-free amd64 Packages
     release v=8.3,o=Debian,a=stable,n=jessie,l=Debian,c=non-free
     origin cdn.debian.net
 990 http://cdn.debian.net/debian/ stable/main amd64 Packages
     release v=8.3,o=Debian,a=stable,n=jessie,l=Debian,c=main
     origin cdn.debian.net
 990 http://mirror.hetzner.de/debian/security/ stable/updates/non-free amd64 Packages
     release v=8,o=Debian,a=stable,n=jessie,l=Debian-Security,c=non-free
     origin mirror.hetzner.de
 990 http://mirror.hetzner.de/debian/security/ stable/updates/contrib amd64 Packages
     release v=8,o=Debian,a=stable,n=jessie,l=Debian-Security,c=contrib
     origin mirror.hetzner.de
 990 http://mirror.hetzner.de/debian/security/ stable/updates/main amd64 Packages
     release v=8,o=Debian,a=stable,n=jessie,l=Debian-Security,c=main
     origin mirror.hetzner.de
 400 http://mirror.hetzner.de/debian/packages/ unstable/non-free amd64 Packages
     release o=Debian,a=unstable,n=sid,l=Debian,c=non-free
     origin mirror.hetzner.de
 400 http://mirror.hetzner.de/debian/packages/ unstable/contrib amd64 Packages
     release o=Debian,a=unstable,n=sid,l=Debian,c=contrib
     origin mirror.hetzner.de
 400 http://mirror.hetzner.de/debian/packages/ unstable/main amd64 Packages
     release o=Debian,a=unstable,n=sid,l=Debian,c=main
     origin mirror.hetzner.de
 500 http://mirror.hetzner.de/debian/packages/ testing/non-free amd64 Packages
     release o=Debian,a=testing,n=stretch,l=Debian,c=non-free
     origin mirror.hetzner.de
 500 http://mirror.hetzner.de/debian/packages/ testing/contrib amd64 Packages
     release o=Debian,a=testing,n=stretch,l=Debian,c=contrib
     origin mirror.hetzner.de
 500 http://mirror.hetzner.de/debian/packages/ testing/main amd64 Packages
     release o=Debian,a=testing,n=stretch,l=Debian,c=main
     origin mirror.hetzner.de
 990 http://mirror.hetzner.de/debian/packages/ stable/non-free amd64 Packages
     release v=8.3,o=Debian,a=stable,n=jessie,l=Debian,c=non-free
     origin mirror.hetzner.de
 990 http://mirror.hetzner.de/debian/packages/ stable/contrib amd64 Packages
     release v=8.3,o=Debian,a=stable,n=jessie,l=Debian,c=contrib
     origin mirror.hetzner.de
 990 http://mirror.hetzner.de/debian/packages/ stable/main amd64 Packages
     release v=8.3,o=Debian,a=stable,n=jessie,l=Debian,c=main
     origin mirror.hetzner.de
Pinned packages:

Best Answer

I don't understand why you are doing here. Why do you have a preferences setting for stable at all if you are running a stable system? As far I know, no preferences setting is necessary for stable in that case.

You don't explicitly say whether you are running a stable system (you really should say so), but if you are not, then I really have no idea what you are doing.

And if the release is on stable, then the usual thing to do for testing and unstable is to set their preferences to less than 100. I usually use 50.

And if you want to downgrade to stable, just do the following (assuming sane settings like the ones above) to downgrade pkgname1 and pkgname2:

apt-get install pkgname1/stable pkgname2/stable

This sets the specified packages to the target release stable.

Incidentally, mixing testing and/or unstable packages with an unstable system is generally a bad idea unless you know what you are doing. Some of the time it is Ok, but most of the time you need to use backports, either from Debian, or self-made.

Related Question