Skip to content

Commit 1868a17

Browse files
committed
contrib: macdeploy: make gen-sdk deterministic
1 parent bb0b39c commit 1868a17

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

contrib/macdeploy/README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ When complete, it will have produced `Bitcoin-Core.dmg`.
1515
A free Apple Developer Account is required to proceed.
1616

1717
Our current macOS SDK
18-
(`Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz`) can be
19-
extracted from
18+
(`Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz`)
19+
can be extracted from
2020
[Xcode_12.2.xip](https://download.developer.apple.com/Developer_Tools/Xcode_12.2/Xcode_12.2.xip).
21+
2122
Alternatively, after logging in to your account go to 'Downloads', then 'More'
2223
and search for [`Xcode_12.2`](https://developer.apple.com/download/all/?q=Xcode%2012.2).
24+
2325
An Apple ID and cookies enabled for the hostname are needed to download this.
24-
The `sha256sum` of the archive should be `28d352f8c14a43d9b8a082ac6338dc173cb153f964c6e8fb6ba389e5be528bd0`.
26+
27+
The `sha256sum` of the downloaded XIP archive should be `28d352f8c14a43d9b8a082ac6338dc173cb153f964c6e8fb6ba389e5be528bd0`.
2528

2629
After Xcode version 7.x, Apple started shipping the `Xcode.app` in a `.xip`
2730
archive. This makes the SDK less-trivial to extract on non-macOS machines. One
@@ -55,7 +58,10 @@ previous stage) as the first argument.
5558
./contrib/macdeploy/gen-sdk '/path/to/Xcode.app'
5659
```
5760

61+
The `sha256sum` of the generated TAR.GZ archive should be `e7ca56bc8804d16624fad68be2e71647747d6629cacaaa3de5fbfa7f444e9eae`.
62+
5863
## Deterministic macOS DMG Notes
64+
5965
Working macOS DMGs are created in Linux by combining a recent `clang`, the Apple
6066
`binutils` (`ld`, `ar`, etc) and DMG authoring tools.
6167

contrib/macdeploy/gen-sdk

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,21 @@ def run():
7575
tarinfo.name = str(pathlib.Path(alt_base_dir, tarinfo.name))
7676
if tarinfo.linkname and tarinfo.linkname.startswith("./"):
7777
tarinfo.linkname = str(pathlib.Path(alt_base_dir, tarinfo.linkname))
78+
# make metadata deterministic
79+
tarinfo.mtime = 0
80+
tarinfo.uid, tarinfo.uname = 0, ''
81+
tarinfo.gid, tarinfo.gname = 0, ''
82+
# don't use isdir() as there are also executable files present
83+
tarinfo.mode = 0o0755 if tarinfo.mode & 0o0100 else 0x0644
7884
return tarinfo
7985
with cd(dir_to_add):
86+
# recursion already adds entries in sorted order
8087
tarfp.add(".", recursive=True, filter=change_tarinfo_base)
8188

8289
print("Creating output .tar.gz file...")
8390
with out_sdktgz_path.open("wb") as fp:
8491
with gzip.GzipFile(fileobj=fp, mode='wb', compresslevel=9, mtime=0) as gzf:
85-
with tarfile.open(mode="w", fileobj=gzf) as tarfp:
92+
with tarfile.open(mode="w", fileobj=gzf, format=tarfile.GNU_FORMAT) as tarfp:
8693
print("Adding MacOSX SDK {} files...".format(sdk_version))
8794
tarfp_add_with_base_change(tarfp, sdk_dir, out_name)
8895
print("Adding libc++ headers...")

0 commit comments

Comments
 (0)