aatvta
Last Updated: February 25, 2016
·
1.837K
· davidduggins

Apt Pinning in Debian

** Warning: Following these instructions might cause the death of kittens. Please make sure you know what you are doing before you follow my instructions **

So many people use Linux distros that are derived from Debian. So few use Debian. One complaint that I hear often from Linux users is that Debian might be stable but it is a little bit behind the cutting edge. Today I am going to share a little trick that lets you run a rolling distro type installation of Debian that is stable enough for most use cases and yet gives you access to more of the latest packages. It's called apt-pinning.

Before we get to the pinning part, we are going to open up our apt sources file and modify our sources. I am assuming that you are running Debian Testing or 'Jessie'. The default behavior for sources is to refer to the release names like Jessie and Sid rather then the more genaric testing and unstable. For starters, in order to make things 'rolling' we need to change 'jessie' to testing. This way when Jessie becomes the stable release, we do not have to change sources to continue installing from testing. The next thing we are going to setup for a rolling release is to include mixed sources for testing and unstable. So if you have followed what I am saying, your sources.list should look something like this:

deb http://ftp.us.debian.org/debian testing main contrib non-free
deb http://ftp.us.debian.org/debian unstable main contrib non-free

Now, this might seem to some as a recipe for disater. This is where pinning come in handy.
The Debian manual for pinning is located here: https://wiki.debian.org/AptPreferences for your reference. What we are about to do is fairly simple.

The behavior that we want is for the majority of packages to be installed from testing and only install from unstable if it is the only identifiable dependency or if we specify manually to install it via apt-get.

So located at /etc/apt/preferences.d we create a file called preferences and enter this:

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

Package: *
Pin: release o=Debian
Pin-Priority: -10

You could, instead of the second block I have, give unstable a lower priority..but this can be akward and I have honestly killed my system this way. The above configuration behaves like I outlined above. Most of the time it installs from testing, occasionally it might install a dependency from unstable and it will only install from unstable if I specifically tell it to.

Occasionally I find a package will not install automatically for me. This is because the pinning rules prevent unstable packages from being installed and apt decided that the unstable version is the most recent and therefor the right one to use. It's easy to install from unstable.

aptitude install -t unstable *package-name*

So, if you are already using Debian or just want to give this a try....please read up on the documentation make sure that you know exactly what you are doing before you actually start running this. You might just kill kittens... You have been warned.