Source: epydoc
Version: 3.0.1+dfsg-7
Severity: wishlist
Tags: patch
User: reproducible-bui...@lists.alioth.debian.org
Usertags: toolchain timestamps
X-Debbugs-Cc: reproducible-bui...@lists.alioth.debian.org

Hi!

In 3.0.1+dfsg-6 a patch has been added that allows packages to disable 
embedding of timestamps.
But the default behavior of epydoc is to still embed timestamps (which requires 
modifications
for each package using epydoc).
If timestamps have to be kept, we have a proposal for using deterministic ones 
[1] (based on
the latest debian/changelog entry), which is contained in the environment 
variable
SOURCE_DATE_EPOCH (which will hopefully soon be exported by debhelper).

The attached patch proposes a way to use this variable to get reproducible 
timestamps, if the
variable has been set (if not, it falls back to the old behavior).

Regards,
 Reiner

[1]: https://wiki.debian.org/ReproducibleBuilds/TimestampsProposal

diff --git a/debian/patches/honour_source_date_epoch.patch b/debian/patches/honour_source_date_epoch.patch
new file mode 100644
index 0000000..31118f0
--- /dev/null
+++ b/debian/patches/honour_source_date_epoch.patch
@@ -0,0 +1,72 @@
+Author: Reiner Herrmann <rei...@reiner-h.de>
+Description: Honour SOURCE_DATE_EPOCH if available
+ Using the current date for timestamps will produce unreproducible
+ manpages. If the environment variable SOURCE_DATE_EPOCH is set,
+ as proposed by the Reproducible Builds effort [1], a deterministic
+ timestamp is avilable that can be used to embed dates.
+ .
+ [1]: https://wiki.debian.org/ReproducibleBuilds/TimestampsProposal
+
+Index: epydoc-3.0.1+dfsg/epydoc/docwriter/html.py
+===================================================================
+--- epydoc-3.0.1+dfsg.orig/epydoc/docwriter/html.py
++++ epydoc-3.0.1+dfsg/epydoc/docwriter/html.py
+@@ -433,6 +433,14 @@ class HTMLWriter:
+                                       and d.container == doc]
+         self.indexed_docs.sort()
+ 
++        # set build time
++        self._build_time = time.gmtime()
++        if os.environ.has_key('SOURCE_DATE_EPOCH'):
++            try:
++                self._build_time = time.gmtime(int(os.environ['SOURCE_DATE_EPOCH']))
++            except ValueError:
++                pass
++
+         # Figure out the url for the top page.
+         self._top_page_url = self._find_top_page(self._top_page)
+ 
+@@ -1780,7 +1788,7 @@ class HTMLWriter:
+         >>>   #endif
+             Generated by Epydoc $epydoc.__version__$
+         >>>     if self._include_build_time:
+-            on $time.asctime()$
++            on $time.asctime(self._build_time)$
+         >>>     #endif
+         >>>   if self._include_log:
+             </a>
+Index: epydoc-3.0.1+dfsg/epydoc/docwriter/latex.py
+===================================================================
+--- epydoc-3.0.1+dfsg.orig/epydoc/docwriter/latex.py
++++ epydoc-3.0.1+dfsg/epydoc/docwriter/latex.py
+@@ -14,7 +14,7 @@ this module is the L{LatexWriter} class.
+ """
+ __docformat__ = 'epytext en'
+ 
+-import os.path, sys, time, re, textwrap, codecs
++import os.path, os, sys, time, re, textwrap, codecs
+ 
+ from epydoc.apidoc import *
+ from epydoc.compat import *
+@@ -1099,6 +1099,12 @@ class LatexWriter:
+     #////////////////////////////////////////////////////////////
+ 
+     def write_header(self, out, where):
++        build_time = time.gmtime()
++        if os.environ.has_key('SOURCE_DATE_EPOCH'):
++            try:
++                build_time = time.gmtime(int(os.environ['SOURCE_DATE_EPOCH']))
++            except ValueError:
++                pass
+         out('%\n% API Documentation')
+         if self._prj_name: out(' for %s' % self._prj_name)
+         if isinstance(where, APIDoc):
+@@ -1106,7 +1112,7 @@ class LatexWriter:
+         else:
+             out('\n%% %s' % where)
+         out('\n%%\n%% Generated by epydoc %s\n' % epydoc.__version__)
+-        out('%% [%s]\n%%\n' % time.asctime(time.localtime(time.time())))
++        out('%% [%s]\n%%\n' % time.asctime(build_time))
+ 
+     def write_start_of(self, out, section_name):
+         out('\n' + 75*'%' + '\n')
diff --git a/debian/patches/series b/debian/patches/series
index 569c18b..582d009 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -7,3 +7,4 @@ python26-tokenizer.patch
 special-latex-entries.patch
 lintian.patch
 build-time.patch
+honour_source_date_epoch.patch

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to