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:
- Install the apt-show-versions command:
apt-get install apt-show-versions
- List the stable and testing packages:
apt-show-versions | grep /testing apt-show-versions | grep /unstable
- 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
- 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 ...
Package: libxrender1 Pin: release a=stable Pin-Priority: 700This 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.