[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Is this really the right thing to do?


> An option for showing only those packages that nothing depends on 
> could be useful.

That bit's easy. My first PERL script did that. But what about alternatives?

Jiri <jiri@baum.com.au>

print <<ENDDOC and exit if $ARGV[0] =~ /-h/;
List installed packages which are "wanted". This means they are not essential
or required, and are not depended or recommended by another installed package.

$0 [-h|--help|-v|--verbose]

  -h, --help      show this help

  -v, --verbose   show the description of each package as well as its name


* alternatives aren't handled properly

* virtual packages aren't handled

* the descriptions are shown without the proper formatting
# ' #(fix apostrophes for syntax highlighting)

$v=1 if $ARGV[0] =~ /-v/;


open(status,'/var/lib/dpkg/status') or die "$0: can't open status file.\n";

while (<status>) {
  next unless /^Status:\s*\S+ ok installed\s*?$/mi;

  %pkg = ('',split /^(\S+?):\s*/m); chomp %pkg;

  $_ = "$pkg{depends},$pkg{recommends},$pkg{'pre-depends'}";
  s/\(.*?\)//g; s/\|/,/g; s/\s+//g; s/,,/,/g; s/,$//; s/^,//;
  for (split /,/) {$used{$_}=1};

  next if $pkg{essential} =~ /yes/i or $pkg{priority} =~ /required/i;

  push @inst,$pkg{package};
  $desc{$pkg{package}}=$pkg{description} if $v;

if ($v) {
  for (sort @inst) {print "$_ - $desc{$_}\n\n" unless $used{$_}};
} else {
  for (sort @inst) {print "$_\n" unless $used{$_}};

Reply to: