Skip to content
Snippets Groups Projects

Remove "session mode"

Merged Simon McVittie requested to merge wip/delete-session-mode into master
1 file
+ 3
53
Compare changes
  • Side-by-side
  • Inline
  • 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: default avatarSimon McVittie <smcv@collabora.com>
+ 5
179
@@ -186,11 +186,7 @@ if [ -n "$log_to_file" ]; then
app="app${STEAM_COMPAT_APP_ID-${SteamAppId}}"
fi
if [ -z "${STEAM_COMPAT_SESSION_ID-}" ]; then
log_filename="slr-${app}-t$(date +'%Y%m%dT%H%M%S').log"
else
log_filename="slr-${app}-s${STEAM_COMPAT_SESSION_ID}.log"
fi
log_filename="slr-${app}-t$(date +'%Y%m%dT%H%M%S').log"
mkdir -p "${log_dir}"
@@ -201,8 +197,7 @@ if [ -n "$log_to_file" ]; then
ln -fns "${log_filename}" "${log_dir}/slr-latest.log" || :
if [[ (-z "$is_main" && -n "${STEAM_COMPAT_SESSION_ID-}")
|| -n "${PRESSURE_VESSEL_BATCH-}" ]]; then
if [ -z "$is_main" ] || [ -n "${PRESSURE_VESSEL_BATCH-}" ]; then
# If we are running setup commands, or if we are gathering a system
# information report, we only redirect stderr to the log, on the
# assumption that stderr is for human-readable diagnostics but
@@ -223,38 +218,6 @@ if [ "$#" -eq 0 ] || [ "x$1" = x-- ]; then
usage 125
fi
# Steam App ID of this app or game
verbose "STEAM_COMPAT_APP_ID=${STEAM_COMPAT_APP_ID-}"
# Session ID used for coordination between processes involving the same game.
# If unset/empty, only execute a single command.
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
# At this point $LD_LIBRARY_PATH might
# 1. be equal to $STEAM_RUNTIME_LIBRARY_PATH (e.g. a game without
# any special launch options).
@@ -308,154 +271,17 @@ IFS="$old_IFS"
unset LD_LIBRARY_PATH
unset STEAM_RUNTIME
pressure_vessel="${PRESSURE_VESSEL_PREFIX:-"${here}/pressure-vessel"}"
if [ -z "${suite}" ]; then
run=run
else
run="run-in-${suite}"
fi
exec_container () {
# Run as a single command
exec "${here}/${run}" \
${container_args[0]+"${container_args[@]}"} \
-- \
"$@" \
${NULL+}
exit 125
}
if [ -z "${STEAM_COMPAT_SESSION_ID-}" ]; then
verbose "Non-session mode, just running the container"
exec_container "$@"
# not reached
fi
# Session mode. Either PRESSURE_VESSEL_SOCKET_DIR or XDG_RUNTIME_DIR are required.
verbose "Session mode"
if [[ -v PRESSURE_VESSEL_SOCKET_DIR ]]; then
if ! [ -O "$PRESSURE_VESSEL_SOCKET_DIR" ]; then
log "PRESSURE_VESSEL_SOCKET_DIR is owned by someone else"
exit 125
fi
rendezvous="${PRESSURE_VESSEL_SOCKET_DIR}/SteamLinuxRuntime.${STEAM_COMPAT_SESSION_ID:?}"
else
if ! [ -O "$XDG_RUNTIME_DIR" ]; then
log "XDG_RUNTIME_DIR is owned by someone else"
exit 125
fi
rendezvous="${XDG_RUNTIME_DIR}/SteamLinuxRuntime.${STEAM_COMPAT_SESSION_ID:?}"
fi
if mkdir -m700 "$rendezvous" 2>/dev/null; then
:
elif [ -d "$rendezvous" ] && [ -O "$rendezvous" ]; then
:
else
log "Unable to create or adopt $rendezvous"
exit 125
fi
terminate_container () {
if ! [ -S "$rendezvous/socket" ]; then
# nothing to do
return
fi
"$pressure_vessel/bin/pressure-vessel-adverb" \
--create \
--wait \
--write \
--lock-file "${rendezvous}/.ref" \
-- \
"$pressure_vessel/bin/pressure-vessel-launch" \
--socket="$rendezvous/socket" \
--terminate
}
if [ -n "$relaunch" ]; 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.
#
# We have to launch pressure-vessel-launcher(1) *without* setting
# SteamAppId, SteamAppUser, etc., otherwise Steam will think the game
# is already running and refuse to run it again. (Tested with SteamAppId,
# just guessing about the others)
"$pressure_vessel/bin/pressure-vessel-adverb" \
--create \
--wait \
--write \
--lock-file "${rendezvous}/.ref" \
-- \
env \
-u FONTCONFIG_PATH \
-u SteamLauncherUI \
-u SteamAppId \
-u SteamAppUser \
-u SteamClientLaunch \
-u SteamEnv \
-u SteamGameId \
-u SteamOverlayGameId \
"${here}/_start-container-in-background" \
${is_main:+--force} \
--session="$rendezvous" \
--suite="$suite" \
-- \
exec "${here}/${run}" \
${container_args[0]+"${container_args[@]}"} \
--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[@]}"} \
)
fi
exec "$pressure_vessel/bin/pressure-vessel-launch" \
--directory="$(pwd)" \
--socket="$rendezvous/socket" \
${launch_args[0]+"${launch_args[@]}"} \
-- \
"$@"
"$@" \
${NULL+}
exit 125
# not reached
# vim:set sw=4 sts=4 et:
Loading