PulseCanvas / app · pulsecanvas.ai / scripts / verify-platform-bundle.py
| 1 | #!/usr/bin/env python3 |
| 2 | """Verify actual flat visionOS native-only distribution bundles.""" |
| 3 | import argparse,hashlib,json,plistlib,re,subprocess |
| 4 | from pathlib import Path |
| 5 | p=argparse.ArgumentParser(description=__doc__);p.add_argument('platform',choices=['vision']);p.add_argument('app',type=Path);args=p.parse_args() |
| 6 | root=Path(__file__).resolve().parents[1];app=args.app;info=plistlib.loads((app/'Info.plist').read_bytes()) |
| 7 | assert info['CFBundleIdentifier']=='com.protomota.pulsecanvas' |
| 8 | assert info['UIDeviceFamily']==[7] |
| 9 | config=(root/'Version.xcconfig').read_text()+'\n'+(root/'visionOS/Release.xcconfig').read_text() |
| 10 | def setting(name: str) -> str: |
| 11 | match=re.search(r'^'+re.escape(name)+r'\s*=\s*(\S+)',config,re.MULTILINE) |
| 12 | assert match, name |
| 13 | return match.group(1) |
| 14 | assert info['CFBundleShortVersionString']==setting('MARKETING_VERSION') |
| 15 | assert info['CFBundleVersion']==setting('CURRENT_PROJECT_VERSION') |
| 16 | assert info['ITSAppUsesNonExemptEncryption'] is False |
| 17 | assert (app/'Assets.car').is_file() and info.get('CFBundleIcons'), 'Compiled icon required' |
| 18 | payload=app/'NativeAssets';source=root/'Sources/PulseCanvas/Resources' |
| 19 | expected={x.name for x in source.glob('*.metal')}|{'Audio/PulseCanvas.mp3','NativeVisualizers.json'} |
| 20 | assert {x.relative_to(payload).as_posix() for x in payload.rglob('*') if x.is_file()}==expected |
| 21 | for relative in expected-{'NativeVisualizers.json'}: assert (payload/relative).read_bytes()==(source/relative).read_bytes(),relative |
| 22 | catalog = json.loads((payload/'NativeVisualizers.json').read_text()) |
| 23 | assert catalog == json.loads((source/'NativeVisualizers.json').read_text()) |
| 24 | assert (app/'Legal/PulseCanvas-LICENSE.txt').read_bytes()==(root/'LICENSE').read_bytes() |
| 25 | assert (app/'PrivacyInfo.xcprivacy').read_bytes()==(root/'macOS/PrivacyInfo.xcprivacy').read_bytes() |
| 26 | for x in app.rglob('*'): |
| 27 | assert not (x.suffix.lower()=='.milk' or 'projectm' in x.name.lower() or 'sparkle' in x.name.lower()),x |
| 28 | if x.suffix=='.json': |
| 29 | d=json.loads(x.read_text());assert not (isinstance(d,dict) and ('stations' in d or 'tracks' in d)), 'Radio must remain server driven' |
| 30 | exe=app/info['CFBundleExecutable'];links=subprocess.check_output(['otool','-L',str(exe)],text=True).lower() |
| 31 | assert not any(x in links for x in ['projectm','sparkle','opengl']) |
| 32 | subprocess.run(['codesign','--verify','--deep','--strict',str(app)],check=True) |
| 33 | signature=subprocess.check_output(['codesign','-dv','--verbose=4',str(app)],stderr=subprocess.STDOUT,text=True) |
| 34 | assert 'Authority=Apple Distribution: Protomota, LLC (22HV69L32T)' in signature |
| 35 | profile=plistlib.loads(subprocess.check_output(['security','cms','-D','-i',str(app/'embedded.mobileprovision')])) |
| 36 | assert profile['TeamIdentifier']==['22HV69L32T'] and not profile['Entitlements']['get-task-allow'] |
| 37 | assert profile['Entitlements']['application-identifier']=='22HV69L32T.com.protomota.pulsecanvas' |
| 38 | print(json.dumps({'platform':args.platform,'version':info['CFBundleShortVersionString'],'build':int(info['CFBundleVersion']),'nativeEffects':catalog['activeCount'],'exactNativeResources':True,'icons':True,'signedDistribution':True,'noExternalEngineOrCatalogs':True,'executableSHA256':hashlib.sha256(exe.read_bytes()).hexdigest()},indent=2)) |