python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / tools / package-management / protontricks / steam-run.patch
blob92565f88fdd036e17463c74a5c77997f293e0e27
1 diff --git a/src/protontricks/cli/main.py b/src/protontricks/cli/main.py
2 index 8be6c71..f5772df 100755
3 --- a/src/protontricks/cli/main.py
4 +++ b/src/protontricks/cli/main.py
5 @@ -14,8 +14,8 @@ import sys
7 from .. import __version__
8 from ..gui import select_steam_app_with_gui
9 -from ..steam import (find_legacy_steam_runtime_path, find_proton_app,
10 - find_steam_path, get_steam_apps, get_steam_lib_paths)
11 +from ..steam import (find_proton_app, find_steam_path, get_steam_apps,
12 + get_steam_lib_paths)
13 from ..util import get_running_flatpak_version, FLATPAK_BWRAP_COMPATIBLE_VERSION, run_command
14 from ..winetricks import get_winetricks_path
15 from .util import (CustomArgumentParser, cli_error_handler, enable_logging,
16 @@ -60,8 +60,7 @@ def main(args=None):
17 "WINE: path to a custom 'wine' executable\n"
18 "WINESERVER: path to a custom 'wineserver' executable\n"
19 "STEAM_RUNTIME: 1 = enable Steam Runtime, 0 = disable Steam "
20 - "Runtime, valid path = custom Steam Runtime path, "
21 - "empty = enable automatically (default)\n"
22 + "Runtime, empty = enable automatically (default)\n"
23 "PROTONTRICKS_GUI: GUI provider to use, accepts either 'yad' "
24 "or 'zenity'"
26 @@ -151,17 +150,9 @@ def main(args=None):
27 if not steam_path:
28 exit_("Steam installation directory could not be found.")
30 - # 2. Find the pre-installed legacy Steam Runtime if enabled
31 - legacy_steam_runtime_path = None
32 - use_steam_runtime = True
34 + # 2. Use Steam Runtime if enabled
35 if os.environ.get("STEAM_RUNTIME", "") != "0" and not args.no_runtime:
36 - legacy_steam_runtime_path = find_legacy_steam_runtime_path(
37 - steam_root=steam_root
38 - )
40 - if not legacy_steam_runtime_path:
41 - exit_("Steam Runtime was enabled but couldn't be found!")
42 + use_steam_runtime = True
43 else:
44 use_steam_runtime = False
45 logger.info("Steam Runtime disabled.")
46 @@ -222,7 +213,6 @@ def main(args=None):
47 proton_app=proton_app,
48 steam_app=steam_app,
49 use_steam_runtime=use_steam_runtime,
50 - legacy_steam_runtime_path=legacy_steam_runtime_path,
51 command=[str(winetricks_path), "--gui"],
52 use_bwrap=use_bwrap
54 @@ -290,7 +280,6 @@ def main(args=None):
55 proton_app=proton_app,
56 steam_app=steam_app,
57 use_steam_runtime=use_steam_runtime,
58 - legacy_steam_runtime_path=legacy_steam_runtime_path,
59 use_bwrap=use_bwrap,
60 command=[str(winetricks_path)] + args.winetricks_command
62 @@ -301,7 +290,6 @@ def main(args=None):
63 steam_app=steam_app,
64 command=args.command,
65 use_steam_runtime=use_steam_runtime,
66 - legacy_steam_runtime_path=legacy_steam_runtime_path,
67 use_bwrap=use_bwrap,
68 # Pass the command directly into the shell *without*
69 # escaping it
70 diff --git a/src/protontricks/steam.py b/src/protontricks/steam.py
71 index a291762..8af06c5 100644
72 --- a/src/protontricks/steam.py
73 +++ b/src/protontricks/steam.py
74 @@ -12,8 +12,8 @@ from .util import lower_dict, is_flatpak_sandbox
76 __all__ = (
77 "COMMON_STEAM_DIRS", "SteamApp", "find_steam_path",
78 - "find_legacy_steam_runtime_path", "get_appinfo_sections",
79 - "get_tool_appid", "find_steam_compat_tool_app", "find_appid_proton_prefix",
80 + "get_appinfo_sections", "get_tool_appid",
81 + "find_steam_compat_tool_app", "find_appid_proton_prefix",
82 "find_proton_app", "get_steam_lib_paths", "get_compat_tool_dirs",
83 "get_custom_compat_tool_installations_in_dir", "get_custom_compat_tool_installations",
84 "find_current_steamid3", "get_appid_from_shortcut",
85 @@ -326,37 +326,6 @@ def find_steam_path():
86 return None, None
89 -def find_legacy_steam_runtime_path(steam_root):
90 - """
91 - Find the legacy Steam Runtime either using the STEAM_RUNTIME env or
92 - steam_root
93 - """
94 - env_steam_runtime = os.environ.get("STEAM_RUNTIME", "")
96 - if env_steam_runtime == "0":
97 - # User has disabled Steam Runtime
98 - logger.info("STEAM_RUNTIME is 0. Disabling Steam Runtime.")
99 - return None
100 - elif env_steam_runtime and Path(env_steam_runtime).is_dir():
101 - # User has a custom Steam Runtime
102 - logger.info(
103 - "Using custom Steam Runtime at %s", env_steam_runtime)
104 - return Path(env_steam_runtime)
105 - elif env_steam_runtime in ["1", ""]:
106 - # User has enabled Steam Runtime or doesn't have STEAM_RUNTIME set;
107 - # default to enabled Steam Runtime in either case
108 - steam_runtime_path = steam_root / "ubuntu12_32" / "steam-runtime"
110 - logger.info(
111 - "Using default Steam Runtime at %s", str(steam_runtime_path))
112 - return steam_runtime_path
114 - logger.error(
115 - "Path in STEAM_RUNTIME doesn't point to a valid Steam Runtime!")
117 - return None
120 APPINFO_STRUCT_HEADER = "<4sL"
121 APPINFO_STRUCT_SECTION = "<LLLLQ20sL"
123 diff --git a/src/protontricks/util.py b/src/protontricks/util.py
124 index cb531fd..9f35aba 100644
125 --- a/src/protontricks/util.py
126 +++ b/src/protontricks/util.py
127 @@ -5,13 +5,13 @@ import shlex
128 import shutil
129 import stat
130 from pathlib import Path
131 -from subprocess import PIPE, check_output, run
132 +from subprocess import PIPE, run
134 __all__ = (
135 "SUPPORTED_STEAM_RUNTIMES", "is_flatpak_sandbox",
136 "get_running_flatpak_version", "lower_dict",
137 - "get_legacy_runtime_library_paths", "get_host_library_paths",
138 - "RUNTIME_ROOT_GLOB_PATTERNS", "get_runtime_library_paths",
139 + "get_host_library_paths", "RUNTIME_ROOT_GLOB_PATTERNS",
140 + "get_runtime_library_paths",
141 "WINE_SCRIPT_RUNTIME_V1_TEMPLATE",
142 "WINE_SCRIPT_RUNTIME_V2_TEMPLATE",
143 "create_wine_bin_dir", "run_command"
144 @@ -81,24 +81,6 @@ def lower_dict(d):
145 return {k.lower(): _lower_value(v) for k, v in d.items()}
148 -def get_legacy_runtime_library_paths(legacy_steam_runtime_path, proton_app):
149 - """
150 - Get LD_LIBRARY_PATH value to use when running a command using Steam Runtime
151 - """
152 - steam_runtime_paths = check_output([
153 - str(legacy_steam_runtime_path / "run.sh"),
154 - "--print-steam-runtime-library-paths"
155 - ])
156 - steam_runtime_paths = str(steam_runtime_paths, "utf-8")
157 - # Add Proton installation directory first into LD_LIBRARY_PATH
158 - # so that libwine.so.1 is picked up correctly (see issue #3)
159 - return "".join([
160 - str(proton_app.proton_dist_path / "lib"), os.pathsep,
161 - str(proton_app.proton_dist_path / "lib64"), os.pathsep,
162 - steam_runtime_paths
163 - ])
166 def get_host_library_paths():
168 Get host library paths to use when creating the LD_LIBRARY_PATH environment
169 @@ -110,7 +92,7 @@ def get_host_library_paths():
170 # Since that command is unavailable with newer Steam Runtime releases,
171 # do it ourselves here.
172 result = run(
173 - ["/sbin/ldconfig", "-XNv"],
174 + ["steam-run", "ldconfig", "-XNv"],
175 check=True, stdout=PIPE, stderr=PIPE
177 lines = result.stdout.decode("utf-8").split("\n")
178 @@ -128,7 +110,7 @@ RUNTIME_ROOT_GLOB_PATTERNS = (
182 -def get_runtime_library_paths(proton_app, use_bwrap=True):
183 +def get_runtime_library_paths(proton_app, proton_app_only=True):
185 Get LD_LIBRARY_PATH value to use when running a command using Steam Runtime
187 @@ -151,7 +133,7 @@ def get_runtime_library_paths(proton_app, use_bwrap=True):
191 - if use_bwrap:
192 + if proton_app_only:
193 return "".join([
194 str(proton_app.proton_dist_path / "lib"), os.pathsep,
195 str(proton_app.proton_dist_path / "lib64"), os.pathsep
196 @@ -167,14 +149,19 @@ def get_runtime_library_paths(proton_app, use_bwrap=True):
200 -WINE_SCRIPT_RUNTIME_V1_TEMPLATE = (
201 - "#!/bin/bash\n"
202 - "# Helper script created by Protontricks to run Wine binaries using Steam Runtime\n"
203 - "export LD_LIBRARY_PATH=\"$PROTON_LD_LIBRARY_PATH\"\n"
204 - "exec \"$PROTON_DIST_PATH\"/bin/{name} \"$@\""
206 +# Add Proton installation directory first into LD_LIBRARY_PATH
207 +# so that libwine.so.1 is picked up correctly (see issue #3)
208 +WINE_SCRIPT_RUNTIME_V1_TEMPLATE = """#!/usr/bin/env -S steam-run bash
209 +# Helper script created by Protontricks to run Wine binaries using Steam Runtime
210 +export LD_LIBRARY_PATH="$PROTON_LD_LIBRARY_PATH":"$LD_LIBRARY_PATH"
211 +exec "$PROTON_DIST_PATH"/bin/{name} "$@"
212 +"""
214 -WINE_SCRIPT_RUNTIME_V2_TEMPLATE = """#!/bin/bash
215 +# The run script calls pressure-vessel-unruntime which will unset
216 +# LD_LIBRARY_PATH defined by steam-run. This will cause Pressure
217 +# Vessel to segfault, so just call pressure-vessel-wrap directly
218 +# instead.
219 +WINE_SCRIPT_RUNTIME_V2_TEMPLATE = """#!/usr/bin/env bash
220 # Helper script created by Protontricks to run Wine binaries using Steam Runtime
221 set -o errexit
223 @@ -242,7 +229,9 @@ if [[ -n "$PROTONTRICKS_INSIDE_STEAM_RUNTIME" ]]; then
224 export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$PROTON_LD_LIBRARY_PATH"
225 "$PROTON_DIST_PATH"/bin/{name} "$@"
226 else
227 - exec "$STEAM_RUNTIME_PATH"/run --share-pid --batch \
228 + exec steam-run "$STEAM_RUNTIME_PATH"/pressure-vessel/bin/pressure-vessel-wrap \
229 + --variable-dir="${{PRESSURE_VESSEL_VARIABLE_DIR:-$STEAM_RUNTIME_PATH/var}}" \
230 + --share-pid --batch \
231 "${{mount_params[@]}}" -- \
232 env PROTONTRICKS_INSIDE_STEAM_RUNTIME=1 \
233 "$PROTONTRICKS_PROXY_SCRIPT_PATH" "$@"
234 @@ -308,7 +297,6 @@ def create_wine_bin_dir(proton_app, use_bwrap=True):
235 def run_command(
236 winetricks_path, proton_app, steam_app, command,
237 use_steam_runtime=False,
238 - legacy_steam_runtime_path=None,
239 use_bwrap=True,
240 **kwargs):
241 """Run an arbitrary command with the correct environment variables
242 @@ -387,7 +375,7 @@ def run_command(
243 os.environ["STEAM_RUNTIME_PATH"] = \
244 str(proton_app.required_tool_app.install_path)
245 os.environ["PROTON_LD_LIBRARY_PATH"] = \
246 - get_runtime_library_paths(proton_app, use_bwrap=use_bwrap)
247 + get_runtime_library_paths(proton_app, proton_app_only=use_bwrap)
249 runtime_name = proton_app.required_tool_app.name
250 logger.info(
251 @@ -408,11 +396,8 @@ def run_command(
252 "Current Steam Runtime not recognized by Protontricks."
254 else:
255 - # Legacy Steam Runtime requires a different LD_LIBRARY_PATH
256 os.environ["PROTON_LD_LIBRARY_PATH"] = \
257 - get_legacy_runtime_library_paths(
258 - legacy_steam_runtime_path, proton_app
260 + get_runtime_library_paths(proton_app, proton_app_only=True)
262 # When Steam Runtime is enabled, create a set of helper scripts
263 # that load the underlying Proton Wine executables with Steam Runtime
264 @@ -420,8 +405,6 @@ def run_command(
265 wine_bin_dir = create_wine_bin_dir(
266 proton_app=proton_app, use_bwrap=use_bwrap
268 - os.environ["LEGACY_STEAM_RUNTIME_PATH"] = \
269 - str(legacy_steam_runtime_path)
271 os.environ["PATH"] = "".join([
272 str(wine_bin_dir), os.pathsep, os.environ["PATH"]
273 diff --git a/tests/cli/test_main.py b/tests/cli/test_main.py
274 index 8b62a61..cc27f9b 100644
275 --- a/tests/cli/test_main.py
276 +++ b/tests/cli/test_main.py
277 @@ -116,15 +116,10 @@ class TestCLIRun:
278 assert str(command.args[0]).endswith(".local/bin/winetricks")
279 assert command.args[1] == "winecfg"
280 assert command.env["PATH"].startswith(str(wine_bin_dir))
281 - assert (
282 - "fake_steam_runtime/lib64" in command.env["PROTON_LD_LIBRARY_PATH"]
284 assert command.env["WINE"] == str(wine_bin_dir / "wine")
285 assert command.env["WINELOADER"] == str(wine_bin_dir / "wine")
286 assert command.env["WINESERVER"] == str(wine_bin_dir / "wineserver")
288 - assert command.env["LEGACY_STEAM_RUNTIME_PATH"] == \
289 - str(steam_runtime_dir / "steam-runtime")
290 assert "STEAM_RUNTIME_PATH" not in command.env
292 for name in ("wine", "wineserver"):
293 @@ -165,16 +160,14 @@ class TestCLIRun:
294 assert command.env["PATH"].startswith(str(wine_bin_dir))
296 # Compared to the traditional Steam Runtime, PROTON_LD_LIBRARY_PATH
297 - # will be different
298 + # will be the same (it would be different without steam-run.patch)
299 proton_install_path = Path(proton_app.install_path)
300 assert command.env["PROTON_LD_LIBRARY_PATH"] == "".join([
301 str(proton_install_path / "dist" / "lib"), os.pathsep,
302 str(proton_install_path / "dist" / "lib64"), os.pathsep
305 - # Environment variables for both legacy and new Steam Runtime exist
306 - assert command.env["LEGACY_STEAM_RUNTIME_PATH"] == \
307 - str(steam_runtime_dir / "steam-runtime")
308 + # Environment variable for new Steam Runtime exists
309 assert command.env["STEAM_RUNTIME_PATH"] == \
310 str(steam_runtime_soldier.install_path)
312 @@ -238,9 +231,7 @@ class TestCLIRun:
313 str(runtime_root / "lib" / "x86_64-linux-gnu")
316 - # Environment variables for both legacy and new Steam Runtime exist
317 - assert command.env["LEGACY_STEAM_RUNTIME_PATH"] == \
318 - str(steam_runtime_dir / "steam-runtime")
319 + # Environment variable for new Steam Runtime exists
320 assert command.env["STEAM_RUNTIME_PATH"] == \
321 str(steam_runtime_soldier.install_path)
323 @@ -344,7 +335,6 @@ class TestCLIRun:
325 # Also ensure log messages are included in the error message
326 assert b"Found Steam directory at" in message
327 - assert b"Using default Steam Runtime" in message
329 def test_run_gui_provider_not_found(self, cli, home_dir, steam_app_factory):
331 @@ -358,20 +348,6 @@ class TestCLIRun:
333 assert "YAD or Zenity is not installed" in result
335 - def test_run_steam_runtime_not_found(
336 - self, cli, steam_dir, steam_app_factory):
337 - """
338 - Try performing a command with Steam Runtime enabled but no
339 - available Steam Runtime installation
340 - """
341 - steam_app_factory(name="Fake game 1", appid=10)
342 - result = cli(
343 - ["10", "winecfg"], env={"STEAM_RUNTIME": "invalid/path"},
344 - expect_returncode=1
347 - assert "Steam Runtime was enabled but couldn't be found" in result
349 def test_run_proton_not_found(self, cli, steam_dir, steam_app_factory):
350 steam_app_factory(name="Fake game 1", appid=10)
351 result = cli(["10", "winecfg"], expect_returncode=1)