diff --git a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility index 4eb7ba26f7..6c861fcca2 100755 --- a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility +++ b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility @@ -984,10 +984,15 @@ def valve_picks(steam_root): return sorted(picks, key=int) +def launch_platforms(entry): + return {part.strip() for option in entry.get("launch_options", ()) + for part in option["oslist"].split(",") if part.strip()} + + def tool_platforms(steam_root): entries = appinfo_entries(os.path.join(steam_root, "appcache", "appinfo.vdf")) - return {app: entry["oslist"] for app, entry in entries.items() - if entry["type"] == "tool" and entry["oslist"] & {"linux", "windows"}} + platforms = {app: entry["oslist"] | launch_platforms(entry) for app, entry in entries.items() if entry["type"] == "tool"} + return {app: found for app, found in platforms.items() if found & {"linux", "windows"}} def native_targets(steam_root, apps): @@ -1227,8 +1232,11 @@ def plan_mapping(current, installed, runnable, default, auto, native=None, picks changes["0"] = default for app in sorted((set(current) | installed | picks | set(auto) | set(overrides) | native_choices | set(tools)) - {"0"}, key=app_order): name = current.get(app, "") - if app in tools and "linux" in tools[app] and "windows" not in tools[app]: - if name and (name.lower() in runnable or "proton" in name.lower()): + if app in tools and "linux" in tools[app]: + if "windows" in tools[app]: + if name and name == auto.get(app): + changes[app] = None + elif name and (name.lower() in runnable or "proton" in name.lower()): changes[app] = None continue if app in overrides: diff --git a/tools/tests/test_steam_tool_platforms.py b/tools/tests/test_steam_tool_platforms.py index 5eddeb3cee..e2bb2218f8 100644 --- a/tools/tests/test_steam_tool_platforms.py +++ b/tools/tests/test_steam_tool_platforms.py @@ -73,6 +73,38 @@ class ToolPlatformsTest(unittest.TestCase): self.assertEqual(auto["900001"], TOOL) self.assertEqual(auto["976730"], TOOL) + def add_launch_only_linux_tool(self): + self.entries[900007] = {"common": {"type": "Tool", "oslist": "windows"}, "config": {"launch": { + "0": {"executable": "bin\\win64\\start.exe", "config": {"oslist": "windows"}}, + "1": {"executable": "bin\\start.sh", "config": {"oslist": "linux", "osarch": "64"}}, + }}} + self.write_appinfo() + + def test_linux_launch_entry_counts_as_a_linux_platform(self): + self.add_launch_only_linux_tool() + self.assertEqual(self.platforms()["900007"], {"windows", "linux"}) + self.assertEqual(self.platforms()["900001"], {"windows"}) + + def test_tool_with_a_linux_build_is_not_given_proton_before_install(self): + self.add_launch_only_linux_tool() + changes, auto = self.plan({"0": TOOL}) + self.assertNotIn("900007", changes) + self.assertNotIn("900007", auto) + self.assertEqual(changes["900001"], TOOL) + + def test_own_proton_mapping_on_a_tool_with_a_linux_build_is_cleared(self): + self.add_launch_only_linux_tool() + changes, auto = self.plan({"0": TOOL, "900007": TOOL}, {"900007": TOOL}) + self.assertIsNone(changes["900007"]) + self.assertNotIn("900007", auto) + + def test_user_selection_on_a_tool_with_a_linux_build_survives(self): + self.add_launch_only_linux_tool() + for name in (TOOL, "custom-windows"): + with self.subTest(name=name): + changes, auto = self.plan({"0": TOOL, "900007": name}, {"976730": TOOL}) + self.assertNotIn("900007", changes) + def test_removed_ge_proton_is_cleared_with_or_without_saved_ownership(self): for saved in ({}, {"1826330": "GE-Proton11-7"}): with self.subTest(saved=saved):