summaryrefslogtreecommitdiffstats
path: root/urpm/md5sum.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-05-15 14:11:16 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-05-15 14:11:16 +0000
commitfd1514ba3b0d3c6d918a7a2c68068d927f275a4f (patch)
treee143e26d1420f4a71812b50b5c8f59b9219401b1 /urpm/md5sum.pm
parentad267f63d66ffe9455591bc326c376709b8f08b8 (diff)
downloadurpmi-fd1514ba3b0d3c6d918a7a2c68068d927f275a4f.tar
urpmi-fd1514ba3b0d3c6d918a7a2c68068d927f275a4f.tar.gz
urpmi-fd1514ba3b0d3c6d918a7a2c68068d927f275a4f.tar.bz2
urpmi-fd1514ba3b0d3c6d918a7a2c68068d927f275a4f.tar.xz
urpmi-fd1514ba3b0d3c6d918a7a2c68068d927f275a4f.zip
- urpmi.addmedia, urpmi.update:
o check downloaded MD5SUM is not invalid HTML code, and try another mirror from mirrorlist (#39918) (useful for servers not returning a valid HTTP error)
Diffstat (limited to 'urpm/md5sum.pm')
-rw-r--r--urpm/md5sum.pm16
1 files changed, 11 insertions, 5 deletions
diff --git a/urpm/md5sum.pm b/urpm/md5sum.pm
index b5d4a7f1..855bfdd1 100644
--- a/urpm/md5sum.pm
+++ b/urpm/md5sum.pm
@@ -8,19 +8,25 @@ sub parse {
my ($md5sum_file) = @_;
my %h = map {
- my ($md5sum, $file) = m|(\S+)\s+(?:\./)?(\S+)|;
+ my ($md5sum, $file) = m|^([0-9-a-f]+)\s+(?:\./)?(\S+)$|i or return;
$file => $md5sum;
- } cat_($md5sum_file);
+ } cat_($md5sum_file) or return;
\%h;
}
+sub check_file {
+ my ($md5sum_file) = @_;
+
+ file_size($md5sum_file) > 32 && parse($md5sum_file);
+}
+
sub from_MD5SUM__or_warn {
my ($urpm, $md5sum_file, $basename) = @_;
$urpm->{debug}(N("examining %s file", $md5sum_file)) if $urpm->{debug};
- my $retrieved_md5sum = parse($md5sum_file)->{$basename}
- or $urpm->{log}(N("warning: md5sum for %s unavailable in MD5SUM file", $basename));
- return $retrieved_md5sum;
+ my $md5sums = parse($md5sum_file) or $urpm->{log}(N("invalid MD5SUM file")), return;
+ $md5sums->{$basename} or $urpm->{log}(N("warning: md5sum for %s unavailable in MD5SUM file", $basename));
+ $md5sums->{$basename};
}
sub compute {