diff options
Diffstat (limited to 'meta/recipes-devtools/perl/perl/debian/fixes/pod_man_reproducible_date.diff')
-rw-r--r-- | meta/recipes-devtools/perl/perl/debian/fixes/pod_man_reproducible_date.diff | 171 |
1 files changed, 0 insertions, 171 deletions
diff --git a/meta/recipes-devtools/perl/perl/debian/fixes/pod_man_reproducible_date.diff b/meta/recipes-devtools/perl/perl/debian/fixes/pod_man_reproducible_date.diff deleted file mode 100644 index d23573f188..0000000000 --- a/meta/recipes-devtools/perl/perl/debian/fixes/pod_man_reproducible_date.diff +++ /dev/null | |||
@@ -1,171 +0,0 @@ | |||
1 | From 9057adc106d6bbef53c9e706523cd94f1a7a08d4 Mon Sep 17 00:00:00 2001 | ||
2 | From: Russ Allbery <rra@debian.org> | ||
3 | Date: Sat, 30 Aug 2014 15:10:41 -0700 | ||
4 | Subject: Support POD_MAN_DATE in Pod::Man for the left-hand footer | ||
5 | |||
6 | Honor the environment variable POD_MAN_DATE and use its contents, if | ||
7 | set, as the value of the left-hand footer if the date option is not | ||
8 | set, overriding the timestamp of the input file. This is primarily | ||
9 | useful to ensure reproducible builds of the same output file given the | ||
10 | same souce and Pod::Man version, even when file timestamps may not be | ||
11 | consistent. Thanks, Niko Tyni. | ||
12 | |||
13 | Bug-Debian: http://bugs.debian.org/759405 | ||
14 | Origin: upstream | ||
15 | Patch-Name: fixes/pod_man_reproducible_date.diff | ||
16 | Upstream-Status: Pending | ||
17 | --- | ||
18 | cpan/podlators/lib/Pod/Man.pm | 69 +++++++++++++++++++++++++++++++----------- | ||
19 | cpan/podlators/t/devise-date.t | 29 +++++++++++++----- | ||
20 | 2 files changed, 72 insertions(+), 26 deletions(-) | ||
21 | |||
22 | diff --git a/cpan/podlators/lib/Pod/Man.pm b/cpan/podlators/lib/Pod/Man.pm | ||
23 | index 72ca9ff..0536662 100644 | ||
24 | --- a/cpan/podlators/lib/Pod/Man.pm | ||
25 | +++ b/cpan/podlators/lib/Pod/Man.pm | ||
26 | @@ -876,25 +876,42 @@ sub devise_title { | ||
27 | } | ||
28 | |||
29 | # Determine the modification date and return that, properly formatted in ISO | ||
30 | -# format. If we can't get the modification date of the input, instead use the | ||
31 | -# current time. Pod::Simple returns a completely unuseful stringified file | ||
32 | -# handle as the source_filename for input from a file handle, so we have to | ||
33 | -# deal with that as well. | ||
34 | +# format. | ||
35 | +# | ||
36 | +# If POD_MAN_DATE is set, that overrides anything else. This can be used for | ||
37 | +# reproducible generation of the same file even if the input file timestamps | ||
38 | +# are unpredictable or the POD coms from standard input. | ||
39 | +# | ||
40 | +# Otherwise, use the modification date of the input if we can stat it. Be | ||
41 | +# aware that Pod::Simple returns the stringification of the file handle as | ||
42 | +# source_filename for input from a file handle, so we'll stat some random ref | ||
43 | +# string in that case. If that fails, instead use the current time. | ||
44 | +# | ||
45 | +# $self - Pod::Man object, used to get the source file | ||
46 | +# | ||
47 | +# Returns: YYYY-MM-DD date suitable for the left-hand footer | ||
48 | sub devise_date { | ||
49 | my ($self) = @_; | ||
50 | + | ||
51 | + # If POD_MAN_DATE is set, always use it. | ||
52 | + if ($ENV{POD_MAN_DATE}) { | ||
53 | + return $ENV{POD_MAN_DATE}; | ||
54 | + } | ||
55 | + | ||
56 | + # Otherwise, get the input filename and try to stat it. If that fails, | ||
57 | + # use the current time. | ||
58 | my $input = $self->source_filename; | ||
59 | my $time; | ||
60 | if ($input) { | ||
61 | - $time = (stat $input)[9] || time; | ||
62 | + $time = (stat($input))[9] || time(); | ||
63 | } else { | ||
64 | - $time = time; | ||
65 | + $time = time(); | ||
66 | } | ||
67 | |||
68 | - # Can't use POSIX::strftime(), which uses Fcntl, because MakeMaker | ||
69 | - # uses this and it has to work in the core which can't load dynamic | ||
70 | - # libraries. | ||
71 | - my ($year, $month, $day) = (localtime $time)[5,4,3]; | ||
72 | - return sprintf ("%04d-%02d-%02d", $year + 1900, $month + 1, $day); | ||
73 | + # Can't use POSIX::strftime(), which uses Fcntl, because MakeMaker uses | ||
74 | + # this and it has to work in the core which can't load dynamic libraries. | ||
75 | + my ($year, $month, $day) = (localtime($time))[5,4,3]; | ||
76 | + return sprintf("%04d-%02d-%02d", $year + 1900, $month + 1, $day); | ||
77 | } | ||
78 | |||
79 | # Print out the preamble and the title. The meaning of the arguments to .TH | ||
80 | @@ -1632,6 +1649,15 @@ argument. | ||
81 | Sets the centered page header to use instead of "User Contributed Perl | ||
82 | Documentation". | ||
83 | |||
84 | +=item date | ||
85 | + | ||
86 | +Sets the left-hand footer. If this option is not set, the contents of the | ||
87 | +environment variable POD_MAN_DATE, if set, will be used. Failing that, | ||
88 | +the modification date of the input file will be used, or the current time | ||
89 | +if stat() can't find that file (which will be the case if the input is | ||
90 | +from C<STDIN>). If obtained from the file modification date or the | ||
91 | +current time, he date will be formatted as C<YYYY-MM-DD>. | ||
92 | + | ||
93 | =item errors | ||
94 | |||
95 | How to report errors. C<die> says to throw an exception on any POD | ||
96 | @@ -1642,13 +1668,6 @@ POD errors entirely, as much as possible. | ||
97 | |||
98 | The default is C<pod>. | ||
99 | |||
100 | -=item date | ||
101 | - | ||
102 | -Sets the left-hand footer. By default, the modification date of the input | ||
103 | -file will be used, or the current date if stat() can't find that file (the | ||
104 | -case if the input is from C<STDIN>), and the date will be formatted as | ||
105 | -C<YYYY-MM-DD>. | ||
106 | - | ||
107 | =item fixed | ||
108 | |||
109 | The fixed-width font to use for verbatim text and code. Defaults to | ||
110 | @@ -1810,6 +1829,20 @@ option was set to C<die>. | ||
111 | |||
112 | =back | ||
113 | |||
114 | +=head1 ENVIRONMENT | ||
115 | + | ||
116 | +=over 4 | ||
117 | + | ||
118 | +=item POD_MAN_DATE | ||
119 | + | ||
120 | +If set, this will be used as the value of the left-hand footer unless the | ||
121 | +C<date> option is explicitly set, overriding the timestamp of the input | ||
122 | +file or the current time. This is primarily useful to ensure reproducible | ||
123 | +builds of the same output file given the same souce and Pod::Man version, | ||
124 | +even when file timestamps may not be consistent. | ||
125 | + | ||
126 | +=back | ||
127 | + | ||
128 | =head1 BUGS | ||
129 | |||
130 | Encoding handling assumes that PerlIO is available and does not work | ||
131 | diff --git a/cpan/podlators/t/devise-date.t b/cpan/podlators/t/devise-date.t | ||
132 | index 3cce9f5..c610dd9 100644 | ||
133 | --- a/cpan/podlators/t/devise-date.t | ||
134 | +++ b/cpan/podlators/t/devise-date.t | ||
135 | @@ -1,15 +1,28 @@ | ||
136 | -#!/usr/bin/perl -w | ||
137 | - | ||
138 | -# In order for MakeMaker to build in the core, nothing can use | ||
139 | -# Fcntl which includes POSIX. devise_date()'s use of strftime() | ||
140 | -# was replaced. This tests that it's identical. | ||
141 | +#!/usr/bin/perl | ||
142 | +# | ||
143 | +# In order for MakeMaker to build in the core, nothing can use Fcntl which | ||
144 | +# includes POSIX. devise_date()'s use of strftime() was replaced. This tests | ||
145 | +# that it's identical. It also tests special handling of the POD_MAN_DATE | ||
146 | +# environment variable. | ||
147 | |||
148 | +use 5.006; | ||
149 | use strict; | ||
150 | - | ||
151 | -use Test::More tests => 1; | ||
152 | +use warnings; | ||
153 | |||
154 | use Pod::Man; | ||
155 | use POSIX qw(strftime); | ||
156 | |||
157 | +use Test::More tests => 2; | ||
158 | + | ||
159 | +# Check that the results of device_date matches strftime. There is no input | ||
160 | +# file name, so this will use the current time. | ||
161 | my $parser = Pod::Man->new; | ||
162 | -is $parser->devise_date, strftime("%Y-%m-%d", localtime); | ||
163 | +is( | ||
164 | + $parser->devise_date, | ||
165 | + strftime('%Y-%m-%d', localtime()), | ||
166 | + 'devise_date matches strftime' | ||
167 | +); | ||
168 | + | ||
169 | +# Set the override environment variable and ensure that it's honored. | ||
170 | +local $ENV{POD_MAN_DATE} = '2014-01-01'; | ||
171 | +is($parser->devise_date, '2014-01-01', 'devise_date honors POD_MAN_DATE'); | ||