Source: sheepdog
Version: 0.8.3-3
Severity: wishlist
Tags: patch
User: reproducible-builds@lists.alioth.debian.org
Usertags: randomness

Hi!

While working on the “reproducible builds” effort [1], we have noticed
that sheepdog could not be built reproducibly.

At build time a bash_completion file is generated with a perl script
that iterates over keys of a hash. This operation is not deterministic,
which results in a different file on each build.
The attached patch is sorting the keys to have a stable order and get
the same output.
Once applied, sheepdog can be built reproducibly in our current
experimental framework.

Regards,
 Reiner

 [1]: https://wiki.debian.org/ReproducibleBuilds


diff --git a/debian/changelog b/debian/changelog
index 05fa9e8..614f77a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+sheepdog (0.8.3-3.0~reproducible1) UNRELEASED; urgency=low
+
+  * Added patch for the script that generates the bash_completion
+    file to produce stable output in order to make builds reproducible.
+
+ -- Reiner Herrmann <rei...@reiner-h.de>  Mon, 12 Jan 2015 20:18:31 +0100
+
 sheepdog (0.8.3-3) unstable; urgency=medium
 
   * Initial Dutch translation of debconf messages thanks to Frans
diff --git a/debian/patches/series b/debian/patches/series
index 0d958b5..5273a01 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 define_EFD_SEMAPHORE_ifnone.diff
 subdir-objects.diff
+sorted_bash_completion.diff
diff --git a/debian/patches/sorted_bash_completion.diff b/debian/patches/sorted_bash_completion.diff
new file mode 100644
index 0000000..f661f0d
--- /dev/null
+++ b/debian/patches/sorted_bash_completion.diff
@@ -0,0 +1,37 @@
+Author: Reiner Herrmann <rei...@reiner-h.de>
+Description: sort keys to produce stable output
+ To make the build reproducible, the script has to
+ produce the same file every time. As the order of
+ 'keys' is not deterministic, they have to be sorted.
+
+Index: sheepdog-0.8.3/script/gen_bash_completion.pl
+===================================================================
+--- sheepdog-0.8.3.orig/script/gen_bash_completion.pl
++++ sheepdog-0.8.3/script/gen_bash_completion.pl
+@@ -52,7 +52,7 @@ foreach (@help) {
+     }
+ }
+ 
+-foreach my $cmd (keys %subcmds) {
++foreach my $cmd (sort keys %subcmds) {
+     my @subcmds = @{$subcmds{$cmd}};
+ 
+     print command($cmd, @subcmds);
+@@ -66,7 +66,7 @@ print <<__EOB__;
+ _dog()
+ {
+     local opts cur cmd subcmd
+-    opts="@{[keys %subcmds]}"
++    opts="@{[sort keys %subcmds]}"
+     cur="\${COMP_WORDS[COMP_CWORD]}"
+ 
+     if [ \$COMP_CWORD -gt 1 ]; then
+@@ -80,7 +80,7 @@ _dog()
+     case "\${cmd}" in
+ __EOB__
+ 
+-    foreach my $cmd (keys %subcmds) {
++    foreach my $cmd (sort keys %subcmds) {
+ 	print <<__EOB__;
+         $cmd)
+             _dog_$cmd \${subcmd}

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Reproducible-builds mailing list
Reproducible-builds@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds

Reply via email to