feat(desktop): add desktop uninstall and legacy LXQt cleanup (#493)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-10 10:59:32 -04:00
1 parent 6e0d456dd7
commit 416eb41d8d
28 files changed
+728 -25

No files matched your search

+25
View File
@@ -33,3 +33,28 @@ The desktop workflow replaces the same-version `kwin_wayland` executable and `li
comes from the signature-checked Arch packages. `desktop-kde.kwin.txt` records the source, patch,
executable, library and build package hashes. Corresponding source is
https://download.kde.org/stable/plasma/6.7.5/kwin-6.7.5.tar.xz plus the patch in this repository.
The inventories use `.gzip` rather than `.gz`: Android's asset packer expands `.gz` and strips
its suffix. The shared local/CI runtime payload check verifies the exact APK names and bytes.
Desktop removal uses `app/src/main/assets/desktop-removal/`, generated by `removal-manifests.py`
from the checksum-pinned LXQt r1, KDE r1/r2 and emulator r1 archives. KDE candidates are the files
of the desktop applications/themes in `seeds.txt` (their source package hashes verified against
`desktop-kde.packages.txt`) plus our overlay. Shared dependencies, fonts, Xwayland and Qt Wayland
remain available to Steam, native apps and emulators. Regenerate the inventories and add the new
version to `versions.txt` when publishing another desktop pin; unknown versions cannot be removed.
Removal checks file size and SHA-256, or the exact symlink target, before unlinking. Base-runtime
pacman files and emulator bundle paths are protected even when they overlap an application.
It never follows parent symlinks or recursively deletes directories. Home, added apps, custom
files and modified package files stay. A pending marker disables the installed state and allows
retry after interruption. Installing the desktop again repairs its package files and clears it.
The old LXQt applications are cleaned after KDE installation and before the next guest launch on
an already-upgraded runtime, protecting both KDE inventories as well as the runtime and emulators.
Only files owned by `lxqt-applications.txt`'s application packages are candidates; dependencies
stay even when the old runtime's pacman database does not record them. In particular, gamescope
still needs the old package's libseat. The source LXQt application archives are the versions in
the published `steamdeck-desktop-r1/desktop.packages.txt`; verify their `.sig` files with
`gpgv --keyring tools/desktop-kde/archlinuxarm-builder.gpg` and the Build System fingerprint used
by `build.sh`. Put their filenames in `selected.txt` in the LXQt cache. `sources.json` records
their SHA-256 values; file identities still come from the checksum-pinned published desktop.
+17
View File
@@ -0,0 +1,17 @@
# Application packages from steamdeck-desktop-r1's desktop.packages.txt.
# Keep dependencies and shared apps/icons (Firefox, mpv, Breeze, xdg-utils and portals).
labwc
lxqt-panel
lxqt-config
lxqt-runner
lxqt-session
lxqt-wayland-session
lxqt-themes
lxqt-qtplugin
pcmanfm-qt
qterminal
featherpad
lximage-qt
papirus-icon-theme
swaybg
wlr-randr
+121
View File
@@ -0,0 +1,121 @@
#!/usr/bin/env python3
"""Generate removal inventories from checksum-pinned published archives.
Usage: removal-manifests.py <LXQt tar.zst> <KDE r1 tar.zst> <KDE r2 tar.zst>
<emulators tar.zst> <verified KDE package cache> <output dir>
<verified LXQt package cache>
Removal includes desktop applications/themes and our overlay, not their shared dependencies.
The KDE cache is verified against the published desktop-kde.packages.txt before use.
The LXQt cache contains the signed application packages listed by desktop.packages.txt;
verify their Arch Linux ARM Build System signatures before generating the inventory.
"""
import gzip
import hashlib
import json
import pathlib
import subprocess
import sys
import tarfile
PINS = [
('lxqt-r1', 'c2bb860b3b1688287451e2495be5db313ec07f8c8af501dfac2768a9f417bc86'),
('desktop-kde-r1', '55747e75d0ec055ab7ea1e92a757f3be227cc3205bb9101f5b53cadef6318579'),
('desktop-kde-r2', '9ba832677b498654136c69d8c8330434d17e4d53cd099acac9bde3ba429b35bf'),
('emulators-r1', 'a1f4806a9663d28f424b4cab1277e0ede80a92e69de5bc063cdc8b45af220164'),
]
SHARED_SEEDS = {'xorg-xwayland', 'qt6-wayland', 'wayland-utils', 'noto-fonts', 'noto-fonts-emoji', 'xdg-utils'}
def sha(file):
with open(file, 'rb') as stream:
return hashlib.file_digest(stream, 'sha256').hexdigest()
def inventory(archive, digest):
if sha(archive) != digest:
raise ValueError(f'{archive}: checksum differs from the published pin')
entries = {}
process = subprocess.Popen(['zstd', '-dc', str(archive)], stdout=subprocess.PIPE)
try:
with tarfile.open(fileobj=process.stdout, mode='r|') as tar:
for entry in tar:
path = entry.name.removeprefix('./').rstrip('/')
assert not any(c in path for c in '\t\n\r') and '..' not in path.split('/') and not path.startswith('/')
if entry.isfile():
entries[path] = f'F\t{entry.size}\t{hashlib.file_digest(tar.extractfile(entry), "sha256").hexdigest()}\t{path}'
elif entry.issym():
assert not any(c in entry.linkname for c in '\t\n\r')
entries[path] = f'L\t0\t{entry.linkname}\t{path}'
elif entry.islnk():
target = entry.linkname.removeprefix('./')
record = entries[target].split('\t', 3)
entries[path] = '\t'.join(record[:3] + [path])
finally:
process.stdout.close()
if process.wait() != 0:
raise ValueError('zstd failed')
return entries
def write(out, name, records):
with open(out / name, 'wb') as stream:
with gzip.GzipFile(fileobj=stream, mode='wb', mtime=0, filename='') as gz:
gz.write(('\n'.join(sorted(set(records))) + '\n').encode())
def main():
archives = [pathlib.Path(p) for p in sys.argv[1:5]]
cache, out, legacy_cache = map(pathlib.Path, sys.argv[5:8])
here = pathlib.Path(__file__).resolve().parent
seeds = {line.strip() for line in (here / 'seeds.txt').read_text().splitlines() if line.strip() and not line.startswith('#')} - SHARED_SEEDS
# Published source package hashes; the caller places this beside the verified cache.
packages = dict(line.split() for line in (cache / 'desktop-kde.packages.txt').read_text().splitlines())
selected = set()
found = set()
for filename, digest in packages.items():
package = filename.rsplit('-', 3)[0]
if package not in seeds:
continue
archive = cache / filename
if sha(archive) != digest:
raise ValueError(f'{filename}: source package checksum mismatch')
with tarfile.open(archive) as tar:
selected.update(e.name.removeprefix('./').rstrip('/') for e in tar if not e.isdir())
found.add(package)
assert found == seeds, f'missing desktop packages: {seeds - found}'
selected.update(str(p.relative_to(here / 'overlay')) for p in (here / 'overlay').rglob('*') if p.is_file())
inventories = [inventory(p, pin[1]) for p, pin in zip(archives, PINS)]
out.mkdir(parents=True, exist_ok=True)
# The old runtime's pacman database omits some gamescope dependencies (e.g. libseat).
# Own only the LXQt application packages, never their dependency closure.
legacy_seeds = {line.strip() for line in (here / 'lxqt-applications.txt').read_text().splitlines()
if line.strip() and not line.startswith('#')}
legacy_selected = set()
legacy_sources = {}
legacy_found = set()
for filename in (legacy_cache / 'selected.txt').read_text().splitlines():
package = filename.rsplit('-', 3)[0]
if package not in legacy_seeds:
continue
archive = legacy_cache / filename
with tarfile.open(archive) as tar:
legacy_selected.update(e.name.removeprefix('./').rstrip('/') for e in tar if not e.isdir())
legacy_sources[filename] = sha(archive)
legacy_found.add(package)
assert legacy_found == legacy_seeds, f'missing LXQt applications: {legacy_seeds - legacy_found}'
legacy_selected.update({'usr/local/bin/steamdeck-desktop', 'usr/local/bin/steamdeck-steam'})
write(out, 'lxqt-r1.tsv.gzip', [record for path, record in inventories[0].items() if path in legacy_selected])
write(out, 'kde-remove.tsv.gzip', [record for inv in inventories[1:3] for path, record in inv.items() if path in selected])
write(out, 'kde-keep.txt.gzip', [path for inv in inventories[1:3] for path in inv])
write(out, 'emulators-keep.txt.gzip', inventories[3])
(out / 'versions.txt').write_text('desktop-kde-r1\ndesktop-kde-r2\n')
(out / 'sources.json').write_text(json.dumps({'archives': dict(PINS), 'desktopApplications': {n: h for n, h in packages.items() if n.rsplit('-', 3)[0] in seeds}, 'legacyApplications': legacy_sources}, indent=2) + '\n')
for name, digest in PINS:
print(name, digest)
print('KDE removable paths', sum(path in selected for path in inventories[2]))
print('KDE removable bytes', sum(int(record.split('\t')[1]) for path, record in inventories[2].items() if path in selected))
print('LXQt removable paths', sum(path in legacy_selected for path in inventories[0]))
if __name__ == '__main__':
main()
+12 -2
View File
@@ -1,5 +1,6 @@
"""Attest prepared runtime inputs and reject stale local or CI APK payloads."""
import hashlib
import gzip
import json
from pathlib import Path
import subprocess
@@ -15,7 +16,7 @@ SOURCE_PATHS = ['app/build.gradle', 'app/src/main/cpp/fakeinput_steam.cpp', 'app
'tools/linuxfs', 'tools/proot', 'tools/aaudio-sink', 'tools/directaudio',
'tools/gamescope/release.env', 'tools/droiddeck-esync/release.env',
'tools/mangoapp', 'tools/msitools', 'tools/build_local.sh',
'tools/release/runtime_inputs.py']
'tools/release/runtime_inputs.py', 'app/src/main/assets/desktop-removal']
def digest(path):
@@ -39,7 +40,7 @@ def sources(root):
def outputs(root):
result = {}
for tree in ['linuxfs', 'directaudio', 'droiddeck-esync']:
for tree in ['linuxfs', 'directaudio', 'droiddeck-esync', 'desktop-removal']:
base = root / 'app/src/main/assets' / tree
for path in base.rglob('*'):
if path.is_file() and not any(part.startswith('.') for part in path.relative_to(base).parts):
@@ -69,6 +70,9 @@ def required():
paths += ['assets/droiddeck-esync/index.json', 'assets/droiddeck-esync/index.json.sig',
'lib/arm64-v8a/libproot.so', 'lib/arm64-v8a/libproot-loader.so',
'lib/arm64-v8a/libdirectaudiorelay.so', 'assets/pulseaudio.tzst']
paths += ['assets/desktop-removal/' + name for name in
['lxqt-r1.tsv.gzip', 'kde-remove.tsv.gzip', 'kde-keep.txt.gzip',
'emulators-keep.txt.gzip', 'versions.txt', 'sources.json']]
return paths
@@ -84,6 +88,12 @@ def record(root=ROOT):
missing = [name for name in required() if name not in paths or not (root / paths[name]).is_file()]
if missing:
raise ValueError('Missing runtime inputs:\n' + '\n'.join(missing))
for name, path in paths.items():
if name.startswith('assets/desktop-removal/') and name.endswith('.gzip'):
try:
gzip.decompress((root / path).read_bytes())
except (OSError, EOFError) as error:
raise ValueError('Invalid desktop removal inventory: ' + name) from error
# Check inside the compressed payload, where a plain Gradle build used to ship no sinks.
process = subprocess.Popen(['zstd', '-dc', str(root / paths['assets/pulseaudio.tzst'])], stdout=subprocess.PIPE)
try:
+25
View File
@@ -0,0 +1,25 @@
import gzip
from pathlib import Path
import unittest
ASSETS = Path(__file__).resolve().parents[2] / 'app/src/main/assets/desktop-removal'
class DesktopRemovalInventoryTest(unittest.TestCase):
def test_legacy_inventory_removes_the_shell_and_retains_gamescope_dependencies(self):
records = gzip.decompress((ASSETS / 'lxqt-r1.tsv.gzip').read_bytes()).decode().splitlines()
paths = {record.split('\t', 3)[3] for record in records}
self.assertIn('usr/bin/lxqt-session', paths)
self.assertIn('usr/bin/labwc', paths)
self.assertIn('usr/local/bin/steamdeck-desktop', paths)
# The runtime pacman database did not protect libseat on the Thor. Removing it
# made gamescope and every Steam/native session exit 127 after desktop cleanup.
self.assertNotIn('usr/lib/libseat.so.1', paths)
self.assertNotIn('usr/lib/libseat.so', paths)
self.assertFalse(any(p.startswith('usr/lib/libSDL2') for p in paths))
self.assertFalse(any(p.startswith(('root/', 'opt/', 'var/')) for p in paths))
if __name__ == '__main__':
unittest.main()
+28 -2
View File
@@ -1,4 +1,5 @@
import importlib.util
import gzip
import io
from pathlib import Path
import subprocess
@@ -22,7 +23,7 @@ class RuntimeInputsTest(unittest.TestCase):
for name in runtime.required():
path = self.root / paths.get(name, 'app/src/main/' + name)
path.parent.mkdir(parents=True, exist_ok=True)
path.write_bytes(b'prepared runtime')
path.write_bytes(gzip.compress(b'inventory') if path.suffix == '.gzip' else b'prepared runtime')
self.source = self.root / 'tools/linuxfs/preload/test.c'
self.source.parent.mkdir(parents=True)
self.source.write_text('current source')
@@ -73,4 +74,29 @@ class RuntimeInputsTest(unittest.TestCase):
def test_complete_current_payload_passes(self):
runtime.record(self.root)
runtime.verify(self.root)
data = runtime.verify(self.root)
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())
runtime.check_apk(apk, self.root)
def test_android_expanding_or_renaming_a_compressed_inventory_is_rejected(self):
runtime.record(self.root)
data = runtime.verify(self.root)
apk = self.root / 'expanded.apk'
with ZipFile(apk, 'w') as package:
for name, output in data['outputs'].items():
content = (self.root / output['path']).read_bytes()
if name.endswith('.gzip'):
name = name.removesuffix('.gzip')
content = gzip.decompress(content)
package.writestr(name, content)
with self.assertRaisesRegex(ValueError, 'APK missing assets/desktop-removal/'):
runtime.check_apk(apk, self.root)
def test_malformed_removal_inventory_cannot_be_attested(self):
path = self.root / 'app/src/main/assets/desktop-removal/kde-remove.tsv.gzip'
path.write_bytes(b'not a gzip stream')
with self.assertRaisesRegex(ValueError, 'Invalid desktop removal inventory'):
runtime.record(self.root)