Subject: Make automake ourput reproducible
From: Josef Möllers <[email-masked]>
To: [email-masked]
Date: Wed, 24 Feb 2021 08:54:17 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

We rely on builds to be reproducible.

The PERL script bin/automake.in calls the perl function "keys" at
several places. The returned list, unfortunately, changes between
invocation of the script. "sort"ing the returned list makes the process
reproducible again.

Attached is a patch courtesy of Dirk Müller.

Josef

--- automake-1.16.3/bin/automake.in
+++ automake-1.16.3/bin/automake.in
@@ -2388,7 +2388,7 @@
   $var->requires_variables ("\@${lt}LIBOBJS\@ used", $lt . 'LIBOBJS')
     if ! keys %libsources;

-  foreach my $iter (keys %libsources)
+  foreach my $iter (sort keys %libsources)
     {
       my $dir = '';
       if ($iter =~ /^(.*)(\.[cly])$/)
@@ -4692,7 +4692,7 @@
 	     DIST_CLEAN, [],
 	     MAINTAINER_CLEAN, []);

-  foreach my $file (keys %clean_files)
+  foreach my $file (sort keys %clean_files)
     {
       my $when = $clean_files{$file};
       prog_error 'invalid entry in %clean_files'
@@ -4762,7 +4762,7 @@
 	       . "not 'install-hook'");

   # Install the -local hooks.
-  foreach (keys %dependencies)
+  foreach (sort keys %dependencies)
     {
       # Hooks are installed on the -am targets.
       s/-am$// or next;
@@ -4784,7 +4784,7 @@
     }

   # All the required targets are phony.
-  depend ('.PHONY', keys %required_targets);
+  depend ('.PHONY', sort keys %required_targets);

   # Actually output gathered targets.
   foreach (sort target_cmp keys %dependencies)
@@ -5260,7 +5260,7 @@
   # has a precise meaning for AC_CONFIG_FILES and so on.
   $traces .= join (' ',
 		   map { "--trace=$_" . ':\$f:\$l::\$d::\$n::\${::}%' }
-		   (keys %traced));
+		   (sort keys %traced));

   verb "running WARNINGS=$ENV{WARNINGS} $traces";
   my $tracefh = new Automake::XFile ("$traces $filename |");
@@ -5831,7 +5831,7 @@
 {
   my ($self) = @_;

-  foreach my $prog (keys %known_programs)
+  foreach my $prog (sort keys %known_programs)
     {
       lang_vala_finish_target ($self, $prog);
     }