Package: perl
Version: 5.22.0-4
Severity: wishlist
Tags: upstream patch
Usertags: timestamps
X-Debbugs-Cc: Russ Allbery <>,

(cc'ing Russ as the podlators upstream author)

Since 5.20.1~rc1-1, Pod::Man has supported the POD_MAN_DATE environment
variable for overriding the page footers, fixing #759405. Since then,
the reproducible builds project has converged on the SOURCE_DATE_EPOCH
specification, which "defines a distribution-agnostic standard for
upstream build processes to consume this timestamp from packaging

It would be good to have Pod::Man support the SOURCE_DATE_EPOCH
environment variable, either instead of or in addition to POD_MAN_DATE,
which is specific to the podlators modules. This would give distributions
aiming for reproducible builds automatic benefits from standardizing on
SOURCE_DATE_EPOCH, without having to add a special case for Pod::Man.

In the context of Debian, while it's possible to set POD_MAN_DATE
externally based on SOURCE_DATE_EPOCH, it's not clear which layer
should do this. Options include dpkg-buildpackage, where special casing
POD_MAN_DATE looks particularly wrong, and debhelper, where this should
probably go in the v9 based dh_auto_* build systems, perhaps only the
Perl ones (perl_build and perl_makemaker). In particular, packages using
old style debhelper debian/rules do not have a place where POD_MAN_DATE
could be injected centrally in debhelper, which would leave out many
packages that would otherwise profit from this.

The attached patch against the current podlators upstream git
repository implements support for SOURCE_DATE_EPOCH in addition to
POD_MAN_DATE. Russ, please let me know what you think. I see POD_MAN_DATE
support hasn't been released upstream yet, so I suppose even backing
that out altogether would still be a valid option if you want to avoid
duplicating the functionality.
Niko Tyni
>From a85d0944a90867cd5f2da58b59d31bd7accf80ed Mon Sep 17 00:00:00 2001
From: Niko Tyni <>
Date: Mon, 12 Oct 2015 17:39:33 +0300
Subject: [PATCH] Make Pod::Man honor the SOURCE_DATE_EPOCH environment

See for
the SOURCE_DATE_EPOCH specification.
 lib/Pod/      | 24 ++++++++++++++++++------
 t/man/devise-date.t | 21 ++++++++++++++++++++-
 2 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/lib/Pod/ b/lib/Pod/
index 56a067e..2096cbc 100644
--- a/lib/Pod/
+++ b/lib/Pod/
@@ -894,6 +894,10 @@ sub devise_title {
 # reproducible generation of the same file even if the input file timestamps
 # are unpredictable or the POD coms from standard input.
+# Otherwise, if SOURCE_DATE_EPOCH is set and can be parsed as seconds
+# since the UNIX epoch, base the timestamp on that.
+# See <>
 # Otherwise, use the modification date of the input if we can stat it.  Be
 # aware that Pod::Simple returns the stringification of the file handle as
 # source_filename for input from a file handle, so we'll stat some random ref
@@ -910,14 +914,22 @@ sub devise_date {
         return $ENV{POD_MAN_DATE};
+    # If SOURCE_DATE_EPOCH is set and can be parsed, use that.
+    my $time;
+    if (defined($ENV{SOURCE_DATE_EPOCH}) &&
+        $ENV{SOURCE_DATE_EPOCH} !~ /\D/) {
+        $time = $ENV{SOURCE_DATE_EPOCH};
+    }
     # Otherwise, get the input filename and try to stat it.  If that fails,
     # use the current time.
-    my $input = $self->source_filename;
-    my $time;
-    if ($input) {
-        $time = (stat($input))[9] || time();
-    } else {
-        $time = time();
+    if (!defined $time) {
+        my $input = $self->source_filename;
+        if ($input) {
+            $time = (stat($input))[9] || time();
+        } else {
+            $time = time();
+        }
     # Can't use POSIX::strftime(), which uses Fcntl, because MakeMaker uses
diff --git a/t/man/devise-date.t b/t/man/devise-date.t
index 27271d9..5fb08e2 100755
--- a/t/man/devise-date.t
+++ b/t/man/devise-date.t
@@ -12,7 +12,7 @@ use warnings;
 use Pod::Man;
 use POSIX qw(strftime);
-use Test::More tests => 3;
+use Test::More tests => 6;
 # Check that the results of device_date matches strftime.  There is no input
 # file name, so this will use the current time.
@@ -30,3 +30,22 @@ is($parser->devise_date, '2014-01-01', 'devise_date honors POD_MAN_DATE');
 # Check that an empty environment variable is honored.
 local $ENV{POD_MAN_DATE} = q{};
 is($parser->devise_date, q{}, 'devise_date honors empty POD_MAN_DATE');
+# Set another environment variable and ensure that it's honored.
+local $ENV{POD_MAN_DATE};
+local $ENV{SOURCE_DATE_EPOCH} = 1439390140;
+is($parser->devise_date, '2015-08-12', 'devise_date honors SOURCE_DATE_EPOCH');
+# Check that POD_MAN_DATE overrides SOURCE_DATE_EPOCH
+local $ENV{POD_MAN_DATE} = '2013-01-01';
+local $ENV{SOURCE_DATE_EPOCH} = 1482676620;
+is($parser->devise_date, '2013-01-01', 'devise_date honors POD_MAN_DATE over SOURCE_DATE_EPOCH');
+# Check that an invalid SOURCE_DATE_EPOCH is not accepted
+local $ENV{POD_MAN_DATE};
+local $ENV{SOURCE_DATE_EPOCH} = '1482676620B';
+    $parser->devise_date,
+    strftime('%Y-%m-%d', gmtime()),
+    'devise_date ignores invalid SOURCE_DATE_EPOCH'

Reproducible-builds mailing list

Reply via email to