Branchwell

PulseCanvas / app · pulsecanvas.ai / scripts / verify-platform-bundle.py

Raw 3.1 KB on 15681b389943bdb82ce0ee35ea3df6538f046361
1#!/usr/bin/env python3
2"""Verify actual flat visionOS native-only distribution bundles."""
3import argparse,hashlib,json,plistlib,re,subprocess
4from pathlib import Path
5p=argparse.ArgumentParser(description=__doc__);p.add_argument('platform',choices=['vision']);p.add_argument('app',type=Path);args=p.parse_args()
6root=Path(__file__).resolve().parents[1];app=args.app;info=plistlib.loads((app/'Info.plist').read_bytes())
7assert info['CFBundleIdentifier']=='com.protomota.pulsecanvas'
8assert info['UIDeviceFamily']==[7]
9config=(root/'Version.xcconfig').read_text()+'\n'+(root/'visionOS/Release.xcconfig').read_text()
10def 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)
14assert info['CFBundleShortVersionString']==setting('MARKETING_VERSION')
15assert info['CFBundleVersion']==setting('CURRENT_PROJECT_VERSION')
16assert info['ITSAppUsesNonExemptEncryption'] is False
17assert (app/'Assets.car').is_file() and info.get('CFBundleIcons'), 'Compiled icon required'
18payload=app/'NativeAssets';source=root/'Sources/PulseCanvas/Resources'
19expected={x.name for x in source.glob('*.metal')}|{'Audio/PulseCanvas.mp3','NativeVisualizers.json'}
20assert {x.relative_to(payload).as_posix() for x in payload.rglob('*') if x.is_file()}==expected
21for relative in expected-{'NativeVisualizers.json'}: assert (payload/relative).read_bytes()==(source/relative).read_bytes(),relative
22catalog = json.loads((payload/'NativeVisualizers.json').read_text())
23assert catalog == json.loads((source/'NativeVisualizers.json').read_text())
24assert (app/'Legal/PulseCanvas-LICENSE.txt').read_bytes()==(root/'LICENSE').read_bytes()
25assert (app/'PrivacyInfo.xcprivacy').read_bytes()==(root/'macOS/PrivacyInfo.xcprivacy').read_bytes()
26for 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'
30exe=app/info['CFBundleExecutable'];links=subprocess.check_output(['otool','-L',str(exe)],text=True).lower()
31assert not any(x in links for x in ['projectm','sparkle','opengl'])
32subprocess.run(['codesign','--verify','--deep','--strict',str(app)],check=True)
33signature=subprocess.check_output(['codesign','-dv','--verbose=4',str(app)],stderr=subprocess.STDOUT,text=True)
34assert 'Authority=Apple Distribution: Protomota, LLC (22HV69L32T)' in signature
35profile=plistlib.loads(subprocess.check_output(['security','cms','-D','-i',str(app/'embedded.mobileprovision')]))
36assert profile['TeamIdentifier']==['22HV69L32T'] and not profile['Entitlements']['get-task-allow']
37assert profile['Entitlements']['application-identifier']=='22HV69L32T.com.protomota.pulsecanvas'
38print(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))