Skip to content

Commit 180286b

Browse files
bjornforoberpar
authored andcommitted
genhtml: honor the SOURCE_DATE_EPOCH variable
Implement the SOURCE_DATE_EPOCH specification[1] for reproducible builds. If SOURCE_DATE_EPOCH is set, use it as timestamp instead of the current time. In this context, reproducible builds means reproducible HTML coverage reports. Known bug: the specification[1] says to defer converting the timestamp to local timezone at presentation time. This is currently not happening; it's converted at build time. [1] https://reproducible-builds.org/specs/source-date-epoch/ Signed-off-by: Bjørn Forsman <[email protected]>
1 parent 41e07ca commit 180286b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

bin/genhtml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2625,9 +2625,18 @@ sub get_date_string()
26252625
my $hour;
26262626
my $min;
26272627
my $sec;
2628+
my @timeresult;
26282629

2630+
if (defined $ENV{'SOURCE_DATE_EPOCH'})
2631+
{
2632+
@timeresult = localtime($ENV{'SOURCE_DATE_EPOCH'});
2633+
}
2634+
else
2635+
{
2636+
@timeresult = localtime();
2637+
}
26292638
($year, $month, $day, $hour, $min, $sec) =
2630-
(localtime())[5, 4, 3, 2, 1, 0];
2639+
@timeresult[5, 4, 3, 2, 1, 0];
26312640

26322641
return sprintf("%d-%02d-%02d %02d:%02d:%02d", $year+1900, $month+1,
26332642
$day, $hour, $min, $sec);

0 commit comments

Comments
 (0)