47

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.

1
  • 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, 2014 at 15:05

4 Answers 4

38

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

5
  • 1
    …this looks like a really slick way to do this. Why is this not officially accepted?? Sep 14, 2016 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
    – Zombo
    Jan 18, 2017 at 0:13
  • 3
    you need to use "stable" / "testing"/ etc. instead of "jessie" / "stretch" for the default release and when using apt
    – amc
    Apr 28, 2017 at 18:58
  • This is definitely the best answer, except as @amc noted above: use stable, unstable and testing instead of release names UNLESS you really know what you're doing (i.e., intending to migrate to another release or some such). Also, you can install an unstable package with apt install mypackage/unstable. Jun 1, 2023 at 19:10
  • This method is less flexible than pinning/priorities and is not suitable when you're using a downstream distro like LMDE (Linux Mint Debian Edition). Aug 21, 2023 at 10:19
16

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
2
  • 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, 2014 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, 2014 at 19:33
7

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!

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

I'm writing this answer w.r.t. the current Debian oldstable/stable version (bullseye/bookworm) because the existing answers are either incomplete or contain inaccuracies.

I am using a downstream distro LMDE 5 based on Debian 11 (bullseye) and wanted to get the latest emoji fonts from Debian 12 (bookworm).

  1. Update APT sources to include bookworm repo by creating a file such as /etc/apt/sources.list.d/bookworm.list with the following content:
    deb http://deb.debian.org/debian bookworm main
    
  2. Update APT preferences to exclude all but one package from bookworm repo by creating a file such as /etc/apt/preferences.d/bookworm.pref with the following content:
    Package: *
    Pin: release n=bookworm
    Pin-Priority: -10
    
    Package: fonts-noto-color-emoji
    Pin: release n=bookworm
    Pin-Priority: 501
    

Replace bookworm with your release codename and fonts-noto-color-emoji with the package name that you want from the latest repo.

In the first block we're stating all packages from bookworm repo should have the least priority (-10 for example). The default priority for packages from the main repo bullseye is 500 whereas for bullseye-backports it is 100. This can be seen by querying the APT cache policy for each package like so apt-cache policy <pkg-name>.

In the second block, we're stating that the package fonts-noto-color-emoji from bookworm should have higher priority than the same package from the main repo bullseye.

Now run apt update and apt list --upgradeable. If your system is already updated it should show just the one package that is to be upgraded from bookworm repo and finally run apt upgrade.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .