From 20778eb0235df70397fc285f9e3b72270bd4aaf4 Mon Sep 17 00:00:00 2001 From: fanquake Date: Thu, 6 Mar 2025 16:02:12 +0000 Subject: [PATCH] RFC: disable compression in macOS gen-sdk script Starting with Python 3.11, Pythons gzip might delegate to zlib. Depending on the OS, i.e Ubuntu vs Fedora, the underlying zlib implementation might differ, resulting in different output. For now, or until a better solution exists, disable compression. This results in the SDK increasing in size to ~230mb. Which is not unreasonable, to regain determinism (and would be significantly worse without the previous commit). See: https://docs.python.org/3/library/gzip.html#gzip.compress --- contrib/macdeploy/README.md | 2 +- contrib/macdeploy/gen-sdk | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/macdeploy/README.md b/contrib/macdeploy/README.md index fd7d4dea988..dbb00f78a2d 100644 --- a/contrib/macdeploy/README.md +++ b/contrib/macdeploy/README.md @@ -52,7 +52,7 @@ path to `Xcode.app` (extracted in the previous stage) as the first argument. ``` The generated archive should be: `Xcode-15.0-15A240d-extracted-SDK-with-libcxx-headers.tar.gz`. -The `sha256sum` should be `250cc83511f8548c8a91012f143a17ad38910fc8f14b45f28240ec46df612697`. +The `sha256sum` should be `2184c9699203ca32521899ca0deec831f2b6af214549c85bfad6ef8554d7778e`. ## Deterministic macOS App Notes diff --git a/contrib/macdeploy/gen-sdk b/contrib/macdeploy/gen-sdk index 3e64189062b..7e3c8bc7c9b 100755 --- a/contrib/macdeploy/gen-sdk +++ b/contrib/macdeploy/gen-sdk @@ -54,7 +54,7 @@ def run(): out_sdktgz_path = pathlib.Path("./{}.tar.gz".format(out_name)) def tarfp_add_with_base_change(tarfp, dir_to_add, alt_base_dir): - """Add all files in dir_to_add to tarfp, but prepent alt_base_dir to the files' + """Add all files in dir_to_add to tarfp, but prepend alt_base_dir to the files' names e.g. if the only file under /root/bazdir is /root/bazdir/qux, invoking: @@ -87,7 +87,7 @@ def run(): print("Creating output .tar.gz file...") with out_sdktgz_path.open("wb") as fp: - with gzip.GzipFile(fileobj=fp, mode='wb', compresslevel=9, mtime=0) as gzf: + with gzip.GzipFile(fileobj=fp, mode='wb', compresslevel=0, mtime=0) as gzf: with tarfile.open(mode="w", fileobj=gzf, format=tarfile.GNU_FORMAT) as tarfp: print("Adding MacOSX SDK {} files...".format(sdk_version)) tarfp_add_with_base_change(tarfp, sdk_dir, out_name)