| 1 |
Author: Reiner Herrmann <[email protected]> |
| 2 |
Description: Honour SOURCE_DATE_EPOCH for embedded timestamp |
| 3 |
When the environment variable SOURCE_DATE_EPOCH is set, use it instead of the |
| 4 |
current time for the embedded build timestamp. |
| 5 |
. |
| 6 |
The specification of SOURCE_DATE_EPOCH is available here: |
| 7 |
https://reproducible-builds.org/specs/source-date-epoch/ |
| 8 |
. |
| 9 |
In the case it is not defined, fall back to current time in UTC. |
| 10 |
Forwarded: https://rt.cpan.org/Ticket/Display.html?id=115614 |
| 11 |
Bug: https://rt.cpan.org/Ticket/Display.html?id=115614 |
| 12 |
|
| 13 |
--- a/inc/Marpa/R2/Build_Me.pm |
| 14 |
+++ b/inc/Marpa/R2/Build_Me.pm |
| 15 |
@@ -83,7 +83,7 @@ |
| 16 |
|
| 17 |
##no critic(ValuesAndExpressions::RequireInterpolationOfMetachars) |
| 18 |
$text .= q{use vars qw($TIMESTAMP)} . qq{;\n}; |
| 19 |
- $text .= q{$TIMESTAMP='} . localtime()->datetime . qq{';\n}; |
| 20 |
+ $text .= q{$TIMESTAMP='} . (gmtime($ENV{SOURCE_DATE_EPOCH} || time()))->datetime . qq{';\n}; |
| 21 |
##use critic |
| 22 |
|
| 23 |
for my $package (@use_packages) { |
| 24 |
@@ -104,7 +104,7 @@ |
| 25 |
|
| 26 |
##no critic(ValuesAndExpressions::RequireInterpolationOfMetachars) |
| 27 |
$text .= q{use vars qw($TIMESTAMP)} . qq{;\n}; |
| 28 |
- $text .= q{$TIMESTAMP='} . localtime()->datetime . qq{';\n}; |
| 29 |
+ $text .= q{$TIMESTAMP='} . (gmtime($ENV{SOURCE_DATE_EPOCH} || time()))->datetime . qq{';\n}; |
| 30 |
##use critic |
| 31 |
|
| 32 |
for my $package (@use_packages) { |