summaryrefslogtreecommitdiff
path: root/gnu/packages/patches/docbook-utils-source-date-epoch.patch
blob: 15c025a72646d2a63ce943125ef99e938e7127fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Source: <https://sources.debian.org/patches/docbook-utils/0.6.14-4/support_source_date_epoch.patch/>

Author: Reiner Herrmann <reiner@reiner-h.de>
Description: Support SOURCE_DATE_EPOCH for timestamps
 To allow generating documents in a reproducible way,
 allow overriding the timestamp through the environment.
 .
 See also: https://reproducible-builds.org/specs/source-date-epoch/
Bug-Debian: https://bugs.debian.org/800797

--- a/helpers/docbook2man-spec.pl
+++ b/helpers/docbook2man-spec.pl
@@ -57,6 +57,7 @@
 use SGMLS;			# Use the SGMLS package.
 use SGMLS::Output;		# Use stack-based output.
 use SGMLS::Refs;
+use POSIX qw(strftime setlocale LC_TIME);
 
 ########################################################################
 # SGMLSPL script produced automatically by the script sgmlspl.pl
@@ -279,6 +280,10 @@
 _END_BANNER
 
 	my $date = `date "+%d %B %Y"`;
+	if ($ENV{SOURCE_DATE_EPOCH}) {
+		setlocale(LC_TIME, "C");
+		$date = strftime("%d %B %Y", gmtime($ENV{SOURCE_DATE_EPOCH} || time));
+	}
 	my $manpage_date = $manpage_date || $date ;
 
 	output '.TH "';