diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2006-01-24 11:13:24 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2006-01-24 11:13:24 +0000 |
commit | e884114e68874533a3156add77ebb9fedae8ec8e (patch) | |
tree | 6831f7bfb32eea7d8a327b261acb1928a93014a0 | |
parent | 4bf206ed763a8efe416f7dbb3fc926e551ae9519 (diff) | |
download | urpmi-e884114e68874533a3156add77ebb9fedae8ec8e.tar urpmi-e884114e68874533a3156add77ebb9fedae8ec8e.tar.gz urpmi-e884114e68874533a3156add77ebb9fedae8ec8e.tar.bz2 urpmi-e884114e68874533a3156add77ebb9fedae8ec8e.tar.xz urpmi-e884114e68874533a3156add77ebb9fedae8ec8e.zip |
Use Digest::MD5 when available
-rw-r--r-- | urpm/util.pm | 15 |
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 |