From 4a1ef91e35ebed8a5f1b5236b76084b2364c07e9 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Thu, 17 Jun 2021 14:13:38 +0100
Subject: [PATCH] _v2-entry-point: Remove support for not relaunching the
 container

This effectively hard-codes PRESSURE_VESSEL_RELAUNCH_CONTAINER to 1:
if we are in "session mode" with a STEAM_COMPAT_SESSION_ID set, then
we will still share a container started by _start-container-in-background
between one or more setup commands, but then we will terminate that
container and start again for the actual game.

We need to do this if we want the actual game to be able to take its
user-specified launch options into account, which is why it has been the
default since January.

Part of T25709.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 common/_v2-entry-point | 56 +++---------------------------------------
 1 file changed, 3 insertions(+), 53 deletions(-)

diff --git a/common/_v2-entry-point b/common/_v2-entry-point
index a17e334..2e25229 100755
--- a/common/_v2-entry-point
+++ b/common/_v2-entry-point
@@ -222,24 +222,11 @@ verbose "STEAM_COMPAT_SESSION_ID=${STEAM_COMPAT_SESSION_ID-}"
 # Used to create sockets.
 verbose "XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR-}"
 
-relaunch=
-
 if [ -z "${STEAM_COMPAT_SESSION_ID-}" ]; then
     info "Non-session mode, behaving like the main program"
     is_main=yes
 elif [ -n "$is_main" ]; then
     info "Main program in session mode"
-    # Use the relaunch mode by default
-    case "${PRESSURE_VESSEL_RELAUNCH_CONTAINER-1}" in
-        (1)
-            relaunch=yes
-            ;;
-        (0)
-            ;;
-        (*)
-            echo "\$PRESSURE_VESSEL_RELAUNCH_CONTAINER should be either 0 or 1" >&2
-            ;;
-    esac
 else
     verbose "Setup program in session mode"
 fi
@@ -360,21 +347,15 @@ terminate_container () {
         --terminate
 }
 
-if [ -n "$relaunch" ]; then
+if [ -n "$is_main" ]; then
     info "Terminating and re-launching container for main game"
     terminate_container || :
     exec_container "$@"
     # not reached
 fi
 
-if [ -n "$is_main" ]; then
-    trap terminate_container EXIT
-fi
-
 # Launch the pressure-vessel-launcher(1). This is used to run the
-# setup commands (--verb=run), if any. If not requested via
-# PRESSURE_VESSEL_RELAUNCH_CONTAINER=1, it is also used to run the
-# actual game.
+# setup commands (--verb=run), if any.
 #
 # We have to launch pressure-vessel-launcher(1) *without* setting
 # SteamAppId, SteamAppUser, etc., otherwise Steam will think the game
@@ -405,41 +386,10 @@ env \
     --terminate-timeout=2 \
     ${NULL+}
 
-launch_args=( \
-)
-
-if [ -n "$is_main" ]; then
-    if [ "${SteamAppId-}" != "${STEAM_COMPAT_APP_ID-}" ]; then
-        log "Mismatch: SteamAppId=${SteamAppId-}, STEAM_COMPAT_APP_ID=${STEAM_COMPAT_APP_ID-}"
-        exit 125
-    fi
-
-    launch_args=( \
-        ${launch_args[0]+"${launch_args[@]}"} \
-        --pass-env-matching '*' \
-        --terminate \
-    )
-
-    # For the main game we wait for all processes to terminate before
-    # shutting down the container.
-    set -- \
-        "$pressure_vessel/bin/pressure-vessel-adverb" \
-        ${PRESSURE_VESSEL_SHELL+--shell="$PRESSURE_VESSEL_SHELL"} \
-        ${PRESSURE_VESSEL_TERMINAL+--terminal="$PRESSURE_VESSEL_TERMINAL"} \
-        --subreaper \
-        -- \
-        "$@"
-else
-    launch_args=( \
-        ${launch_args[0]+"${launch_args[@]}"} \
-        --unset-env LD_PRELOAD \
-    )
-fi
-
 exec "$pressure_vessel/bin/pressure-vessel-launch" \
     --directory="$(pwd)" \
     --socket="$rendezvous/socket" \
-    ${launch_args[0]+"${launch_args[@]}"} \
+    --unset-env LD_PRELOAD \
     -- \
     "$@"
 exit 125
-- 
GitLab