From 646de7067306de16958f9248b4f01ca730ca5c52 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 8 Jul 2008 18:05:48 +0000 Subject: 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 --- urpm/get_pkgs.pm | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'urpm/get_pkgs.pm') 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")); -- cgit v1.2.1