mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 20:45:43 +00:00
* fix(steam): mark ARM64-uninstallable tool dependencies installed The ARM64 client cannot install Proton EasyAntiCheat Runtime (1826330), which it refuses as an invalid platform, or that tool's Steam Linux Runtime 1.0 (scout) dependency (1070560), which has no ARM64 depot. After the EULA hand-off the client starts the dependency install and aborts in glibc's smallbin check. Write the bare installed manifest DroidDeck already uses for adopted games for those two tools before the client starts: only on the ARM64 client, only when appinfo shows no ARM64 depot, and never over a fully installed manifest. Refs: ValveSoftware/steam-for-linux#13937, DroidDeck #2313 * fix(steam): seed a tool only when no library has it installed, and write manifests atomically A partial manifest in the first library no longer hides a full install in another one, and a failed write leaves no truncated or stray manifest. * fix(steam): publish tool manifests without replacing concurrent installs
206 lines
9.5 KiB
Python
206 lines
9.5 KiB
Python
import runpy
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest import mock
|
|
|
|
from tools.tests.test_droiddeck_fex import AppInfoTest
|
|
|
|
BIN = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin"
|
|
SESSION = BIN / "droiddeck-session"
|
|
COMPAT = runpy.run_path(str(BIN / "steam-compatibility"))
|
|
EAC = 1826330
|
|
SCOUT = 1070560
|
|
EAC_ID = str(EAC)
|
|
SCOUT_ID = str(SCOUT)
|
|
EAC_NAME = "Proton EasyAntiCheat Runtime"
|
|
SCOUT_NAME = "Steam Linux Runtime 1.0 (scout)"
|
|
|
|
|
|
def tool(name, osarch="", kind="tool", installdir=None):
|
|
return {
|
|
"common": {"name": name, "oslist": "linux", "osarch": osarch, "type": kind},
|
|
"config": {"installdir": installdir or name},
|
|
}
|
|
|
|
|
|
class SteamToolManifestSeedTest(unittest.TestCase):
|
|
def setUp(self):
|
|
temporary = tempfile.TemporaryDirectory()
|
|
self.addCleanup(temporary.cleanup)
|
|
self.root = Path(temporary.name)
|
|
self.steam = self.root / "Steam"
|
|
(self.steam / "appcache").mkdir(parents=True)
|
|
(self.steam / "steamapps").mkdir()
|
|
self.entries = {EAC: tool(EAC_NAME), SCOUT: tool(SCOUT_NAME)}
|
|
self.write_appinfo()
|
|
|
|
def write_appinfo(self, entries=None):
|
|
COMPAT["APPINFO_CACHE"].clear()
|
|
(self.steam / "appcache/appinfo.vdf").write_bytes(
|
|
AppInfoTest.appinfo(self.entries if entries is None else entries))
|
|
|
|
def manifest(self, app, root=None):
|
|
return (root or self.steam) / ("steamapps/appmanifest_%s.acf" % app)
|
|
|
|
def seed(self):
|
|
return COMPAT["seed_unavailable_arm64_tools"](str(self.steam))
|
|
|
|
def test_seeds_bare_manifests_for_unavailable_tool_dependencies(self):
|
|
self.assertEqual(self.seed(), [EAC_ID, SCOUT_ID])
|
|
for app, name in ((EAC_ID, EAC_NAME), (SCOUT_ID, SCOUT_NAME)):
|
|
text = self.manifest(app).read_text()
|
|
for expected in ('"appid" "%s"' % app, '"Universe" "1"', '"StateFlags" "4"',
|
|
'"name" "%s"' % name, '"installdir" "%s"' % name,
|
|
'"AutoUpdateBehavior" "1"'):
|
|
self.assertIn(expected, text)
|
|
self.assertFalse(self.manifest("976730").exists())
|
|
|
|
def test_seeding_is_idempotent(self):
|
|
self.seed()
|
|
first = {app: self.manifest(app).read_text() for app in (EAC_ID, SCOUT_ID)}
|
|
self.assertEqual(self.seed(), [])
|
|
self.assertEqual({app: self.manifest(app).read_text() for app in first}, first)
|
|
|
|
def test_a_real_install_in_another_library_is_never_overwritten(self):
|
|
other = self.root / "SD"
|
|
(other / "steamapps").mkdir(parents=True)
|
|
existing = '"AppState"\n{\n\t"appid"\t"%s"\n\t"StateFlags"\t"4"\n}\n' % SCOUT_ID
|
|
(other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).write_text(existing)
|
|
(self.steam / "steamapps/libraryfolders.vdf").write_text(
|
|
'"libraryfolders"\n{\n\t"0"\n\t{\n\t\t"path"\t\t"%s"\n\t}\n}\n' % other)
|
|
self.assertEqual(self.seed(), [EAC_ID])
|
|
self.assertFalse(self.manifest(SCOUT_ID).exists())
|
|
self.assertEqual((other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).read_text(), existing)
|
|
|
|
def test_a_partial_install_in_another_library_is_completed_in_place(self):
|
|
other = self.root / "SD"
|
|
(other / "steamapps").mkdir(parents=True)
|
|
partial = '"AppState"\n{\n\t"appid"\t"%s"\n\t"StateFlags"\t"2"\n}\n' % SCOUT_ID
|
|
(other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).write_text(partial)
|
|
(self.steam / "steamapps/libraryfolders.vdf").write_text(
|
|
'"libraryfolders"\n{\n\t"0"\n\t{\n\t\t"path"\t\t"%s"\n\t}\n}\n' % other)
|
|
self.assertEqual(self.seed(), [EAC_ID, SCOUT_ID])
|
|
self.assertFalse(self.manifest(SCOUT_ID).exists())
|
|
self.assertIn('"StateFlags" "4"',
|
|
(other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).read_text())
|
|
|
|
def test_a_real_install_in_any_library_wins_over_a_partial_one(self):
|
|
other = self.root / "SD"
|
|
(other / "steamapps").mkdir(parents=True)
|
|
partial = '"AppState"\n{\n\t"appid"\t"%s"\n\t"StateFlags"\t"2"\n}\n' % SCOUT_ID
|
|
installed = '"AppState"\n{\n\t"appid"\t"%s"\n\t"StateFlags"\t"4"\n}\n' % SCOUT_ID
|
|
self.manifest(SCOUT_ID).write_text(partial)
|
|
(other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).write_text(installed)
|
|
(self.steam / "steamapps/libraryfolders.vdf").write_text(
|
|
'"libraryfolders"\n{\n\t"0"\n\t{\n\t\t"path"\t\t"%s"\n\t}\n}\n' % other)
|
|
self.assertEqual(self.seed(), [EAC_ID])
|
|
self.assertEqual(self.manifest(SCOUT_ID).read_text(), partial)
|
|
self.assertEqual((other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).read_text(), installed)
|
|
|
|
def test_a_failed_write_leaves_no_manifest_behind(self):
|
|
real_link = COMPAT["os"].link
|
|
|
|
def fail_for_scout(source, target):
|
|
if SCOUT_ID in str(target):
|
|
raise OSError("disk full")
|
|
return real_link(source, target)
|
|
|
|
with mock.patch.object(COMPAT["os"], "link", side_effect=fail_for_scout):
|
|
self.assertEqual(self.seed(), [EAC_ID])
|
|
self.assertFalse(self.manifest(SCOUT_ID).exists())
|
|
self.assertEqual(sorted(p.name for p in (self.steam / "steamapps").iterdir()),
|
|
["appmanifest_%s.acf" % EAC_ID])
|
|
self.assertEqual(self.seed(), [SCOUT_ID])
|
|
self.assertEqual(self.manifest(SCOUT_ID).read_text(),
|
|
COMPAT["manifest_text"](SCOUT_ID, SCOUT_NAME, SCOUT_NAME, True))
|
|
|
|
def test_new_manifest_publication_preserves_a_concurrent_install(self):
|
|
real_link = COMPAT["os"].link
|
|
installed = COMPAT["manifest_text"](SCOUT_ID, "Existing tool", "Existing", False)
|
|
|
|
def publish(source, target):
|
|
if SCOUT_ID in str(target):
|
|
Path(target).write_text(installed)
|
|
return real_link(source, target)
|
|
|
|
with mock.patch.object(COMPAT["os"], "link", side_effect=publish):
|
|
self.assertEqual(self.seed(), [EAC_ID])
|
|
self.assertEqual(self.manifest(SCOUT_ID).read_text(), installed)
|
|
self.assertEqual(self.seed(), [])
|
|
self.assertFalse(list((self.steam / "steamapps").glob(".appmanifest_*")))
|
|
|
|
def test_partial_staged_write_is_not_published_and_retry_repairs(self):
|
|
real_temporary = COMPAT["tempfile"].NamedTemporaryFile
|
|
|
|
def temporary(*args, **kwargs):
|
|
output = real_temporary(*args, **kwargs)
|
|
real_write = output.write
|
|
|
|
def write(text):
|
|
if SCOUT_ID in text:
|
|
real_write(text[:text.index(' "installdir"')])
|
|
output.flush()
|
|
raise OSError("disk full")
|
|
return real_write(text)
|
|
|
|
output.write = write
|
|
return output
|
|
|
|
with mock.patch.object(COMPAT["tempfile"], "NamedTemporaryFile", side_effect=temporary):
|
|
self.assertEqual(self.seed(), [EAC_ID])
|
|
self.assertFalse(self.manifest(SCOUT_ID).exists())
|
|
self.assertFalse(list((self.steam / "steamapps").glob(".appmanifest_*")))
|
|
self.assertEqual(self.seed(), [SCOUT_ID])
|
|
self.assertEqual(self.manifest(SCOUT_ID).read_text(),
|
|
COMPAT["manifest_text"](SCOUT_ID, SCOUT_NAME, SCOUT_NAME, True))
|
|
|
|
def test_failed_replacement_preserves_partial_manifest_and_retry_repairs(self):
|
|
partial = '"AppState" { "appid" "%s" "StateFlags" "2" }' % SCOUT_ID
|
|
self.manifest(SCOUT_ID).write_text(partial)
|
|
with mock.patch.object(COMPAT["os"], "replace", side_effect=OSError("disk full")):
|
|
self.assertEqual(self.seed(), [EAC_ID])
|
|
self.assertEqual(self.manifest(SCOUT_ID).read_text(), partial)
|
|
self.assertFalse(list((self.steam / "steamapps").glob(".appmanifest_*")))
|
|
self.assertEqual(self.seed(), [SCOUT_ID])
|
|
self.assertEqual(self.manifest(SCOUT_ID).read_text(),
|
|
COMPAT["manifest_text"](SCOUT_ID, SCOUT_NAME, SCOUT_NAME, True))
|
|
|
|
def test_tools_with_an_arm64_depot_are_skipped(self):
|
|
entries = dict(self.entries)
|
|
entries[SCOUT] = tool(SCOUT_NAME, osarch="arm64")
|
|
self.write_appinfo(entries)
|
|
self.assertEqual(self.seed(), [EAC_ID])
|
|
self.assertFalse(self.manifest(SCOUT_ID).exists())
|
|
|
|
def test_an_app_that_is_not_a_tool_is_skipped(self):
|
|
entries = dict(self.entries)
|
|
entries[SCOUT] = tool(SCOUT_NAME, kind="game")
|
|
self.write_appinfo(entries)
|
|
self.assertEqual(self.seed(), [EAC_ID])
|
|
self.assertFalse(self.manifest(SCOUT_ID).exists())
|
|
|
|
def test_missing_appinfo_uses_the_display_names(self):
|
|
(self.steam / "appcache/appinfo.vdf").unlink()
|
|
COMPAT["APPINFO_CACHE"].clear()
|
|
self.assertEqual(self.seed(), [EAC_ID, SCOUT_ID])
|
|
self.assertIn('"name" "%s"' % SCOUT_NAME, self.manifest(SCOUT_ID).read_text())
|
|
|
|
def test_flag_seeds_without_running_full_compatibility_setup(self):
|
|
with mock.patch.object(COMPAT["sys"], "argv",
|
|
["steam-compatibility", str(self.steam), "--seed-arm64-tools"]):
|
|
COMPAT["main"]()
|
|
self.assertTrue(self.manifest(EAC_ID).is_file())
|
|
self.assertTrue(self.manifest(SCOUT_ID).is_file())
|
|
self.assertFalse((self.steam / "compatibilitytools.d").exists())
|
|
|
|
def test_session_seeds_only_on_the_arm64_client_path(self):
|
|
arm64, x64 = SESSION.read_text().split(
|
|
" else\n _dd_x64_tool=$(droiddeck-steam-x64 --default-tool)", 1)
|
|
self.assertIn('steam-compatibility "$steam_root" --seed-arm64-tools', arm64)
|
|
self.assertNotIn("--seed-arm64-tools", x64)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|