about summary refs log tree commit diff
path: root/pkgs/tools/package-management/protontricks/steam-run.patch
blob: bcc1fc9898361687979d275e655f336652484cbc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
diff --git a/src/protontricks/cli/main.py b/src/protontricks/cli/main.py
index c77d287..236c2a9 100755
--- a/src/protontricks/cli/main.py
+++ b/src/protontricks/cli/main.py
@@ -17,8 +17,7 @@ from ..flatpak import (FLATPAK_BWRAP_COMPATIBLE_VERSION,
                        get_running_flatpak_version)
 from ..gui import (prompt_filesystem_access, select_steam_app_with_gui,
                    select_steam_installation)
-from ..steam import (find_legacy_steam_runtime_path, find_proton_app,
-                     find_steam_installations, get_steam_apps,
+from ..steam import (find_proton_app, find_steam_installations, get_steam_apps,
                      get_steam_lib_paths)
 from ..util import run_command
 from ..winetricks import get_winetricks_path
@@ -67,8 +66,7 @@ def main(args=None, steam_path=None, steam_root=None):
             "WINE: path to a custom 'wine' executable\n"
             "WINESERVER: path to a custom 'wineserver' executable\n"
             "STEAM_RUNTIME: 1 = enable Steam Runtime, 0 = disable Steam "
-            "Runtime, valid path = custom Steam Runtime path, "
-            "empty = enable automatically (default)\n"
+            "Runtime, empty = enable automatically (default)\n"
             "PROTONTRICKS_GUI: GUI provider to use, accepts either 'yad' "
             "or 'zenity'"
         ),
@@ -204,17 +202,9 @@ def main(args=None, steam_path=None, steam_root=None):
         if not steam_path:
             exit_("No Steam installation was selected.")
 
-    # 2. Find the pre-installed legacy Steam Runtime if enabled
-    legacy_steam_runtime_path = None
-    use_steam_runtime = True
-
+    # 2. Use Steam Runtime if enabled
     if os.environ.get("STEAM_RUNTIME", "") != "0" and not args.no_runtime:
-        legacy_steam_runtime_path = find_legacy_steam_runtime_path(
-            steam_root=steam_root
-        )
-
-        if not legacy_steam_runtime_path:
-            exit_("Steam Runtime was enabled but couldn't be found!")
+        use_steam_runtime = True
     else:
         use_steam_runtime = False
         logger.info("Steam Runtime disabled.")
@@ -281,7 +271,6 @@ def main(args=None, steam_path=None, steam_root=None):
             proton_app=proton_app,
             steam_app=steam_app,
             use_steam_runtime=use_steam_runtime,
-            legacy_steam_runtime_path=legacy_steam_runtime_path,
             command=[str(winetricks_path), "--gui"],
             use_bwrap=use_bwrap,
             start_wineserver=start_background_wineserver
@@ -361,7 +350,6 @@ def main(args=None, steam_path=None, steam_root=None):
             proton_app=proton_app,
             steam_app=steam_app,
             use_steam_runtime=use_steam_runtime,
-            legacy_steam_runtime_path=legacy_steam_runtime_path,
             use_bwrap=use_bwrap,
             start_wineserver=start_background_wineserver,
             command=[str(winetricks_path)] + args.winetricks_command
@@ -373,7 +361,6 @@ def main(args=None, steam_path=None, steam_root=None):
             steam_app=steam_app,
             command=args.command,
             use_steam_runtime=use_steam_runtime,
-            legacy_steam_runtime_path=legacy_steam_runtime_path,
             use_bwrap=use_bwrap,
             start_wineserver=start_background_wineserver,
             # Pass the command directly into the shell *without*
diff --git a/src/protontricks/data/scripts/bwrap_launcher.sh b/src/protontricks/data/scripts/bwrap_launcher.sh
index b5552e1..b11bc99 100644
--- a/src/protontricks/data/scripts/bwrap_launcher.sh
+++ b/src/protontricks/data/scripts/bwrap_launcher.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 # Helper script
 set -o errexit
 
@@ -80,6 +80,8 @@ done
 log_info "Following directories will be mounted inside container: ${mount_dirs[*]}"
 log_info "Using temporary directory: $PROTONTRICKS_TEMP_PATH"
 
-exec "$STEAM_RUNTIME_PATH"/run --share-pid --launcher \
+exec steam-run "$STEAM_RUNTIME_PATH"/pressure-vessel/bin/pressure-vessel-wrap \
+--variable-dir="${PRESSURE_VESSEL_VARIABLE_DIR:-$STEAM_RUNTIME_PATH/var}" \
+--share-pid --launcher \
 "${mount_params[@]}" -- \
 --bus-name="com.github.Matoking.protontricks.App${STEAM_APPID}_${PROTONTRICKS_SESSION_ID}"
diff --git a/src/protontricks/data/scripts/wine_launch.sh b/src/protontricks/data/scripts/wine_launch.sh
index 1f8a432..2d82f2b 100644
--- a/src/protontricks/data/scripts/wine_launch.sh
+++ b/src/protontricks/data/scripts/wine_launch.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env -S steam-run bash
 # Helper script created by Protontricks to run Wine binaries using Steam Runtime
 set -o errexit
 
@@ -158,8 +158,8 @@ if [[ -n "$PROTONTRICKS_INSIDE_STEAM_RUNTIME"
         export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$PROTON_LD_LIBRARY_PATH"
         log_info "Appending to LD_LIBRARY_PATH: $PROTON_LD_LIBRARY_PATH"
     elif [[ "$PROTONTRICKS_STEAM_RUNTIME" = "legacy" ]]; then
-        export LD_LIBRARY_PATH="$PROTON_LD_LIBRARY_PATH"
-        log_info "LD_LIBRARY_PATH set to $LD_LIBRARY_PATH"
+        export LD_LIBRARY_PATH="$PROTON_LD_LIBRARY_PATH":"$LD_LIBRARY_PATH"
+        log_info "Inserting to head of LD_LIBRARY_PATH: $PROTON_LD_LIBRARY_PATH"
     fi
     exec "$PROTON_DIST_PATH"/bin/@@name@@ "$@" || :
 elif [[ "$PROTONTRICKS_STEAM_RUNTIME" = "bwrap" ]]; then
diff --git a/src/protontricks/data/scripts/wineserver_keepalive.sh b/src/protontricks/data/scripts/wineserver_keepalive.sh
index 8168dae..559de33 100644
--- a/src/protontricks/data/scripts/wineserver_keepalive.sh
+++ b/src/protontricks/data/scripts/wineserver_keepalive.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 # A simple keepalive script that will ensure a wineserver process is kept alive
 # for the duration of the Protontricks session.
 # This is accomplished by launching a simple Windows batch script that will
diff --git a/src/protontricks/steam.py b/src/protontricks/steam.py
index c39b51d..79de098 100644
--- a/src/protontricks/steam.py
+++ b/src/protontricks/steam.py
@@ -14,9 +14,8 @@ from .util import lower_dict
 
 __all__ = (
     "COMMON_STEAM_DIRS", "SteamApp", "find_steam_installations",
-    "find_steam_path", "find_legacy_steam_runtime_path",
-    "iter_appinfo_sections", "get_appinfo_sections", "get_tool_appid",
-    "find_steam_compat_tool_app", "find_appid_proton_prefix",
+    "find_steam_path", "iter_appinfo_sections", "get_appinfo_sections",
+    "get_tool_appid", "find_steam_compat_tool_app", "find_appid_proton_prefix",
     "find_proton_app", "get_steam_lib_paths", "get_compat_tool_dirs",
     "get_custom_compat_tool_installations_in_dir",
     "get_custom_compat_tool_installations", "find_current_steamid3",
@@ -393,37 +392,6 @@ def find_steam_path():
         return None, None
 
 
-def find_legacy_steam_runtime_path(steam_root):
-    """
-    Find the legacy Steam Runtime either using the STEAM_RUNTIME env or
-    steam_root
-    """
-    env_steam_runtime = os.environ.get("STEAM_RUNTIME", "")
-
-    if env_steam_runtime == "0":
-        # User has disabled Steam Runtime
-        logger.info("STEAM_RUNTIME is 0. Disabling Steam Runtime.")
-        return None
-    elif env_steam_runtime and Path(env_steam_runtime).is_dir():
-        # User has a custom Steam Runtime
-        logger.info(
-            "Using custom Steam Runtime at %s", env_steam_runtime)
-        return Path(env_steam_runtime)
-    elif env_steam_runtime in ["1", ""]:
-        # User has enabled Steam Runtime or doesn't have STEAM_RUNTIME set;
-        # default to enabled Steam Runtime in either case
-        steam_runtime_path = steam_root / "ubuntu12_32" / "steam-runtime"
-
-        logger.info(
-            "Using default Steam Runtime at %s", str(steam_runtime_path))
-        return steam_runtime_path
-
-    logger.error(
-        "Path in STEAM_RUNTIME doesn't point to a valid Steam Runtime!")
-
-    return None
-
-
 APPINFO_STRUCT_HEADER = "<4sL"
 APPINFO_V27_STRUCT_SECTION = "<LLLLQ20sL"
 APPINFO_V28_STRUCT_SECTION = "<LLLLQ20sL20s"
diff --git a/src/protontricks/util.py b/src/protontricks/util.py
index 7e95af5..7dc9a29 100644
--- a/src/protontricks/util.py
+++ b/src/protontricks/util.py
@@ -8,14 +8,14 @@ import shutil
 import tempfile
 import re
 from pathlib import Path
-from subprocess import PIPE, check_output, run, Popen, DEVNULL
+from subprocess import PIPE, run, Popen, DEVNULL
 
 import pkg_resources
 
 __all__ = (
     "SUPPORTED_STEAM_RUNTIMES", "lower_dict",
-    "get_legacy_runtime_library_paths", "get_host_library_paths",
-    "RUNTIME_ROOT_GLOB_PATTERNS", "get_runtime_library_paths",
+    "get_host_library_paths", "RUNTIME_ROOT_GLOB_PATTERNS",
+    "get_runtime_library_paths",
     "WINE_SCRIPT_TEMPLATE", "create_wine_bin_dir", "run_command"
 )
 
@@ -43,24 +43,6 @@ def lower_dict(d):
     return {k.lower(): _lower_value(v) for k, v in d.items()}
 
 
-def get_legacy_runtime_library_paths(legacy_steam_runtime_path, proton_app):
-    """
-    Get LD_LIBRARY_PATH value to use when running a command using Steam Runtime
-    """
-    steam_runtime_paths = check_output([
-        str(legacy_steam_runtime_path / "run.sh"),
-        "--print-steam-runtime-library-paths"
-    ])
-    steam_runtime_paths = str(steam_runtime_paths, "utf-8")
-    # Add Proton installation directory first into LD_LIBRARY_PATH
-    # so that libwine.so.1 is picked up correctly (see issue #3)
-    return "".join([
-        str(proton_app.proton_dist_path / "lib"), os.pathsep,
-        str(proton_app.proton_dist_path / "lib64"), os.pathsep,
-        steam_runtime_paths
-    ])
-
-
 def get_host_library_paths():
     """
     Get host library paths to use when creating the LD_LIBRARY_PATH environment
@@ -72,7 +54,7 @@ def get_host_library_paths():
     # Since that command is unavailable with newer Steam Runtime releases,
     # do it ourselves here.
     result = run(
-        ["/sbin/ldconfig", "-XNv"],
+        ["steam-run", "ldconfig", "-XNv"],
         check=True, stdout=PIPE, stderr=PIPE
     )
     lines = result.stdout.decode("utf-8").split("\n")
@@ -90,7 +72,7 @@ RUNTIME_ROOT_GLOB_PATTERNS = (
 )
 
 
-def get_runtime_library_paths(proton_app, use_bwrap=True):
+def get_runtime_library_paths(proton_app, proton_app_only=True):
     """
     Get LD_LIBRARY_PATH value to use when running a command using Steam Runtime
     """
@@ -111,7 +93,7 @@ def get_runtime_library_paths(proton_app, use_bwrap=True):
             f"Could not find Steam Runtime runtime root for {runtime_app.name}"
         )
 
-    if use_bwrap:
+    if proton_app_only:
         return "".join([
             str(proton_app.proton_dist_path / "lib"), os.pathsep,
             str(proton_app.proton_dist_path / "lib64"), os.pathsep
@@ -313,7 +295,7 @@ def run_command(
             wine_environ["STEAM_RUNTIME_PATH"] = \
                 str(proton_app.required_tool_app.install_path)
             wine_environ["PROTON_LD_LIBRARY_PATH"] = \
-                get_runtime_library_paths(proton_app, use_bwrap=use_bwrap)
+                get_runtime_library_paths(proton_app, proton_app_only=use_bwrap)
 
             runtime_name = proton_app.required_tool_app.name
             logger.info(
@@ -337,13 +319,9 @@ def run_command(
                     "Current Steam Runtime not recognized by Protontricks."
                 )
         else:
-            # Legacy Steam Runtime requires a different LD_LIBRARY_PATH
-            # that is produced by a script.
             wine_environ["PROTONTRICKS_STEAM_RUNTIME"] = "legacy"
             wine_environ["PROTON_LD_LIBRARY_PATH"] = \
-                get_legacy_runtime_library_paths(
-                    legacy_steam_runtime_path, proton_app
-                )
+                get_runtime_library_paths(proton_app, proton_app_only=True)
 
             # bwrap is not available, so ensure it is not launched even if the
             # user configured it so
@@ -353,7 +331,6 @@ def run_command(
     # configuring the environment and Wine before launching the underlying
     # Wine binaries.
     wine_bin_dir = create_wine_bin_dir(proton_app)
-    wine_environ["LEGACY_STEAM_RUNTIME_PATH"] = str(legacy_steam_runtime_path)
     wine_environ["PATH"] = os.pathsep.join(
         [str(wine_bin_dir), wine_environ["PATH"]]
     )
diff --git a/tests/cli/test_main.py b/tests/cli/test_main.py
index 0a35f8d..9b96629 100644
--- a/tests/cli/test_main.py
+++ b/tests/cli/test_main.py
@@ -121,15 +121,10 @@ class TestCLIRun:
         assert str(command.args[0]).endswith(".local/bin/winetricks")
         assert command.args[1] == "winecfg"
         assert command.env["PATH"].startswith(str(wine_bin_dir))
-        assert (
-            "fake_steam_runtime/lib64" in command.env["PROTON_LD_LIBRARY_PATH"]
-        )
         assert command.env["WINE"] == str(wine_bin_dir / "wine")
         assert command.env["WINELOADER"] == str(wine_bin_dir / "wine")
         assert command.env["WINESERVER"] == str(wine_bin_dir / "wineserver")
 
-        assert command.env["LEGACY_STEAM_RUNTIME_PATH"] == \
-            str(steam_runtime_dir / "steam-runtime")
         assert command.env["PROTONTRICKS_STEAM_RUNTIME"] == "legacy"
         assert "STEAM_RUNTIME_PATH" not in command.env
 
@@ -180,16 +175,14 @@ class TestCLIRun:
         assert command.env["PATH"].startswith(str(wine_bin_dir))
 
         # Compared to the traditional Steam Runtime, PROTON_LD_LIBRARY_PATH
-        # will be different
+        # will be the same (it would be different without steam-run.patch)
         proton_install_path = Path(proton_app.install_path)
         assert command.env["PROTON_LD_LIBRARY_PATH"] == "".join([
             str(proton_install_path / "dist" / "lib"), os.pathsep,
             str(proton_install_path / "dist" / "lib64"), os.pathsep
         ])
 
-        # Environment variables for both legacy and new Steam Runtime exist
-        assert command.env["LEGACY_STEAM_RUNTIME_PATH"] == \
-            str(steam_runtime_dir / "steam-runtime")
+        # Environment variable for new Steam Runtime exists
         assert command.env["STEAM_RUNTIME_PATH"] == \
             str(steam_runtime_soldier.install_path)
         assert command.env["PROTONTRICKS_STEAM_RUNTIME"] == "bwrap"
@@ -254,9 +247,7 @@ class TestCLIRun:
             str(runtime_root / "lib" / "x86_64-linux-gnu")
         ]))
 
-        # Environment variables for both legacy and new Steam Runtime exist
-        assert command.env["LEGACY_STEAM_RUNTIME_PATH"] == \
-            str(steam_runtime_dir / "steam-runtime")
+        # Environment variable for new Steam Runtime exists
         assert command.env["STEAM_RUNTIME_PATH"] == \
             str(steam_runtime_soldier.install_path)
         assert command.env["PROTONTRICKS_STEAM_RUNTIME"] == "legacy"
@@ -407,7 +398,6 @@ class TestCLIRun:
 
         # Also ensure log messages are included in the error message
         assert b"Found Steam directory at" in message
-        assert b"Using default Steam Runtime" in message
 
     def test_run_gui_provider_not_found(self, cli, home_dir, steam_app_factory):
         """
@@ -421,20 +411,6 @@ class TestCLIRun:
 
         assert "YAD or Zenity is not installed" in result
 
-    def test_run_steam_runtime_not_found(
-            self, cli, steam_dir, steam_app_factory):
-        """
-        Try performing a command with Steam Runtime enabled but no
-        available Steam Runtime installation
-        """
-        steam_app_factory(name="Fake game 1", appid=10)
-        result = cli(
-            ["10", "winecfg"], env={"STEAM_RUNTIME": "invalid/path"},
-            expect_returncode=1
-        )
-
-        assert "Steam Runtime was enabled but couldn't be found" in result
-
     def test_run_proton_not_found(self, cli, steam_dir, steam_app_factory):
         steam_app_factory(name="Fake game 1", appid=10)
         result = cli(["10", "winecfg"], expect_returncode=1)
diff --git a/tests/conftest.py b/tests/conftest.py
index 106e0d9..8236f3a 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -169,7 +169,7 @@ def steam_runtime_dir(steam_dir):
     """
     (steam_dir.parent / "root" / "ubuntu12_32" / "steam-runtime").mkdir(parents=True)
     (steam_dir.parent / "root" / "ubuntu12_32" / "steam-runtime" / "run.sh").write_text(
-        "#!/bin/bash\n"
+        "#!/usr/bin/env -S steam-run bash\n"
         """if [ "$1" = "--print-steam-runtime-library-paths" ]; then\n"""
         "    echo 'fake_steam_runtime/lib:fake_steam_runtime/lib64'\n"
         "fi"
@@ -735,7 +735,7 @@ def xdg_user_dir_bin(home_dir):
     # Only mock PICTURES and DOWNLOAD; mocking everything isn't necessary
     # for the tests.
     (home_dir / ".local" / "bin" / "xdg-user-dir").write_text(
-        '#!/bin/bash\n'
+        '#!/usr/bin/env -S steam-run bash\n'
         'if [[ "$1" == "PICTURES" ]]; then\n'
         '    echo "$HOME/Pictures"\n'
         'elif [[ "$1" == "DOWNLOAD" ]]; then\n'
diff --git a/tests/test_flatpak.py b/tests/test_flatpak.py
index cb2b9bb..440b704 100644
--- a/tests/test_flatpak.py
+++ b/tests/test_flatpak.py
@@ -159,36 +159,6 @@ class TestGetInaccessiblePaths:
 
         assert len(inaccessible_paths) == 0
 
-    @pytest.mark.usefixtures("xdg_user_dir_bin")
-    def test_flatpak_xdg_user_dir(self, monkeypatch, tmp_path, home_dir):
-        """
-        Test that XDG filesystem permissions such as 'xdg-pictures' and
-        'xdg-download' are detected correctly
-        """
-        flatpak_info_path = tmp_path / "flatpak-info"
-
-        flatpak_info_path.write_text(
-            "[Application]\n"
-            "name=fake.flatpak.Protontricks\n"
-            "\n"
-            "[Instance]\n"
-            "flatpak-version=1.12.1\n"
-            "\n"
-            "[Context]\n"
-            "filesystems=xdg-pictures;"
-        )
-        monkeypatch.setattr(
-            "protontricks.flatpak.FLATPAK_INFO_PATH", str(flatpak_info_path)
-        )
-
-        inaccessible_paths = get_inaccessible_paths([
-            str(home_dir / "Pictures"),
-            str(home_dir / "Download")
-        ])
-
-        assert len(inaccessible_paths) == 1
-        assert str(inaccessible_paths[0]) == str(home_dir / "Download")
-
     def test_flatpak_unknown_permission(self, monkeypatch, tmp_path, caplog):
         """
         Test that unknown filesystem permissions are ignored
diff --git a/tests/test_util.py b/tests/test_util.py
index ec5f4f3..0b0a66c 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -98,44 +98,6 @@ class TestRunCommand:
         assert command.env["WINELOADER"] == "/fake/wine"
         assert command.env["WINESERVER"] == "/fake/wineserver"
 
-    def test_unknown_steam_runtime_detected(
-            self, home_dir, proton_factory, runtime_app_factory,
-            steam_app_factory, caplog):
-        """
-        Test that Protontricks will log a warning if it encounters a Steam
-        Runtime it does not recognize
-        """
-        steam_runtime_medic = runtime_app_factory(
-            name="Steam Linux Runtime - Medic",
-            appid=14242420,
-            runtime_dir_name="medic"
-        )
-        proton_app = proton_factory(
-            name="Proton 5.20", appid=100, compat_tool_name="proton_520",
-            is_default_proton=True, required_tool_app=steam_runtime_medic
-        )
-        steam_app = steam_app_factory(name="Fake game", appid=10)
-
-        run_command(
-            winetricks_path=Path("/usr/bin/winetricks"),
-            proton_app=proton_app,
-            steam_app=steam_app,
-            command=["echo", "nothing"],
-            shell=True,
-            use_steam_runtime=True
-        )
-
-        # Warning will be logged since Protontricks does not recognize
-        # Steam Runtime Medic and can't ensure it's being configured correctly
-        warning = next(
-            record for record in caplog.records
-            if record.levelname == "WARNING"
-            and "not recognized" in record.getMessage()
-        )
-        assert warning.getMessage() == \
-            "Current Steam Runtime not recognized by Protontricks."
-
-
 class TestLowerDict:
     def test_lower_nested_dict(self):
         """