summaryrefslogtreecommitdiffstats
path: root/rpm-find-leaves
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-07-01 12:13:47 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-07-01 12:13:47 +0000
commitc315ca224db78ab5766a21408c084cceda9bf306 (patch)
tree829aed84575736c9b2418a0e5feeb7e9ba432dd7 /rpm-find-leaves
parent146c51874702fa7383065e3656e74205f5537148 (diff)
downloadurpmi-c315ca224db78ab5766a21408c084cceda9bf306.tar
urpmi-c315ca224db78ab5766a21408c084cceda9bf306.tar.gz
urpmi-c315ca224db78ab5766a21408c084cceda9bf306.tar.bz2
urpmi-c315ca224db78ab5766a21408c084cceda9bf306.tar.xz
urpmi-c315ca224db78ab5766a21408c084cceda9bf306.zip
create urpm::select::installed_leaves() out of rpm-find-leaves
Diffstat (limited to 'rpm-find-leaves')
-rw-r--r--rpm-find-leaves36
1 files changed, 6 insertions, 30 deletions
diff --git a/rpm-find-leaves b/rpm-find-leaves
index e8c544ba..731e8e5b 100644
--- a/rpm-find-leaves
+++ b/rpm-find-leaves
@@ -4,6 +4,7 @@ use strict;
use urpm;
use urpm::msg;
+use urpm::select;
my %options = (
restrict_group => 0,
@@ -40,39 +41,14 @@ while ($_ = shift) {
print $usage; exit 1;
}
-my @packages;
-{
- my $db = urpm::db_open_or_die_($urpm) or die "Can't open RPM db\n";
- $db->traverse(sub {
- my ($p) = @_;
- $p->pack_header;
- push @packages, $p;
- });
-}
-
-my %l;
-my %provides;
-foreach my $pkg (@packages) {
- next if $options{restrict_group} && $pkg->group !~ /\Q$options{group}/oi;
- $l{$pkg->name} = $pkg;
- push @{$provides{$_}}, $pkg foreach $pkg->provides_nosense;
-}
-
-foreach my $pkg (@packages) {
- foreach my $prop ($pkg->requires) {
- my ($n, $s) = URPM::property2name_range($prop);
- foreach my $p (@{$provides{$n} || []}) {
- $p != $pkg && $p->provides_overlap($prop) and
- delete $l{$p->name};
- }
- }
-}
+my $discard = $options{restrict_group} && sub { $_[0]->group !~ /\Q$options{group}/oi };
+my $leaves = urpm::select::installed_leaves($urpm, $discard);
if ($options{fullname}) {
- foreach my $k (sort keys %l) {
- my $l = $l{$k};
+ foreach my $k (sort keys %$leaves) {
+ my $l = $leaves->{$k};
print $l->name, '-', $l->version, '-', $l->release, '.', $l->arch, "\n";
}
} else {
- print "$_\n" foreach sort keys %l;
+ print "$_\n" foreach sort keys %$leaves;
}