proton: Allow forwarding commands into the Proton environment

Recent versions of the Steam Runtime include an IPC server/client pair
which can be used to run commands inside the container environment
(or any other special execution environment), analogous to sshd/ssh or
flatpak-portal/flatpak-spawn. The server runs inside the Steam Runtime
container and accepts commands over D-Bus; the client runs on the host
system, asks the server to run a command, and forwards its stdin, stdout
and stderr back to the host.

https://gitlab.steamos.cloud/steamrt/steamlinuxruntime/-/merge_requests/72
adds support for injecting commands into the SteamLinuxRuntime_soldier
compatibility tool (and any later version, such as sniper). However,
Steam compatibility tools are stackable: in particular, Proton runs in a
soldier container (or presumably sniper in future). If we are debugging
a Proton game, then ideally we will want to inject commands into Proton's
execution environment rather than soldier's, so that they run with the
correct environment variables etc. to communicate with a running Proton
session. In particular, it's important that the `WINEPREFIX` is correct.

The steam-runtime-launcher-interface-0 program implements the
interface for compatibility tools to use to decide where, if anywhere,
to launch the command server.

This commit does not alter the scripts produced by
PROTON_DUMP_DEBUG_COMMANDS. To run those scripts' commands in the
container environment, pass their filenames to
steam-runtime-launch-client.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Link: https://github.com/ValveSoftware/Proton/pull/5891
This commit is contained in:
Simon McVittie 2022-06-08 18:17:05 +01:00 committed by Arkadiusz Hiler
parent 4cc575b2f4
commit 79c9b6a15d

11
proton
View File

@ -1398,6 +1398,11 @@ class Session:
return subprocess.call(args, env=local_env, stderr=self.log_file, stdout=self.log_file)
def run(self):
if shutil.which('steam-runtime-launcher-interface-0') is not None:
adverb = ['steam-runtime-launcher-interface-0', 'proton']
else:
adverb = []
if "PROTON_DUMP_DEBUG_COMMANDS" in self.env and nonzero(self.env["PROTON_DUMP_DEBUG_COMMANDS"]):
try:
self.dump_dbg_scripts()
@ -1415,9 +1420,11 @@ class Session:
# CoD: Black Ops 3 workaround
if os.environ.get("SteamGameId", 0) == "311210":
rc = self.run_proc([g_proton.wine_bin, "c:\\Program Files (x86)\\Steam\\steam.exe"] + sys.argv[2:] + self.cmdlineappend)
argv = [g_proton.wine_bin, "c:\\Program Files (x86)\\Steam\\steam.exe"]
else:
rc = self.run_proc([g_proton.wine64_bin, "c:\\windows\\system32\\steam.exe"] + sys.argv[2:] + self.cmdlineappend)
argv = [g_proton.wine64_bin, "c:\\windows\\system32\\steam.exe"]
rc = self.run_proc(adverb + argv + sys.argv[2:] + self.cmdlineappend)
if remote_debug_proc:
remote_debug_proc.kill()