Quick Tip: Installing bleeding edge packages on Debian stable

For a server, I prefer to run the latest stable release of Debian, but once in a while I need a newer package than what's available from the stable repository.

The solution is in the Apt How-To available from Debian. See section 3.8, title "How to keep a mixed system".

First, a word of warning. APT is great but will dutifully do as you say, so you could get yourself into trouble. Mix packages from different releases with caution. When a package has lots of dependencies, often a newer version of a prerequisite package is listed, so to upgrade a single package to the testing version, APT might have to upgrade a number of other packages as well. This may become problematic. APT will warn you before doing anything, so consider those carefully. Personally, I don't have a hard rule for mixing packages. Sometimes it makes sense to mix, sometimes it makes more sense to just setup a dedicated box or a VM to run Debian Testing/Unstable.

IMPORTANT: the "unstable" version of Debian is the version to which the newest versions of Debian packages are uploaded first. This distribution sees all of the changes that packages go through, both small ones and more drastic ones which affect many packages or the whole system. For this reason, this version of the distribution should not be used by inexperienced users or by those who need proven stability.
The 'testing' distribution is not necessarily better than 'unstable', because it does not receive security updates quickly. For servers and other production systems stable should always be used.

Here are the steps (this example is for getting the latest Bind9 package):

1. Edit /etc/apt/sources.list and add testing package source repository to your source list

# testing
deb http://ftp.us.debian.org/debian/ testing main contrib non-free
deb-src http://ftp.us.debian.org/debian/ testing main contrib non-free
 
# testing security
deb http://security.debian.org testing/updates main contrib non-free
deb-src http://security.debian.org testing/updates main contrib non-free

2. Create /etc/apt/apt.conf and add:

APT::Default-Release "stable";
APT::Cache-Limit "25165824";

This will tell apt not to automagically upgrade all your packages (essentially "upgrading" your entire system to the testing or unstable release) and also raise the cache limits as the default cache value is probably too small to accomodate this new larger set of packages.

3. Create /etc/apt/preferences and add:

Package: *
Pin: release a=stable
Pin-Priority: 990
 
Package: *
Pin: release a=testing
Pin-Priority: 450

This will tell apt to default to a stable version of a package, rather than to a higher release.

4. Update apt

aptitude update

5. Probably the easiest way to check what versions of Bind9 available from the repositories is to search packages.debian.org:

links2 http://packages.debian.org/bind9

6. Install Bind9 from the testing repository

aptitude -t testing install bind9

That's it. Debian's advanced package management system is one more reason I love it more every day. ;-)

Leave a comment

NOTE: Enclose quotes in <blockquote></blockquote>. Enclose code in <pre lang="LANG"></pre> (where LANG is one of these).