Hi, Brian Servis <[EMAIL PROTECTED]> writes: > *- On 7 Dec, peter karlsson wrote about "Finding left-over libraries" > > I remove packages, unnecessary libraries are not removed. Because > > of this, I would like to get a list of packages that no packages > > depend on (restricted, for instance, to packages starting with > > lib). ... > > Unforunately there is no way to do this cleanly now. There has been/is > active discussion on this very subject on the the -devel list. One of > the issues to be concerned with is on a machine used for development > where nothing directly depends on a lib*-dev package except at build > time when you need to link to the headers.
Well, its not clean, and it doesn't even work correctly (it doesn't correctly handle |-dependecies), and there are probably other bugs, but here is a perl script that I threw together when I was new to Debian (and perl) that does what you want: It lists all packages nothing depends on and that are not essential, and also says whether they are suggested or recommended by other packages. It occasionally gives false positives (I think the missing |-handling is to be blamed), and I also found a case where it gives false negatives (some gnome packages have circular dependencies, I think). I wonder if all this could be done much more cleanly with libapt (never looked into that). Anyway, if anybody wants to improve on this, you're welcome. Perhaps post it back to the list. Matthias #!/usr/bin/perl # TODO # handle OR use English; open PKGLIST, "dpkg --get-selections |"; while (<PKGLIST>) { ($pkg, $sel) = split; push @pkglist, $pkg if $sel == "install"; } open STATUS, "dpkg --status @pkglist |"; $INPUT_RECORD_SEPARATOR = ""; while (<STATUS>) { ($package) = /^Package: (.*)$/m; ($essential) = /^Essential: (.*)$/m; ($priority) = /^Priority: (.*)$/m; ($size) = /^Installed-Size: (.*)$/m; unless ($essential) { push @packages, $package; $priorities{$package} = $priority.", ".$size."k"; } ($foo) = /^Pre-Depends: (.*)$/m; foreach $p (map {/^\S*/; $MATCH;} split /, */, $foo) { push @{$pre_depends{$p}}, $package; } ($foo) = /^Depends: (.*)$/m; foreach $p (map {/^\S*/; $MATCH;} split /, */, $foo) { push @{$depends{$p}}, $package; } ($foo) = /^Provides: (.*)$/m; foreach $p (map {/^\S*/; $MATCH;} split /, */, $foo) { push @{$provides{$p}}, $package; } ($foo) = /^Suggests: (.*)$/m; foreach $p (map {/^\S*/; $MATCH;} split /, */, $foo) { push @{$suggests{$p}}, $package; } ($foo) = /^Recommends: (.*)$/m; foreach $p (map {/^\S*/; $MATCH;} split /, */, $foo) { push @{$recommends{$p}}, $package; } } foreach $p (keys %provides) { foreach $pp (@{$provides{$p}}) { push @{$pre_depends{$pp}}, map $_." (via $p)", @{$pre_depends{$p}} if defined $pre_depends{$p}; push @{$depends{$pp}}, map $_." (via $p)", @{$depends{$p}} if defined $depends{$p}; push @{$suggests{$pp}}, map $_." (via $p)", @{$suggests{$p}} if defined $suggests{$p}; push @{$recommends{$pp}}, map $_." (via $p)", @{$recommends{$p}} if defined $recommends{$p}; } } $LIST_SEPARATOR = ", "; foreach $p (@packages) { next if defined($pre_depends{$p}) || defined($depends{$p}); print "$p ($priorities{$p})"; print "\nsuggested by: @{$suggests{$p}}" if defined $suggests{$p}; print "\nrecommended by: @{$recommends{$p}}" if defined $recommends{$p}; print "\n\n"; }