mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
fix: a failed Steam client download ends the session with a message instead of silently (#997)
This commit is contained in:
1 parent
152b961940
commit
abeaf7ccb6
38 files changed
+267
-9
No files matched your search
@@ -4,6 +4,11 @@ export HOME=${HOME:-/root}
|
||||
mode=${1:-desktop}
|
||||
shift || true
|
||||
step() { echo "== STEP $(date -u +%H:%M:%S) $*"; }
|
||||
steam_setup_failed() {
|
||||
echo "== steam: the Steam client could not be set up (status $1)"
|
||||
[ -z "${BL_STEAM_EXIT_FILE:-}" ] || printf '%s\n' "$1" > "$BL_STEAM_EXIT_FILE"
|
||||
exit "$1"
|
||||
}
|
||||
if [ -n "${BL_LOG:-}" ] && [ -z "${BL_INSIDE:-}" ]; then
|
||||
mkdir -p "$(dirname "$BL_LOG")" 2>/dev/null
|
||||
if [ "$(stat -c %s "$BL_LOG" 2>/dev/null || echo 0)" -gt 8388608 ]; then
|
||||
@@ -361,10 +366,10 @@ case $mode in
|
||||
# droiddeck-steam-install removes the repair request: read it first so Repair Steam covers both clients.
|
||||
_bl_x64_repair=0
|
||||
[ -e "$HOME/.bl-steam-repair" ] && _bl_x64_repair=1
|
||||
droiddeck-steam-install || exit $?
|
||||
droiddeck-steam-install || steam_setup_failed $?
|
||||
droiddeck-steam-install --sync steamdeck_publicbeta || step "could not update the arm64 client's parts; the x86-64 client keeps its own web helper"
|
||||
step "checking the x86-64 Steam client (FEX, experimental; the first run downloads ~2 GB)"
|
||||
BL_X64_REPAIR=$_bl_x64_repair droiddeck-steam-x64 --prepare || exit $?
|
||||
BL_X64_REPAIR=$_bl_x64_repair droiddeck-steam-x64 --prepare || steam_setup_failed $?
|
||||
step "x86-64 Steam client ready"
|
||||
steam_root=${BL_X64_HOME:-$HOME/.droiddeck-x64}/.local/share/Steam
|
||||
steam_client=(droiddeck-steam-x64 --exec)
|
||||
@@ -374,7 +379,7 @@ case $mode in
|
||||
fi
|
||||
else
|
||||
step "checking the Steam client (first run downloads it, ~1-2 min with nothing on screen)"
|
||||
droiddeck-steam-install || exit $?
|
||||
droiddeck-steam-install || steam_setup_failed $?
|
||||
step "Steam client ready"
|
||||
steam_root=$XDG_DATA_HOME/Steam
|
||||
if [ -f "${BL_X64_HOME:-$HOME/.droiddeck-x64}/.local/share/Steam/local.vdf" ]; then
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import tempfile
|
||||
import textwrap
|
||||
import unittest
|
||||
|
||||
|
||||
SESSION = Path(__file__).resolve().parents[1] / 'linuxfs/overlay/usr/local/bin/droiddeck-session'
|
||||
SOURCE = SESSION.read_text()
|
||||
ARM64_BRANCH = SOURCE.index(' else\n step "checking the Steam client (first run')
|
||||
START = SOURCE.index(' droiddeck-steam-install || steam_setup_failed $?\n', ARM64_BRANCH)
|
||||
END = SOURCE.index(' step "Steam client ready"\n', START)
|
||||
HELPER = re.search(r'^steam_setup_failed\(\) \{\n.*?^\}\n', SOURCE, re.M | re.S).group()
|
||||
INSTALL_BLOCK = HELPER + textwrap.dedent(SOURCE[START:END])
|
||||
RUN_GAMESCOPE = re.search(r'^run_gamescope\(\) \(\n.*?^\)\n', SOURCE, re.M | re.S).group()
|
||||
MARKER = '== steam: the Steam client could not be set up'
|
||||
|
||||
|
||||
class SteamClientSetupFailureTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.temp.cleanup)
|
||||
self.root = Path(self.temp.name)
|
||||
|
||||
def installer(self, status):
|
||||
script = self.root / 'droiddeck-steam-install'
|
||||
script.write_text('#!/bin/bash\n'
|
||||
'echo "curl: (35) Recv failure: Connection reset by peer" >&2\n'
|
||||
'exit ' + str(status) + '\n')
|
||||
script.chmod(0o755)
|
||||
|
||||
def env(self, **extra):
|
||||
base = {k: v for k, v in os.environ.items() if k != 'BL_STEAM_EXIT_FILE'}
|
||||
return dict(base, PATH=str(self.root) + os.pathsep + os.environ['PATH'],
|
||||
XDG_RUNTIME_DIR=str(self.root), **extra)
|
||||
|
||||
def run_block(self, status, exit_file=None):
|
||||
self.installer(status)
|
||||
extra = {'BL_STEAM_EXIT_FILE': str(exit_file)} if exit_file else {}
|
||||
return subprocess.run(['bash', '-c', INSTALL_BLOCK + 'echo continued\n'], env=self.env(**extra),
|
||||
capture_output=True, text=True, timeout=10)
|
||||
|
||||
def test_failed_install_reports_its_status_in_the_exit_file(self):
|
||||
exit_file = self.root / 'exit'
|
||||
result = self.run_block(1, exit_file)
|
||||
self.assertEqual(1, result.returncode)
|
||||
self.assertIn(MARKER + ' (status 1)', result.stdout)
|
||||
self.assertNotIn('continued', result.stdout)
|
||||
self.assertEqual('1\n', exit_file.read_text())
|
||||
|
||||
def test_failed_install_outside_gamescope_still_exits_with_its_status(self):
|
||||
result = self.run_block(50)
|
||||
self.assertEqual(50, result.returncode)
|
||||
self.assertIn(MARKER + ' (status 50)', result.stdout)
|
||||
|
||||
def test_ready_client_continues_without_a_report(self):
|
||||
exit_file = self.root / 'exit'
|
||||
result = self.run_block(0, exit_file)
|
||||
self.assertEqual(0, result.returncode)
|
||||
self.assertIn('continued', result.stdout)
|
||||
self.assertNotIn(MARKER, result.stdout)
|
||||
self.assertFalse(exit_file.exists())
|
||||
|
||||
def test_failed_install_survives_successful_compositor_shutdown(self):
|
||||
self.installer(1)
|
||||
compositor = self.root / 'gamescope'
|
||||
compositor.write_text('#!/bin/bash\n"$@"\nexit 0\n')
|
||||
compositor.chmod(0o755)
|
||||
child = self.root / 'session-child'
|
||||
child.write_text('#!/bin/bash\n' + INSTALL_BLOCK + 'exit 0\n')
|
||||
child.chmod(0o755)
|
||||
result = subprocess.run(['bash', '-c', RUN_GAMESCOPE + '\nrun_gamescope "$@"', 'session', str(child)],
|
||||
env=self.env(), capture_output=True, text=True, timeout=10)
|
||||
self.assertEqual(1, result.returncode)
|
||||
self.assertIn(MARKER, result.stdout)
|
||||
self.assertEqual(list(self.root.glob('droiddeck-steam-exit.??????')), [])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user