I want to install a single package (and its dependencies, but only to the extent those are not satisfiable in Wheezy) from Debian Jessie onto my Wheezy system, without upgrading "everything and the kitchen sink" to the Jessie versions. Specifically, I'd like to install kpcli, which is available packaged in Jessie but not in Wheezy.

Everything I've found indicates that I should add the Jessie repositories to my sources list, set pinning to keep everything at wheezy and only take the single package from jessie, and it'll pretty much just fall into place. However, it isn't falling into place for me. If I create /etc/apt.d/sources.list.d/jessie.list with the following content:

deb ftp://ftp.debian.org/debian/ jessie main
deb-src ftp://ftp.debian.org/debian/ jessie main

and then create /etc/apt/preferences.d/jessie with:

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

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

and run apt-get -u update followed by apt-get -u install kpcli/jessie, then I expect apt-get to pull in kpcli and maybe a small handful of other packages from Jessie, and leave the remainder of my installed system untouched. (My system is a fully up to date installation of Wheezy.) Alternatively, if I got the pin priority too low, I'd expect it to do nothing. Rather, on my system, apt-get wants to upgrade several hundred packages.

What, exactly, is needed to install just this one single package of a Jessie version while leaving the remainder of my Wheezy system untouched?

Note that in this particular case, the software is actually written in Perl so there's no compilation to binary or anything like that involved; however, there is a handful of Perl module dependencies. Hence, one possible alternative would be to install the .deb (downloaded manually) using something that only (1) allows specifying a single, local .deb archive that is to be installed, like dpkg -i, and (2) handles dependencies in an intelligent way, which plain dpkg -i doesn't. However, for all the searching I've done on several occasions and failed to come up with a simple-to-follow guide for how to do this, a generic solution (one that works for binary, compiled packages as well) would be great.

  • 4
    The usual way to handle this is by backporting - rebuilding the package from the Debian sources on Wheezy. The package you are using appears to be perl (or at least depends on it), so is probably not difficult to backport. If you want more details, please say so. I could probably provide a walkthrough if you really need it. Jan 3 '14 at 15:05

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.)

  • 1
    …this looks like a really slick way to do this. Why is this not officially accepted?? Sep 14 '16 at 5:53
  • 1
    I get The value 'stretch' is invalid for APT::Default-Release as such a release is not available in the sources Jan 18 '17 at 0:13
  • 1
    you need to use "stable" / "testing"/ etc. instead of "jessie" / "stretch" for the default release and when using apt
    – amc
    Apr 28 '17 at 18:58

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
  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
  • sudo apt-get -u install kpcli/jessie still gives me 316 upgraded, 137 newly installed, 251 to remove and 1688 not upgraded. with your suggested priorities. If I do apt-cache policy perl (one of the packages it wants to upgrade) it shows 5.18.1-5 as a candidate at priority 500, and installed 5.14.2-21+deb7u1 also at priority 500. It almost looks like, for whatever reason, apt isn't picking up the priorities...
    – user
    Jan 4 '14 at 19:18
  • OK, I got something. Looks like the trick was to use Package: kpcli* (rather than Package: kpcli) and then a Package: * Pin: release o=Debian Pin-Priority: -10 at the end. Then of course there are hard dependencies leading to versions of Perl only available in Jessie, which in turn needs a newer libc6! I'm not about to go that route, honestly, but this at least got me the result I was after. Thank you!
    – user
    Jan 4 '14 at 19:33

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!

  • 3
    wouldn't this install ALL packages from jessy?
    – rubo77
    Dec 16 '14 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.