How do I install a single package from Debian testing or unstable on stable?

There's actually a way to do it without using pinning / priorities at all. Instead, you can specify what's the default release you'll install packages from, which will then be used unless otherwise specified by using the target release parameter. This works the same way if you only want to install selected packages from e.g. backports.

I'll show this for installing packages from Stretch into Jessie, as those are the current stable / testing, but it works the same way for installing Jessie packages in Wheezy like it was originally asked.

First, add stretch as repository, e.g. in /etc/apt/sources.list.d/stretch.list:

deb http://ftp.debian.org/debian stretch main

Then, to set the default release, create a file like /etc/apt/apt.conf.d/default-release containing:

APT::Default-Release "jessie";

(In Wheezy, I think apt.conf.d didn't exist and you'd need to put that snippet in /etc/apt/apt.conf).

Then, installing a package from testing is as simple as aptitude -t stretch install kpcli without you needing to worry about pinning priorities.

Note: @amc pointed out in the comments that if you use apt instead of aptitude, you have to use "stable" as Default-Release instead of "jessie". Thank you! (Of course, you can use aptitude with that setting as well.)


For each entry (stable, testing, unstable) you have pin-priority 500. You shouldn't use pin > 1000. I use 1001 only when I want to downgrade something. I have testing+sid+experimental entries specified in /etc/apt/sources.list and the following /etc/apt/preferences file:

Package: *
Pin: release o=Debian,a=testing
Pin-Priority: 900

Package: *
Pin: release o=Debian,a=experimental
Pin-Priority: 130

The value 500 is default for unstable. So, let's try to check iceweasel:

# apt-cache policy iceweasel
iceweasel:
  Installed: (none)
  Candidate: 17.0.10esr-1~deb7u1
  Version table:
     26.0-1 0
        130 http://ftp.pl.debian.org/debian/ experimental/main amd64 Packages
     24.2.0esr-1 0
        500 http://ftp.pl.debian.org/debian/ sid/main amd64 Packages
     17.0.10esr-1~deb7u1 0
        900 http://ftp.pl.debian.org/debian/ testing/main amd64 Packages

So, if I tried to install iceweasel, it would be downloaded from the testing branch because it has the highest priority.

Try to change the priorities to:

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

Package: kpcli
Pin: release a=jessie
Pin-Priority: 910

Pin: release a=wheezy should be Pin: release n=wheezy, maybe.

From the man page:

The following record assigns a high priority to all package versions belonging to any distribution whose Codename is "jessie".

           Package: *
           Pin: release n=jessie
           Pin-Priority: 900

So that is correct!

Tags:

Debian

Apt