mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 15:26:04 +00:00
feat(onboarding): background first-run downloads, one setup card, no wait for Steam (#3091)
* feat(onboarding): one setup card, Steam client and Proton downloaded in the background, no component toast * feat(onboarding): an optional Bluetooth controllers row in the setup card asks for the permission up front * feat(onboarding): prefetch Steam's whole package cache, one foreground notification, child-process setup while downloads run * test(steam): the cache pass keeps packages under Steam's names and is not repeated * feat(onboarding): unpack the whole Steam client ahead of time and record it as installed, downloads no longer wait for a cool device * feat(onboarding): setup progress on the Steam home page, Bluetooth asked only from the setup card, Steam unpacks its own files * fix(onboarding): review fixes: removal does not report setup progress, cancel stops the whole prefetch, cache files are verified, no resume toast * fix(onboarding): a cancelled prefetch is never a setup failure * fix(onboarding): the Steam fact is updated atomically * feat(onboarding): Bluetooth controllers moves into the Steam integration list
This commit is contained in:
1 parent
15b1e196af
commit
59e98afae7
22 files changed
+590
-37
No files matched your search
@@ -65,12 +65,14 @@ if [ -n "$repair" ]; then
|
||||
[ "$(sha1sum "$part" | cut -d' ' -f1)" = "$sum" ] || rm -f "$part"
|
||||
done
|
||||
fi
|
||||
cache_only=
|
||||
[ "${1:-}" = --cache ] && cache_only=1
|
||||
sync=
|
||||
if [ "${1:-}" = --sync ]; then
|
||||
case "${2:-}" in publicbeta|steamdeck_publicbeta) sync=$2 ;; *) sync=$steam_channel ;; esac
|
||||
manifest=steam_client_${sync}_linuxarm64
|
||||
fi
|
||||
[ -z "$sync" ] && [ -x "$steam_root/steamrtarm64/steam" ] && [ -f "$stamp" ] && exit 0
|
||||
[ -z "$sync" ] && [ -z "$cache_only" ] && [ -x "$steam_root/steamrtarm64/steam" ] && [ -f "$stamp" ] && exit 0
|
||||
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
@@ -167,6 +169,46 @@ if ! fetch_manifest; then
|
||||
fallback=1
|
||||
fetch_manifest || exit 1
|
||||
fi
|
||||
if [ -n "$cache_only" ]; then
|
||||
cache=$steam_root/package
|
||||
cached=$cache/droiddeck-cached
|
||||
[ "$(cat "$cached" 2>/dev/null)" = "$version" ] && exit 0
|
||||
awk -F'"' '
|
||||
/^\t"/ && NF >= 3 && $4 == "" { block = $2 }
|
||||
$2 == "file" { file[block] = $4 }
|
||||
$2 == "sha2" { sha[block] = $4 }
|
||||
$2 == "size" { size[block] = $4 }
|
||||
$2 == "zipvz" { vz[block] = $4 }
|
||||
$2 == "sha2vz" { vzsha[block] = $4 }
|
||||
END {
|
||||
for (b in file) {
|
||||
f = file[b]; h = sha[b]; n = size[b] + 0
|
||||
if (b in vz) { f = vz[b]; h = vzsha[b]; k = split(f, bits, "_"); n = bits[k] + 0 }
|
||||
print b, f, h, n
|
||||
}
|
||||
}
|
||||
' "$work/manifest" | sort > "$work/cache"
|
||||
mkdir -p "$cache"
|
||||
total=$(grep -c . "$work/cache" 2>/dev/null || echo 0)
|
||||
total_bytes=$(awk '{ n += $4 } END { print n + 0 }' "$work/cache")
|
||||
done_bytes=0
|
||||
i=0
|
||||
while read -r block file sum size; do
|
||||
i=$((i + 1))
|
||||
progress "$cache/$file" "$block"
|
||||
fetched=""
|
||||
for host in "${cdn_order[@]}"; do
|
||||
if fetch "$host/$file" "$cache/$file" "$size" "$sum" "$block"; then
|
||||
fetched=$host
|
||||
break
|
||||
fi
|
||||
done
|
||||
[ -n "$fetched" ] || { echo "droiddeck-steam-install: $file failed on every CDN" >&2; exit 1; }
|
||||
done_bytes=$((done_bytes + size))
|
||||
done < "$work/cache"
|
||||
echo "$version" > "$cached"
|
||||
exit 0
|
||||
fi
|
||||
if [ -n "$sync" ]; then
|
||||
installed=$(awk -F'"' '$2 == "version" { print $4; exit }' "$steam_root/package/$manifest.manifest" 2>/dev/null || true)
|
||||
if [ -x "$steam_root/steamrtarm64/steam" ] && [ "$installed" = "$version" ]; then
|
||||
|
||||
@@ -314,6 +314,46 @@ done(28 if end < len(data) else 0)
|
||||
def download(self):
|
||||
return self.steam / 'package/droiddeck-download'
|
||||
|
||||
def cache_manifest(self):
|
||||
plain = b'plain-package'
|
||||
packed = b'packed-package'
|
||||
(self.cdn / 'a.zip.1111').write_bytes(plain)
|
||||
(self.cdn / 'b.zip.vz.2222_14').write_bytes(packed)
|
||||
(self.cdn / 'steam_client_steamdeck_publicbeta_linuxarm64').write_text(
|
||||
'"linuxarm64"\n{\n\t"version" "123456"\n'
|
||||
'\t"a_all"\n\t{\n'
|
||||
f'\t\t"file" "a.zip.1111"\n\t\t"size" "{len(plain)}"\n\t\t"sha2" "{hashlib.sha256(plain).hexdigest()}"\n'
|
||||
'\t}\n'
|
||||
'\t"b_all"\n\t{\n'
|
||||
'\t\t"file" "b.zip.9999"\n\t\t"size" "99"\n\t\t"sha2" "00"\n'
|
||||
'\t\t"zipvz" "b.zip.vz.2222_14"\n'
|
||||
f'\t\t"sha2vz" "{hashlib.sha256(packed).hexdigest()}"\n'
|
||||
'\t}\n}\n')
|
||||
|
||||
def test_the_cache_pass_keeps_every_package_under_the_names_steam_looks_for(self):
|
||||
self.cache_manifest()
|
||||
result = self.install(None, '--cache')
|
||||
self.assertEqual(0, result.returncode, result.stderr)
|
||||
package = self.steam / 'package'
|
||||
self.assertEqual(b'plain-package', (package / 'a.zip.1111').read_bytes())
|
||||
self.assertEqual(b'packed-package', (package / 'b.zip.vz.2222_14').read_bytes())
|
||||
self.assertFalse((package / 'b.zip.9999').exists())
|
||||
self.assertEqual('123456\n', (package / 'droiddeck-cached').read_text())
|
||||
|
||||
def test_the_cache_pass_is_not_repeated_for_the_same_client_version(self):
|
||||
self.cache_manifest()
|
||||
self.assertEqual(0, self.install(None, '--cache').returncode)
|
||||
requests = len(self.requests.read_text().splitlines())
|
||||
self.assertEqual(0, self.install(None, '--cache').returncode)
|
||||
self.assertEqual(requests + 1, len(self.requests.read_text().splitlines()))
|
||||
|
||||
def test_a_cached_package_is_not_fetched_again(self):
|
||||
self.cache_manifest()
|
||||
(self.steam / 'package').mkdir(parents=True)
|
||||
(self.steam / 'package/a.zip.1111').write_bytes(b'plain-package')
|
||||
self.assertEqual(0, self.install(None, '--cache').returncode)
|
||||
self.assertNotIn('a.zip.1111', self.requests.read_text())
|
||||
|
||||
def test_progress_is_counted_in_megabytes_across_parts(self):
|
||||
self.two_parts()
|
||||
result = self.install()
|
||||
|
||||
Reference in new issue
Block a user