Eric Wong wrote: > How about using the generic Digest module instead? > > Something like this (totally untested) patch: > > diff --git a/build-aux/announce-gen b/build-aux/announce-gen > index 3ca90a9..c453d44 100755 > --- a/build-aux/announce-gen > +++ b/build-aux/announce-gen > @@ -29,8 +29,7 @@ my $VERSION = '2012-01-06 07:46'; # UTC > use strict; > > use Getopt::Long; > -use Digest::MD5; > -use Digest::SHA1; > +use Digest; > use POSIX qw(strftime); > > (my $ME = $0) =~ s|.*/||; > @@ -151,17 +150,14 @@ sub print_checksums (@) > print "Here are the MD5 and SHA1 checksums:\n"; > print "\n"; > > - foreach my $meth (qw (md5 sha1)) > + foreach my $meth (qw (MD5 SHA-1)) > { > foreach my $f (@file) > { > open IN, '<', $f > or die "$ME: $f: cannot open for reading: $!\n"; > binmode IN; > - my $dig = > - ($meth eq 'md5' > - ? Digest::MD5->new->addfile(*IN)->hexdigest > - : Digest::SHA1->new->addfile(*IN)->hexdigest); > + my $dig = Digest->new($meth)->addfile(*IN)->hexdigest;
Thanks for the suggestion. That would be better if we knew all checksum-printing users are using new-enough Perl. For that matter, I don't know if any announce-gen user is even still printing MD5/SHA1 checksums. I've just checked, and see more than a few checksum-printing announcements in 2011, but then I confirmed that even Debian's lenny (old-stable) has perl-5.10, which included a new-enough Digest module. So it's probably ok. Here's a proposed patch. If anyone who makes announce-gen print digests is using a system with too-old perl (predating 5.9.3), please reply here. >From f96f5ef533bf4d719a67ff069fff8f2c1a6a5c04 Mon Sep 17 00:00:00 2001 From: Eric Wong <normalper...@yhbt.net> Date: Wed, 21 Mar 2012 09:31:43 +0100 Subject: [PATCH] announce-gen: simplify checksum printing code * build-aux/announce-gen: Simply use Digest module; drop Digest::MD5. (print_checksums): Simplify. Copyright-paperwork-exempt: Yes --- ChangeLog | 6 ++++++ build-aux/announce-gen | 13 ++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0076e06..1800e98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-03-21 Eric Wong <normalper...@yhbt.net> (tiny change) + + announce-gen: simplify checksum printing code + * build-aux/announce-gen: Simply use Digest module; drop Digest::MD5. + (print_checksums): Simplify. + 2012-03-20 Reuben Thomas <r...@sc3d.org> announce-gen: use Digest::SHA when possible diff --git a/build-aux/announce-gen b/build-aux/announce-gen index b9c9360..bb416b1 100755 --- a/build-aux/announce-gen +++ b/build-aux/announce-gen @@ -3,7 +3,7 @@ eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}' if 0; # Generate a release announcement message. -my $VERSION = '2012-03-20 23:17'; # UTC +my $VERSION = '2012-03-21 08:22'; # UTC # The definition above must lie within the first 8 lines in order # for the Emacs time-stamp write hook (at end) to update it. # If you change this file with Emacs, please let the write hook @@ -29,9 +29,7 @@ my $VERSION = '2012-03-20 23:17'; # UTC use strict; use Getopt::Long; -use Digest::MD5; -eval { require Digest::SHA; } - or eval { use Digest::SHA1; }; +use Digest; use POSIX qw(strftime); (my $ME = $0) =~ s|.*/||; @@ -152,17 +150,14 @@ sub print_checksums (@) print "Here are the MD5 and SHA1 checksums:\n"; print "\n"; - foreach my $meth (qw (md5 sha1)) + foreach my $meth (qw (MD5 SHA-1)) { foreach my $f (@file) { open IN, '<', $f or die "$ME: $f: cannot open for reading: $!\n"; binmode IN; - my $dig = - ($meth eq 'md5' - ? Digest::MD5->new->addfile(*IN)->hexdigest - : Digest::SHA1->new->addfile(*IN)->hexdigest); + my $dig = Digest->new($meth)->addfile(*IN)->hexdigest; close IN; print "$dig $f\n"; } -- 1.7.10.rc1.23.g16a10