PulseCanvas / app · pulsecanvas.ai / scripts / prepare-sparkle.py
| 1 | #!/usr/bin/env python3 |
| 2 | """Download the official pinned Sparkle distribution; never export signing keys.""" |
| 3 | import hashlib, json, tarfile, urllib.request |
| 4 | from pathlib import Path |
| 5 | root = Path(__file__).resolve().parents[1] |
| 6 | config = json.loads((root / 'macOS/DirectRelease.json').read_text()) |
| 7 | folder = root / '.build/sparkle' |
| 8 | folder.mkdir(parents=True, exist_ok=True) |
| 9 | version = config['sparkleVersion'] |
| 10 | archive = folder / f'Sparkle-{version}.tar.xz' |
| 11 | if not archive.exists(): |
| 12 | urllib.request.urlretrieve(f'https://github.com/sparkle-project/Sparkle/releases/download/{version}/{archive.name}', archive) |
| 13 | assert hashlib.sha256(archive.read_bytes()).hexdigest() == config['sparkleArchiveSHA256'], 'Sparkle SHA-256 mismatch' |
| 14 | with tarfile.open(archive) as package: |
| 15 | for entry in package.getmembers(): |
| 16 | assert not Path(entry.name).is_absolute() and '..' not in Path(entry.name).parts |
| 17 | if entry.issym() or entry.islnk(): |
| 18 | assert not Path(entry.linkname).is_absolute() and '..' not in Path(entry.linkname).parts |
| 19 | package.extractall(folder) |
| 20 | print(f'Verified official Sparkle {version}') |