File 0001-Sort-output-of-dumped-dictionaries-for-reproducible-.patch of Package perl-Wx

From cfb24d6c3de259ad46fdc96099419fed22636c28 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Tue, 21 Feb 2017 06:37:03 +0100
Subject: [PATCH 1/2] Sort output of dumped dictionaries for reproducible
 builds
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

By default, dictionaries are dumped in hash order, with a random hash
initialization value.
Also sort export list and make entries unique, exports may be declared
in multiple files.

Signed-off-by: Stefan BrĂ¼ns <stefan.bruens@rwth-aachen.de>
---
 build/Wx/build/MakeMaker/Any_OS.pm |  2 ++
 build/Wx/build/Options.pm          |  2 ++
 script/fix_alien_path.pl           |  2 ++
 script/make_exp_list.pl            | 13 ++++++++++---
 4 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/build/Wx/build/MakeMaker/Any_OS.pm b/build/Wx/build/MakeMaker/Any_OS.pm
index 55d3b7b..5dd2a2f 100644
--- a/build/Wx/build/MakeMaker/Any_OS.pm
+++ b/build/Wx/build/MakeMaker/Any_OS.pm
@@ -200,6 +200,8 @@ sub postamble_core {
   # strictly necessary, but it's better to keep them in case the
   # dependencies here are changed
   require Data::Dumper;
+  # sort output for reproducible builds
+  $Data::Dumper::Sortkeys = 1;
   Wx::build::Utils::write_string( 'files.lst',
                                   Data::Dumper->Dump( [ \%files ] ) );
   # $exp and fix_alien depend on wxt_copy_files to ensure that blib/lib/Wx
diff --git a/build/Wx/build/Options.pm b/build/Wx/build/Options.pm
index 578bec5..a0fb8da 100644
--- a/build/Wx/build/Options.pm
+++ b/build/Wx/build/Options.pm
@@ -163,6 +163,8 @@ sub write_config_file {
   my $file = shift;
 
   require Data::Dumper;
+  # sort output for reproducible builds
+  $Data::Dumper::Sortkeys = 1;
   my $str = Data::Dumper->Dump( [ { extra_libs   => $extra_libs,
                                     extra_cflags => $extra_cflags,
                                     alien_key    => $alien_key,
diff --git a/script/fix_alien_path.pl b/script/fix_alien_path.pl
index 99aca90..83266a7 100644
--- a/script/fix_alien_path.pl
+++ b/script/fix_alien_path.pl
@@ -30,6 +30,8 @@ my $key = Alien::wxWidgets->key;
 my $version = Alien::wxWidgets->version;
 my @libs = Alien::wxWidgets->library_keys;
 my %libs; @libs{@libs} = Alien::wxWidgets->shared_libraries( @libs );
+# sort output for reproducible builds
+$Data::Dumper::Sortkeys = 1;
 my $libs = Data::Dumper::Dumper( \%libs );
 
 my $keyd;
diff --git a/script/make_exp_list.pl b/script/make_exp_list.pl
index 211a484..9b32dbd 100644
--- a/script/make_exp_list.pl
+++ b/script/make_exp_list.pl
@@ -22,6 +22,11 @@ my %packages;
 my $tag;
 my $package;
 
+sub unique_sorted {
+  my %v = %{ { map { ($_ => 1) } @{$_[0]} } };
+  sort keys %v;
+}
+
 sub add_to_exports {
   my( $values, $tags ) = @_;
 
@@ -91,11 +96,12 @@ package Wx::Wx_Exp; # for RPM
 EOT
 
 foreach my $package ( sort keys %packages ) {
-print OUT <<EOT;
+  my @exp = unique_sorted( $packages{$package}{exp_ok} );
+  print OUT <<EOT;
 
 package ${package};
 
-push \@EXPORT_OK, qw(@{$packages{$package}{exp_ok}});
+push \@EXPORT_OK, qw(@exp);
 
 \$EXPORT_TAGS{'everything'} = \\\@EXPORT_OK;
 
@@ -103,8 +109,9 @@ EOT
 
   foreach my $tag ( sort keys %{ $packages{$package}{tags} } ) {
     next unless length $tag;
+    my @pkgtags = unique_sorted( $packages{$package}{tags}{$tag} );
     print OUT <<EOT;
-\$EXPORT_TAGS{'$tag'} = [ qw(@{ $packages{$package}{tags}{$tag} }) ];
+\$EXPORT_TAGS{'$tag'} = [ qw(@pkgtags) ];
 EOT
   }
 }
-- 
2.11.1