Mixing the worlds with Debian

Do you use Debian? I do, for my laptop and servers. It's the coolest.

The problem with Debian has always been, what stream do you use? There's stable (woody), testing (sarge) and unstable (sid). Side note: the releases are named after Toy Story characters, with the unstable release always being called sid - he was the kid next door that used to blow his toys up ;) So what do you do when you're running woody on your firewall, but want the SNMP packages from sarge or sid? You investigate apt- pinning right here!

First thing, you need to change your entries in /etc/apt/sources.list so that you have all three streams shown as package sources. It needs to look like this:

falcon:~# cat /etc/apt/sources.list

# Stable
deb ftp://ftp.wa.au.debian.org/debian/ stable main non-free contrib
deb http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free
deb-src http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free
deb http://security.debian.org stable/updates main contrib non-free

# Testing
deb ftp://ftp.wa.au.debian.org/debian/ testing main non-free contrib
deb http://non-us.debian.org/debian-non-US testing/non-US main contrib non-free
deb-src http://non-us.debian.org/debian-non-US testing/non-US main contrib non-free

# Unstable
deb ftp://ftp.wa.au.debian.org/debian/ unstable main non-free contrib
deb http://non-us.debian.org/debian-non-US unstable/non-US main contrib non-free
deb-src http://non-us.debian.org/debian-non-US unstable/non-US main contrib non-free

Then you need to tell apt what distribution you want to use as the default. Also, because the cache might not be big enough to handle packages from all three streams, you need to bump its size up a little. You might not have an /etc/apt/apt.conf, so make one

falcon:~# cat /etc/apt/apt.conf

APT::Default-Release "stable";

APT::Cache-Limit "8388608";

Lastly, we edit /etc/apt/preferences (again, this might need to be made) so it has the pinning order, that is, the order in which preferences will be weighted

falcon:~# cat /etc/apt/preferences

Package: *
Pin: release a=stable
Pin-Priority: 700

Package: *
Pin: release a=testing
Pin-Priority: 650

Package: *
Pin: release a=unstable
Pin-Priority: 600

Now run an update (apt-get update). You should have now instructed your Debian system to use all three pools of packages, and the preference order in which to use them. To force another pool you use the -t switch, like this:

falcon:~# apt-get -t unstable install snmp

Hopefully somone will find this useful; I know I sure have. There's more information available on the Debian apt-get HOWTO page, and this Apt-Pinning for Beginners page