[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#783475: texi2html: [PATCH] Allow make the build of documentation reproducible adding the use-date flag.



Hi,

On Sun, 17 May 2015 20:25:31 -0300 Juan Picca <jumapico@gmail.com> wrote:
> Modified patch after comments and advices of Jérémy Bobbio.
> The option was renamed to --build-date and now expects an unix time
> integer which is formatted using pretty_time instead of using a given
> string to show as timestamp.

I have done two modifications to your patch:

 - Instead of letting the default for --build-date be undef (resulting
in the date of today being printed) the default is now the values of the
environment variable $SOURCE_DATE_EPOCH.

 - Explicitly check if variable is undef or otherwise SOURCE_DATE_EPOCH
can never be set to 0 as this would then evaluate as false

Kind regards,
akira
diff -u texi2html-1.82+dfsg1/debian/changelog texi2html-1.82+dfsg1/debian/changelog
--- texi2html-1.82+dfsg1/debian/changelog
+++ texi2html-1.82+dfsg1/debian/changelog
@@ -1,3 +1,10 @@
+texi2html (1.82+dfsg1-3.0~reproducible1) UNRELEASED; urgency=medium
+
+  * Add patch to honour $SOURCE_DATE_EPOCH and command line option
+    --build-date
+
+ -- akira <marivalenm@gmail.com>  Fri, 07 Aug 2015 18:07:18 +0200
+
 texi2html (1.82+dfsg1-3) unstable; urgency=low
 
   * QA upload.
diff -u texi2html-1.82+dfsg1/debian/patches/series texi2html-1.82+dfsg1/debian/patches/series
--- texi2html-1.82+dfsg1/debian/patches/series
+++ texi2html-1.82+dfsg1/debian/patches/series
@@ -2,0 +3 @@
+03_add_build-date_param.patch
only in patch2:
unchanged:
--- texi2html-1.82+dfsg1.orig/debian/patches/03_add_build-date_param.patch
+++ texi2html-1.82+dfsg1/debian/patches/03_add_build-date_param.patch
@@ -0,0 +1,83 @@
+Description: Add --build-date command line flag.
+ Allow create reproducible documentation passing a unix time in the command
+ line.
+Author: Juan Picca <jumapico@gmail.com>
+Last-Update: 2015-05-16
+--- a/T2h_i18n.pm
++++ b/T2h_i18n.pm
+@@ -295,7 +295,14 @@ sub pretty_date($)
+     my $lang = shift;
+     my($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);
+ 
+-    ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
++    if (defined $Texi2HTML::Config::BUILD_DATE)
++    {
++        ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime($Texi2HTML::Config::BUILD_DATE);
++    }
++    else
++    {
++        ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
++    }
+     $year += ($year < 70) ? 2000 : 1900;
+     # obachman: Let's do it as the Americans do
+     #return($MONTH_NAMES->{$lang}[$mon] . ", " . $mday . " " . $year);
+--- a/texi2html.init
++++ b/texi2html.init
+@@ -260,6 +260,10 @@ $MONOLITHIC = 1;
+ # the specified url are used as stylesheet links
+ @CSS_REFS = ();
+ 
++# -build-date
++# Use the given unix time as build date showing UTC timezone when it is used
++$BUILD_DATE = $ENV{'SOURCE_DATE_EPOCH'};
++
+ ######################
+ # The following options are only relevant if $L2H is set
+ #
+--- a/texi2html.pl
++++ b/texi2html.pl
+@@ -261,6 +261,7 @@ $EXTERNAL_DIR
+ $IGNORE_PREAMBLE_TEXT
+ @CSS_FILES
+ @CSS_REFS
++$BUILD_DATE
+ $INLINE_CONTENTS
+ $INLINE_INSERTCOPYING
+ );
+@@ -2600,6 +2601,13 @@ $T2H_OPTIONS -> {'css-ref'} =
+  verbose => 'generate reference to the CSS URL $s'
+ };
+ 
++$T2H_OPTIONS -> {'build-date'} =
++{
++ type => '=i',
++ linkage => \$Texi2HTML::Config::BUILD_DATE,
++ verbose => 'use the given unix time as build date showing UTC timezone when it is used'
++};
++
+ $T2H_OPTIONS -> {'transliterate-file-names'} =
+ {
+  type => '!',
+--- a/doc/texi2html.texi
++++ b/doc/texi2html.texi
+@@ -523,6 +523,8 @@ Display a short help and exit.
+ Be verbose.
+ @item @longopt{version}
+ Display version information and exit.
++@item @longopt{build-date=@var{unixtime}}
++Use the given unix time as build date showing UTC timezone when it is used.
+ @end table
+ 
+ @c --------------------------------------------------------
+--- a/doc/texi2html.info
++++ b/doc/texi2html.info
+@@ -435,6 +435,9 @@ Miscellaneous general options:
+ `--version'
+      Display version information and exit.
+ 
++`--build-date=UNIXTIME'
++     Use the given unix time as build date showing UTC timezone when it is used.
++
+ 
+ File: texi2html.info,  Node: Splitting output,  Next: Output files,  Prev: General options,  Up: Invoking texi2html
+ 

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: