Monday, July 28, 2014

Mix and match stable and testing releases in Debian

My Debian system runs the current stable Debian distribution Wheezy. However, there are software packages that are only available in the current testing distribution Jessie. Examples are dateutils, and Enlightenment 0.17. Too eager to wait for Jessie to become stable, and too lazy to build these packages from source, I used the apt-pinning technique to coerce APT, Debian's package manager, to install these packages on Wheezy.

Apt-pinning lets you mix and match the different distributions in a Debian release: stable, testing, and unstable. The steps below explain how to specify that all packages should be installed or updated from Wheezy (the stable version), with the exception of dateutils which we 'pin' to Jessie (the testing version).

Disclaimer: Apt-pinning is considered an advanced topic in Debian. Use at your own risk.

  1. Add testing to sources.list.

    The file /etc/apt/sources.list specifies the software releases you want and where to fetch them.

    Assuming that your sources.list file currently links to Wheezy only, it should resemble something like the following, notwithstanding the actual mirror site.

    deb http://deb.vanvps.com/debian/ wheezy main contrib non-free deb http://security.debian.org/ wheezy/updates main deb http://deb.vanvps.com/debian/ wheezy-updates main

    Append the following line to the file:

    deb http://deb.vanvps.com/debian/ jessie main contrib non-free
  2. Specify install priority preferences.
    • Create the file /etc/apt/preferences if it does not exist.

      This file specifies the priority preferences of which Debian version (e.g., testing vs stable) to install for packages.

    • Insert the following lines.
      Package: dateutils Pin: release n=jessie Pin-Priority: 750 Package: * Pin: release n=wheezy Pin-Priority: 700 Package: * Pin: release o=Debian Pin-Priority: -10

      Any package that is not named dateutils, and is not part of Wheezy is matched by the third section with a priority of -10. A negative priority means that the package will never be installed or upgraded. This entails that no package from Jessie other than dateutils will ever be installed or upgraded.

      When a newer version of dateutils becomes available in Jessie, dateutils will be updated. This is because the dateutils package is matched by the first section, which takes precedence over the third section.

      It is highly recommended that you read the man(5) page for apt_preferences to know more about setting preferences.

  3. Update APT repository.
    $ sudo apt-get update
  4. Install dateutils.

    The following command installs dateutils from testing, and also attempts to fulfill its dependencies from testing.

    $ sudo apt-get -t testing install dateutils

To upgrade your system, execute, as usual, sudo apt-get upgrade. dateutils is upgraded from Jessie while all other packages are upgraded from Wheezy.

No comments: