diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2006-11-09 16:36:22 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2006-11-09 16:36:22 +0000 |
commit | e53a4ff3a5d5a883cfa4543d059a722719b4106b (patch) | |
tree | d2fdf37c0727d9ee196b7f51e5fe5952583a84ef | |
parent | 793775ab16fb362ed9a005f4a1967323844802d3 (diff) | |
download | urpmi-e53a4ff3a5d5a883cfa4543d059a722719b4106b.tar urpmi-e53a4ff3a5d5a883cfa4543d059a722719b4106b.tar.gz urpmi-e53a4ff3a5d5a883cfa4543d059a722719b4106b.tar.bz2 urpmi-e53a4ff3a5d5a883cfa4543d059a722719b4106b.tar.xz urpmi-e53a4ff3a5d5a883cfa4543d059a722719b4106b.zip |
create get_computed_md5sum() out of parse_md5sum() (it is the same except for logging)
and use it
-rw-r--r-- | urpm.pm | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -244,17 +244,10 @@ sub read_config { } #- read MD5 sums (usually not in urpmi.cfg but in a separate file) - my $md5sum = $urpm->open_safe("<", "$urpm->{statedir}/MD5SUM"); - if ($md5sum) { - local $_; - while (<$md5sum>) { - my ($md5sum, $file) = /(\S*)\s+(.*)/; - foreach (@{$urpm->{media}}) { - ($_->{synthesis} ? "synthesis." : "") . $_->{hdlist} eq $file - and $_->{md5sum} = $md5sum, last; - } + foreach (@{$urpm->{media}}) { + if (my $md5sum = get_computed_md5sum("$urpm->{statedir}/MD5SUM", ($_->{synthesis} ? "synthesis." : "") . $_->{hdlist})) { + $_->{md5sum} = $md5sum; } - close $md5sum; } #- remember global options for write_config @@ -3434,15 +3427,22 @@ sub get_updates_description { } #- parse an MD5SUM file from a mirror -sub parse_md5sum { - my ($urpm, $path, $basename) = @_; - $urpm->{log}(N("examining MD5SUM file")); +sub get_computed_md5sum { + my ($path, $basename) = @_; my ($retrieved_md5sum) = map { my ($md5sum, $file) = m|(\S+)\s+(?:\./)?(\S+)|; $file && $file eq $basename ? $md5sum : (); - } cat_($path) or $urpm->{log}(N("warning: md5sum for %s unavailable in MD5SUM file", $basename)); + } cat_($path); + + $retrieved_md5sum; +} +sub parse_md5sum { + my ($urpm, $path, $basename) = @_; + $urpm->{log}(N("examining MD5SUM file")); + my $retrieved_md5sum = get_computed_md5sum($path, $basename) + or $urpm->{log}(N("warning: md5sum for %s unavailable in MD5SUM file", $basename)); return $retrieved_md5sum; } |