74 lines
4.1 KiB
Bash
Executable File
74 lines
4.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Pinned offline pack + tested code, retained certificate, new artifact only, HTTP bytes.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
python3 - <<'PY'
|
|
from pathlib import Path
|
|
import hashlib,json
|
|
root=Path.cwd()
|
|
assert not (root/'artifacts/lan-voice-v060-arm64-debug.apk').exists(), 'Refuse overwriting release'
|
|
assert (root/'artifacts/lan-voice-v052-arm64-debug.apk').is_file()
|
|
tests=json.loads((root/'logs/avatar-060/client-tests.json').read_text())
|
|
assert tests['status']=='passed' and tests['jvm_entry_points']==9
|
|
for path,digest in tests['hashes'].items(): assert hashlib.sha256((root/path).read_bytes()).hexdigest()==digest,path
|
|
for name in ('a01-v1.manifest.json','a01-v1.call-avatar-manifest.json'):
|
|
original=(root/'docs/avatar'/name).read_bytes()
|
|
target='manifest.json' if name=='a01-v1.manifest.json' else 'call-avatar-manifest.json'
|
|
assert original==(root/'app/src/main/assets/avatar/a01-v1'/target).read_bytes()
|
|
base=json.loads((root/'docs/avatar/a01-v1.manifest.json').read_text())
|
|
call=json.loads((root/'docs/avatar/a01-v1.call-avatar-manifest.json').read_text())
|
|
for row in base['assets']+[base['staticFallback'],call['waiting']]:
|
|
assert hashlib.sha256((root/'app/src/main/assets/avatar/a01-v1'/row['path']).read_bytes()).hexdigest()==row['sha256']
|
|
print('Verified tested source and all offline candidate hashes')
|
|
PY
|
|
./scripts/build.sh
|
|
source /home/ubuntu/android-build/env.sh
|
|
TOOLS=/home/ubuntu/android-build/sdk/build-tools/34.0.0
|
|
APK=app/build/outputs/apk/debug/app-debug.apk
|
|
"$TOOLS/aapt" dump badging "$APK" > logs/avatar-060/badging.txt
|
|
"$TOOLS/apksigner" verify --verbose --print-certs "$APK" > logs/avatar-060/signature.txt
|
|
python3 - <<'PY'
|
|
from pathlib import Path
|
|
import hashlib,json,re,shutil,subprocess,urllib.request,zipfile
|
|
root=Path.cwd();logs=root/'logs/avatar-060'
|
|
badge=(logs/'badging.txt').read_text()
|
|
for value in ("name='com.gorios.lanvoice'","versionCode='11'","versionName='0.6.0'","sdkVersion:'26'","targetSdkVersion:'34'"):assert value in badge,value
|
|
assert re.search(r'^native-code: (.+)$',badge,re.M)[1].strip()=="'arm64-v8a'"
|
|
sig=(logs/'signature.txt').read_text();pattern=r'Signer #1 certificate SHA-256 digest: (\w+)'
|
|
for version in ('051','052'):
|
|
old=root/f'artifacts/lan-voice-v{version}-arm64-debug.apk'
|
|
output=subprocess.check_output(['/home/ubuntu/android-build/sdk/build-tools/34.0.0/apksigner','verify','--print-certs',str(old)],text=True)
|
|
assert re.search(pattern,output)[1]==re.search(pattern,sig)[1], 'Signing certificate mismatch'
|
|
source=root/'app/build/outputs/apk/debug/app-debug.apk'
|
|
with zipfile.ZipFile(source) as archive:
|
|
for file in (root/'app/src/main/assets/avatar/a01-v1').rglob('*'):
|
|
if file.is_file():
|
|
name='assets/'+str(file.relative_to(root/'app/src/main/assets'))
|
|
assert archive.read(name)==file.read_bytes(),name
|
|
if file.suffix=='.mp4':assert archive.getinfo(name).compress_type==zipfile.ZIP_STORED
|
|
artifact=root/'artifacts/lan-voice-v060-arm64-debug.apk'
|
|
assert not artifact.exists()
|
|
shutil.copy2(source,artifact)
|
|
digest=hashlib.sha256(artifact.read_bytes()).hexdigest()
|
|
sidecar=artifact.with_suffix('.apk.sha256');sidecar.write_text(f'{digest} {artifact.name}\n')
|
|
base='http://192.168.31.124:8080/'
|
|
opener=urllib.request.build_opener(urllib.request.ProxyHandler({}))
|
|
url=None
|
|
for prefix in ('','artifacts/'):
|
|
try:
|
|
candidate=base+prefix+artifact.name
|
|
with opener.open(candidate,timeout=15) as response:
|
|
assert response.status==200;data=response.read()
|
|
assert len(data)==artifact.stat().st_size and hashlib.sha256(data).hexdigest()==digest
|
|
with opener.open(candidate+'.sha256',timeout=15) as response:
|
|
assert response.status==200 and response.read()==sidecar.read_bytes()
|
|
url=candidate;break
|
|
except Exception:pass
|
|
assert url, 'New APK exists; matching HTTP delivery unavailable. Preserve artifact and inspect before continuing.'
|
|
result={'version':'0.6.0','versionCode':11,'apk':str(artifact.relative_to(root)),
|
|
'bytes':artifact.stat().st_size,'sha256':digest,'url':url,'httpBytesVerified':True,
|
|
'signature':'apksigner_verified','sameCertificateAs':['0.5.1','0.5.2'],'deviceTestStatus':'pending'}
|
|
(logs/'release.json').write_text(json.dumps(result,indent=2)+'\n')
|
|
print(json.dumps(result,indent=2))
|
|
PY
|