steam-backlog-enforcer/_installer_import/run.sh
Krzysztof kuhy Rudnicki c1b6fdd16f Map safe games to a FOSS Proton
Install the pinned proton-cachyos-native build (signature and
sha256 checked, .INSTALL never run), decide per game whether it
is safe, write the CompatToolMapping as text, add --map-installed
and --valve-proton, and drop steamcmd from install.sh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:57:48 +01:00

106 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
# ============================================================================
# Install a Steam game from whatever you happen to have: an AppID, a Steam URL,
# or the game's name.
#
# ./run.sh 284160
# ./run.sh https://steamcommunity.com/app/284160/guides/
# ./run.sh BeamNG.drive
# ./run.sh BeamNG
#
# Dependencies install themselves on first run. Every other argument is passed
# straight through to the CLI, so `./run.sh --help` lists the full set.
# ============================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly SCRIPT_DIR
readonly VENV_PY="${SCRIPT_DIR}/.venv/bin/python"
readonly STAMP="${SCRIPT_DIR}/.venv/.deps-ok"
readonly INSTALLER="${SCRIPT_DIR}/install.sh"
readonly PROTON_LOCK="${SCRIPT_DIR}/steam_installer/data/proton-native.lock"
SKIP_DEPS="${SGI_SKIP_DEPS:-0}"
DEPS_ONLY=0
ARGS=()
usage() {
echo "Usage: run.sh [TARGET] [OPTIONS]"
echo
echo "TARGET is any of:"
echo " 284160 an AppID"
echo " https://steamcommunity.com/app/284160/... a Steam URL"
echo " BeamNG.drive the exact name"
echo " BeamNG part of the name"
echo
echo "run.sh options:"
echo " --no-deps Skip the dependency check (also: SGI_SKIP_DEPS=1)"
echo " --deps-only Install dependencies and exit"
echo " -h, --help Show this help, then the installer's own options"
echo
if [[ -x "$VENV_PY" ]]; then
"$VENV_PY" -m steam_installer.cli --help
fi
exit 0
}
# Dependencies are only re-checked when the stamp is missing or older than the
# files that decide what gets installed, so a normal run adds no startup cost.
deps_are_current() {
[[ -x "$VENV_PY" ]] || return 1
[[ -f "$STAMP" ]] || return 1
[[ "$STAMP" -nt "$INSTALLER" ]] || return 1
[[ "$STAMP" -nt "${SCRIPT_DIR}/pyproject.toml" ]] || return 1
[[ "$STAMP" -nt "$PROTON_LOCK" ]] || return 1
# A bumped pin or a deleted tool folder: the stamp alone would miss both.
"$VENV_PY" -m steam_installer.proton_native --check >/dev/null 2>&1
}
main() {
if [[ "$SKIP_DEPS" != "1" ]] && ! deps_are_current; then
"$INSTALLER"
fi
if [[ "$DEPS_ONLY" -eq 1 ]]; then
exit 0
fi
[[ -x "$VENV_PY" ]] || {
echo "error: no virtualenv at ${VENV_PY}. Run ./install.sh" >&2
exit 1
}
# `-m` rather than the console script, so a stale .venv shim can never
# shadow the working tree.
exec "$VENV_PY" -m steam_installer.cli "${ARGS[@]}"
}
while [[ $# -gt 0 ]]; do
case $1 in
--no-deps)
SKIP_DEPS=1
shift
;;
--deps-only)
DEPS_ONLY=1
shift
;;
-h | --help)
usage
;;
--)
shift
ARGS+=("$@")
break
;;
*)
ARGS+=("$1")
shift
;;
esac
done
main