diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2008-07-08 16:37:05 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2008-07-08 16:37:05 +0000 |
commit | e5a33d4993881ab56c414adee112e713c7d9984a (patch) | |
tree | 3cb0de2888b6a4a3211e2fae820816bfd39a867d /urpm/get_pkgs.pm | |
parent | 731c48756908997850eb3cb69f732c6f82e1927e (diff) | |
download | urpmi-e5a33d4993881ab56c414adee112e713c7d9984a.tar urpmi-e5a33d4993881ab56c414adee112e713c7d9984a.tar.gz urpmi-e5a33d4993881ab56c414adee112e713c7d9984a.tar.bz2 urpmi-e5a33d4993881ab56c414adee112e713c7d9984a.tar.xz urpmi-e5a33d4993881ab56c414adee112e713c7d9984a.zip |
create _selected2local_and_ids() out of selected2list()
Diffstat (limited to 'urpm/get_pkgs.pm')
-rw-r--r-- | urpm/get_pkgs.pm | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/urpm/get_pkgs.pm b/urpm/get_pkgs.pm index ae7844cd..0312321a 100644 --- a/urpm/get_pkgs.pm +++ b/urpm/get_pkgs.pm @@ -22,7 +22,7 @@ sub clean_all_cache { #- returns a list of lists containing the source description for each rpm, #- matching the exact number of registered media; ignored media being #- associated to a null list. -sub selected2list { +sub _selected2local_and_ids { my ($urpm, $packages, %options) = @_; my (%protected_files, %local_sources, %fullname2id); @@ -55,7 +55,7 @@ sub selected2list { } } - my (%id_map, @remaining_ids); + my %id2ids; foreach my $id (values %fullname2id) { my $pkg = $urpm->{depslist}[$id]; my $fullname = $pkg->fullname; @@ -71,15 +71,26 @@ sub selected2list { } grep { $fullname eq $_->fullname } $urpm->packages_by_name($pkg->name); }; - # id_map is a remapping of id. - # it is needed because @list must be [ { id => pkg } ] where id is one the selected id, - # not really the real package id - $id_map{$_} = $id foreach @pkg_ids; + $id2ids{$id} = \@pkg_ids; + } + + (\%local_sources, \%id2ids); +} + +sub selected2list { + my ($urpm, $selected, %options) = @_; + + my ($local_sources, $id2ids) = _selected2local_and_ids($urpm, $selected, %options); - push @remaining_ids, @pkg_ids; + # id_map is a remapping of id. + # it is needed because @list must be [ { id => pkg } ] where id is one the selected id, + # not really the real package id + my %id_map; + foreach my $id (keys %$id2ids) { + $id_map{$_} = $id foreach @{$id2ids->{$id}}; } - @remaining_ids = sort { $a <=> $b } @remaining_ids; + my @remaining_ids = sort { $a <=> $b } keys %id_map; my @list = map { my $medium = $_; @@ -102,7 +113,7 @@ sub selected2list { return; } - (\%local_sources, \@list); + ($local_sources, \@list); } sub verify_partial_rpm_and_move { |