diff options
author | Pavol Rusnak <pavol@rusnak.io> | 2022-03-12 12:13:53 +0100 |
---|---|---|
committer | Pavol Rusnak <pavol@rusnak.io> | 2022-03-12 12:35:56 +0100 |
commit | ba30a5407e065e9d6dd037351e83f56a43f38f19 (patch) | |
tree | cc7bb4aa1b3934b900a4476eaaf22a16f55695d4 /contrib/macdeploy/gen-sdk | |
parent | 1868a17e5a46c96bfd2d3f28e876bbaa74d1417f (diff) | |
download | bitcoin-ba30a5407e065e9d6dd037351e83f56a43f38f19.tar.xz |
contrib: macdeploy: monkey-patch gen-sdk to be deterministic
on different Python versions (there was a change in TAR handling
between Python 3.8 and Python 3.9)
Diffstat (limited to 'contrib/macdeploy/gen-sdk')
-rwxr-xr-x | contrib/macdeploy/gen-sdk | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/contrib/macdeploy/gen-sdk b/contrib/macdeploy/gen-sdk index f1d18fae70..d70cc8613c 100755 --- a/contrib/macdeploy/gen-sdk +++ b/contrib/macdeploy/gen-sdk @@ -8,6 +8,21 @@ import gzip import os import contextlib +# monkey-patch Python 3.8 and older to fix wrong TAR header handling +# see https://github.com/bitcoin/bitcoin/pull/24534 +# and https://github.com/python/cpython/pull/18080 for more info +if sys.version_info < (3, 9): + _old_create_header = tarfile.TarInfo._create_header + def _create_header(info, format, encoding, errors): + buf = _old_create_header(info, format, encoding, errors) + # replace devmajor/devminor with binary zeroes + buf = buf[:329] + bytes(16) + buf[345:] + # recompute checksum + chksum = tarfile.calc_chksums(buf)[0] + buf = buf[:-364] + bytes("%06o\0" % chksum, "ascii") + buf[-357:] + return buf + tarfile.TarInfo._create_header = staticmethod(_create_header) + @contextlib.contextmanager def cd(path): """Context manager that restores PWD even if an exception was raised.""" |