diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2008-07-01 12:13:47 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2008-07-01 12:13:47 +0000 |
commit | c315ca224db78ab5766a21408c084cceda9bf306 (patch) | |
tree | 829aed84575736c9b2418a0e5feeb7e9ba432dd7 /urpm/select.pm | |
parent | 146c51874702fa7383065e3656e74205f5537148 (diff) | |
download | urpmi-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 'urpm/select.pm')
-rw-r--r-- | urpm/select.pm | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/urpm/select.pm b/urpm/select.pm index dc663d6f..60f35317 100644 --- a/urpm/select.pm +++ b/urpm/select.pm @@ -602,5 +602,42 @@ sub translate_why_removed_one { $fullname . ($s ? "\n ($s)" : ''); } +sub installed_packages_packed { + my ($urpm) = @_; + + my $db = urpm::db_open_or_die_($urpm) or die "Can't open RPM db\n"; + my @l; + $db->traverse(sub { + my ($pkg) = @_; + $pkg->pack_header; + push @l, $pkg; + }); + \@l; +} + +sub installed_leaves { + my ($urpm, $o_discard) = @_; + + my $packages = installed_packages_packed($urpm); + + my (%l, %provides); + foreach my $pkg (@$packages) { + next if $o_discard && $o_discard->($pkg); + $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}; + } + } + } + + \%l; +} 1; |