diff --git a/depot/_start-container-in-background b/depot/_start-container-in-background index 1f13b5bae2efaeb77ec7136fac3c3f4b5cd8cd17..15d721736cadff12cdc15e52ea33c0716f7f0aa2 100755 --- a/depot/_start-container-in-background +++ b/depot/_start-container-in-background @@ -12,7 +12,7 @@ deploy= force= info= rendezvous= -suite=scout +suite= use_timestamp= verbose= @@ -64,10 +64,10 @@ usage () { echo "Must be run while holding a lock." echo echo "Options" - echo "--deploy=DIR Deploy to this directory [default=SUITE]." + 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=scout]." + 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." @@ -94,7 +94,6 @@ while [ "$#" -gt 0 ]; do ;; (--deploy) - deploy="$2" shift 2 ;; @@ -142,13 +141,8 @@ while [ "$#" -gt 0 ]; do esac done -run_in_steamrt="${here}/run-in-steamrt" pressure_vessel="${PRESSURE_VESSEL_PREFIX:-"${here}/pressure-vessel"}" -if [ -z "$deploy" ]; then - deploy="$suite" -fi - if [ -z "$rendezvous" ]; then log "A session path is required" exit 64 @@ -168,14 +162,14 @@ 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" -"${run_in_steamrt}" \ - --arch=amd64,i386 \ - --deploy \ - --runtime=com.valvesoftware.SteamRuntime.Platform \ - --suite="${suite}" \ - "${deploy}" \ - -- \ +"${here}/${run}" \ --filesystem="$pressure_vessel" \ --filesystem="$rendezvous" \ --launcher \ diff --git a/depot/_v2-entry-point b/depot/_v2-entry-point index 6fba045adb7e800f27c15a531253abadb3a78c51..cc63b771172ac13e206404c0dc22873d4e7d1bbc 100755 --- a/depot/_v2-entry-point +++ b/depot/_v2-entry-point @@ -8,9 +8,8 @@ me="${me##*/}" # This is a prototype and will probably not survive in its current form. # Don't rely on it. -deploy= is_main=yes -suite=scout +suite= verbose= log_to_file= log_dir=${STEAM_LINUX_RUNTIME_LOG_DIR-"${PRESSURE_VESSEL_VARIABLE_DIR-"${here}/var"}"} @@ -71,10 +70,10 @@ usage () { echo "COMMAND [ARGS...] Run this." echo echo "Options" - echo "--deploy=DIR Deploy to this directory [default=SUITE]." + echo "--deploy=DIR Ignored for backwards compatibility." echo "--keep-logs Do not remove the older logs of this same app id." echo "--log-to-file Log to a file instead of the default stderr." - echo "--suite=SUITE Run in this runtime [default=scout]." + echo "--suite=SUITE Run in this runtime [default=choose automatically]." echo "--use-timestamp Prepend the timestamp to the log entries [default with --log-to-file]." echo "--verb=%verb% Mode to operate in [default=waitforexitandrun]." echo "--verbose Be more verbose." @@ -103,7 +102,6 @@ while [ "$#" -gt 0 ]; do ;; (--deploy) - deploy="$2" shift 2 ;; @@ -164,10 +162,6 @@ while [ "$#" -gt 0 ]; do esac done -if [ -z "$deploy" ]; then - deploy="$suite" -fi - if [ -n "$log_to_file" ]; then app= log_filename= @@ -295,15 +289,15 @@ pressure_vessel="${PRESSURE_VESSEL_PREFIX:-"${here}/pressure-vessel"}" # Arguments for pressure-vessel-wrap, currently none declare -a container_args=() +if [ -z "${suite}" ]; then + run=run +else + run="run-in-${suite}" +fi + exec_container () { # Run as a single command - exec "$here/run-in-steamrt" \ - --arch=amd64,i386 \ - --deploy \ - --runtime=com.valvesoftware.SteamRuntime.Platform \ - --suite="${suite}" \ - "${deploy}" \ - -- \ + exec "${here}/${run}" \ ${container_args[0]+"${container_args[@]}"} \ -- \ "$@" \ diff --git a/depot/deploy-runtime b/depot/deploy-runtime index 003f901db7dbe8c3ed718efa83ac60b582e625e7..87e1af43cdc3a7b136edb560b5d98f95824da33a 100755 --- a/depot/deploy-runtime +++ b/depot/deploy-runtime @@ -1,284 +1,4 @@ #!/bin/sh - -# deploy-runtime — unpack and deploy a new runtime -# -# Copyright © 2019-2021 Collabora Ltd. -# -# SPDX-License-Identifier: MIT -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - set -eu - -me="$(readlink -f "$0")" -here="${me%/*}" -me="${me##*/}" - -arch=amd64,i386 -basename= -name= -runtime=com.valvesoftware.SteamRuntime.Platform -suite=scout -verbose= - -log () { - printf '%s\n' "$me: $*" >&2 -} - -verbose () { - if [ -n "$verbose" ]; then - log "$@" - fi -} - -usage () { - local code="$1" - shift - - if [ "$code" -ne 0 ]; then - exec >&2 - fi - - echo "Usage: $me [OPTIONS]" - echo - echo "Deploy a runtime. For concurrency, must be called with the" - echo "current working directory's lock held." - echo - echo "Options:" - echo "--arch ARCH Use architecture(s) ARCH instead of amd64,i386" - echo "--basename NAME Unpack archive based on NAME instead of RUNTIME-SUITE-ARCH" - echo "--name DIR Unpack into var/DIR, instead of var/SUITE" - echo "--runtime RUNTIME Use runtime RUNTIME instead of" - echo " com.valvesoftware.SteamRuntime.Platform" - echo "--suite SUITE Use suite SUITE instead of scout" - exit "$code" -} - -check_ok_for_filename () { - case "$2" in - (*/*) - log "Error: $1 cannot contain a slash" - return 1 - ;; - - (-*) - log "Error: $1 cannot start with a dash" - return 1 - ;; - - (.*) - log "Error: $1 cannot start with a dot" - return 1 - ;; - esac -} - -getopt_temp="help" -getopt_temp="${getopt_temp},architecture:,arch:" -getopt_temp="${getopt_temp},basename:" -getopt_temp="${getopt_temp},name:" -getopt_temp="${getopt_temp},runtime:" -getopt_temp="${getopt_temp},suite:" -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 - ;; - - (--architecture | --arch) - arch="$2" - shift 2 - ;; - - (--basename) - basename="$2" - shift 2 - ;; - - (--name) - name="$2" - shift 2 - ;; - - (--runtime) - runtime="$2" - shift 2 - ;; - - (--suite) - suite="$2" - shift 2 - ;; - - (--verbose) - verbose=yes - shift - ;; - - (--) - shift - break - ;; - - (-*) - log "Unknown option: $1" - usage 64 # EX_USAGE from sysexits.h - # not reached - ;; - - (*) - break - ;; - esac -done - -if [ -z "${PRESSURE_VESSEL_VARIABLE_DIR-}" ]; then - mkdir -p "${here}/var" - export PRESSURE_VESSEL_VARIABLE_DIR="${here}/var" -fi - -# Make it absolute -case "$PRESSURE_VESSEL_VARIABLE_DIR" in - (/*) - ;; - (*) - export PRESSURE_VESSEL_VARIABLE_DIR="${here}/${PRESSURE_VESSEL_VARIABLE_DIR}" - ;; -esac - -if [ -z "$basename" ]; then - basename="${runtime}-${arch}-${suite}" -fi - -if [ -z "$name" ]; then - name="${suite}" -fi - -if [ -n "$verbose" ]; then - tar_v=v -else - tar_v= -fi - -check_ok_for_filename ARCH "$arch" -check_ok_for_filename BASENAME "$basename" -check_ok_for_filename NAME "$name" -check_ok_for_filename RUNTIME "$runtime" -check_ok_for_filename SUITE "$suite" - -current_build_id="$(cat "${here}/${basename}-buildid.txt")" -check_ok_for_filename "build ID" "$current_build_id" - -updated= - -# Ensure that current_build_id is unpacked -if [ -d "${PRESSURE_VESSEL_VARIABLE_DIR}/${name}_${current_build_id}/files" ]; then - verbose "${name}_${current_build_id}/files already unpacked" -else - rm -fr --one-file-system "${PRESSURE_VESSEL_VARIABLE_DIR}/.${name}_${current_build_id}_unpack-temp" - mkdir "${PRESSURE_VESSEL_VARIABLE_DIR}/.${name}_${current_build_id}_unpack-temp" - tar \ - -C "${PRESSURE_VESSEL_VARIABLE_DIR}/.${name}_${current_build_id}_unpack-temp" \ - -z"${tar_v}"xf \ - "${here}/${basename}-runtime.tar.gz" - - # If we have the detached debug symbols, we extract them too - if [ -f "${here}/${basename}-debug.tar.gz" ]; then - tar \ - -C "${PRESSURE_VESSEL_VARIABLE_DIR}/.${name}_${current_build_id}_unpack-temp/files/lib/debug" \ - --strip-components=1 \ - -z"${tar_v}"xf \ - "${here}/${basename}-debug.tar.gz" \ - "files/" - fi - - mv \ - "${PRESSURE_VESSEL_VARIABLE_DIR}/.${name}_${current_build_id}_unpack-temp" \ - "${PRESSURE_VESSEL_VARIABLE_DIR}/${name}_${current_build_id}" - - updated=yes -fi - -if [ -z "$updated" ] \ - && [ -d "${PRESSURE_VESSEL_VARIABLE_DIR}/${name}/files" ] \ - && [ -L "${PRESSURE_VESSEL_VARIABLE_DIR}/${name}" ] -then - verbose "${name} is already a symlink to some runtime" -else - rm -fr "${PRESSURE_VESSEL_VARIABLE_DIR}/${name}" - ln -fns "${name}_${current_build_id}" "${PRESSURE_VESSEL_VARIABLE_DIR}/${name}" -fi - -if [ -L "${here}/${name}" ] -then - verbose "Removing old symbolic link ${here}/${name}" - rm -f "${here}/${name}" || : -fi - -pressure_vessel="${PRESSURE_VESSEL_PREFIX:-"${here}/pressure-vessel"}" - -adverb="$pressure_vessel/bin/pressure-vessel-adverb" - -# GC old runtimes -for deployment in \ - "${here}/${name}"_before_* \ - "${here}/${name}"_[0-9].* \ - "${here}/.${name}"_*_unpack-temp \ - "${PRESSURE_VESSEL_VARIABLE_DIR}/${name}"_[0-9].* \ - "${PRESSURE_VESSEL_VARIABLE_DIR}/.${name}"_*_unpack-temp \ -; do - if ! [ -d "$deployment" ]; then - continue - fi - if [ "x$deployment" = "x${PRESSURE_VESSEL_VARIABLE_DIR}/${name}_${current_build_id}" ]; then - continue - fi - if ! [ -d "$deployment/files" ]; then - continue - fi - if [ -e "$deployment/keep" ]; then - continue - fi - if [ -d "$deployment/files/usr" ]; then - lockfile="$deployment/files/usr/.ref" - else - lockfile="$deployment/files/.ref" - fi - - # Ignore any errors here: if we can't undeploy an old runtime - # (either because it's in use, or because we can't create the lock - # file for some reason, or because rm -fr fails) we waste a bit of - # disk space and continue to launch the game. The old runtime will - # get deleted eventually, so no harm done. - "$adverb" \ - --create --write \ - --lock-file "$lockfile" \ - -- \ - rm -fr "$deployment" || : -done - -# vim:set sw=4 sts=4 et: +echo "$0: This script is no longer used" >&2 +exit 2 diff --git a/depot/run-in-steamrt b/depot/run-in-steamrt index 8000470ff6b03e2d7a89275f13de5fb90f61b033..87e1af43cdc3a7b136edb560b5d98f95824da33a 100755 --- a/depot/run-in-steamrt +++ b/depot/run-in-steamrt @@ -1,276 +1,4 @@ #!/bin/sh - -# run-in-steamrt — undo the Steam Runtime's environment and use -# a given runtime, assuming the layout of the SteamLinuxRuntime depot. -# -# Copyright © 2019-2021 Collabora Ltd. -# -# SPDX-License-Identifier: MIT -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - set -eu - -me="$(readlink -f "$0")" -here="${me%/*}" -me="${me##*/}" -NULL= - -if [ "x${STEAM_RUNTIME_CONTAINER_TEST-}" = x1 ]; then - echo "$me: STEAM_RUNTIME_CONTAINER_TEST=1 is deprecated, please set PRESSURE_VESSEL_WRAP_GUI=1 if you want the 'developer mode' GUI" >&2 - export PRESSURE_VESSEL_WRAP_GUI=1 -fi - -arch=amd64,i386 -basename= -deploy= -runtime=com.valvesoftware.SteamRuntime.Platform -suite= -name= -verbose= - -log () { - printf '%s\n' "$me: $*" >&2 -} - -verbose () { - if [ -n "$verbose" ]; then - log "$@" - fi -} - -usage () { - local code="$1" - shift - - if [ "$code" -ne 0 ]; then - exec >&2 - fi - - echo "Usage:" - echo "$me [OPTIONS] NAME [-- [PVW_OPTIONS] [--]] PROGRAM ARGS" - echo - echo "Run a program in a runtime." - echo - echo "PVW_OPTIONS, PROGRAM, ARGS are passed to pressure-vessel-wrap." - echo "Run 'pressure-vessel-wrap --help' for more details." - echo - echo "Required arguments" - echo "NAME Use the 'files' subdirectory of NAME for the" - echo " runtime's content." - echo - echo "Options (default shown in [])" - echo "--arch=ARCH Use architecture(s) ARCH [amd64,i386]" - echo "--basename=BASE Use filenames based on BASE [RUNTIME-SUITE-ARCH]" - echo "--deploy Automatically deploy new versions from an archive" - echo " if available, and make NAME a symbolic link" - echo " to the latest" - echo "--runtime RUNTIME Use runtime RUNTIME" - echo " [com.valvesoftware.SteamRuntime.Platform]" - echo "--suite=SUITE Use suite SUITE [NAME]" - exit "$code" -} - -check_ok_for_filename () { - case "$2" in - (*/*) - log "Error: $1 cannot contain a slash" - return 1 - ;; - - (-*) - log "Error: $1 cannot start with a dash" - return 1 - ;; - - (.*) - log "Error: $1 cannot start with a dot" - return 1 - ;; - esac -} - -getopt_temp="help" -getopt_temp="${getopt_temp},architecture:,arch:" -getopt_temp="${getopt_temp},basename:" -getopt_temp="${getopt_temp},deploy" -getopt_temp="${getopt_temp},runtime:" -getopt_temp="${getopt_temp},suite:" -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 - ;; - - (--architecture | --arch) - arch="$2" - shift 2 - ;; - - (--basename) - basename="$2" - shift 2 - ;; - - (--deploy) - deploy=yes - shift - ;; - - (--runtime) - runtime="$2" - shift 2 - ;; - - (--suite) - suite="$2" - shift 2 - ;; - - (--verbose) - verbose=yes - shift - ;; - - (--) - shift - break - ;; - - (-*) - log "Unknown option: $1" - usage 64 # EX_USAGE from sysexits.h - # not reached - ;; - - (*) - break - ;; - esac -done - -if [ "$#" -eq 0 ] || [ "x$1" = x-- ]; then - log "Error: A runtime to use is required" - usage 64 -fi - -name="$1" -verbose "Runtime name: $name" -shift - -if [ -z "$suite" ]; then - suite="${name}" -fi - -if [ -z "$basename" ]; then - basename="${runtime}-${arch}-${suite}" -fi - -verbose "Architecture(s): $arch" -verbose "Basename: $basename" -verbose "Runtime: $runtime" -verbose "Suite: $suite" -verbose "Deploy: ${deploy:-no}" - -check_ok_for_filename ARCH "$arch" -check_ok_for_filename BASENAME "$basename" -check_ok_for_filename NAME "$name" -check_ok_for_filename RUNTIME "$runtime" -check_ok_for_filename SUITE "$suite" - -pressure_vessel="${PRESSURE_VESSEL_PREFIX:-"${here}/pressure-vessel"}" - -if [ -z "${PRESSURE_VESSEL_VARIABLE_DIR-}" ]; then - mkdir -p "${here}/var" - export PRESSURE_VESSEL_VARIABLE_DIR="${here}/var" -fi - -# Make it absolute -case "$PRESSURE_VESSEL_VARIABLE_DIR" in - (/*) - ;; - (*) - export PRESSURE_VESSEL_VARIABLE_DIR="${here}/${PRESSURE_VESSEL_VARIABLE_DIR}" - ;; -esac - -adverb="$pressure_vessel/bin/pressure-vessel-adverb" - -if [ -n "$deploy" ]; then - if ! current_build_id="$(cat "${here}/${basename}-buildid.txt")"; then - # Ignore: there is no build ID in the depot. We'll just use a - # ${name} directory if it exists. - : - elif [ -d "${PRESSURE_VESSEL_VARIABLE_DIR}/${name}_${current_build_id}/files" ] \ - && [ -d "${PRESSURE_VESSEL_VARIABLE_DIR}/${name}" ] \ - && [ -L "${PRESSURE_VESSEL_VARIABLE_DIR}/${name}" ] \ - && [ "x$(readlink "${PRESSURE_VESSEL_VARIABLE_DIR}/${name}")" = "x${name}_${current_build_id}" ] - then - # Fast path: skip the locking and the deploy step if the correct runtime - # is already in place. - : - else - # Take a lock on this directory while we deploy new runtimes, to avoid - # two runs fighting. - ( - unset LD_LIBRARY_PATH - unset LD_PRELOAD - "$adverb" \ - --create --write --wait \ - --lock-file "${PRESSURE_VESSEL_VARIABLE_DIR}/.ref" \ - -- \ - "$here/deploy-runtime" \ - --arch="${arch}" \ - --basename="${basename}" \ - --runtime="${runtime}" \ - --suite="${suite}" \ - --name="${name}" \ - ${verbose:+--verbose} \ - ${NULL+} - ) - fi -fi - -if [ -e /.flatpak-info ] && [ -z "${PRESSURE_VESSEL_COPY_RUNTIME_INTO+set}" ]; then - export PRESSURE_VESSEL_COPY_RUNTIME_INTO="$PRESSURE_VESSEL_VARIABLE_DIR" -fi - -if [ -e "${here}/var/copy-runtime" ] && [ -z "${PRESSURE_VESSEL_COPY_RUNTIME_INTO+set}" ]; then - export PRESSURE_VESSEL_COPY_RUNTIME_INTO="$PRESSURE_VESSEL_VARIABLE_DIR" -fi - -export PRESSURE_VESSEL_RUNTIME_BASE="${here}" - -if [ -d "${PRESSURE_VESSEL_VARIABLE_DIR}/${name}/files" ]; then - export PRESSURE_VESSEL_RUNTIME="${PRESSURE_VESSEL_VARIABLE_DIR}/${name}/files" -else - export PRESSURE_VESSEL_RUNTIME="${name}/files" -fi - -exec "$pressure_vessel/bin/pressure-vessel-unruntime" "$@" - -# vim:set sw=4 sts=4 et: +echo "$0: This script is no longer used" >&2 +exit 2 diff --git a/populate-depot.py b/populate-depot.py index 0a7a4c15a11e7c2306a3b15adbbc8b9f116ac01d..885d0247286c7ee26727e190ecb0bb20f429b166 100755 --- a/populate-depot.py +++ b/populate-depot.py @@ -270,14 +270,19 @@ me="$(readlink -f "$0")" here="${{me%/*}}" me="${{me##*/}}" -exec "$here/run-in-steamrt" \\ - --arch={escaped_arch} \\ - --deploy \\ - --runtime={escaped_runtime} \\ - --suite={escaped_suite} \\ - {escaped_name} \\ - -- \\ - "$@" +archive={escaped_runtime}-{escaped_arch}-{escaped_suite}-runtime.tar.gz +pressure_vessel="${{PRESSURE_VESSEL_PREFIX:-"${{here}}/pressure-vessel"}}" + +export PRESSURE_VESSEL_GC_LEGACY_RUNTIMES=1 +unset PRESSURE_VESSEL_RUNTIME +export PRESSURE_VESSEL_RUNTIME_ARCHIVE="${{archive}}" +export PRESSURE_VESSEL_RUNTIME_BASE="${{here}}" + +if [ -z "${{PRESSURE_VESSEL_VARIABLE_DIR-}}" ]; then + export PRESSURE_VESSEL_VARIABLE_DIR="${{here}}/var" +fi + +exec "${{pressure_vessel}}/bin/pressure-vessel-unruntime" "$@" ''' @@ -661,8 +666,6 @@ class Main: writer.write('// Generated file, do not edit\n') words = [ '/_v2-entry-point', - '--deploy=' + shlex.quote(runtime.name), - '--suite=' + shlex.quote(runtime.suite), '--verb=%verb%', '--', ]