Package: python-reportlab
Version: 3.3.0-1
Severity: normal
Tags: patch
User: reproducible-builds@lists.alioth.debian.org
Usertags: toolchain timestamps

Hi,
While working on the “reproducible builds” effort [1], we have noticed that
reportlab embeds current timestamp in the generated PDF. This behavior make
packages whose documentation is generated with reportlab unreproducible.

The attached patch fixes this behavior honoring the SOURCE_DATE_EPOCH [2]
environment variable.

[1] https://wiki.debian.org/ReproducibleBuilds
[2] https://reproducible-builds.org/specs/source-date-epoch/
Description: Honour SOURCE_DATE_EPOCH environment variable
 If the SOURCE_DATE_EPOCH environment variable is set, reportlab will use
 it instead of the current timestamp.
 See https://reproducible-builds.org/specs/source-date-epoch/
 .
 python-reportlab (3.3.0-1.0~reproducible1) UNRELEASED; urgency=medium
 .
   * Honour SOURCE_DATE_EPOCH, to generate PDFs reproducibly
Author: boyska <piutto...@logorroici.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- python-reportlab-3.3.0.orig/src/reportlab/pdfbase/pdfdoc.py
+++ python-reportlab-3.3.0/src/reportlab/pdfbase/pdfdoc.py
@@ -1730,8 +1730,12 @@ _NOWT=None
 def _getTimeStamp():
     global _NOWT
     if not _NOWT:
-        import time
-        _NOWT = time.time()
+        import os
+        if 'SOURCE_DATE_EPOCH' in os.environ:
+            _NOWT = float(os.environ['SOURCE_DATE_EPOCH'])
+        else:
+            import time
+            _NOWT = time.time()
     return _NOWT
 
 class PDFDate(PDFObject):
_______________________________________________
Reproducible-builds mailing list
Reproducible-builds@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds

Reply via email to