summaryrefslogtreecommitdiff
path: root/help2man.PL
diff options
context:
space:
mode:
authorBrendan O'Dea <bod@debian.org>2015-06-15 23:14:05 +1000
committerBrendan O'Dea <bod@debian.org>2015-06-15 23:53:06 +1000
commit8448110e8b7567147b70ff54ddf771306a56d39d (patch)
tree82b032805f46dc86c25d9479a1aae8b6556e2426 /help2man.PL
parent610266e8eb71b4df4d70df7d6d9a0df030461e35 (diff)
downloadhelp2man-8448110e8b7567147b70ff54ddf771306a56d39d.tar.gz
Add support for reproducible builds: $SOURCE_DATE_EPOCH
Diffstat (limited to 'help2man.PL')
-rwxr-xr-xhelp2man.PL14
1 files changed, 13 insertions, 1 deletions
diff --git a/help2man.PL b/help2man.PL
index 664cc47..96146eb 100755
--- a/help2man.PL
+++ b/help2man.PL
@@ -366,11 +366,23 @@ for my $hash (\(%include, %replace, %append, %append_match))
my $help_text = get_option_value $ARGV[0], $help_option;
$version_text ||= get_option_value $ARGV[0], $version_option;
+# By default the generated manual pages will include the current date. This may
+# however be overriden by setting the environment variable $SOURCE_DATE_EPOCH
+# to an integer value of the seconds since the UNIX epoch. This is primarily
+# intended to support reproducible builds (wiki.debian.org/ReproducibleBuilds)
+# and will additionally ensure that the output date string is UTC.
+my $epoch_secs = time;
+if (exists $ENV{SOURCE_DATE_EPOCH} and $ENV{SOURCE_DATE_EPOCH} =~ /^(\d+)$/)
+{
+ $epoch_secs = $1;
+ $ENV{TZ} = 'UTC';
+}
+
# Translators: the following message is a strftime(3) format string, which in
# the English version expands to the month as a word and the full year. It
# is used on the footer of the generated manual pages. If in doubt, you may
# just use %x as the value (which should be the full locale-specific date).
-my $date = enc strftime _("%B %Y"), localtime;
+my $date = enc strftime _("%B %Y"), localtime $epoch_secs;
my $program = program_basename $ARGV[0];
my $package = $program;
my $version;