Include vendored Rust crates

resolves: rhbz#1927510
This commit is contained in:
Christian Heimes 2021-02-16 14:51:17 +01:00
parent cdd2277525
commit e818eed647
3 changed files with 34 additions and 2 deletions

1
.gitignore vendored
View File

@ -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

View File

@ -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

View File

@ -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)