diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2008-07-08 18:05:48 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2008-07-08 18:05:48 +0000 |
commit | 646de7067306de16958f9248b4f01ca730ca5c52 (patch) | |
tree | 14b98233c1ecccd6b5b21e82d62c8f4f3a6fea12 /urpm/get_pkgs.pm | |
parent | ec49bc330577f2b7535ad658ab0608ecace5a9a2 (diff) | |
download | urpmi-646de7067306de16958f9248b4f01ca730ca5c52.tar urpmi-646de7067306de16958f9248b4f01ca730ca5c52.tar.gz urpmi-646de7067306de16958f9248b4f01ca730ca5c52.tar.bz2 urpmi-646de7067306de16958f9248b4f01ca730ca5c52.tar.xz urpmi-646de7067306de16958f9248b4f01ca730ca5c52.zip |
goal: get rid of $list which must be used together with $urpm->{media}, and use $blists instead
- create urpm::get_pkgs::selected2local_and_blists(),
which is similar to selected2list(), but returns a $blists
- the following functions have been modified to use a $blists instead of $list:
urpm::cdrom::copy_packages_of_removable_media()
urpm::install::prepare_transaction()
urpm::removable::try_mounting_non_cdroms()
urpm::get_pkgs::download_packages_of_distant_media()
- adapt code to use $blists
Diffstat (limited to 'urpm/get_pkgs.pm')
-rw-r--r-- | urpm/get_pkgs.pm | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/urpm/get_pkgs.pm b/urpm/get_pkgs.pm index 71336da0..7be7f33b 100644 --- a/urpm/get_pkgs.pm +++ b/urpm/get_pkgs.pm @@ -131,6 +131,28 @@ sub selected2list { ($local_sources, \@list); } +#- side-effects: none +sub _create_blists { + my ($media, $list) = @_; + + #- make sure everything is correct on input... + $media or return; + @$media == @$list or return; + + my $i; + [ map { + my $list = $list->[$i++]; + %$list ? { medium => $_, list => $list } : (); + } @$media ]; +} + +sub selected2local_and_blists { + my ($urpm, $selected, %options) = @_; + + my ($local_sources, $list) = selected2local_and_blists($urpm, $selected, %options); + ($local_sources, _create_blists($urpm->{media}, $list)); +} + sub verify_partial_rpm_and_move { my ($urpm, $cachedir, $filename) = @_; @@ -147,19 +169,16 @@ sub verify_partial_rpm_and_move { # TODO verify that files are downloaded from the right corresponding media #- options: quiet, callback, sub download_packages_of_distant_media { - my ($urpm, $list, $sources, $error_sources, %options) = @_; + my ($urpm, $blists, $sources, $error_sources, %options) = @_; my %errors; #- get back all ftp and http accessible rpm files into the local cache - foreach my $n (0..$#$list) { + foreach my $blist (@$blists) { my %distant_sources; - #- ignore media that contain nothing for the current set of files - values %{$list->[$n]} or next; - #- examine all files to know what can be indexed on multiple media. - while (my ($i, $url) = each %{$list->[$n]}) { + while (my ($i, $url) = each %{$blist->{list}}) { #- the given URL is trusted, so the file can safely be ignored. defined $sources->{$i} and next; my $local_file = file_from_local_url($url); @@ -189,8 +208,8 @@ sub download_packages_of_distant_media { #- download files from the current medium. if (%distant_sources) { - $urpm->{log}(N("retrieving rpm files from medium \"%s\"...", $urpm->{media}[$n]{name})); - if (urpm::download::sync($urpm, $urpm->{media}[$n], [ values %distant_sources ], + $urpm->{log}(N("retrieving rpm files from medium \"%s\"...", $blist->{media}{name})); + if (urpm::download::sync($urpm, $blist->{media}, [ values %distant_sources ], dir => "$cachedir/partial", quiet => $options{quiet}, resume => $urpm->{options}{resume}, callback => $options{callback})) { $urpm->{log}(N("...retrieving done")); |