Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have used a tool that calculates the minimal set of packages you can install to get the current set of packages you have. This is different than telling you what your selections are. It literally finds the shortest list of packages that will, through dependencies, give you what you currently have.

I forgot where to find this tool. What is it called?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

aptitude can get you most of the way with its search feature. Here's how you find everything installed that wasn't only an automatic dependency:

aptitude search -F "%p" "?installed ?not(?automatic)"

This wont be optimal some of these may be able to be removed but I don't know a simple way to work that out. Perhaps the answer lies in man aptitude.

On second thought, with that list you could loop through it and find the dependant packages (not dependencies) for each one. If one of those is in the master list, remove the current package from the list... but only after you've parsed the whole list or you'll miss intermediates in a 3+ level dep tree.

You find dependants with a query like this:

aptitude search '~i~Dpackage'

I'd try and write the script but I'm typing this on a tiny phone keyboard. Even I have limits.

Edit: After five minute of trying to sleep, I started hacking away on this. something like this should do the job:

orig=$(aptitude search -F "%p" "?installed ?not(?automatic)")
newlist="";
for p in $orig; do
    depended=0;
    for dependant in `aptitude search -F "%p" "~i~D$p"`; do
        if [[ $orig == "* $dependant *" ]]; then
            depended=1;
        fi;
    done;
    if [[ $depended == 0 ]]; then
        newlist="$newlist $p";
    fi;
done;
echo $newlist

Note this takes a really long time to run and it might be over-keen (eg it will remove thing that you manually installed, that you want to be manually installed, if they are depended on by something else in the $orig list that you perhaps installed afterwards).

share|improve this answer
    
Wait, what? Running this will remove all the packages I installed? –  Oxwivi Feb 20 '11 at 14:46
    
No. The second route will remove non-auto things from the outputted list if something else in the list depends on it. So it might not be accurate. It doesn't actually remove anything from the system. –  Oli Feb 20 '11 at 15:32
    
Oh, I see. I want to find out the least package I need to install for all the packages I got for minimal Ubuntu. Will there be any auto packages listed? And I don't want the recommended dependencies of my packages either. –  Oxwivi Feb 21 '11 at 14:44
    
@Toki That's the aim of the second part script... It aims to hide anything that is depended on by anything else in the list. But as I say, it's very slow (because it hammers aptitude for every dependency). If in doubt, the first one will do the job and do it quickly. –  Oli Feb 21 '11 at 15:12

I have written a small python script to do that, posted as a gist here.

You give it a set of package names on the command line, and it should give you a smaller, minimal set of packages that imply all the others you have given as arguments. Here, x11-proto-fixes-dev is implied (a dependency of) by libgtk2.0-dev:

fuwaad:~$ python mindeps.py x11proto-fixes-dev libgtk2.0-dev
libgtk2.0-dev
share|improve this answer

I tried answers from this and two other similar questions on a system I've been running for years and the shortest list I could get was 1338 packages, most of which were obviously dependencies or stock packages.

However, over on the Unix/Linux Stack Exchange I found this answer, which pulls the list of stock packages for your install from the Ubuntu mirror and filters it out. That got my list down to 404 packages that looks sane to me.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.