Hi,

Toomas Tamm wrote on 2014-06-20 14:39:57 +0300 [Re: fai-mirror and conflicting 
packages]:
> On Fri, 2014-06-20 at 13:09 +0200, Thomas Lange wrote:
> > >>>>> On Fri, 20 Jun 2014 12:02:39 +0200, Andreas Heinlein 
> > >>>>> <aheinl...@gmx.com> said:
> >     > Perhaps you have an idea how to do this better than manually seeking
> >     > through the list and try to find out the really needed packages?
> > I do not know a tools for that. But using apt-cache (depends and
> > rdepends) and apt-rdepends should help creating a small programm for
> > that task. Ask on #debian-devel if someone already did that.

actually, I've done that. It's a quick and dirty hack, uncommented and without
any guarantees, but it seems to have worked for me at some point in time ;-),
so feel free to try it if you like (and please tell me if something doesn't
work). Reads 'dpkg --get-selections' type output from stdin and writes to
stdout (including package count lines, so you'll have to delete those ;-).
I just saw that I write a different format to stdout (only one package per
line, without the 'install' required on stdin).

Regards,
Holger
#!/usr/bin/perl -w

use strict;
use AptPkg::Cache;

my $cache = new AptPkg::Cache;
my %pkglist = ();

# fill package list from 'dpkg --get-selections' type input
while (<>) {
  if (/^(\S+)\s+install/) {
    $pkglist {$1} = 1;
  }
}

print "Fine, found ", (scalar keys %pkglist), " packages.\n";

# iterate over package list, remove dependencies of each packet
foreach my $p (keys %pkglist) {
  if ($cache -> {$p} {CurrentVer} {DependsList}) {
    foreach my $dep (@{$cache -> {$p} {CurrentVer} {DependsList}}) {
      if ($dep->{DepType} eq 'Depends') {
        delete $pkglist {$dep -> {TargetPkg} {Name}};
      }
      # print "DBG: $p $dep->{DepType} $dep->{TargetPkg}{Name}\n";
    }
  }
}

# print resulting package list
foreach (sort keys %pkglist) {
  print "$_\n";
}
print "remaining packages: ", (scalar keys %pkglist), "\n";

Antwort per Email an