Debian apt-get pinning

The aim of this article is to explain how to install Debian packages from different releases. As I’m writing this, I’m running wheezy and I’d like to install few packages from jessie¬†(currently testing).

What we need to do is:

  • add testing release to apt sources
  • change priority of testing release via preferences file
  • install desired packages from testing release

Adding testing release to apt sources

As stated above, I’m currently running wheezy release and I’d like to add testing release, but I’d like only certain packages from latter release. My current /etc/apt/sources.list file looks like this:

deb http://ftp.si.debian.org/debian/ wheezy main
deb-src http://ftp.si.debian.org/debian/ wheezy main
deb http://security.debian.org/ wheezy/updates main
deb-src http://security.debian.org/ wheezy/updates main
deb http://ftp.si.debian.org/debian/ wheezy-updates main
deb-src http://ftp.si.debian.org/debian/ wheezy-updates main

We just need to duplicate the #1 and #2 lines and change wheezy to testing (or jessie). So my new file looks like this:

deb http://ftp.si.debian.org/debian/ wheezy main
deb-src http://ftp.si.debian.org/debian/ wheezy main
deb http://security.debian.org/ wheezy/updates main
deb-src http://security.debian.org/ wheezy/updates main
deb http://ftp.si.debian.org/debian/ wheezy-updates main
deb-src http://ftp.si.debian.org/debian/ wheezy-updates main
deb http://ftp.si.debian.org/debian/ testing main
deb-src http://ftp.si.debian.org/debian/ testing main

If we did apt-get update and apt-get upgrade right now, we’d get a bunch of updated packages from testing release. As we don’t want that, we’ll lower the priority of testing release via preferences file – it’s called pinning.

Creating preferences file and lowering priority

Create or edit the file /etc/apt/preferences. We’ll set priority to every package in testing release to 50. Copy and paste this into your /etc/apt/preferences file:

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

Now we can run apt-get update and check if everything is as expected.

# apt-get update
...
...

# apt-cache policy
 100 /var/lib/dpkg/status
     release a=now
 500 http://ftp.si.debian.org/debian/ testing/main Translation-en
  50 http://ftp.si.debian.org/debian/ testing/main amd64 Packages
     release o=Debian,a=testing,n=jessie,l=Debian,c=main
     origin ftp.si.debian.org
 500 http://packages.dotdeb.org/ wheezy/all amd64 Packages
     release o=packages.dotdeb.org,a=stable,n=wheezy,l=packages.dotdeb.org,c=all
     origin packages.dotdeb.org
 500 http://ftp.si.debian.org/debian/ wheezy-updates/main Translation-en
 500 http://ftp.si.debian.org/debian/ wheezy-updates/main amd64 Packages
     release o=Debian,a=stable-updates,n=wheezy-updates,l=Debian,c=main
     origin ftp.si.debian.org
 500 http://security.debian.org/ wheezy/updates/main Translation-en
 500 http://security.debian.org/ wheezy/updates/main amd64 Packages
     release v=7.0,o=Debian,a=stable,n=wheezy,l=Debian-Security,c=main
     origin security.debian.org
 500 http://ftp.si.debian.org/debian/ wheezy/main Translation-en
 500 http://ftp.si.debian.org/debian/ wheezy/main amd64 Packages
     release v=7.7,o=Debian,a=stable,n=wheezy,l=Debian,c=main
     origin ftp.si.debian.org
Pinned packages:

 Installing packages from different Debian release

To install a package and its dependencies from different Debian release simply use the -t switch to apt-get.

apt-get install -t testing package-name

This should install your package from testing release and leave everything else alone (except depending packages).

Hope this helps!


Tags: , , , , , ,

 
 
 

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close