Bug#1052950: sphinxcontrib-mermaid: please make the build reproducible
Chris Lamb
lamby at debian.org
Tue Sep 26 15:04:21 BST 2023
Source: sphinxcontrib-mermaid
Version: 0.9.2-1
Severity: wishlist
Tags: patch
User: reproducible-builds at lists.alioth.debian.org
Usertags: randomness
X-Debbugs-Cc: reproducible-bugs at lists.alioth.debian.org
Hi,
Whilst working on the Reproducible Builds effort [0], we noticed that
sphinxcontrib-mermaid could not be built reproducibly.
This is because it used Python's uuid.uuid4() method. Patch attached
that seeds this value from SOURCE_DATE_EPOCH if it exists.
[0] https://reproducible-builds.org/
Regards,
--
,''`.
: :' : Chris Lamb
`. `'` lamby at debian.org / chris-lamb.co.uk
`-
-------------- next part --------------
--- a/debian/patches/docs-Reproducible-build.patch 1970-01-01 01:00:00.000000000 +0100
--- b/debian/patches/docs-Reproducible-build.patch 2023-09-26 13:24:47.132348582 +0100
@@ -0,0 +1,25 @@
+Description: Make the build reproducible
+Author: Chris Lamb <lamby at debian.org>
+Last-Update: 2023-09-26
+
+--- sphinxcontrib-mermaid-0.9.2.orig/sphinxcontrib/mermaid.py
++++ sphinxcontrib-mermaid-0.9.2/sphinxcontrib/mermaid.py
+@@ -37,6 +37,9 @@ logger = logging.getLogger(__name__)
+
+ mapname_re = re.compile(r'<map id="(.*?)"')
+
++import random
++rnd = random.Random()
++rnd.seed(os.environ.get("SOURCE_DATE_EPOCH"))
+
+ class mermaid(nodes.General, nodes.Inline, nodes.Element):
+ pass
+@@ -138,7 +141,7 @@ class Mermaid(Directive):
+ node["inline"] = True
+ if "zoom" in self.options:
+ node["zoom"] = True
+- node["zoom_id"] = f"id-{uuid.uuid4()}"
++ node["zoom_id"] = "id-{}".format(uuid.UUID(version=4, int=rnd.getrandbits(128)))
+
+ caption = self.options.get("caption")
+ if caption:
--- a/debian/patches/series 2023-09-26 12:47:21.140521439 +0100
--- b/debian/patches/series 2023-09-26 13:23:54.004130039 +0100
@@ -3,3 +3,4 @@
docs-Correct-section-for-generated-manpages.patch
Privacy-Remove-linking-to-graphics-for-badges.patch
docs-Don-t-sideload-an-animated-GIF-file.patch
+docs-Reproducible-build.patch
More information about the Reproducible-bugs
mailing list