#!/usr/bin/env python3 """Build the authorized UI-only internal debug candidate; runtime03 remains unchanged.""" from pathlib import Path import argparse, hashlib, importlib.util, json, re, urllib.request, zipfile ROOT=Path(__file__).resolve().parents[1] spec=importlib.util.spec_from_file_location('natural_packaging',ROOT/'scripts/package-avatar-natural.py') natural=importlib.util.module_from_spec(spec);spec.loader.exec_module(natural) LOG=ROOT/'logs/avatar-062';natural.LOG=LOG ARTIFACT=ROOT/'artifacts/lan-voice-v062-ui-candidate-arm64-debug.apk' BASELINE=ROOT/'artifacts/lan-voice-v061-natural-engineering-arm64-debug.apk' BASELINE_SHA='8809ff5c2bec26f229b3c4dd505c54f7a3e02756f33bee4db904f1253b49e0fc' CERT='b9608336bc1ed1de3269bb4594f9fe718daaa5439511c5187aa385d2b799dcf1' # Saved code13 source fingerprints: this delivery changes chrome, not mouth rendering. UNCHANGED={ 'ContinuousBodyRenderer.kt':'4144db91db07585bf066080a251dc40b664775baab33b6267ef1c895d323f0f7', 'ContinuousAvatarView.kt':'ff1952f2975902834010c68bc7307e61eb80d2edfe5b4449e99d26577cafb4c4', 'ContinuousFramePresenter.kt':'78a2a33ef672d1245bfc5d65d6fd700f22ec190dc0d00b1035140b51514ecc0b', 'ContinuousMouth.kt':'19a599297219a312a6600cc46d86b4190ad5a6066754954fcf51d4601bcef3e2', } sha=lambda data:hashlib.sha256(data).hexdigest() def main(): parser=argparse.ArgumentParser(description=__doc__) parser.add_argument('--import-only',action='store_true') parser.add_argument('--verify-existing',action='store_true') args=parser.parse_args();LOG.mkdir(parents=True,exist_ok=True) assert sha(BASELINE.read_bytes())==BASELINE_SHA,'Code13 baseline drift' for name,digest in UNCHANGED.items(): assert sha((ROOT/'app/src/main/java/com/gorios/lanvoice/avatar'/name).read_bytes())==digest,'Unexpected mouth renderer change: '+name m,files=natural.import_runtime() if args.import_only: natural.verify_decode(m) print('PASS: unchanged runtime03 exact manifest/body/97patch hashes, CFR/full decode and independent alpha algebra; no renderer or mouth repair claimed') return natural.tests_current() assert 'PASS: clean home' in (ROOT/'logs/avatar-safe-061/ui-contract-tests.txt').read_text() assert 'BUILD SUCCESSFUL' in (LOG/'android-test-compile.txt').read_text(),'Compile optional device UI probe first' if args.verify_existing: assert ARTIFACT.is_file();built=ARTIFACT else: assert not ARTIFACT.exists(),'Never overwrite an existing delivered candidate' natural.run([ROOT/'scripts/build.sh','assembleDebug','-PavatarNatural=true','-PavatarUiCandidate=true','-PnaturalManifestSha='+natural.PIN],'assemble.txt') built=ROOT/'app/build/outputs/apk/debug/app-debug.apk' cert=natural.verify(built,files,14,'0.6.2-ui-dev');assert cert==CERT signature=natural.run([natural.TOOLS/'apksigner','verify','--print-certs',BASELINE],'signature-code13.txt') assert CERT in signature with zipfile.ZipFile(built) as new,zipfile.ZipFile(BASELINE) as old: names={n for n in old.namelist() if n.startswith('assets/avatar/') and not n.endswith('/')} assert names=={n for n in new.namelist() if n.startswith('assets/avatar/') and not n.endswith('/')} assert all(new.read(n)==old.read(n) for n in names),'UI-only APK changed portrait asset bytes' if not args.verify_existing: with ARTIFACT.open('xb') as stream:stream.write(built.read_bytes()) digest=sha(ARTIFACT.read_bytes());checksum=f'{digest} {ARTIFACT.name}\n'.encode() side=ARTIFACT.with_suffix('.apk.sha256');assert not side.exists() or side.read_bytes()==checksum side.write_bytes(checksum) url='http://192.168.31.124:8080/'+ARTIFACT.name opener=urllib.request.build_opener(urllib.request.ProxyHandler({})) with opener.open(url,timeout=15) as response: data=response.read();assert response.status==200 and len(data)==ARTIFACT.stat().st_size and sha(data)==digest with opener.open(url+'.sha256',timeout=15) as response:assert response.status==200 and response.read()==checksum result={'scope':'ui_only_internal_debug_candidate','version':'0.6.2-ui-dev','versionCode':14, 'apk':str(ARTIFACT),'url':url,'bytes':ARTIFACT.stat().st_size,'sha256':digest, 'sameCertificateSha256':cert,'manifestSha256':natural.PIN,'httpBytesVerified':True, 'mouthChanged':False,'mouthDeformationResolved':False,'naturalQuality':'not_certified', 'uiDeviceInstrumentation':'compiled_not_run','devicePerf':'not_tested', 'actualGpuUvColor':'not_measured','compliance1s':'not_certified','productionApproval':False, 'offlineExtra':'avatar_offline_preview'} (LOG/'delivery.json').write_text(json.dumps(result,indent=2)+'\n') print(json.dumps(result,indent=2)) if __name__=='__main__':main()