From 441b21055e6e05dab8fdda7d131f178208cf4c63 Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Thu, 17 Jun 2021 14:31:49 +0100 Subject: [PATCH] _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. Signed-off-by: Simon McVittie <smcv@collabora.com> --- common/_start-container-in-background | 208 -------------------------- common/_v2-entry-point | 128 +--------------- 2 files changed, 5 insertions(+), 331 deletions(-) delete mode 100755 common/_start-container-in-background diff --git a/common/_start-container-in-background b/common/_start-container-in-background deleted file mode 100755 index bc9a863..0000000 --- a/common/_start-container-in-background +++ /dev/null @@ -1,208 +0,0 @@ -#!/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: diff --git a/common/_v2-entry-point b/common/_v2-entry-point index 2e25229..795aa9b 100755 --- a/common/_v2-entry-point +++ b/common/_v2-entry-point @@ -175,11 +175,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}" @@ -190,8 +186,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 @@ -215,22 +210,9 @@ 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-}" -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 # 1. be equal to $STEAM_RUNTIME_LIBRARY_PATH (e.g. a game without # any special launch options). @@ -288,111 +270,11 @@ 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 "$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" \ - -- \ +exec "${here}/${run}" \ ${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 -# not reached # vim:set sw=4 sts=4 et: -- GitLab