Source: python-reportlab Version: 3.3.0-1 Severity: wishlist Tags: patch User: reproducible-bui...@lists.alioth.debian.org Usertags: timestamps X-Debbugs-Cc: reproducible-bui...@lists.alioth.debian.org
Hi! While working on the "reproducible builds" effort [1], we have noticed that python-reportlab could not be built reproducibly. It embeds timestamps into metadata of generated PDF files. The attached patch adds support for SOURCE_DATE_EPOCH [2], so that a deterministic timestamp is used if it is available. It also removes an additional timestamp in the content of the user guide. Regards, Reiner [1]: https://wiki.debian.org/ReproducibleBuilds [2]: https://reproducible-builds.org/specs/source-date-epoch/
diff --git a/debian/patches/reproducible-build.patch b/debian/patches/reproducible-build.patch new file mode 100644 index 0000000..1b88790 --- /dev/null +++ b/debian/patches/reproducible-build.patch @@ -0,0 +1,55 @@ +Description: Enable reproducible building + - Remove timestamp from documentation + - When generating PDF files, honour SOURCE_DATE_EPOCH for timestamps in + metadata: https://reproducible-builds.org/specs/source-date-epoch/ + - Interpret timestamps in generated PDF files as UTC. + +--- a/docs/userguide/ch1_intro.py ++++ b/docs/userguide/ch1_intro.py +@@ -10,7 +10,6 @@ + title("ReportLab PDF Library") + title("User Guide") + centred('ReportLab Version ' + reportlab.Version) +-centred((datetime(2000,1,1,0,0,0) if invariant else datetime.now()).strftime('Document generated on %Y/%m/%d %H:%M:%S %Z')) + + nextTemplate("TOC") + +--- a/src/reportlab/pdfbase/pdfdoc.py ++++ b/src/reportlab/pdfbase/pdfdoc.py +@@ -1731,7 +1731,9 @@ + global _NOWT + if not _NOWT: + import time +- _NOWT = time.time() ++ import os ++ import datetime ++ _NOWT = int(os.environ.get('SOURCE_DATE_EPOCH', time.time())) + return _NOWT + + class PDFDate(PDFObject): +@@ -1739,22 +1741,17 @@ + def __init__(self, invariant=rl_config.invariant, dateFormatter=None): + if invariant: + now = (2000,1,1,0,0,0,0) +- self.dhh = 0 +- self.dmm = 0 + else: + import time +- now = tuple(time.localtime(_getTimeStamp())[:6]) +- from time import timezone +- self.dhh = int(timezone / (3600.0)) +- self.dmm = (timezone % 3600) % 60 ++ now = tuple(time.gmtime(_getTimeStamp())[:6]) + self.date = now[:6] + self.dateFormatter = dateFormatter + + def format(self, doc): + dfmt = self.dateFormatter or ( + lambda yyyy,mm,dd,hh,m,s: +- "D:%04d%02d%02d%02d%02d%02d%+03d'%02d'" +- % (yyyy,mm,dd,hh,m,s,self.dhh,self.dmm)) ++ "D:%04d%02d%02d%02d%02d%02d+00'00'" ++ % (yyyy,mm,dd,hh,m,s)) + return format(PDFString(dfmt(*self.date)), doc) + + class Destination(PDFObject): diff --git a/debian/patches/series b/debian/patches/series index 79de88c..0f5a457 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1,2 @@ gsfonts.diff +reproducible-build.patch
signature.asc
Description: Digital signature