deborphan: find packages you don’t want
October 21st, 2007 edited by paulgearArticle submitted by James Cameron. Please help DPOTD by submitting good articles about software you like!
If you’ve been reading debaday for a while, chances are you now have a heap of packages installed that you’ve tried out, some of which you want to keep installed, and some of which you have forgotten.
Those forgotten packages can cost you. They might contain setuid binaries or running daemons that could compromise your security. Future upgrades take longer, and there will be more to download. Your backups have grown. You are doing backups, right? That’s what duplicity was for.
If you’ve been using aptitude to install packages, then the autoclean command will remove a few things you don’t want.
An example using deborphan on a Debian Etch system:
# deborphan libssl0.9.7 libstdc++5
In this example, deborphan discovered two fairly small packages that were superfluous, and so they can be removed. Since deborphan gives you only package names in this mode, they can be used in a command:
# aptitude purge `deborphan`
Or if you are in the habit of working at a level below aptitude:
# dpkg --purge `deborphan`
Recursive Deborphan
What you remove may reveal something else as newly orphaned. You
might even want to do this recursively:
#!/bin/sh while [ -n "`deborphan`" ]; do deborphan echo aptitude purge `deborphan` done
You might call that a deborphan-recursive script.
Not Just Libraries
Deborphan gives you a list of packages installed on your system that no other package depends on. By default this will only show library packages. But it can also be told to give you a list of all such packages using the -a flag … consider this compound command:
# dpkg-query -W --showformat='${Installed-Size} ${Package}\n' \ `deborphan -a | awk '{print $2}'` | sort -rn
You might name this deborphan-by-size. What it does is give you a sorted list of packages that nothing depends on, in descending order by package size. Work down from the top, choosing what you do not want installed. But remember that every time you remove a package, the list might change because the removed package might have dependencies that are now orphaned.
What’s the worst that could happen? You might remove some package that you will have to reinstall and reconfigure. You have backups. [If you have installed any applications without using the Debian packaging system, it's a different story. You will have to manually make sure that the packages deborphan removes are not required for them to operate. Ed.]
Or how about a small system where you have removed as much as possible so that you have the most space available for your own stuff? Deborphan can be used step by step to challenge you to remove packages you don’t really need. Eventually dpkg, apt-get, or aptitude will warn you about removing a package it considers essential. That’s where you stop, unless you really want some trouble.
Sometimes library packages are installed just to satisfy some dependency of a package in development. Developers will find deborphan’s decisions cause them to reinstall packages they need for software development … an answer to that is to either create a metapackage that refers to the packages you need, or to do your package building in a pbuilder.
Deborphan is available in Debian and Ubuntu since before time began.
Posted in Debian, Ubuntu | 16 Comments »