67 lines
4.3 KiB
Bash
Executable File
67 lines
4.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# Ordinary workspace shell: normal build entry, true package/signature checks, archive + HTTP check.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
python3 - <<'PY'
|
|
from pathlib import Path
|
|
import hashlib,json
|
|
root=Path.cwd();directory=root/'logs/voice-investigation'
|
|
load=lambda name:json.loads((directory/name).read_text())
|
|
deploy=load('gateway-emotion-deploy.json');probe=load('probe-emotion.json');client=load('client-emotion-tests.json');compat=load('reply-structure.json')
|
|
assert deploy['applied'] and deploy['health']=='ok' and deploy['environment_unchanged']
|
|
assert probe['status']=='passed' and probe['downlink_bytes']>0 and probe['emotion_before_pcm'] and probe['drained_ack'] and probe['tts_requests']==1
|
|
assert compat['status']=='passed' and client['status']=='passed'
|
|
for name,digest in deploy['hashes'].items():assert hashlib.sha256((root/'gateway'/name).read_bytes()).hexdigest()==digest,name
|
|
for name,digest in client['hashes'].items():assert hashlib.sha256((root/name).read_bytes()).hexdigest()==digest,name
|
|
assert not (root/'artifacts/lan-voice-v051-arm64-debug.apk').exists(), 'release artifact exists: refusing overwrite'
|
|
print('Verified tested client/provider source and successful deployed pipeline before APK build')
|
|
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
|
|
mkdir -p logs/voice-investigation artifacts
|
|
"$TOOLS/aapt" dump badging "$APK" > logs/voice-investigation/release-emotion-badging.txt
|
|
"$TOOLS/apksigner" verify --verbose --print-certs "$APK" > logs/voice-investigation/release-emotion-signature.txt
|
|
python3 - <<'PY'
|
|
import hashlib,json,re,shutil,urllib.request,subprocess
|
|
from pathlib import Path
|
|
root=Path.cwd()
|
|
badging=(root/'logs/voice-investigation/release-emotion-badging.txt').read_text()
|
|
assert "name='com.gorios.lanvoice'" in badging
|
|
assert "versionCode='9'" in badging and "versionName='0.5.1'" in badging
|
|
native=re.search(r'^native-code: (.+)$',badging,re.M)
|
|
assert native and native[1].strip()=="'arm64-v8a'", 'unexpected ABI'
|
|
source=root/'app/build/outputs/apk/debug/app-debug.apk'
|
|
previous=root/'artifacts/lan-voice-v040-arm64-debug.apk'
|
|
if previous.exists():
|
|
old=subprocess.check_output(['/home/ubuntu/android-build/sdk/build-tools/34.0.0/apksigner','verify','--print-certs',str(previous)],text=True)
|
|
new=(root/'logs/voice-investigation/release-emotion-signature.txt').read_text()
|
|
pattern=r'Signer #1 certificate SHA-256 digest: (\w+)'
|
|
assert re.search(pattern,old)[1]==re.search(pattern,new)[1], 'signing certificate changed: update install would fail'
|
|
artifact=root/'artifacts/lan-voice-v051-arm64-debug.apk'
|
|
assert not artifact.exists(), 'release artifact exists: refusing overwrite'
|
|
assert hashlib.sha256((root/'artifacts/lan-voice-v040-arm64-debug.apk').read_bytes()).hexdigest()=='5a6f88cb2f825dbcd5c7b8c1f212b369534bc53c49533e196fb5e9287902e934'
|
|
assert hashlib.sha256((root/'artifacts/lan-voice-v050-arm64-debug.apk').read_bytes()).hexdigest()=='da47f7a08f63a68fbb6dbe7fb3d803ee58b402de393112a32f92a63ad50c1f33'
|
|
shutil.copy2(source,artifact)
|
|
digest=hashlib.sha256(artifact.read_bytes()).hexdigest()
|
|
artifact.with_suffix('.apk.sha256').write_text(f'{digest} {artifact.name}\n')
|
|
# Existing HTTP server root can be the workspace or artifacts; check the actual bytes.
|
|
base='http://192.168.31.124:8080/'
|
|
opener=urllib.request.build_opener(urllib.request.ProxyHandler({}))
|
|
url=None
|
|
for path in ('artifacts/'+artifact.name, artifact.name):
|
|
try:
|
|
with opener.open(base+path,timeout=15) as response:
|
|
assert response.status==200
|
|
content=response.read()
|
|
assert len(content)==artifact.stat().st_size
|
|
downloaded=hashlib.sha256(content).hexdigest()
|
|
if downloaded==digest: url=base+path;break
|
|
except Exception: pass
|
|
assert url is not None, 'APK built, but existing HTTP server did not serve matching bytes'
|
|
result=dict(version_name='0.5.1',version_code=9,apk=str(artifact.relative_to(root)),bytes=artifact.stat().st_size,sha256=digest,url=url,download_http_status=200,download_bytes=len(content),signature='apksigner_verified',real_phone_playback='not_tested')
|
|
(root/'logs/voice-investigation/release-emotion.json').write_text(json.dumps(result,indent=2)+'\n')
|
|
print(json.dumps(result,indent=2))
|
|
PY
|