summaryrefslogtreecommitdiffstats
path: root/urpm
diff options
context:
space:
mode:
Diffstat (limited to 'urpm')
-rw-r--r--urpm/util.pm15
1 files changed, 12 insertions, 3 deletions
diff --git a/urpm/util.pm b/urpm/util.pm
index 51091a6b..dfd133f8 100644
--- a/urpm/util.pm
+++ b/urpm/util.pm
@@ -82,9 +82,18 @@ sub untaint {
}
sub md5sum {
- #- Use an external command to avoid depending on perl
my ($file) = @_;
- return((split ' ', `/usr/bin/md5sum '$file'`)[0]);
+ eval { require Digest::MD5 };
+ if ($@) {
+ #- Use an external command to avoid depending on perl
+ return((split ' ', `/usr/bin/md5sum '$file'`)[0]);
+ } else {
+ my $ctx = Digest::MD5->new;
+ open my $fh, $file or return '';
+ $ctx->addfile($fh);
+ close $fh;
+ return $ctx->hexdigest;
+ }
}
sub copy {
@@ -115,6 +124,6 @@ urpm::util - Misc. utilities subs for urpmi
Copyright (C) 2005 MandrakeSoft SA
-Copyright (C) 2005 Mandriva SA
+Copyright (C) 2005, 2006 Mandriva SA
=cut