diff options
author | Francois Pons <fpons@mandriva.com> | 2002-01-16 18:21:42 +0000 |
---|---|---|
committer | Francois Pons <fpons@mandriva.com> | 2002-01-16 18:21:42 +0000 |
commit | 43a2e10ca24e7e3aefc448a81d2b5ecb1ad75a68 (patch) | |
tree | a83977b31deaaef21f71ce946e6695402c0c60c5 /rpm-find-leaves | |
parent | a9a81651654af34db20a0b4bab4488c7a50cab38 (diff) | |
download | urpmi-43a2e10ca24e7e3aefc448a81d2b5ecb1ad75a68.tar urpmi-43a2e10ca24e7e3aefc448a81d2b5ecb1ad75a68.tar.gz urpmi-43a2e10ca24e7e3aefc448a81d2b5ecb1ad75a68.tar.bz2 urpmi-43a2e10ca24e7e3aefc448a81d2b5ecb1ad75a68.tar.xz urpmi-43a2e10ca24e7e3aefc448a81d2b5ecb1ad75a68.zip |
3.2-1mdk
Diffstat (limited to 'rpm-find-leaves')
-rw-r--r-- | rpm-find-leaves | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/rpm-find-leaves b/rpm-find-leaves index 781422b7..32d9668c 100644 --- a/rpm-find-leaves +++ b/rpm-find-leaves @@ -1,32 +1,22 @@ #!/usr/bin/perl -use lib "../rpmtools"; - -local $_ = join '', @ARGV; - -/-h/ and die "usage: rpm-find-leaves [--show-unknown]\n"; - -$show_unknown = /-show-unknown/; +@ARGV and die "usage: rpm-find-leaves\n"; use rpmtools; -$f = "/var/lib/urpmi/depslist.ordered"; -open F, $f or die "read_depslist: can't open file $f\n"; -$o = new rpmtools; -$o->read_depslist(\*F); - -chop, $l{$_} = 1 foreach `rpm -qa --queryformat "%{name}\n"`; +$db = rpmtools::db_open(''); +rpmtools::db_traverse($db, [ qw(name version release provides requires) ], sub { + push @packages, $_[0]; +}); +rpmtools::db_close($db); -%m = %l; - -foreach (@{$o->{depslist}}) { - delete $m{$_->{name}} or next; - delete $l{$o->{depslist}[$_]{name}} foreach split ' ', $_->{deps}; +foreach my $pkg (@packages) { + $l{$pkg->{name}} = 1; + push @{$provides{$_}}, $pkg->{name} foreach @{$pkg->{provides} || []}; } -!$m{$_} and print "$_\n" foreach sort keys %l; - -if ($show_unknown) { - print "\n"; - print "$_\n" foreach sort keys %m; +foreach my $pkg (@packages) { + delete @l{grep { $_ ne $pkg->{name} } @{$provides{$_} || []}} foreach @{$pkg->{requires} || []}; } + +print "$_\n" foreach sort keys %l; |