On Sun, Jun 26, 2016 at 05:58:37PM +0200, Reiner Herrmann wrote:
> The attached patch makes it honour SOURCE_DATE_EPOCH, if it is
> available, to get a deterministic timestamp.

The patch has an issue when SOURCE_DATE_EPOCH is not defined.
An updated patch is attached which handles this case correctly.
Thanks to intrigeri for spotting it, and sorry for the noise!
diff --git a/debian/patches/reproducible_build.patch b/debian/patches/reproducible_build.patch
new file mode 100644
index 0000000..62b76f4
--- /dev/null
+++ b/debian/patches/reproducible_build.patch
@@ -0,0 +1,30 @@
+Author: Reiner Herrmann <rei...@reiner-h.de>
+Description: Honour SOURCE_DATE_EPOCH for embedded timestamp
+ When the environment variable SOURCE_DATE_EPOCH is set, use it instead of the
+ current time for the embedded build timestamp.
+ .
+ The specification of SOURCE_DATE_EPOCH is available here:
+ https://reproducible-builds.org/specs/source-date-epoch/
+ .
+ In the case it is not defined, fall back to current time in UTC.
+
+--- a/inc/Marpa/R2/Build_Me.pm
++++ b/inc/Marpa/R2/Build_Me.pm
+@@ -83,7 +83,7 @@
+ 
+ ##no critic(ValuesAndExpressions::RequireInterpolationOfMetachars)
+     $text .= q{use vars qw($TIMESTAMP)} . qq{;\n};
+-    $text .= q{$TIMESTAMP='} . localtime()->datetime . qq{';\n};
++    $text .= q{$TIMESTAMP='} . (gmtime($ENV{SOURCE_DATE_EPOCH} || time()))->datetime . qq{';\n};
+ ##use critic
+ 
+     for my $package (@use_packages) {
+@@ -104,7 +104,7 @@
+ 
+ ##no critic(ValuesAndExpressions::RequireInterpolationOfMetachars)
+     $text .= q{use vars qw($TIMESTAMP)} . qq{;\n};
+-    $text .= q{$TIMESTAMP='} . localtime()->datetime . qq{';\n};
++    $text .= q{$TIMESTAMP='} . (gmtime($ENV{SOURCE_DATE_EPOCH} || time()))->datetime . qq{';\n};
+ ##use critic
+ 
+     for my $package (@use_packages) {
diff --git a/debian/patches/series b/debian/patches/series
index f8d2256..b4a3780 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 1001_xs_boot_workaround.patch
 2001_libmarpa_external_linkage.patch
+reproducible_build.patch

Attachment: signature.asc
Description: Digital signature

Reply via email to