diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | urpm/get_pkgs.pm | 27 | ||||
-rw-r--r-- | urpm/main_loop.pm | 12 |
3 files changed, 29 insertions, 13 deletions
@@ -3,6 +3,9 @@ - urpmi, urpmi.addmedia, urpmi.update: o have fatal errors on some errors that must not happen (eg: moving rpm from download dir to cachedir) +- urpmi: + o do not say "files are missing" when the downloaded rpm is corrupted + (rpmdrake must add a "bad_rpms" callback to display the new message) Version 5.5 - 23 February 2008, by Pascal "Pixel" Rigaux diff --git a/urpm/get_pkgs.pm b/urpm/get_pkgs.pm index b6a792dc..4bda4e99 100644 --- a/urpm/get_pkgs.pm +++ b/urpm/get_pkgs.pm @@ -110,6 +110,8 @@ sub selected2list { sub download_packages_of_distant_media { my ($urpm, $list, $sources, $error_sources, %options) = @_; + my %errors; + #- get back all ftp and http accessible rpm files into the local cache foreach my $n (0..$#$list) { my %distant_sources; @@ -126,7 +128,7 @@ sub download_packages_of_distant_media { if (-r $local_file) { $sources->{$i} = $local_file; } else { - $error_sources->{$i} = $local_file; + $errors{$i} = [ $local_file, 'missing' ]; } } elsif ($url =~ m!^([^:]*):/(.*/([^/]*\.rpm))\Z!) { $distant_sources{$i} = "$1:/$2"; #- will download now @@ -165,22 +167,27 @@ sub download_packages_of_distant_media { #- present the error to the user. foreach my $i (keys %distant_sources) { my ($filename) = $distant_sources{$i} =~ m|/([^/]*\.rpm)$|; - if ($filename && -s "$partial_dir/$filename" && - URPM::verify_rpm("$partial_dir/$filename", nosignatures => 1)) - { - #- it seems the the file has been downloaded correctly and has been checked to be valid. - unlink "$rpms_dir/$filename"; - urpm::sys::move_or_die($urpm, "$partial_dir/$filename", "$rpms_dir/$filename"); - $sources->{$i} = "$rpms_dir/$filename"; + if ($filename && -s "$partial_dir/$filename") { + if (URPM::verify_rpm("$partial_dir/$filename", nosignatures => 1)) { + #- it seems the the file has been downloaded correctly and has been checked to be valid. + unlink "$rpms_dir/$filename"; + urpm::sys::move_or_die($urpm, "$partial_dir/$filename", "$rpms_dir/$filename"); + $sources->{$i} = "$rpms_dir/$filename"; + } else { + unlink "$partial_dir/$filename"; + $errors{$i} = [ $distant_sources{$i}, 'bad' ]; + } } else { - $error_sources->{$i} = $distant_sources{$i}; + $errors{$i} = [ $distant_sources{$i}, 'missing' ]; } } } } #- clean failed download which have succeeded. - delete @$error_sources{keys %$sources}; + delete @$errors{keys %$sources}; + + %$error_sources = map { @$_ } values %errors; 1; } diff --git a/urpm/main_loop.pm b/urpm/main_loop.pm index 6491dab0..0b93be47 100644 --- a/urpm/main_loop.pm +++ b/urpm/main_loop.pm @@ -252,13 +252,19 @@ $callbacks->{completed} and $callbacks->{completed}->(); #- keep a track of error code. my $exit_code = 0; -if (values %error_sources) { - $callbacks->{missing_files_summary} and $callbacks->{missing_files_summary}->(\%error_sources); +if (my @missing = grep { $error_sources{$_} eq 'missing' } keys %error_sources) { + $callbacks->{missing_files_summary} and $callbacks->{missing_files_summary}->({ map { $_ => $_ } @missing }); #- Warning : the following message is parsed in urpm::parallel_* print N("Installation failed, some files are missing:\n%s\nYou may want to update your urpmi database", - join "\n", map { s|([^:]*://[^/:\@]*:)[^/:\@]*(\@.*)|$1xxxx$2|; " $_" } values %error_sources), "\n"; + join "\n", map { " " . urpm::download::hide_password($_) } @missing), "\n"; $exit_code = 10; } +if (my @bad = grep { $error_sources{$_} eq 'bad' } keys %error_sources) { + $callbacks->{bad_rpms} and $callbacks->{bad_rpms}->(@bad); + print N("Installation failed, bad rpms:\n%s", + join "\n", map { " " . urpm::download::hide_password($_) } @bad), "\n"; + $exit_code = 11; +} if ($nok) { $callbacks->{trans_error_summary} and $callbacks->{trans_error_summary}->($nok, \@errors); $nok > 1 and print P("%d installation transaction failed", |