Nov 212012

Today I was in need to install 1 single package from the unstable release of Debian in a server installed with the stable release, so what’s the best way to get this done ?

For this example I’ll use the package drush because there are a lot of differences in the versions between the different release of Debian.

But as first thing you must be sure to have all the repository that you want to use in the file /etc/apt/sources.list in these days if you are using a server that uses the stable release (squeeze) you should have something similar to this one:

deb squeeze main contrib non-free
deb wheezy main contrib non-free
deb unstable main contrib non-free
deb squeeze/updates main contrib
deb-src squeeze/updates main contrib
deb squeeze-backports main contrib non-free

This list defines all the standard repository: stable (squeeze), testing (wheezy) and Sid aka Unstable, we are also defining the backport repository and the security repository.

Now, to know which versions are available for a package that you want to install use the command: apt-cache policy packagename, so using drush as package I get this output:

apt-cache policy drush
  Installed: (none)
  Candidate: 3.3-1 0
  Version table:
     5.7-1 0
        100 unstable/main amd64 Packages
        100 /var/lib/dpkg/status
     5.4-1 0
        500 wheezy/main amd64 Packages
     4.5-2~bpo60+1 0
        650 squeeze-backports/main amd64 Packages
     3.3-1 0
        700 squeeze/main amd64 Packages

If you wonder what are the numbers at the start of each repository, these are the priority of every source, the higher has more priority and they are read from the file /etc/apt/preferences that on my server contains these information:

Package: *
Pin: release  a=stable
Pin-Priority: 700
Package: *
Pin: release a=squeeze-backports
Pin-Priority: 650
Package: *
Pin: release  a=testing
Pin-Priority: 600
Package: *
Pin: release a=unstable
Pin-Priority: 100

So by default the system would install the package from the stable release, and in general this is what i want, but this time I want to install the 5.7 version of the package, let’s see how to do this:

First Method

You can use apt-get -t distribution install package with this command you’ll use the named distribution to install the package name and the dependencies, so using

apt-get -t unstable install drush

Will install drush 5.7-1 0 AND php 5.4.4-9, one of the dependencies of this package.
This could be exactly what you are searching for, but perhaps you just want to have drush from the unstable distribution and keep php at the stable distribution ?

Second Method

To install just drush from the unstable distribution you can use the command: apt-get install drush/unstable the command is similar to the former, BUT there is an important difference this command tell to apt to install ONLY the package drush from the unstable distribution and all its dependencies will be taken from the default distribution; in this case from the stable distirbution, and so at the end of this command you’ll have drush 5.7-1 0 AND php 5.3.3-7+squeeze14

More ways

These 2 ways should cover most of your needs, but it’s also possible to temporary change the priority file or tell apt-get to install a specific version, and I’m sure that there are other ways to achieve this result, as usual there is more than one way to get the result on GNU/Linux and it’s a thing I love of this operating system.

Popular Posts:

Flattr this!

  2 Responses to “How to install a single package from Debian SID or Debian Testing”

  1. In general, mixing stable and upstream Debian repos will lead to dependency problems down the road, judging by thousands of posts on the Debian forums by newbies that have done exactly what you advise, only to realize later that many packages are now uninstallable. Debian specifically advises against your method.

    A safer method is to download the deb directly from and use gdebi to try and install it. If there’s dependency issues with the stable libraries, it will refuse to do so.

    The very best method, though it’s the most work, is to backport the newer package from the source code against the stable libraries. This does take some skill for some packages, but absolutely will not break anything.

  2. As Steve Pusser already sated, it is not advisable to mix Stable with Testing or Sid. Fortunately, in this case, the package is relatively “independent” and can be installed without much hassle, but in many cases it is necessary to update a core package (like PHP) that would break various installed packages.
    The best method is to compile the package using the Stable tree.

    I do not understand your APT Preferences. Backports has a priority of 1, yet you gave it 650; and any non-installed package has a priority of 500, but you gave 700 to Stable and 600 to Testing and Sid. Is it not easier to give Testing and Sid a priority of 1, like Backports?

    There seems to be a problem with the Testing repository, because you gave it 600 and its Apt-Cache shows that it has 500 (just like any non-configured repository).

    One of the European mirrors for Backports should give you a faster connection.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>