Source: dh-python
Version: 2.20160818
Severity: wishlist
Tags: patch
User: reproducible-builds@lists.alioth.debian.org
Usertags: environment toolchain
X-Debbugs-Cc: reproducible-builds@lists.alioth.debian.org

Hi,

Whilst working on the Reproducible Builds effort [0], I noticed
that some packages on i386 are not reproducible as they embed
debugging symbols that vary depending on whether a 32 or 64-bit
kernel is being used.

The root cause is because temporary build directories include the
uname output:

 -'build/bdist.linux-x86_64' does not exist -- can't clean it
 +'build/bdist.linux-i686' does not exist -- can't clean it

This value comes from ``sysconfig.get_platform``:

  http://sources.debian.net/src/python2.7/2.7.12-2/Lib/sysconfig.py/#L572-L584
  http://sources.debian.net/src/python3.5/3.5.2-3/Lib/sysconfig.py/#L646-L658

We can easily fix it for all dh-python packages by exporting
_PYTHON_HOST_PLATFORM in the environment (if not set!) to something
that does not vary depending on the kernel. For example, combining
DEB_TARGET_ARCH_OS and DEB_TARGET_ARCH (eg. "linux-i386").

Patch attached.

 [0] https://reproducible-builds.org/


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      la...@debian.org / chris-lamb.co.uk
       `-
diff --git a/dhpython/tools.py b/dhpython/tools.py
index 6e47e17..93bde14 100644
--- a/dhpython/tools.py
+++ b/dhpython/tools.py
@@ -199,6 +199,18 @@ def execute(command, cwd=None, env=None, log_output=None, 
shell=True):
         * None if output should be included in the returned dict, or
         * False if output should be redirectored to stdout/stderr
     """
+    if env is None:
+        env = os.environ
+    try:
+        # Override _PYTHON_HOST_PLATFORM if not set to ensure debugging symbols
+        # on, for example, i386 emded a constant name regardless of the
+        # 32/64-bit kernel.
+        env.setdefault(
+            '_PYTHON_HOST_PLATFORM',
+            '{env[DEB_TARGET_ARCH_OS]}-{env[DEB_TARGET_ARCH]}'.format(env=env),
+        )
+    except KeyError:
+        pass
     args = {'shell': shell, 'cwd': cwd, 'env': env}
     close = False
     if log_output is False:
_______________________________________________
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