#!/usr/bin/env python3 """Build an offline Mac ZIP with two hash-pinned official runtimes and executable modes.""" import argparse,hashlib,importlib.util,json,stat,struct,tarfile,zipfile from pathlib import Path ROOT=Path(__file__).resolve().parents[1] spec=importlib.util.spec_from_file_location('windows_packager',ROOT/'scripts/package-editor-windows.py') common=importlib.util.module_from_spec(spec);spec.loader.exec_module(common) VERSION='22.23.3' HASHES={'arm64':'23b25245dcfb9af7262f8ff142e9e2e0af025368117329e7a7458a51e5922f53','x64':'8a677b0219178efd6eb0e475457c4afb452b521a92f6e67845a73bd85727f2a8'} NAME='ColorBlockEditor-Mac-0.19.0-20261019' def sha(data):return hashlib.sha256(data).hexdigest() def put(root,rel,data,mode=0o644): p=root/rel;p.parent.mkdir(parents=True,exist_ok=True);p.write_bytes(data);p.chmod(mode) def verify(archive): result=common.verify(archive) with zipfile.ZipFile(archive) as z: m=json.loads(z.read(NAME+'/PACKAGE_MANIFEST.json')) for r in m['files']: assert stat.S_IMODE(z.getinfo(NAME+'/'+r['path']).external_attr>>16)==r['mode'],r['path'] assert all(r['mode']==0o755 for r in m['files'] if r['path'].endswith('.command') or r['path'].endswith('/node')) result['executableModesVerified']=True return result def build(args): runtimes={} for arch in HASHES: archive=getattr(args,arch);assert sha(archive.read_bytes())==HASHES[arch],f'{arch} official SHA mismatch' prefix=f'node-v{VERSION}-darwin-{arch}' with tarfile.open(archive,'r:gz') as t: binary=t.extractfile(prefix+'/bin/node').read();license=t.extractfile(prefix+'/LICENSE').read() assert binary[:4]==b'\xcf\xfa\xed\xfe' assert struct.unpack_from('