Skip to content

Commit

Permalink
Bug 1871895 - Switch unpack-sdk.py to sha512. r=firefox-build-system-…
Browse files Browse the repository at this point in the history
…reviewers,ahochheiden

That will more easily allow to use tooltool.

Differential Revision: https://phabricator.services.mozilla.com/D197304
  • Loading branch information
glandium committed Dec 28, 2023
1 parent 61cd516 commit acf309e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build/docs/toolchains.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Once you have found the SDK you want, you can create or update toolchain tasks
in ``taskcluster/ci/toolchain/macosx-sdk.yml``.

The ``taskcluster/scripts/misc/unpack-sdk.py`` script takes the url of a SDK
package, the sha256 hash for its content, the path to the SDK in the package,
package, the sha512 hash for its content, the path to the SDK in the package,
and an output directory, and extracts the package in that directory.

Both scripts should be run via ``mach python``. The latter is automatically
Expand Down
6 changes: 3 additions & 3 deletions taskcluster/ci/toolchain/macos-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ macosx64-sdk-13.3:
run:
arguments:
- https://swcdn.apple.com/content/downloads/15/62/032-84673-A_7A1TG1RF8Z/xpc8q44ggn2pkn82iwr0fi1zeb9cxi8ath/CLTools_macOSNMOS_SDK.pkg
- c33545d543a38911aee2a65d4bf7ff4932c12de1e6a042ae38e6415f65a10710
- 8de3306508dca31040b3b49ff370e96c94f4546bcf22cb4069abbb18e2d6bce8e20d40a6903f00ae75558175b624a979ea0444f54bc6d9d67e841f2000b0d863
- Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk
toolchain-artifact: project/gecko/mac-sdk/MacOSX13.3.sdk.tar.zst
toolchain-alias:
Expand All @@ -44,7 +44,7 @@ macosx64-sdk-14.2:
arguments:
- unpack-sdk.py
- http://taskcluster/tooltool.mozilla-releng.net/sha512/22ce0acc9ab5c28845218b8c686d0208d6bf66bef64a369d3c0622247ba1258b438c9e44c64bb2bacf5e99eb398a6e7a337f2730cd4a969a7f0d2d5d3107306a
- 3765eade716c472a521e5b982e6932cdc6ba79df3fed4e765d0536039340b730
- 22ce0acc9ab5c28845218b8c686d0208d6bf66bef64a369d3c0622247ba1258b438c9e44c64bb2bacf5e99eb398a6e7a337f2730cd4a969a7f0d2d5d3107306a
- Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk
toolchain-artifact: project/gecko/mac-sdk/MacOSX14.2.sdk.tar.zst
toolchain-alias:
Expand All @@ -59,7 +59,7 @@ macosx64-sdk-14.2-public:
run:
arguments:
- https://swcdn.apple.com/content/downloads/35/47/042-23550-A_M34N50O9N3/sua6ev7bjcexvorh4709vsgk64zgvsl42p/CLTools_macOSNMOS_SDK.pkg
- 3765eade716c472a521e5b982e6932cdc6ba79df3fed4e765d0536039340b730
- 22ce0acc9ab5c28845218b8c686d0208d6bf66bef64a369d3c0622247ba1258b438c9e44c64bb2bacf5e99eb398a6e7a337f2730cd4a969a7f0d2d5d3107306a
- Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk
toolchain-artifact: project/gecko/mac-sdk/MacOSX14.2.sdk.tar.zst
toolchain-alias:
Expand Down
10 changes: 5 additions & 5 deletions taskcluster/scripts/misc/unpack-sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@
from mozpack.macpkg import Pbzx, uncpio, unxar


def unpack_sdk(url, sha256, extract_prefix, out_dir="."):
def unpack_sdk(url, sha512, extract_prefix, out_dir="."):
with tempfile.TemporaryFile() as pkg:
hash = hashlib.sha256()
hash = hashlib.sha512()
for attempt in range(3):
if attempt != 0:
print(f"Failed to download from {url}. Retrying", file=sys.stderr)

with urlopen(url) as fh:
# Equivalent to shutil.copyfileobj, but computes sha256 at the same time.
# Equivalent to shutil.copyfileobj, but computes sha512 at the same time.
while True:
buf = fh.read(1024 * 1024)
if not buf:
break
hash.update(buf)
pkg.write(buf)
digest = hash.hexdigest()
if digest == sha256:
if digest == sha512:
break
else:
raise Exception(f"(actual) {digest} != (expected) {sha256}")
raise Exception(f"(actual) {digest} != (expected) {sha512}")

pkg.seek(0, os.SEEK_SET)

Expand Down

0 comments on commit acf309e

Please sign in to comment.