From e818eed647a1e83c2c9002a9e750f687fe9b5f81 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 16 Feb 2021 14:51:17 +0100 Subject: [PATCH] Include vendored Rust crates resolves: rhbz#1927510 --- .gitignore | 1 + sources | 1 + vendor_rust.py | 34 ++++++++++++++++++++++++++++++++-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 87f501d..32c836d 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ /cryptography-3.4.2.tar.gz.asc /cryptography-3.4.4.tar.gz /cryptography-3.4.4.tar.gz.asc +/cryptography-3.4.4-vendor.tar.bz2 diff --git a/sources b/sources index 20b61a3..3142fdd 100644 --- a/sources +++ b/sources @@ -1,2 +1,3 @@ SHA512 (cryptography-3.4.4.tar.gz) = 3c94cb3eccc67cd1d7be9d16353f94a08019534517bbe9cd97ee75f05631418d1688fa7efc7284a62482d22b731de524f45268cf357d47a37a2fb033f1b9b3fc SHA512 (cryptography-3.4.4.tar.gz.asc) = 395c8af891a2ae9c2a5954291e58d223fb5a9157794f22cf83bb798dd13534277d44846edca723b44dcbcb609e5db55e3fca7416fd452f23c5bb6e126c4c5284 +SHA512 (cryptography-3.4.4-vendor.tar.bz2) = c1ab9ad8e1580bae315416f455db7f9376f78787f6859758645f40f0380225c65952e7d2c60e441029cb6d9f7f447b3667c98b85edd2204f2c0e20aef4fd1905 diff --git a/vendor_rust.py b/vendor_rust.py index 4e25214..cd8355e 100755 --- a/vendor_rust.py +++ b/vendor_rust.py @@ -2,7 +2,6 @@ """Vendor PyCA cryptography's Rust crates """ import argparse -import glob import os import re import tarfile @@ -28,6 +27,37 @@ def cargo(cmd, manifest): ) +def tar_reset(tarinfo): + """Reset user, group, mtime, and mode to create reproducible tar""" + tarinfo.uid = 0 + tarinfo.gid = 0 + tarinfo.uname = "root" + tarinfo.gname = "root" + tarinfo.mtime = 0 + if tarinfo.type == tarfile.DIRTYPE: + tarinfo.mode = 0o755 + else: + tarinfo.mode = 0o644 + if tarinfo.pax_headers: + raise ValueError(tarinfo.name, tarinfo.pax_headers) + return tarinfo + + +def tar_reproducible(tar, basedir): + """Create reproducible tar file""" + + content = [basedir] + for root, dirs, files in os.walk(basedir): + for directory in dirs: + content.append(os.path.join(root, directory)) + for filename in files: + content.append(os.path.join(root, filename)) + content.sort() + + for fn in content: + tar.add(fn, filter=tar_reset, recursive=False, arcname=fn) + + def main(): args = parser.parse_args() spec = args.spec @@ -70,7 +100,7 @@ def main(): print("\nCreating tar ball...", file=sys.stderr) with tarfile.open(vendor_file, "x:bz2") as tar: - tar.add(VENDOR_DIR) + tar_reproducible(tar, VENDOR_DIR) # remove vendor dir shutil.rmtree(VENDOR_DIR)