2011年11月16日星期三

Removing unnecessary packages with deborphan


Over time most Debian installations acquire packages which are no longer required - they've just been pulled in to satisfy dependencies of software you've since removed. Whilst there are many ways to fix this, the deborphan package is probably the simplest.
deborphan looks for orphaned packages, that is packages which are not required by any other package upon your system.
For example, if you install the game late as follows you'll see that you've pulled in a new package late-data:
[email protected]:~# apt-get install late
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
  late-data 
The following NEW packages will be installed:
  late late-data
If you later decide to remove the late package you could do that easily :
dpkg --purge late
But you've left the late-data package upon your system, redundent and orphaned. You could manually remove this, but what about other similar packages you might have lying around, getting needlessly upgraded and wasting disk space?
Enter deborphan. Install it:
[email protected]:~# apt-get install deborphan
Once installed simply run it to display a list of the packages it thinks you don't need upon your system:
[email protected]:~$ deborphan 
libsdl-image1.2
(Note that you don't need root privileges to use this tool, it merely reads the installed package lists - it won't remove any packages itself, merely tell you what it thinks you should remove).
As we can see it's decided that the libsdl-image1.2 package isn't required, because no currently installed package depends upon its presence.
There are some other options you can give to the command, which increase it's ability to spot things. These are the "--guess-foo" options. By default it will only list packages which are in the libraries section of the Debian archive, as these are the most likely candidates for removal.
In addition to showing removable library packages it allows you to display potentially orphaned data packages:
[email protected]:~$ deborphan --guess-data
late-data
The manpage shows this option as well as other "guessing" options, and you can read it by invoking:
man deborphan
If you wish to see all the packages which aren't required you could run:
[email protected]:~$ deborphan --guess-all
libxpm-dev
libxp-dev
xprt-xprintorg
libxrandr-dev
libxtst-dev
pm-dev
late-data
libjpeg-progs
libxmuu-dev
libxtrap-dev
libhtml-parser-perl
libxmu-dev
Most of the packages it reports are development packages, not required per se, but required if you wish to build things from source and link against package libraries.
As with most common jobs in Debian there are alternative methods of cleaning up your system, such as the cruft package.
Additionally some of the package managers such as aptitude and dselect allow you to handle orphaned packages - but I've always thought deborphan was a very underated tool!

sudo deborphan -A package_name # not list this package by deborphan
sudo aptitude purge $(deborphan -n --guess-all) # remove all unnecessary packages in aptitude

没有评论:

发表评论