diff options
author | Thierry Vignaud <thierry.vignaud@gmail.com> | 2020-01-17 00:27:01 +0100 |
---|---|---|
committer | Thierry Vignaud <thierry.vignaud@gmail.com> | 2020-01-17 11:12:15 +0100 |
commit | 53624bcd2bbc6fd91c7a487b0703ddf427e312de (patch) | |
tree | 6d54b4483958295863601e612dc91ea2c088aff1 | |
parent | 03996585be4cdb7088d0bc0b40913f1fc844de25 (diff) | |
download | rpmtools-53624bcd2bbc6fd91c7a487b0703ddf427e312de.tar rpmtools-53624bcd2bbc6fd91c7a487b0703ddf427e312de.tar.gz rpmtools-53624bcd2bbc6fd91c7a487b0703ddf427e312de.tar.bz2 rpmtools-53624bcd2bbc6fd91c7a487b0703ddf427e312de.tar.xz rpmtools-53624bcd2bbc6fd91c7a487b0703ddf427e312de.zip |
switch from md5sum to Digest::MD5
performance & memory usage are similar
It helps gaining support on more platforms for CPAN testers, especially
for urpmi
This show that maybe creating an helper in a support module wouldn't
hurt...
-rwxr-xr-x | Makefile.PL | 1 | ||||
-rw-r--r-- | NEWS | 2 | ||||
-rwxr-xr-x | gendistrib | 16 | ||||
-rwxr-xr-x | genhdlist2 | 12 |
4 files changed, 26 insertions, 5 deletions
diff --git a/Makefile.PL b/Makefile.PL index 69938ba..a5a0053 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -37,6 +37,7 @@ WriteMakefile( INC => '', LIBS => [ '' ], PREREQ_PM => { + 'Digest::MD5' => '0', 'ExtUtils::MakeMaker' => '0', 'Getopt::Long' => '0', 'List::Util' => '1.33', @@ -1,3 +1,5 @@ +- switch from md5sum to Digest::MD5 thus improving urpmi test coverage + Version 7.11 - 13 January 2020, by Thierry Vignaud - cpan_testers: @@ -3,6 +3,7 @@ (our $VERSION) = q(Id: gendistrib 20724 2006-11-30 13:13:27Z rafael ) =~ /(\d+)/; use strict; +use Cwd; use MDV::Distribconf::Build; use Getopt::Long; @@ -184,11 +185,18 @@ if (grep { !$_->{noneedrebuild} } @hdlists) { # this MD5SUM is mostly obsolete, but is still needed up to 2007.1 # (and even on cooker for existing urpmi.cfg) require File::Glob; - my $md5sum1 = `cd $destinfodir ; /usr/bin/md5sum hdlist_*` if glob("$destinfodir/hdlist_*"); - my $md5sum2 = `cd $destinfodir ; /usr/bin/md5sum synthesis*` if glob("$destinfodir/synthesis*"); + require Digest::MD5; + my $md5sum; + my $cwd = getcwd(); + chdir($destinfodir); + foreach my $fn (glob("hdlist_*"), glob("synthesis*")) { + open(my $fh, '<', $fn) or die "Can't open '$fn': $!"; + binmode($fh); + $md5sum .= Digest::MD5->new->addfile($fh)->hexdigest . " $fn\n"; + } + chdir($cwd); open my $md5sumfh, '>', "$destinfodir/MD5SUM" or die "Can't create $destinfodir/MD5SUM: $!\n"; - print $md5sumfh $md5sum1 if $md5sum1; - print $md5sumfh $md5sum2 if $md5sum2; + print $md5sumfh $md5sum if $md5sum; } print STDERR "Calculating size of medias\n" unless $nooutput; @@ -2,6 +2,7 @@ our ($VERSION) = q(Id: genhdlist2 20460 2006-11-23 13:19:11Z pixel ) =~ /(\d+\.\d+)/; +use Cwd; use URPM; use List::Util 'any'; use MDV::Packdrakeng; @@ -427,8 +428,17 @@ sub generate_versioned_media_info { sub generate_md5sum { my ($media_info_dir, $media_info_files) = @_; + require Digest::MD5; print "updating $media_info_dir/MD5SUM\n" if $verbose >= 0; - my $m = `cd '$media_info_dir' ; /usr/bin/md5sum @$media_info_files`; + my $cwd = getcwd(); + chdir($media_info_dir); + my $m; + foreach my $fn (@$media_info_files) { + open(my $fh, '<', $fn) or die "Can't open '$fn': $!"; + binmode($fh); + $m .= Digest::MD5->new->addfile($fh)->hexdigest . " $fn\n"; + } + chdir($cwd); unlink "$media_info_dir/MD5SUM"; # ensure no hard link is used open(my $f, '>', "$media_info_dir/MD5SUM") or die "Can't write MD5SUM: $!\n"; print $f $m; |