summaryrefslogtreecommitdiffstats
path: root/meta/recipes-graphics/piglit/piglit/0001-serializer.py-make-.gz-files-reproducible.patch
blob: 2efba6f86698984e34df0e51f34c2b0a8adad62c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From 1919bb7f4072d73dcbb64d0e06eff5b04529c3db Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Mon, 16 Nov 2020 18:01:02 +0000
Subject: [PATCH] serializer.py: make .gz files reproducible

.gz format contains mtime of the compressed data, and
SOURCE_DATE_EPOCH is the standard way to make it reproducuble.

Upstream-Status: Pending
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
 tests/serializer.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/serializer.py b/tests/serializer.py
index bd14bc3db..bc5b45d7f 100644
--- a/tests/serializer.py
+++ b/tests/serializer.py
@@ -138,7 +138,10 @@ def serializer(name, profile, outfile):
                 et.SubElement(env, 'env', name=k, value=v)
 
     tree = et.ElementTree(root)
-    with gzip.open(outfile, 'wb') as f:
+    reproducible_mtime = None
+    if 'SOURCE_DATE_EPOCH' in os.environ:
+        reproducible_mtime=os.environ['SOURCE_DATE_EPOCH']
+    with gzip.GzipFile(outfile, 'wb', mtime=reproducible_mtime) as f:
         tree.write(f, encoding='utf-8', xml_declaration=True)