]> Savannah Git Hosting - gnulib.git/commitdiff
announce-gen: avoid failure when Digest::SHA is installed
authorDaiki Ueno <ueno@gnu.org>
Tue, 9 Jul 2013 06:54:48 +0000 (15:54 +0900)
committerPádraig Brady <P@draigBrady.com>
Mon, 14 Jul 2014 09:12:16 +0000 (10:12 +0100)
When Digest::SHA is available, Digest::SHA1 is not loaded and thus
Digest::SHA1->new in print_checksums fails.
* build-aux/announce-gen (digest_classes): New associative array
for available message digest implementations.
(print_locations): Use it.

ChangeLog
build-aux/announce-gen

index 9b3c85d794b1167436563d95840500e4daccd065..e3d86b350890ee965aab64e72720e7cc1b55158a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2014-07-14  Daiki Ueno  <ueno@gnu.org>
+
+       announce-gen: avoid failure when Digest::SHA is installed
+       When Digest::SHA is available, Digest::SHA1 is not loaded and thus
+       Digest::SHA1->new in print_checksums fails.
+       * build-aux/announce-gen (digest_classes): New associative array
+       for available message digest implementations.
+       (print_locations): Use it.
+
 2014-07-13  Pádraig Brady  <P@draigBrady.com>
 
        gettext: revert "update macros to version 0.19"
index a3aebf76220f3ad4b75c1ec8a9bb1f1b69ec7d19..60e0e397c29806994295d99a28d4fce33579fb59 100755 (executable)
@@ -3,7 +3,7 @@ eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}'
     if 0;
 # Generate a release announcement message.
 
-my $VERSION = '2012-06-08 06:53'; # UTC
+my $VERSION = '2013-07-09 06:39'; # 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,15 +29,18 @@ my $VERSION = '2012-06-08 06:53'; # UTC
 use strict;
 
 use Getopt::Long;
-use Digest::MD5;
-eval { require Digest::SHA; }
-  or eval 'use Digest::SHA1';
 use POSIX qw(strftime);
 
 (my $ME = $0) =~ s|.*/||;
 
 my %valid_release_types = map {$_ => 1} qw (alpha beta stable);
 my @archive_suffixes = ('tar.gz', 'tar.bz2', 'tar.lzma', 'tar.xz');
+my %digest_classes =
+  (
+   'md5' => (eval { require Digest::MD5; } and 'Digest::MD5'),
+   'sha1' => ((eval { require Digest::SHA; } and 'Digest::SHA')
+              or (eval { require Digest::SHA1; } and 'Digest::SHA1'))
+  );
 my $srcdir = '.';
 
 sub usage ($)
@@ -157,15 +160,13 @@ sub print_checksums (@)
 
   foreach my $meth (qw (md5 sha1))
     {
+      my $class = $digest_classes{$meth} or next;
       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 = $class->new->addfile(*IN)->hexdigest;
           close IN;
           print "$dig  $f\n";
         }