Add scheduled TV updates from Forgejo
Check a commit-pinned manifest on a configurable schedule, notify about newer versions, verify downloaded APKs, and hand off installation to Android. Generate the feed with each signed build. Include the wake artwork recovery fix and on-device lifecycle and updater regression tests.
This commit is contained in:
parent
f5f1c0928f
commit
0d1a11d943
23 changed files with 1493 additions and 51 deletions
27
scripts/make-update-manifest.py
Normal file
27
scripts/make-update-manifest.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Generate the small feed committed beside the signed APK; URLs resolve inside one Git commit."""
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
import xml.etree.ElementTree as ET
|
||||
from pathlib import Path
|
||||
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
ns = '{http://schemas.android.com/apk/res/android}'
|
||||
manifest = ET.parse(root / 'app/src/main/AndroidManifest.xml').getroot()
|
||||
code = int(manifest.get(ns + 'versionCode'))
|
||||
name = manifest.get(ns + 'versionName')
|
||||
apk = root / 'output/Luma.apk'
|
||||
badging = subprocess.check_output([str(root / '.tools/sdk/build-tools/34.0.0/aapt2'), 'dump', 'badging', str(apk)], text=True)
|
||||
assert f"versionCode='{code}'" in badging and f"versionName='{name}'" in badging, 'Rebuild the APK before generating its update manifest'
|
||||
gradle = (root / 'app/build.gradle').read_text()
|
||||
assert re.search(r'versionCode\s+' + str(code) + r'\b', gradle), 'Manifest and Gradle version codes differ'
|
||||
assert "versionName '" + name + "'" in gradle, 'Manifest and Gradle version names differ'
|
||||
feed = dict(schema=1, packageName='tv.luma.launcher', versionCode=code, versionName=name,
|
||||
minSdk=int(manifest.find('uses-sdk').get(ns + 'minSdkVersion')), apk='Luma.apk',
|
||||
size=apk.stat().st_size, sha256=hashlib.sha256(apk.read_bytes()).hexdigest(),
|
||||
notes=(root / 'docs/UPDATE_NOTES.md').read_text().strip())
|
||||
assert len(feed['notes']) <= 4000
|
||||
(root / 'output/update.json').write_text(json.dumps(feed, indent=2) + '\n')
|
||||
print('Generated output/update.json for Luma ' + name)
|
||||
Loading…
Add table
Add a link
Reference in a new issue