Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68fb659cb9 |
No files matched your search
@@ -1149,6 +1149,7 @@ case $mode in
|
||||
droiddeck-steam-library "$steam_root" || true
|
||||
step "setting up the ARM64 Proton compatibility tool"
|
||||
steam-compatibility "$steam_root" || true
|
||||
steam-compatibility "$steam_root" --seed-arm64-tools || true
|
||||
if [ -z "${DD_DESKTOP:-}" ] && [ "${DD_STEAM_UI:-}" != desktop ]; then
|
||||
droiddeck-steam-ui-scale "$steam_root" "${DD_WIDTH:-1280}" "${DD_HEIGHT:-720}" || true
|
||||
fi
|
||||
|
||||
@@ -26,6 +26,8 @@ SNIPER_APPID = "1628350"
|
||||
SLR4_APPID = "4183110"
|
||||
FEX_DEPENDENCIES = (FEX_APPID, SNIPER_APPID, SLR4_APPID)
|
||||
REQUIRED_TOOLS = (PROTON_ARM64_APPID,) + FEX_DEPENDENCIES
|
||||
ARM64_TOOL_DEPENDENCIES = (("1826330", "Proton EasyAntiCheat Runtime"),
|
||||
("1070560", "Steam Linux Runtime 1.0 (scout)"))
|
||||
# "0" = the app's "Valve Proton only when needed": Valve's ARM64 Proton is fetched only for a title or
|
||||
# default set to a tool built from it, or while no own Proton build is installed.
|
||||
VALVE_PROTON_ENV = "DD_VALVE_PROTON"
|
||||
@@ -1012,10 +1014,15 @@ def manifest_text(appid, name, installdir, bare=False):
|
||||
return text[:-2] + ' "AutoUpdateBehavior" "1"\n}\n' if bare else text
|
||||
|
||||
|
||||
def app_manifest(steam_root, app):
|
||||
def manifest_paths(steam_root, app):
|
||||
for library in libraries(steam_root):
|
||||
yield os.path.join(library, "steamapps", "appmanifest_%s.acf" % app)
|
||||
|
||||
|
||||
def app_manifest(steam_root, app):
|
||||
for path in manifest_paths(steam_root, app):
|
||||
try:
|
||||
with open(os.path.join(library, "steamapps", "appmanifest_%s.acf" % app), encoding="utf-8", errors="replace") as f:
|
||||
with open(path, encoding="utf-8", errors="replace") as f:
|
||||
return tokenize(f.read())
|
||||
except OSError:
|
||||
continue
|
||||
@@ -1030,6 +1037,42 @@ def manifest_flags(tokens):
|
||||
return 0
|
||||
|
||||
|
||||
def seed_unavailable_arm64_tools(steam_root):
|
||||
entries = appinfo_entries(os.path.join(steam_root, "appcache", "appinfo.vdf"),
|
||||
[app for app, _ in ARM64_TOOL_DEPENDENCIES])
|
||||
steamapps = os.path.join(steam_root, "steamapps")
|
||||
os.makedirs(steamapps, exist_ok=True)
|
||||
seeded = []
|
||||
for app, display in ARM64_TOOL_DEPENDENCIES:
|
||||
entry = entries.get(app)
|
||||
if entry is not None:
|
||||
if entry["type"] not in ("", "tool"):
|
||||
continue
|
||||
if "arm64" in entry["osarch"] or "aarch64" in entry["osarch"]:
|
||||
continue
|
||||
manifest = app_manifest(steam_root, app)
|
||||
if manifest is not None and manifest_flags(manifest) & FULLY_INSTALLED:
|
||||
continue
|
||||
name = (entry or {}).get("name") or display
|
||||
installdir = (entry or {}).get("installdir") or name
|
||||
path = next((p for p in manifest_paths(steam_root, app) if os.path.isfile(p)),
|
||||
os.path.join(steamapps, "appmanifest_%s.acf" % app))
|
||||
try:
|
||||
if manifest is None:
|
||||
with open(path, "x", encoding="utf-8") as f:
|
||||
f.write(manifest_text(app, name, installdir, True))
|
||||
else:
|
||||
temporary = path + ".droiddeck"
|
||||
with open(temporary, "w", encoding="utf-8") as f:
|
||||
f.write(manifest_text(app, name, installdir, True))
|
||||
os.replace(temporary, path)
|
||||
except OSError as e:
|
||||
print("steam-compatibility: could not mark %s installed (%s)" % (app, e))
|
||||
continue
|
||||
seeded.append(app)
|
||||
return seeded
|
||||
|
||||
|
||||
def valve_proton_on_demand():
|
||||
return os.environ.get(VALVE_PROTON_ENV) == "0"
|
||||
|
||||
@@ -1801,6 +1844,11 @@ def main():
|
||||
steam_root = sys.argv[1]
|
||||
if "--valve-proton-needed" in sys.argv[2:]:
|
||||
sys.exit(0 if valve_proton_needed(steam_root) else 1)
|
||||
if "--seed-arm64-tools" in sys.argv[2:]:
|
||||
seeded = seed_unavailable_arm64_tools(steam_root)
|
||||
if seeded:
|
||||
print("steam-compatibility: marked unavailable ARM64 tool(s) installed: %s" % ", ".join(seeded))
|
||||
return
|
||||
if "--x64" in sys.argv[2:]:
|
||||
x64_repoint(steam_root, os.environ.get("DD_COMPAT_TOOL"), "--live" in sys.argv[2:])
|
||||
return
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
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_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()
|
||||
Reference in new issue
Block a user