diff --git a/common/_v2-entry-point b/common/_v2-entry-point index 1a77a88a3744cc61f0847bb3e082fb6c9632ef8f..e0c7678c457dca547f5979494e887794e9daaa83 100755 --- a/common/_v2-entry-point +++ b/common/_v2-entry-point @@ -22,6 +22,13 @@ ld_preload= # Arguments for pressure-vessel-wrap declare -a container_args=() +# Will be edited by a script, be careful +this_compat_tool_appid= + +if [ -f "${here}/steam_appid.txt" ]; then + this_compat_tool_appid="$(< "${here}/steam_appid.txt")" +fi + if [ -n "${LD_PRELOAD-}" ]; then container_args+=("--env-if-host=LD_PRELOAD=$LD_PRELOAD") ld_preload="$LD_PRELOAD" @@ -279,7 +286,10 @@ done IFS="$old_IFS" case "${STEAM_COMPAT_LAUNCHER_SERVICE-}" in - (container-runtime) + ("") + ;; + + ("$this_compat_tool_appid" | container-runtime) launcher_service=yes ;; esac diff --git a/populate-depot.py b/populate-depot.py index 3e78be19cfa9ae702f2c74ca7b013c9b0f7f7359..86f76a72dbb12442ab7852fb773893db0ef10e09 100755 --- a/populate-depot.py +++ b/populate-depot.py @@ -551,6 +551,7 @@ class Main: source_dir: str = HERE, ssh_host: str = '', ssh_path: str = '', + steam_app_id: str = '', suite: str = '', toolmanifest: bool = False, unpack_ld_library_path: str = '', @@ -619,6 +620,7 @@ class Main: self.source_dir = source_dir self.ssh_host = ssh_host self.ssh_path = ssh_path + self.steam_app_id = steam_app_id self.toolmanifest = toolmanifest self.unpack_ld_library_path = unpack_ld_library_path self.unpack_runtime = unpack_runtime @@ -791,9 +793,30 @@ class Main: 'Cannot use --unpack-source with --layered' ) - self.merge_dir_into_depot( - os.path.join(self.source_dir, 'runtimes', 'scout-on-soldier') + source_dir = os.path.join( + self.source_dir, + 'runtimes', + 'scout-on-soldier', ) + self.merge_dir_into_depot(source_dir) + + if self.steam_app_id: + with open( + os.path.join(source_dir, 'scout-on-soldier-entry-point-v2') + ) as text_reader, open( + os.path.join(self.depot, 'scout-on-soldier-entry-point-v2'), + 'w', + ) as text_writer: + for line in text_reader: + if line.startswith('this_compat_tool_appid='): + line = f'this_compat_tool_appid={self.steam_app_id}\n' + + text_writer.write(line) + + os.chmod( + os.path.join(self.depot, 'scout-on-soldier-entry-point-v2'), + 0o755, + ) if self.runtime.version: self.unpack_ld_library_path = self.depot @@ -888,6 +911,24 @@ class Main: if os.path.exists(root): self.merge_dir_into_depot(root) + if self.steam_app_id: + with open( + os.path.join(self.source_dir, 'common', '_v2-entry-point') + ) as text_reader, open( + os.path.join(self.depot, '_v2-entry-point'), + 'w', + ) as text_writer: + for line in text_reader: + if line.startswith('this_compat_tool_appid='): + line = f'this_compat_tool_appid={self.steam_app_id}\n' + + text_writer.write(line) + + os.chmod( + os.path.join(self.depot, '_v2-entry-point'), + 0o755, + ) + pressure_vessel_runtime = self.pressure_vessel_runtime if self.pressure_vessel_version: @@ -1869,6 +1910,10 @@ def main() -> None: 'Source directory for files to include in the depot' ) ) + parser.add_argument( + '--steam-app-id', default='', + help='Set Steam app ID for the depot', + ) parser.add_argument( '--toolmanifest', default=False, action='store_true', help='Generate toolmanifest.vdf', diff --git a/runtimes/scout-on-soldier/scout-on-soldier-entry-point-v2 b/runtimes/scout-on-soldier/scout-on-soldier-entry-point-v2 index 420934fb03f40c0c5c3c266c40f7a3819ecfb31a..d21e4d14da6c02faa8da3223f95f23d18e4378e0 100755 --- a/runtimes/scout-on-soldier/scout-on-soldier-entry-point-v2 +++ b/runtimes/scout-on-soldier/scout-on-soldier-entry-point-v2 @@ -12,6 +12,9 @@ unset LD_PRELOAD me="$(readlink -f "$0")" here="${me%/*}" +# Will be edited by a script, be careful +this_compat_tool_appid= + log () { printf '%s\n' "${me}[$$]: $*" >&2 || : } @@ -102,8 +105,15 @@ main () { esac done + if [ -f "${here}/steam_appid.txt" ]; then + this_compat_tool_appid="$(< "${here}/steam_appid.txt")" + fi + case "${STEAM_COMPAT_LAUNCHER_SERVICE-}" in - (scout-in-container | scout-on-soldier) + ("") + ;; + + ("$this_compat_tool_appid" | scout-in-container | scout-on-soldier) launcher_service=yes ;; esac diff --git a/tests/scout.sh b/tests/scout.sh index 57dbafca98efee1444c5d5bf4d1f48f693831220..74f937c7ed1d72af60df079442207b929ae3428a 100755 --- a/tests/scout.sh +++ b/tests/scout.sh @@ -10,7 +10,7 @@ if [ -n "${TESTS_ONLY-}" ]; then exit 0 fi -populate_depot_args=() +populate_depot_args=("--steam-app-id=1070560") if [ -n "${IMAGES_DOWNLOAD_CREDENTIAL-}" ]; then populate_depot_args=( \ @@ -66,6 +66,12 @@ python3 ./populate-depot.py \ scout \ ${NULL+} find depots/test-scout-archives -ls > depots/test-scout-archives.txt + +if ! grep '^this_compat_tool_appid=1070560' depots/test-scout-archives/_v2-entry-point >/dev/null; then + echo "Bail out! App ID not found in _v2-entry-point" + exit 1 +fi + echo "ok 1 - scout, deploying from archive" rm -fr depots/test-scout-unpacked @@ -81,6 +87,12 @@ python3 ./populate-depot.py \ scout \ ${NULL+} find depots/test-scout-unpacked -ls > depots/test-scout-unpacked.txt + +if ! grep '^this_compat_tool_appid=1070560' depots/test-scout-unpacked/_v2-entry-point >/dev/null; then + echo "Bail out! App ID not found in _v2-entry-point" + exit 1 +fi + echo "ok 2 - scout, running from unpacked directory" rm -fr depots/test-scout-layered @@ -106,6 +118,11 @@ if ! grep $'^LD_LIBRARY_PATH\t-\tscout\t-\t#' depots/test-scout-layered/VERSIONS exit 1 fi +if ! grep '^this_compat_tool_appid=1070560' depots/test-scout-layered/scout-on-soldier-entry-point-v2 >/dev/null; then + echo "Bail out! App ID not found in scout-on-soldier-entry-point-v2" + exit 1 +fi + echo "ok 3 - scout, layered on soldier, reusing standard LDLP runtime" rm -fr depots/test-scout-layered-beta diff --git a/tests/sniper.sh b/tests/sniper.sh index b7030f455dea9292217c9766a3066dd83ea7cee3..5e76c73328d85f1f3e6d63eb88411af5d8458dff 100755 --- a/tests/sniper.sh +++ b/tests/sniper.sh @@ -10,7 +10,7 @@ if [ -n "${TESTS_ONLY-}" ]; then exit 0 fi -populate_depot_args=() +populate_depot_args=("--steam-app-id=1628350") if [ -n "${IMAGES_DOWNLOAD_CREDENTIAL-}" ]; then populate_depot_args=( \ @@ -66,6 +66,12 @@ python3 ./populate-depot.py \ sniper \ ${NULL+} find depots/test-sniper-archives -ls > depots/test-sniper-archives.txt + +if ! grep '^this_compat_tool_appid=1628350' depots/test-sniper-archives/_v2-entry-point >/dev/null; then + echo "Bail out! App ID not found in _v2-entry-point" + exit 1 +fi + echo "ok 1 - sniper, deploying from archive" rm -fr depots/test-sniper-unpacked @@ -81,6 +87,12 @@ python3 ./populate-depot.py \ sniper \ ${NULL+} find depots/test-sniper-unpacked -ls > depots/test-sniper-unpacked.txt + +if ! grep '^this_compat_tool_appid=1628350' depots/test-sniper-unpacked/_v2-entry-point >/dev/null; then + echo "Bail out! App ID not found in _v2-entry-point" + exit 1 +fi + echo "ok 2 - sniper, running from unpacked directory" # vim:set sw=4 sts=4 et: diff --git a/tests/soldier.sh b/tests/soldier.sh index 7e6a25c34346d059affc2baea2ddc89edaa3c322..c79064a95833de1ada6f784c5706d571b11d022a 100755 --- a/tests/soldier.sh +++ b/tests/soldier.sh @@ -10,7 +10,7 @@ if [ -n "${TESTS_ONLY-}" ]; then exit 0 fi -populate_depot_args=() +populate_depot_args=("--steam-app-id=1391110") if [ -n "${IMAGES_DOWNLOAD_CREDENTIAL-}" ]; then populate_depot_args=( \ @@ -77,6 +77,11 @@ if ! grep $'^depot\t0\\.1\\.2\\.3\t' depots/test-soldier-archives/VERSIONS.txt > exit 1 fi +if ! grep '^this_compat_tool_appid=1391110' depots/test-soldier-archives/_v2-entry-point >/dev/null; then + echo "Bail out! App ID not found in _v2-entry-point" + exit 1 +fi + buildid="$(cat "depots/test-soldier-archives/$archive-buildid.txt")" soldier_version="$( IFS="$(printf '\t')" @@ -137,6 +142,11 @@ python3 ./populate-depot.py \ ${NULL+} find depots/test-soldier-unpacked -ls > depots/test-soldier-unpacked.txt +if ! grep '^this_compat_tool_appid=1391110' depots/test-soldier-unpacked/_v2-entry-point >/dev/null; then + echo "Bail out! App ID not found in _v2-entry-point" + exit 1 +fi + soldier_version="$( IFS="$(printf '\t')" while read -r component version runtime comment; do