mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 06:15:58 +00:00
feat: ship proot, DirectAudio, Xbox, Comet and hand tracking as CI-built add-on packs (#1198)
* perf: download hand tracking models and native libs on first use * feat: build and publish add-on packs in CI, add Xbox and Comet packs * feat: ship proot and DirectAudio drivers as CI-built packs * test: hand tracking readiness requires the tracking pack * ci: attach PR test-build packs to the PR release instead of Components
This commit is contained in:
1 parent
0663593920
commit
e3246b7dd5
72 files changed
+710
-112
No files matched your search
@@ -29,6 +29,32 @@ class RuntimeInputsTest(unittest.TestCase):
|
||||
self.source.parent.mkdir(parents=True)
|
||||
self.source.write_text('current source')
|
||||
self.audio(['pactl', 'modules/arm64/module-aaudio-sink.so', 'modules/arm64/module-directaudio-native-sink.so'])
|
||||
self.packs()
|
||||
|
||||
def pack(self, name, files):
|
||||
stream = io.BytesIO()
|
||||
with tarfile.open(fileobj=stream, mode='w') as archive:
|
||||
for rel, content in files.items():
|
||||
entry = tarfile.TarInfo(rel)
|
||||
entry.size = len(content)
|
||||
archive.addfile(entry, io.BytesIO(content))
|
||||
path = self.root / runtime.PACKS / (name + '.tar.zst')
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_bytes(subprocess.run(['zstd', '-q', '-c'], input=stream.getvalue(), capture_output=True, check=True).stdout)
|
||||
|
||||
def packs(self):
|
||||
self.pack('tracking', {library.rsplit('/', 1)[1]: b'library' for library in runtime.PACKED_LIBRARIES})
|
||||
proot = {}
|
||||
for name, (pack, rel) in runtime.PACKED_FILES.items():
|
||||
proot[rel] = (self.root / runtime.outputs(self.root)[name]).read_bytes()
|
||||
self.pack('proot', proot)
|
||||
for prefix, name in runtime.PACKED.items():
|
||||
base = self.root / 'app/src/main' / prefix
|
||||
self.pack(name, {path.relative_to(base).as_posix(): path.read_bytes() for path in base.rglob('*') if path.is_file()})
|
||||
|
||||
@staticmethod
|
||||
def in_apk(name):
|
||||
return name not in runtime.PACKED_FILES and not any(name.startswith(prefix) for prefix in runtime.PACKED)
|
||||
|
||||
def audio(self, names):
|
||||
stream = io.BytesIO()
|
||||
@@ -40,6 +66,11 @@ class RuntimeInputsTest(unittest.TestCase):
|
||||
path = self.root / 'app/build/prepared-assets/pulseaudio.tzst'
|
||||
path.write_bytes(subprocess.run(['zstd', '-q', '-c'], input=stream.getvalue(), capture_output=True, check=True).stdout)
|
||||
|
||||
def test_an_apk_still_carrying_proot_is_rejected(self):
|
||||
apk = self.current_apk(self.root / 'bundled.apk', {'lib/arm64-v8a/libproot.so': b'prepared runtime'})
|
||||
with self.assertRaisesRegex(ValueError, 'proot pack provides'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_missing_proot_cannot_be_attested(self):
|
||||
(self.root / 'app/src/main/jniLibs/arm64-v8a/libproot.so').unlink()
|
||||
with self.assertRaisesRegex(ValueError, 'libproot.so'):
|
||||
@@ -82,6 +113,8 @@ class RuntimeInputsTest(unittest.TestCase):
|
||||
apk = self.root / 'old.apk'
|
||||
with ZipFile(apk, 'w') as package:
|
||||
for name, output in data['outputs'].items():
|
||||
if not self.in_apk(name):
|
||||
continue
|
||||
content = b'stale' if name == 'assets/linuxfs/libssbs.so' else (self.root / output['path']).read_bytes()
|
||||
package.writestr(name, content)
|
||||
with self.assertRaisesRegex(ValueError, 'stale runtime input'):
|
||||
@@ -93,9 +126,43 @@ class RuntimeInputsTest(unittest.TestCase):
|
||||
apk = self.root / 'current.apk'
|
||||
with ZipFile(apk, 'w') as package:
|
||||
for name, output in data['outputs'].items():
|
||||
package.writestr(name, (self.root / output['path']).read_bytes())
|
||||
if self.in_apk(name):
|
||||
package.writestr(name, (self.root / output['path']).read_bytes())
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def current_apk(self, path, extra=None):
|
||||
runtime.record(self.root)
|
||||
data = runtime.verify(self.root)
|
||||
with ZipFile(path, 'w') as package:
|
||||
for name, output in data['outputs'].items():
|
||||
if self.in_apk(name):
|
||||
package.writestr(name, (self.root / output['path']).read_bytes())
|
||||
for name, content in (extra or {}).items():
|
||||
package.writestr(name, content)
|
||||
return path
|
||||
|
||||
def test_an_apk_still_carrying_a_packed_tree_is_rejected(self):
|
||||
apk = self.current_apk(self.root / 'bundled.apk', {'assets/linuxfs/usr/local/lib/droiddeck-xbox/xodus-cli': b'prepared runtime'})
|
||||
with self.assertRaisesRegex(ValueError, 'xbox pack provides'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_an_apk_still_carrying_tracking_libraries_is_rejected(self):
|
||||
apk = self.current_apk(self.root / 'bundled.apk', {runtime.PACKED_LIBRARIES[0]: b'library'})
|
||||
with self.assertRaisesRegex(ValueError, 'tracking pack provides'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_a_stale_pack_is_rejected(self):
|
||||
apk = self.current_apk(self.root / 'current.apk')
|
||||
self.pack('comet', {'comet': b'old build', 'version': b'old'})
|
||||
with self.assertRaisesRegex(ValueError, 'comet is missing or has a stale'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_a_missing_pack_is_rejected(self):
|
||||
apk = self.current_apk(self.root / 'current.apk')
|
||||
(self.root / runtime.PACKS / 'xbox.tar.zst').unlink()
|
||||
with self.assertRaisesRegex(ValueError, 'Missing add-on pack xbox'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_windows_manifest_matches_portable_apk_paths(self):
|
||||
path_type = type(self.root)
|
||||
original_relative_to = path_type.relative_to
|
||||
@@ -114,6 +181,8 @@ class RuntimeInputsTest(unittest.TestCase):
|
||||
apk = self.root / 'portable.apk'
|
||||
with ZipFile(apk, 'w') as package:
|
||||
for name, output in data['outputs'].items():
|
||||
if not self.in_apk(name):
|
||||
continue
|
||||
self.assertNotIn('\\', name)
|
||||
self.assertNotIn('\\', output['path'])
|
||||
package.writestr(name, (self.root / output['path']).read_bytes())
|
||||
@@ -125,6 +194,8 @@ class RuntimeInputsTest(unittest.TestCase):
|
||||
apk = self.root / 'expanded.apk'
|
||||
with ZipFile(apk, 'w') as package:
|
||||
for name, output in data['outputs'].items():
|
||||
if not self.in_apk(name):
|
||||
continue
|
||||
content = (self.root / output['path']).read_bytes()
|
||||
if name.endswith('.gzip'):
|
||||
name = name.removesuffix('.gzip')
|
||||
|
||||
Reference in new issue
Block a user