Source: emscripten
Version: 2.0.8~dfsg-6
Severity: wishlist
Tags: patch
User: reproducible-bui...@lists.alioth.debian.org
Usertags: randomness
X-Debbugs-Cc: reproducible-b...@lists.alioth.debian.org

Hi,

Whilst working on the Reproducible Builds effort [0] we noticed that
emscripten could not be built reproducibly.

This is because it generates a switch/case statement using Python's
random functionality.

Patch attached that seeds this random component using the
SOURCE_DATE_EPOCH environment variable [1].

 [0] https://reproducible-builds.org/
 [1] https://reproducible-builds.org/specs/source-date-epoch/


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      la...@debian.org / chris-lamb.co.uk
       `-
--- a/debian/patches/3001_reproducible_build.patch      1970-01-01 
01:00:00.000000000 +0100
--- b/debian/patches/3001_reproducible_build.patch      2020-11-02 
10:10:35.965216078 +0000
@@ -0,0 +1,23 @@
+Description: Make the build reproducible
+Author: Chris Lamb <la...@debian.org>
+Last-Update: 2020-11-02
+
+--- emscripten-2.0.8~dfsg.orig/tools/create_dom_pk_codes.py
++++ emscripten-2.0.8~dfsg/tools/create_dom_pk_codes.py
+@@ -32,7 +32,7 @@
+ # Use #include <emscripten/dom_pk_codes.h> in your code to access these IDs.
+ 
+ from __future__ import print_function
+-import sys, random
++import sys, random, os
+ 
+ input_strings = [
+   (0x0, 'Unidentified',          'DOM_PK_UNKNOWN'),
+@@ -241,6 +241,7 @@ def hash_all(k1, k2):
+ # Try hash function format h_i = ((h_(i-1) ^ k_1) << k_2) ^ s_i, where h_i is 
the hash function
+ # value at step i, k_1 and k_2 are the constants we are searching, and s_i is 
the i'th input
+ # character
++random.seed(os.environ.get('SOURCE_DATE_EPOCH'))
+ perfect_hash_table = None
+ while perfect_hash_table == None:
+   # The search space is super-narrow, but since there are so few items to 
hash, practically
--- a/debian/patches/series     2020-11-02 09:46:05.927304184 +0000
--- b/debian/patches/series     2020-11-02 10:10:35.153204675 +0000
@@ -10,3 +10,4 @@
 2006_call_emscripten_in_PATH.patch
 2007_es_check.patch
 2008_minify_html.patch
+3001_reproducible_build.patch
-- 
Pkg-javascript-devel mailing list
Pkg-javascript-devel@alioth-lists.debian.net
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-javascript-devel

Reply via email to