[mm-common: 1/2] util/meson_aux: make tarball reproducible




commit 7646c38d153ffdfbca2134f1d1ea524b7d07ca77
Author: Jelle van der Waa <jelle archlinux org>
Date:   Mon Sep 26 23:51:20 2022 +0200

    util/meson_aux: make tarball reproducible
    
    Set the owner/gid of a tarball to make the output tarball reproducible.
    
    Signed-off-by: Jelle van der Waa <jelle archlinux org>

 util/meson_aux/skeletonmm-tarball.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/util/meson_aux/skeletonmm-tarball.py b/util/meson_aux/skeletonmm-tarball.py
index db9e650..138184c 100755
--- a/util/meson_aux/skeletonmm-tarball.py
+++ b/util/meson_aux/skeletonmm-tarball.py
@@ -39,10 +39,16 @@ elif output_file.endswith('.gz'):
 else:
   mode = 'w'
 
+def reset(tarinfo):
+    tarinfo.uid = tarinfo.gid = 0
+    tarinfo.uname = tarinfo.gname = "root"
+    return tarinfo
+
+
 with tarfile.open(output_file, mode=mode) as tar_file:
   os.chdir(source_dir) # Input filenames are relative to source_dir.
   for file in sys.argv[3:]:
-    tar_file.add(file)
+    tar_file.add(file, filter=reset)
 # Errors raise exceptions. If an exception is raised, Meson+ninja will notice
 # that the command failed, despite exit(0).
 sys.exit(0)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]