summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--urpm.pm14
-rw-r--r--urpm/util.pm10
2 files changed, 17 insertions, 7 deletions
diff --git a/urpm.pm b/urpm.pm
index c51af8f2..4b2a0d4c 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -1096,16 +1096,17 @@ this could happen if you mounted manually the directory when creating the medium
$urpm->{log}(N("computing md5sum of existing source hdlist (or synthesis)"));
if ($medium->{synthesis}) {
-e "$urpm->{statedir}/synthesis.$medium->{hdlist}" and
- $medium->{md5sum} = (split ' ', `md5sum '$urpm->{statedir}/synthesis.$medium->{hdlist}'`)[0];
+ $medium->{md5sum} = md5sum("$urpm->{statedir}/synthesis.$medium->{hdlist}");
} else {
-e "$urpm->{statedir}/$medium->{hdlist}" and
- $medium->{md5sum} = (split ' ', `md5sum '$urpm->{statedir}/$medium->{hdlist}'`)[0];
+ $medium->{md5sum} = md5sum("$urpm->{statedir}/$medium->{hdlist}");
}
}
}
if ($medium->{md5sum}) {
$urpm->{log}(N("examining MD5SUM file"));
local $_;
+ undef $retrieved_md5sum;
open my $fh, reduce_pathname("$with_hdlist_dir/../MD5SUM");
while (<$fh>) {
my ($md5sum, $file) = m|(\S+)\s+(?:\./)?(\S+)| or next;
@@ -1178,7 +1179,7 @@ this could happen if you mounted manually the directory when creating the medium
#- keep checking md5sum of file just copied ! (especially on nfs or removable device).
if (!$error && $retrieved_md5sum) {
$urpm->{log}(N("computing md5sum of copied source hdlist (or synthesis)"));
- (split ' ', `md5sum '$urpm->{cachedir}/partial/$medium->{hdlist}'`)[0] eq $retrieved_md5sum or
+ md5sum("$urpm->{cachedir}/partial/$medium->{hdlist}") eq $retrieved_md5sum or
$error = 1, $urpm->{error}(N("copy of [%s] failed (md5sum mismatch)", $with_hdlist_dir));
}
@@ -1381,16 +1382,17 @@ this could happen if you mounted manually the directory when creating the medium
$urpm->{log}(N("computing md5sum of existing source hdlist (or synthesis)"));
if ($medium->{synthesis}) {
-e "$urpm->{statedir}/synthesis.$medium->{hdlist}" and
- $medium->{md5sum} = (split ' ', `md5sum '$urpm->{statedir}/synthesis.$medium->{hdlist}'`)[0];
+ $medium->{md5sum} = md5sum("$urpm->{statedir}/synthesis.$medium->{hdlist}");
} else {
-e "$urpm->{statedir}/$medium->{hdlist}" and
- $medium->{md5sum} = (split ' ', `md5sum '$urpm->{statedir}/$medium->{hdlist}'`)[0];
+ $medium->{md5sum} = md5sum("$urpm->{statedir}/$medium->{hdlist}");
}
}
}
if ($medium->{md5sum}) {
$urpm->{log}(N("examining MD5SUM file"));
local $_;
+ undef $retrieved_md5sum;
open my $fh, "$urpm->{cachedir}/partial/MD5SUM";
while (<$fh>) {
my ($md5sum, $file) = m|(\S+)\s+(?:\./)?(\S+)| or next;
@@ -1519,7 +1521,7 @@ this could happen if you mounted manually the directory when creating the medium
#- check downloaded file has right signature.
if (-e "$urpm->{cachedir}/partial/$basename" && -s _ > 32 && $retrieved_md5sum) {
$urpm->{log}(N("computing md5sum of retrieved source hdlist (or synthesis)"));
- unless ((split ' ', `md5sum '$urpm->{cachedir}/partial/$basename'`)[0] eq $retrieved_md5sum) {
+ unless (md5sum("$urpm->{cachedir}/partial/$basename") eq $retrieved_md5sum) {
$urpm->{error}(N("...retrieving failed: %s", N("md5sum mismatch")));
unlink "$urpm->{cachedir}/partial/$basename";
}
diff --git a/urpm/util.pm b/urpm/util.pm
index 01121284..eb2fc912 100644
--- a/urpm/util.pm
+++ b/urpm/util.pm
@@ -5,7 +5,9 @@ use Exporter;
our @ISA = 'Exporter';
our @EXPORT = qw(quotespace unquotespace
remove_internal_name
- reduce_pathname offset_pathname);
+ reduce_pathname offset_pathname
+ md5sum
+);
#- quoting/unquoting a string that may be containing space chars.
sub quotespace { my $x = $_[0] || ''; $x =~ s/(\s)/\\$1/g; $x }
@@ -70,6 +72,12 @@ sub offset_pathname {
$result . join('/', reverse @corrections);
}
+sub md5sum {
+ #- Use an external command to avoid depending on perl
+ my ($file) = @_;
+ return( (split ' ', `md5sum '$file'`)[0] );
+}
+
1;
__END__