Jim Meyering <j...@meyering.net> writes:

> I too prefer the shorter checksums and would like to encourage the use
> of the more compact representation by making that the default. Not
> just to keep line lengths under 80 columns, but just generally to
> minimize the noise of checksums in announcements.

I think both options look fine. How about leaving the default as it was
originally and adding the '--hex' option for the output Bruno prefers?

I've attached a patch, but I haven't pushed yet in case anyone
disagrees.

Collin

>From b1af025996e6afd8c48216b1585c787a819658fe Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Sun, 1 Dec 2024 21:33:32 -0800
Subject: [PATCH] announce-gen: Add the --hex option.

* build-aux/announce-gen (print_checksums_hex): New function.
(print_checksums_base64): New function.
(print_checksums): Call the new functions.
---
 ChangeLog              |  7 +++++++
 build-aux/announce-gen | 45 +++++++++++++++++++++++++++++++++++-------
 2 files changed, 45 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6d6fc99169..cc85aeb4b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-12-01  Collin Funk  <collin.fu...@gmail.com>
+
+	announce-gen: Add the --hex option.
+	* build-aux/announce-gen (print_checksums_hex): New function.
+	(print_checksums_base64): New function.
+	(print_checksums): Call the new functions.
+
 2024-12-01  Bruno Haible  <br...@clisp.org>
 
 	announce-gen: Show an SHA256 sum that can be verified more easily.
diff --git a/build-aux/announce-gen b/build-aux/announce-gen
index 0ec065a437..f7277585b4 100755
--- a/build-aux/announce-gen
+++ b/build-aux/announce-gen
@@ -35,7 +35,7 @@
 eval 'exec perl -wSx "$0" "$@"'
      if 0;
 
-my $VERSION = '2024-07-17 02:16'; # UTC
+my $VERSION = '2024-12-02 05:27'; # 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
@@ -180,14 +180,11 @@ sub digest_file_base64_wrap ($$)
   return $h . '=' x $pad{$alg};
 }
 
-sub print_checksums (@)
+sub print_checksums_hex (@)
 {
   my (@file) = @_;
 
-  print "Here are the SHA1 and SHA256 checksums:\n";
-  print "\n";
-
-  use Digest::file qw(digest_file_hex digest_file_base64);
+  use Digest::file qw(digest_file_hex);
 
   foreach my $f (@file)
     {
@@ -198,6 +195,38 @@ sub print_checksums (@)
     }
 }
 
+sub print_checksums_base64 (@)
+{
+  my (@file) = @_;
+
+  use Digest::file qw(digest_file_hex digest_file_base64);
+
+  foreach my $f (@file)
+    {
+      print '  ', digest_file_hex ($f, "SHA-1"), "  $f\n";
+      print '  ', digest_file_base64_wrap ($f, "SHA-256"), "  $f\n";
+    }
+  print "\nVerify the base64 SHA256 checksum with cksum -a sha256 --check\n";
+  print "from coreutils-9.2 or OpenBSD's cksum since 2007.\n\n";
+}
+
+sub print_checksums ($@)
+{
+  my ($print_hex, @file) = @_;
+
+  print "Here are the SHA1 and SHA256 checksums:\n";
+  print "\n";
+
+  if ($print_hex)
+    {
+      print_checksums_hex (@file);
+    }
+  else
+    {
+      print_checksums_base64 (@file);
+    }
+}
+
 =item C<print_news_deltas ($news_file, $prev_version, $curr_version)
 
 Print the section of the NEWS file C<$news_file> addressing changes
@@ -428,6 +457,7 @@ sub readable_interval($)
   my $bootstrap_tools;
   my $gnulib_version;
   my $print_checksums_p = 1;
+  my $print_hex = 0;
   my $gpg_key_email;
   my $gpg_keyring_url;
 
@@ -456,6 +486,7 @@ sub readable_interval($)
      'bootstrap-tools=s'  => \$bootstrap_tools,
      'gnulib-version=s'   => \$gnulib_version,
      'print-checksums!'   => \$print_checksums_p,
+     'hex'                => \$print_hex,
      'archive-suffix=s'   => \@archive_suffixes,
 
      help => sub { usage 0 },
@@ -621,7 +652,7 @@ EOF
     }
 
   $print_checksums_p
-    and print_checksums (@sizable);
+    and print_checksums ($print_hex, @sizable);
 
   print <<EOF;
 Use a .sig file to verify that the corresponding file (without the
-- 
2.47.1

Reply via email to