Skip to content
Snippets Groups Projects
Commit b511a4db authored by Simon McVittie's avatar Simon McVittie
Browse files

_v2-entry-point: Remove support for running in "session mode"


We used to use this to process Windows games' installscripts, but since
Steam beta 1623823138, Steam implements a much simpler interface for
running installscripts and we don't need this any more. Less code means
fewer bugs!

See also steam-runtime-tools!324, which documents the old and new
compatibility tool interfaces.

Resolves: T28961
Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent 4a1ef91e
No related branches found
No related tags found
No related merge requests found
Pipeline #15129 failed
#!/usr/bin/env bash
set -eu
me="$(readlink -f "$0")"
here="${me%/*}"
me="${me##*/}"
# This is a prototype and will probably not survive in its current form.
# Don't rely on it.
force=
info=
rendezvous=
suite=
use_timestamp=
verbose=
if [ "${STEAM_LINUX_RUNTIME_VERBOSE-}" = 1 ]; then
verbose=yes
# Propagate it to pressure-vessel too
export PRESSURE_VESSEL_VERBOSE=1
fi
if [ "${STEAM_LINUX_RUNTIME_LOG-}" = 1 ]; then
# If we are logging to a file, use the timestamp
info=yes
use_timestamp=yes
fi
log () {
if [ -n "$use_timestamp" ]; then
printf '%s\n' "$(LD_PRELOAD='' date +'%H:%M:%S.%6N'): ${me}[$$]: $*" >&2
else
printf '%s\n' "${me}[$$]: $*" >&2
fi
}
info () {
if [ -n "${info}${verbose}" ]; then
log "$@"
fi
}
verbose () {
if [ -n "$verbose" ]; then
log "$@"
fi
}
info "argv: $(printf '%q ' "$@")"
usage () {
local code="$1"
shift
if [ "$code" -ne 0 ]; then
exec >&2
fi
echo "Usage:"
echo "$me [OPTIONS] [-- [PVL_OPTIONS]]"
echo
echo "Must be run while holding a lock."
echo
echo "Options"
echo "--deploy=DIR Ignored for backwards compatibility."
echo "--force Try even if an earlier attempt failed."
echo "--session=PATH Directory representing a session."
echo "--suite=SUITE Run in this runtime [default=choose automatically]."
echo "--use-timestamp Prepend the timestamp to the log entries."
echo "--verbose Be more verbose."
exit "${code}"
}
getopt_temp="help"
getopt_temp="${getopt_temp},deploy:"
getopt_temp="${getopt_temp},force"
getopt_temp="${getopt_temp},session:"
getopt_temp="${getopt_temp},suite:"
getopt_temp="${getopt_temp},use-timestamp:"
getopt_temp="${getopt_temp},verbose"
getopt_temp="$(getopt -o '' --long "$getopt_temp" -n "$me" -- "$@")"
eval "set -- $getopt_temp"
unset getopt_temp
while [ "$#" -gt 0 ]; do
case "$1" in
(--help)
usage 0
# not reached
;;
(--deploy)
shift 2
;;
(--force)
force=yes
shift
;;
(--session)
rendezvous="$2"
shift 2
;;
(--suite)
suite="$2"
shift 2
;;
(--use-timestamp)
use_timestamp=yes
shift
;;
(--verbose)
verbose=yes
# Propagate it to pressure-vessel too
export PRESSURE_VESSEL_VERBOSE=1
shift
;;
(--)
shift
break
;;
(-*)
log "Unknown option: $1"
usage 64 # EX_USAGE from sysexits.h
# not reached
;;
(*)
break
;;
esac
done
pressure_vessel="${PRESSURE_VESSEL_PREFIX:-"${here}/pressure-vessel"}"
if [ -z "$rendezvous" ]; then
log "A session path is required"
exit 64
fi
if [ -S "$rendezvous/socket" ]; then
info "Session already started in $rendezvous"
exit 0
fi
if [ -z "$force" ] && [ -e "$rendezvous/failed" ]; then
log "Starting session already failed, not trying again."
log "Remove $rendezvous/failed to retry."
exit 70 # EX_SOFTWARE
fi
rm -f "$rendezvous/fifo"
mkfifo "$rendezvous/fifo"
if [ -z "${suite}" ]; then
run=run
else
run="run-in-${suite}"
fi
info "Starting pressure-vessel-launcher in background"
"${here}/${run}" \
--filesystem="$pressure_vessel" \
--filesystem="$rendezvous" \
--launcher \
--pass-fd=3 \
"$@" \
-- \
--info-fd=3 \
--socket-directory="$rendezvous" \
< /dev/null >&2 3>"$rendezvous/fifo" &
container_pid="$!"
info "Started pressure-vessel-launcher in background, pid $container_pid"
socket=$(
while read -r line; do
case "$line" in
(socket=*)
echo "${line#socket=}"
break
;;
esac
done < "$rendezvous/fifo"
)
if [ -z "$socket" ] || ! [ -S "$socket" ]; then
: > "$rendezvous/failed"
log "Error starting pressure-vessel container"
if [ -z "${STEAM_LINUX_RUNTIME_VERBOSE-}" ]; then
log "Try environment variable STEAM_LINUX_RUNTIME_VERBOSE=1 for more details"
fi
kill "$container_pid" || :
exit 70 # EX_SOFTWARE
fi
ln -fns "$socket" "$rendezvous/socket"
verbose "OK, ready to exit"
exit 0
# vim:set sw=4 sts=4 et:
...@@ -175,11 +175,7 @@ if [ -n "$log_to_file" ]; then ...@@ -175,11 +175,7 @@ if [ -n "$log_to_file" ]; then
app="app${STEAM_COMPAT_APP_ID-${SteamAppId}}" app="app${STEAM_COMPAT_APP_ID-${SteamAppId}}"
fi fi
if [ -z "${STEAM_COMPAT_SESSION_ID-}" ]; then log_filename="slr-${app}-t$(date +'%Y%m%dT%H%M%S').log"
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
mkdir -p "${log_dir}" mkdir -p "${log_dir}"
...@@ -190,8 +186,7 @@ if [ -n "$log_to_file" ]; then ...@@ -190,8 +186,7 @@ if [ -n "$log_to_file" ]; then
ln -fns "${log_filename}" "${log_dir}/slr-latest.log" || : ln -fns "${log_filename}" "${log_dir}/slr-latest.log" || :
if [[ (-z "$is_main" && -n "${STEAM_COMPAT_SESSION_ID-}") if [ -z "$is_main" ] || [ -n "${PRESSURE_VESSEL_BATCH-}" ]; then
|| -n "${PRESSURE_VESSEL_BATCH-}" ]]; then
# If we are running setup commands, or if we are gathering a system # If we are running setup commands, or if we are gathering a system
# information report, we only redirect stderr to the log, on the # information report, we only redirect stderr to the log, on the
# assumption that stderr is for human-readable diagnostics but # assumption that stderr is for human-readable diagnostics but
...@@ -215,22 +210,9 @@ fi ...@@ -215,22 +210,9 @@ fi
# Steam App ID of this app or game # Steam App ID of this app or game
verbose "STEAM_COMPAT_APP_ID=${STEAM_COMPAT_APP_ID-}" 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. # Used to create sockets.
verbose "XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR-}" verbose "XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR-}"
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"
else
verbose "Setup program in session mode"
fi
# At this point $LD_LIBRARY_PATH might # At this point $LD_LIBRARY_PATH might
# 1. be equal to $STEAM_RUNTIME_LIBRARY_PATH (e.g. a game without # 1. be equal to $STEAM_RUNTIME_LIBRARY_PATH (e.g. a game without
# any special launch options). # any special launch options).
...@@ -288,111 +270,11 @@ else ...@@ -288,111 +270,11 @@ else
run="run-in-${suite}" run="run-in-${suite}"
fi fi
exec_container () { exec "${here}/${run}" \
# 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 "$is_main" ]; then
info "Terminating and re-launching container for main game"
terminate_container || :
exec_container "$@"
# not reached
fi
# Launch the pressure-vessel-launcher(1). This is used to run the
# 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
# 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 LD_PRELOAD \
-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" \
-- \
${container_args[0]+"${container_args[@]}"} \ ${container_args[0]+"${container_args[@]}"} \
--terminate-timeout=2 \
${NULL+}
exec "$pressure_vessel/bin/pressure-vessel-launch" \
--directory="$(pwd)" \
--socket="$rendezvous/socket" \
--unset-env LD_PRELOAD \
-- \ -- \
"$@" "$@" \
${NULL+}
exit 125 exit 125
# not reached
# vim:set sw=4 sts=4 et: # vim:set sw=4 sts=4 et:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment