Listing & Downgrading Unstable/Testing Debian Packages

Posted by ryan
at 2:44 PM on Monday, October 31, 2005

I like to keep my debian machines pretty true to the stable release – but every once and awhile I’ll make an exception for some piece of software I really feel I need and install from the testing or unstable repository. Most of the time I end up not really needing or using that application, but that’s besides the point. The point is that I like to take a quick monthly inventory of what installed packages are not from the stable source, and usually downgrade to the stable if not completely remove the unstable package. Here’s how I do it:

  1. Install the apt-show-versions command:
    apt-get install apt-show-versions
  2. List the stable and testing packages:
    apt-show-versions | grep /testing
    apt-show-versions | grep /unstable
At this point I usually go through and remove individual packages making sure that there’s nothing important in their dependencies. However, this is pretty inconvenient and when I’m feeling particularly saucy I will downgrade my whole machine to stable. This is much easier and you can always cancel when apt-get confirms what packages are being downgraded:
  1. Edit your /etc/apt/preferences file and change the “Pin-Priority” value of the stable section to 1001. Some of you may not already have this file, so I’ll just put the contents of mine (the majority of which comes from the apt-pinning guide):
    <b>Package: *
    Pin: release a=stable
    Pin-Priority: 1001</b>
    
    Package: *
    Pin: release a=testing
    Pin-Priority: 650
    
    Package: *
    Pin: release a=unstable
    Pin-Priority: 600
  2. Do an upgrade to perform the downgrade (somewhat oxy-moronish, but you do go the start menu to stop Windows too…):
    apt-get upgrade
    Reading Package Lists... Done
    Building Dependency Tree... Done
    The following packages will be DOWNGRADED:
      binfmt-support ...

Basically, to downgrade debian packages, set the pin-priority to 1001 for the stable packages in your /etc/apt/preferences. Similarly, to downgrade an individual package you can set up a similar section in your preferences file for that package. Let’s say I want to downgrade the “libxrender1” package from unstable to stable. I could do this by adding this section to my /etc/apt/preferences file:
Package: libxrender1
Pin: release a=stable
Pin-Priority: 700
This says to ensure (or “pin”) that the libxrender1 package is a stable package w/ priority 700 (this number just needs to be above the unstable and testing priorities if you’re apt-pinning). Now an upgrade will make sure this package is downgraded to the stable version:
apt-get upgrade
Reading Package Lists... Done
Building Dependency Tree... Done
The following packages will be DOWNGRADED:
  libxrender1
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and ...

At this point you may see that you still have some unstable or testing packages still installed (using apt-show-versions | grep /unstable). This occurs either when there are no stable versions of these packages available OR another package that cannot be downgraded depends on that version of the package. After doing the mass downgrade I will usually go through and remove a remaining individual unstable package and do a downgrade again. Often removing one of the remaining unstable packages will resolve the bottle neck and a subsequent downgrade will clear out a lot of stuff.

For the more sinister amongst us here is any easy way to remove ALL packages of a certain package:

apt-get remove `apt-show-versions -b | grep testing`
or
apt-get remove `apt-show-versions -b | grep unstable`
If you’re knee-deep in non-stable packages this will often want to remove your whole system, so it is only helpful if you have a few packages with minimal dependencies to remove.

Remember that when push comes to shove you can always remove and re-install a particularly stubborn package – apt-get will keep the config files for a package unless told otherwise so you don’t lose any of your data or setup files.

Comments

Leave a response

  1. BenijiMay 10, 2006 @ 08:22 PM
    In order to downgrade packages you need to remove a default release line from your apt conf: bq. APT::Default-Release "stable"; Dont ask me why.