mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
feat: optional x86-64 Steam client (Valve's Linux client under FEX) beside the arm64 one (#152)
An opt-in second Steam client (Steam settings, Steam client: x86-64): Valve's x86-64 Linux client, unchanged, runs under FEX in its own home with its own game library and the same sign-in. Linux builds run directly, so titles such as Team Fortress 2 and Half-Life use their Linux versions; Windows games use DroidDeck-Proton as on arm64. The arm64 client stays the default. - droiddeck-steam-x64: FEX and the x86-64 rootfs from DroidDeck-Components (sha256-pinned), client install and sync from Valve's CDN, sign-in shared with the arm64 client, its web helper on the GPU (ANGLE GL over FEX's GL thunk, zink, Turnip), Proton wrappers for the arm64 client's tools, DroidDeck direct for Linux builds, SD-card library (x86-64/ beside the arm64 one), repair. - FEX 2610 built by build-fex.yml with thunks and three patches: an openat2 fallback without openat2 (proot), newer-clang thunkgen, MAP_32BIT exhaustion returning ENOMEM. libblsession resolves RESOLVE_IN_ROOT paths inside the root. - Session: x86-64 gating, shortcuts and compatibility tools per client, logs from the client that ran. - App: client setting with the FEX version, an x86-64 chip on the Games header, the active client's library, art, storage, downloads, repair, Offline Mode, Decky, desktop mode, optional VAC diagnostics; per-client state for art, the content log, repair and leftovers. - Strings in every locale. - Review fixes: the library cache is saved only by the newest scan; an abandoned session's Steam logs come from the client it recorded; distinct VAC console names; FEXInterpreter in CPU pinning; clearer VAC hint in pl, ru, uk, cs and bg.
This commit is contained in:
1 parent
ab799e6938
commit
db8d1c9910
125 files changed
+4953
-263
No files matched your search
@@ -27,6 +27,15 @@ export BL_DESKTOP=1
|
||||
ln -sf /usr/local/bin/droiddeck-steam-launch /usr/local/bin/steamdeck-steam 2>/dev/null
|
||||
ln -sf /usr/local/bin/droiddeck-steam-shim /usr/local/bin/steam 2>/dev/null
|
||||
python3 /usr/local/bin/droiddeck-desktop-games 2>&1 | sed 's/^/[games] /'
|
||||
cat > /usr/share/applications/droiddeck-steam-x64.desktop <<'ENTRY'
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Steam x86-64 (FEX, experimental)
|
||||
Comment=Valve's x86-64 Linux client under FEX, in its own home with its own login
|
||||
Exec=qterminal -e /usr/local/bin/droiddeck-steam-x64
|
||||
Icon=steam
|
||||
Categories=System;
|
||||
ENTRY
|
||||
python3 /usr/local/bin/droiddeck-pad-defaults 2>&1 | sed 's/^/[pads] /'
|
||||
( while sleep 30; do python3 /usr/local/bin/droiddeck-pad-defaults 2>&1 | sed 's/^/[pads] /'; done ) &
|
||||
python3 /usr/local/bin/droiddeck-desktop-gpu 2>&1 | sed 's/^/[gpu] /'
|
||||
|
||||
@@ -21,6 +21,7 @@ Requests: ping, exec, focus, cdp, quit. Each answer is {"ok": true, ...} or
|
||||
import base64
|
||||
import json
|
||||
import math
|
||||
import re
|
||||
import os
|
||||
import selectors
|
||||
import signal
|
||||
@@ -254,6 +255,31 @@ def focus_snapshot():
|
||||
return snap
|
||||
|
||||
|
||||
STEAM_APP_CLASS = re.compile(r"steam_app_(\d+)$")
|
||||
|
||||
|
||||
def tag_game_windows(snap):
|
||||
if os.environ.get("BL_STEAM_CLIENT_ARCH") != "x86_64":
|
||||
return False
|
||||
tagged = False
|
||||
for display, wins in snap.get("displays", {}).items():
|
||||
if display == os.environ.get("DISPLAY"):
|
||||
continue
|
||||
for win in wins:
|
||||
match = STEAM_APP_CLASS.match(win.get("class") or "")
|
||||
if not match or win.get("appId") or win.get("map") != "viewable" or win.get("overrideRedirect"):
|
||||
continue
|
||||
try:
|
||||
done = subprocess.run(["xprop", "-display", display, "-id", str(win["window"]), "-f", "STEAM_GAME", "32c",
|
||||
"-set", "STEAM_GAME", match.group(1)],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=5).returncode == 0
|
||||
except (OSError, subprocess.TimeoutExpired):
|
||||
done = False
|
||||
log("game window %s on %s tagged STEAM_GAME=%s: %s" % (win["window"], display, match.group(1), "ok" if done else "failed"))
|
||||
tagged = tagged or done
|
||||
return tagged
|
||||
|
||||
|
||||
def vr_scene_app(path=Path('/run/droiddeck/droiddeck-steamvr/scene-focus.json'), proc=Path('/proc')):
|
||||
"""Only a live SteamVR scene with its dashboard hidden may claim game focus."""
|
||||
try:
|
||||
@@ -326,6 +352,9 @@ class FocusWatcher(threading.Thread):
|
||||
log("focus snapshot failed: %s" % e)
|
||||
time.sleep(2)
|
||||
continue
|
||||
if tag_game_windows(snap):
|
||||
self.changed.set()
|
||||
continue
|
||||
body = {k: v for k, v in snap.items() if k != "t"}
|
||||
if body == self.last:
|
||||
continue
|
||||
|
||||
@@ -4,8 +4,10 @@ import re
|
||||
import sys
|
||||
|
||||
HOME = os.environ.get("HOME", "/root")
|
||||
STEAM_ROOT = sys.argv[1] if len(sys.argv) > 1 else os.path.join(HOME, ".local/share/Steam")
|
||||
LIBRARIES = ((STEAM_ROOT, "Steam Games"), ("/mnt/droiddeck-sd", "SD Games"))
|
||||
X64 = os.environ.get("BL_STEAM_CLIENT_ARCH") == "x86_64"
|
||||
CLIENT_HOME = (os.environ.get("BL_X64_HOME") or os.path.join(HOME, ".droiddeck-x64")) if X64 else HOME
|
||||
STEAM_ROOT = sys.argv[1] if len(sys.argv) > 1 else os.path.join(CLIENT_HOME, ".local/share/Steam")
|
||||
LIBRARIES = ((STEAM_ROOT, "Steam Games"), ("/mnt/droiddeck-sd/x86-64" if X64 else "/mnt/droiddeck-sd", "SD Games"))
|
||||
NOT_GAMES = {228980, 1070560, 1391110, 1493710, 1628350, 3127680, 4183110, 4185400, 4427310, 4628740}
|
||||
APPS_DIR = os.path.join(HOME, ".local/share/applications")
|
||||
PREFIX = "droiddeck-game-"
|
||||
|
||||
@@ -422,6 +422,12 @@ def guest_environment(fex, env):
|
||||
result["FEX_APP_CONFIG_LOCATION"] = CONFIG_DIR + "/"
|
||||
result["FEX_APP_DATA_LOCATION"] = data + "/"
|
||||
result["FEX_APP_CACHE_LOCATION"] = CACHE_DIR + "/"
|
||||
# Valve's FEX-Emu binds its server socket under $STEAM_COMPAT_DATA_PATH/fex-emu whatever FEX_APP_DATA_LOCATION or
|
||||
# FEX_SERVERSOCKETPATH say, and sun_path is 108 bytes: compatdata under the app's data folder is too long.
|
||||
if result.get("STEAM_COMPAT_DATA_PATH"):
|
||||
short = data if data != DATA_DIR else "/tmp/fex"
|
||||
os.makedirs(short, exist_ok=True)
|
||||
result["STEAM_COMPAT_DATA_PATH"] = short
|
||||
result.setdefault("FEX_SILENTLOG", "0")
|
||||
result.setdefault("FEX_OUTPUTLOG", "stderr")
|
||||
if fex["portable"]:
|
||||
|
||||
@@ -261,7 +261,7 @@ def mark_install_scripts(command, env):
|
||||
ones stop with an error."""
|
||||
if not any(arg.lower().replace("\\", "/").endswith("iscriptevaluator.exe") for arg in command):
|
||||
return
|
||||
root = env.get("STEAM_COMPAT_CLIENT_INSTALL_PATH") or str(Path.home() / ".local/share/Steam")
|
||||
root = env.get("BL_X64_STEAM_ROOT") or env.get("STEAM_COMPAT_CLIENT_INSTALL_PATH") or str(Path.home() / ".local/share/Steam")
|
||||
scripts = [str(Path(root) / arg.replace("\\", "/")) for arg in command if EVALUATOR_SCRIPT.search(arg)]
|
||||
scripts = [path for path in scripts if os.path.isfile(path)]
|
||||
if not scripts:
|
||||
|
||||
@@ -6,9 +6,11 @@ LIBRARIES=${DROIDDECK_LIBRARIES-/mnt/droiddeck /mnt/droiddeck-sd}
|
||||
redist="$steam_root/steamapps/common/Steamworks Shared/_CommonRedist"
|
||||
|
||||
read_scripts() { xargs -0 -r awk -v want="${1:-redists}" '
|
||||
FNR == 1 { depth = 0; pending = "" }
|
||||
/^[[:space:]]*\{/ { depth++; name[depth] = pending; key[depth] = ""; vulkan[depth] = 0; pending = ""; next }
|
||||
FNR == 1 { depth = 0; pending = ""; appid = "" }
|
||||
/^[[:space:]]*\{/ { depth++; name[depth] = pending; key[depth] = ""; vulkan[depth] = 0; proc[depth] = 0; pending = ""; next }
|
||||
/^[[:space:]]*\}/ {
|
||||
if (depth > 0 && key[depth] == "" && proc[depth] && appid != "" && name[depth] != "" && vulkan[depth] == (want == "vulkan"))
|
||||
printf "HKEY_LOCAL_MACHINE\\\\Software\\\\Valve\\\\Steam\\\\Apps\\\\%s\t%s\n", appid, name[depth]
|
||||
if (depth > 0 && key[depth] != "" && name[depth] != "" && vulkan[depth] == (want == "vulkan"))
|
||||
printf "%s\t%s\n", key[depth], name[depth]
|
||||
if (depth > 0) depth--
|
||||
@@ -16,8 +18,10 @@ read_scripts() { xargs -0 -r awk -v want="${1:-redists}" '
|
||||
}
|
||||
{
|
||||
n = split($0, part, "\"")
|
||||
if (n >= 5 && tolower(part[2]) == "appid" && part[4] ~ /^[0-9]+$/) { appid = part[4]; next }
|
||||
if (n >= 5 && tolower(part[2]) == "hasrunkey") { key[depth] = part[4]; next }
|
||||
if (n >= 5 && tolower(part[2]) ~ /^process [0-9]+$/) {
|
||||
proc[depth] = 1
|
||||
program = tolower(part[4])
|
||||
sub(/.*[\\\/]/, "", program)
|
||||
if (program ~ /vulkan/) vulkan[depth] = 1
|
||||
|
||||
@@ -33,9 +33,9 @@ prepare_locale() {
|
||||
|
||||
clear_stale_tmp() {
|
||||
local running names=() n
|
||||
running=$(pgrep -af 'steamwebhelper|steamrtarm64/steam|--type=|droiddeck-appimage-run|dbus-run-session|dbus-daemon.*--session|dbus-launch|kwin|plasmashell' 2>/dev/null)
|
||||
running=$(pgrep -af 'steamwebhelper|steamrtarm64/steam|steamrt64/steam|--type=|droiddeck-appimage-run|dbus-run-session|dbus-daemon.*--session|dbus-launch|kwin|plasmashell' 2>/dev/null)
|
||||
case $running in
|
||||
*steamwebhelper* | *steamrtarm64/steam*) ;;
|
||||
*steamwebhelper* | *steamrtarm64/steam* | *steamrt64/steam*) ;;
|
||||
*) names+=(-o -name 'mangohud.????????' -o -name '.com.valvesoftware.Steam.??????'
|
||||
-o -name 'steam_chrome_shmem_uid*' -o \( -type d -empty -name 'steam??????' \)) ;;
|
||||
esac
|
||||
@@ -79,10 +79,11 @@ run_gamescope() (
|
||||
collect_steam_logs() {
|
||||
[ -n "${BL_DEBUG_DIR:-}" ] || return 0
|
||||
local steam_root=${XDG_DATA_HOME:-$HOME/.local/share}/Steam
|
||||
[ "${steam_x64:-0}" = 1 ] && steam_root=${BL_X64_HOME:-$HOME/.droiddeck-x64}/.local/share/Steam
|
||||
mkdir -p "$BL_DEBUG_DIR/steam" 2>/dev/null || return 0
|
||||
[ -d "$steam_root/logs" ] && find "$steam_root/logs" -maxdepth 1 -type f -size -8192k \
|
||||
-exec cp {} "$BL_DEBUG_DIR/steam/" \; 2>/dev/null
|
||||
[ -f "$HOME/.steam/steam/logs/steamwebhelper.log" ] && cp "$HOME/.steam/steam/logs/steamwebhelper.log" "$BL_DEBUG_DIR/steam/" 2>/dev/null
|
||||
[ "${steam_x64:-0}" = 0 ] && [ -f "$HOME/.steam/steam/logs/steamwebhelper.log" ] && cp "$HOME/.steam/steam/logs/steamwebhelper.log" "$BL_DEBUG_DIR/steam/" 2>/dev/null
|
||||
local sync_store=$HOME/.local/share/droiddeck-esync sync_file
|
||||
if [ -d "$sync_store" ] && mkdir -p "$BL_DEBUG_DIR/droiddeck-esync" 2>/dev/null; then
|
||||
for sync_file in launches.log tools.tsv wanted.tsv prefixes.json; do
|
||||
@@ -344,17 +345,52 @@ case $mode in
|
||||
esac
|
||||
;;
|
||||
steam)
|
||||
step "checking the Steam client (first run downloads it, ~1-2 min with nothing on screen)"
|
||||
droiddeck-steam-install || exit $?
|
||||
step "Steam client ready"
|
||||
steam_root=$XDG_DATA_HOME/Steam
|
||||
steam_x64=0
|
||||
[ "${BL_STEAM_CLIENT_ARCH:-}" = x86_64 ] && steam_x64=1
|
||||
steam_cef_gpu=1
|
||||
if [ "$steam_x64" = 1 ]; then
|
||||
step "checking the Steam client's arm64 parts (first run downloads them, ~1-2 min)"
|
||||
# droiddeck-steam-install removes the repair request: read it first so Repair Steam covers both clients.
|
||||
_bl_x64_repair=0
|
||||
[ -e "$HOME/.bl-steam-repair" ] && _bl_x64_repair=1
|
||||
droiddeck-steam-install || exit $?
|
||||
droiddeck-steam-install --sync steamdeck_publicbeta || step "could not update the arm64 client's parts; the x86-64 client keeps its own web helper"
|
||||
step "checking the x86-64 Steam client (FEX, experimental; the first run downloads ~2 GB)"
|
||||
BL_X64_REPAIR=$_bl_x64_repair droiddeck-steam-x64 --prepare || exit $?
|
||||
step "x86-64 Steam client ready"
|
||||
steam_root=${BL_X64_HOME:-$HOME/.droiddeck-x64}/.local/share/Steam
|
||||
steam_client=(droiddeck-steam-x64 --exec)
|
||||
if [ "${BL_X64_X86_WEBHELPER:-0}" = 1 ] &&
|
||||
! droiddeck-steam-x64 --webhelper-gpu; then
|
||||
steam_cef_gpu=0
|
||||
fi
|
||||
else
|
||||
step "checking the Steam client (first run downloads it, ~1-2 min with nothing on screen)"
|
||||
droiddeck-steam-install || exit $?
|
||||
step "Steam client ready"
|
||||
steam_root=$XDG_DATA_HOME/Steam
|
||||
if [ -f "${BL_X64_HOME:-$HOME/.droiddeck-x64}/.local/share/Steam/local.vdf" ]; then
|
||||
droiddeck-steam-x64 --sync-login || true
|
||||
fi
|
||||
steam_client=("$steam_root/steamrtarm64/steam")
|
||||
fi
|
||||
_bl_proton_root=$steam_root
|
||||
if [ "$steam_x64" = 1 ]; then
|
||||
_bl_proton_root=$XDG_DATA_HOME/Steam
|
||||
if ! ls -d "$_bl_proton_root"/compatibilitytools.d/GE-Proton*-aarch64 >/dev/null 2>&1 &&
|
||||
! grep -q '^ge' "$HOME/.bl-proton-extra" 2>/dev/null; then
|
||||
echo ge >> "$HOME/.bl-proton-extra"
|
||||
fi
|
||||
fi
|
||||
if [ -s "$HOME/.bl-proton-extra" ]; then
|
||||
_bl_left=$HOME/.bl-proton-extra.left
|
||||
: > "$_bl_left"
|
||||
_bl_got_proton=0
|
||||
while read -r _bl_extra || [ -n "$_bl_extra" ]; do
|
||||
case ${_bl_extra# } in ""|"#"*) continue ;; esac
|
||||
step "installing Proton '$_bl_extra' (large download, several minutes)"
|
||||
if droiddeck-proton-extra "$steam_root" $_bl_extra; then
|
||||
if droiddeck-proton-extra "$_bl_proton_root" $_bl_extra; then
|
||||
_bl_got_proton=1
|
||||
step "installed Proton '$_bl_extra'"
|
||||
else
|
||||
step "Proton '$_bl_extra' failed; will retry next session"
|
||||
@@ -362,6 +398,9 @@ case $mode in
|
||||
fi
|
||||
done < "$HOME/.bl-proton-extra"
|
||||
mv -f "$_bl_left" "$HOME/.bl-proton-extra"
|
||||
if [ "$steam_x64" = 1 ] && [ "$_bl_got_proton" = 1 ]; then
|
||||
droiddeck-steam-x64 --prepare || true
|
||||
fi
|
||||
fi
|
||||
if [ -s "$HOME/.bl-steam-urls" ]; then
|
||||
while read -r _bl_url || [ -n "$_bl_url" ]; do
|
||||
@@ -381,7 +420,9 @@ case $mode in
|
||||
bl_zram_scan() {
|
||||
_bl_game=0 _bl_pids=()
|
||||
for _d in /proc/[0-9]*; do
|
||||
IFS= read -r -d '' _c 2>/dev/null < "$_d/cmdline" || continue
|
||||
# Under FEX the program is FEX's first argument.
|
||||
{ IFS= read -r -d '' _c && case ${_c##*/} in FEX|FEXInterpreter) IFS= read -r -d '' _c ;; esac; } \
|
||||
2>/dev/null < "$_d/cmdline" || continue
|
||||
case ${_c##*/} in
|
||||
reaper) _bl_game=1 ;;
|
||||
steam|steamwebhelper) _bl_pids+=("${_d#/proc/}") ;;
|
||||
@@ -430,6 +471,7 @@ case $mode in
|
||||
/usr/local/bin/droiddeck-launcher-cores "$BL_LAUNCH_DIR/agent/focus.json" 2>&1 &
|
||||
fi
|
||||
|
||||
if [ "$steam_x64" = 0 ]; then
|
||||
step "registering the app's game library with Steam"
|
||||
droiddeck-steam-library "$steam_root" || true
|
||||
step "setting up the ARM64 Proton compatibility tool"
|
||||
@@ -442,7 +484,22 @@ case $mode in
|
||||
droiddeck-steam-shortcuts "$steam_root" "$BL_ADDED_GAMES" || true
|
||||
fi
|
||||
droiddeck-seed-redists "$steam_root" || true
|
||||
if [ ! -f "$steam_root/steamapps/appmanifest_4427310.acf" ]; then
|
||||
else
|
||||
_bl_x64_tool=$(droiddeck-steam-x64 --default-tool)
|
||||
if [ -n "$_bl_x64_tool" ]; then
|
||||
if [ -n "${BL_ADDED_GAMES:-}" ]; then
|
||||
step "adding the app's own games to the x86-64 client's library"
|
||||
BL_COMPAT_TOOL=$_bl_x64_tool droiddeck-steam-shortcuts "$steam_root" "$BL_ADDED_GAMES" || true
|
||||
fi
|
||||
step "pointing the x86-64 client's Windows titles at $_bl_x64_tool"
|
||||
BL_COMPAT_TOOL=$_bl_x64_tool steam-compatibility "$steam_root" --x64 || true
|
||||
fi
|
||||
if [ -z "${BL_DESKTOP:-}" ] && [ "${BL_STEAM_UI:-}" != desktop ]; then
|
||||
droiddeck-steam-ui-scale "$steam_root" "${BL_WIDTH:-1280}" "${BL_HEIGHT:-720}" || true
|
||||
fi
|
||||
droiddeck-seed-redists "$steam_root" || true
|
||||
fi
|
||||
if [ "$steam_x64" = 0 ] && [ ! -f "$steam_root/steamapps/appmanifest_4427310.acf" ]; then
|
||||
step "asking the client to fetch the ARM64 Proton"
|
||||
set -- "$@" steam://install/4427310
|
||||
(
|
||||
@@ -454,7 +511,7 @@ case $mode in
|
||||
steam-compatibility "$steam_root" >/dev/null 2>&1 || true
|
||||
step "compatibility layer installed: restarting the Steam client once"
|
||||
: > "$HOME/.bl-restart-once"
|
||||
"$steam_root/steamrtarm64/steam" -shutdown >/dev/null 2>&1 || true
|
||||
"${steam_client[@]}" -shutdown >/dev/null 2>&1 || true
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
@@ -478,7 +535,7 @@ case $mode in
|
||||
sleep 10
|
||||
[ -f "$_bl_acf" ] && exit 0
|
||||
step "signed in: asking the client again for the ARM64 Proton (try $_bl_try of 3)"
|
||||
"$steam_root/steamrtarm64/steam" steam://install/4427310 >/dev/null 2>&1 || true
|
||||
"${steam_client[@]}" steam://install/4427310 >/dev/null 2>&1 || true
|
||||
sleep 50
|
||||
done
|
||||
exit 0
|
||||
@@ -712,23 +769,26 @@ BUSCONF
|
||||
echo "== steam: devtools port $BL_CDP_PORT, guest processes only"
|
||||
fi
|
||||
[ -n "${BL_LAUNCH_DIR:-}" ] && mkdir -p "$BL_LAUNCH_DIR/agent" && echo "$BL_CDP_PORT" > "$BL_LAUNCH_DIR/agent/cdp-port"
|
||||
"${_bl_compat_env[@]}" droiddeck-steam-compat "$steam_root" 2>&1 &
|
||||
[ "$steam_x64" = 1 ] || "${_bl_compat_env[@]}" droiddeck-steam-compat "$steam_root" 2>&1 &
|
||||
_bl_ui=(-gamepadui)
|
||||
[ "${BL_STEAM_UI:-}" = desktop ] && _bl_ui=()
|
||||
_bl_cef=(-cef-force-gpu -cef-use-gl=angle -cef-use-angle=vulkan)
|
||||
[ "${steam_cef_gpu:-1}" = 1 ] || _bl_cef=(-cef-disable-gpu)
|
||||
if [ "${BL_DESKTOP:-}" = 1 ] && [ "${BL_STEAM_UI:-}" = desktop ]; then
|
||||
_bl_cef=(-cef-disable-gpu)
|
||||
_bl_ui=(-nobigpicture)
|
||||
fi
|
||||
if [ "${BL_STEAM_UI:-}" != desktop ]; then
|
||||
_bl_ui+=(-steamdeck -steamos3)
|
||||
export STEAM_GAMESCOPE_NIS_SUPPORTED=1
|
||||
export STEAM_GAMESCOPE_FANCY_SCALING_SUPPORT=1
|
||||
echo "== steam: Deck mode on (-steamdeck -steamos3)"
|
||||
if [ "$steam_x64" = 0 ] || [ "${BL_X64_DECK:-1}" != 0 ]; then
|
||||
_bl_ui+=(-steamdeck -steamos3)
|
||||
export STEAM_GAMESCOPE_NIS_SUPPORTED=1
|
||||
export STEAM_GAMESCOPE_FANCY_SCALING_SUPPORT=1
|
||||
echo "== steam: Deck mode on (-steamdeck -steamos3)"
|
||||
fi
|
||||
fi
|
||||
export STEAMOS_STEAM_SHUTDOWN_SENTINEL="$HOME/.bl-steam-shutdown"
|
||||
export STEAMOS_STEAM_REBOOT_SENTINEL="$HOME/.bl-steam-reboot"
|
||||
if ! pgrep -f 'steamwebhelper|steamrtarm64/steam' >/dev/null 2>&1; then
|
||||
if ! pgrep -f 'steamwebhelper|steamrtarm64/steam|steamrt64/steam' >/dev/null 2>&1; then
|
||||
_stale=""
|
||||
for _f in "$steam_root/.crash" "$steam_root/steam.pid" \
|
||||
"$steam_root/config/htmlcache/SingletonLock" "$steam_root/config/htmlcache/SingletonCookie" \
|
||||
@@ -743,10 +803,16 @@ BUSCONF
|
||||
[ -n "${BL_STEAM_LANGUAGE:-}" ] && _bl_lang=(-language "$BL_STEAM_LANGUAGE")
|
||||
steam_beta=$steam_root/package/beta
|
||||
if [ -n "${BL_ADDED_GAMES:-}" ] && [ -f "$BL_ADDED_GAMES" ]; then
|
||||
droiddeck-steam-games watch "$steam_root" "$BL_ADDED_GAMES" &
|
||||
if [ "$steam_x64" = 0 ]; then
|
||||
droiddeck-steam-games watch "$steam_root" "$BL_ADDED_GAMES" &
|
||||
else
|
||||
BL_STEAMCLIENT=$XDG_DATA_HOME/Steam/steamrtarm64/steamclient.so \
|
||||
BL_STEAM_SHUTDOWN="droiddeck-steam-x64 --exec -shutdown" \
|
||||
droiddeck-steam-games watch "$steam_root" "$BL_ADDED_GAMES" &
|
||||
fi
|
||||
games_watcher=$!
|
||||
fi
|
||||
echo "== steam args: ${_bl_ui[*]} ${_bl_cdp[*]} ${_bl_lang[*]} -clientbeta $steam_channel -no-cef-sandbox -cef-ozone-platform=x11 ${_bl_cef[*]} $*"
|
||||
echo "== steam args: ${_bl_ui[*]} ${_bl_cdp[*]} ${_bl_lang[*]} -clientbeta $steam_channel -no-cef-sandbox -cef-ozone-platform=x11 ${_bl_cef[*]} $*$([ "$steam_x64" = 1 ] && echo ' (x86-64 client under FEX)')"
|
||||
steam_updates=0
|
||||
rm -f "$HOME/.bl-stop-requested" "$STEAMOS_STEAM_SHUTDOWN_SENTINEL" "$STEAMOS_STEAM_REBOOT_SENTINEL"
|
||||
steam_other_game_running() {
|
||||
@@ -768,7 +834,7 @@ BUSCONF
|
||||
printf '%s\n' "$1" > "$HOME/.bl-restarted-for"
|
||||
echo "== steam: $2; restarting Steam to launch it"
|
||||
printf '%s\n' "$1" > "$HOME/.bl-restart-game"
|
||||
"$steam_root/steamrtarm64/steam" -shutdown >/dev/null 2>&1
|
||||
"${steam_client[@]:-$steam_root/steamrtarm64/steam}" -shutdown >/dev/null 2>&1
|
||||
}
|
||||
steam_launch_game() {
|
||||
local state=0 tries
|
||||
@@ -781,7 +847,7 @@ BUSCONF
|
||||
return
|
||||
fi
|
||||
fi
|
||||
"$steam_root/steamrtarm64/steam" "steam://rungameid/$1" >/dev/null 2>&1
|
||||
"${steam_client[@]:-$steam_root/steamrtarm64/steam}" "steam://rungameid/$1" >/dev/null 2>&1
|
||||
[ "$state" -eq 3 ] && return
|
||||
for tries in 1 2 3 4 5 6 7 8; do
|
||||
nap 1
|
||||
@@ -822,7 +888,7 @@ BUSCONF
|
||||
pgrep -f 'SteamLaunch AppId=[0-9]' >/dev/null 2>&1 && return 0
|
||||
echo "== steam: the client dropped shortcut(s)$lost when they exited; restarting Steam so it lists them again"
|
||||
: > "$HOME/.bl-restart-lost"
|
||||
"$steam_root/steamrtarm64/steam" -shutdown >/dev/null 2>&1
|
||||
"${steam_client[@]:-$steam_root/steamrtarm64/steam}" -shutdown >/dev/null 2>&1
|
||||
}
|
||||
steam_bring_forward() {
|
||||
local end=$((SECONDS + 600)) behind=0 line name value focused other n
|
||||
@@ -895,13 +961,34 @@ BUSCONF
|
||||
done
|
||||
return 1
|
||||
}
|
||||
compat_pending=$HOME/.bl-compat-pending
|
||||
compat_restarted=$HOME/.bl-compat-restarted
|
||||
rm -f "$compat_pending"
|
||||
: > "$compat_restarted"
|
||||
compat_restarts=0
|
||||
compat_settled() {
|
||||
local app m flags r card=/mnt/droiddeck-sd
|
||||
# The arm64 card library may hold that client's copy of the same title.
|
||||
[ "$steam_x64" = 1 ] && card=/mnt/droiddeck-sd/x86-64
|
||||
while read -r app; do
|
||||
[ -n "$app" ] || continue
|
||||
m=
|
||||
for r in "$steam_root" "$card"; do
|
||||
[ -f "$r/steamapps/appmanifest_$app.acf" ] && { m=$r/steamapps/appmanifest_$app.acf; break; }
|
||||
done
|
||||
[ -n "$m" ] || return 1
|
||||
flags=$(sed -n 's/^[[:space:]]*"StateFlags"[[:space:]]*"\([0-9]*\)".*/\1/p' "$m" | head -n 1)
|
||||
[ "$flags" = 4 ] || return 1
|
||||
done < "$compat_pending"
|
||||
! pgrep -f 'reaper SteamLaunch' >/dev/null 2>&1
|
||||
}
|
||||
while :; do
|
||||
if [ -n "$requests" ]; then
|
||||
if [ -e "$BL_LAUNCH_DIR/steam-stop" ]; then
|
||||
rm -f "$BL_LAUNCH_DIR/steam-stop"
|
||||
: > "$HOME/.bl-stop-requested"
|
||||
echo "== steam: the app asked for a clean exit"
|
||||
"$steam_root/steamrtarm64/steam" -shutdown >/dev/null 2>&1 || true
|
||||
"${steam_client[@]}" -shutdown >/dev/null 2>&1 || true
|
||||
exit 0
|
||||
fi
|
||||
if [ -f "$BL_LAUNCH_DIR/steam-uninstall" ]; then
|
||||
@@ -911,7 +998,7 @@ BUSCONF
|
||||
''|0*|*[!0-9]*|???????????*) echo "== steam: ignored invalid uninstall request" ;;
|
||||
*)
|
||||
echo "== steam: opening the uninstall dialog for $uninstall_id"
|
||||
"$steam_root/steamrtarm64/steam" "steam://uninstall/$uninstall_id" >/dev/null 2>&1 &
|
||||
"${steam_client[@]}" "steam://uninstall/$uninstall_id" >/dev/null 2>&1 &
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
@@ -944,8 +1031,9 @@ BUSCONF
|
||||
steam_check_exits
|
||||
if [ "$beat" -le 720 ] && [ -n "${BL_CLIENT_CPUS:-}" ]; then
|
||||
for _d in /proc/[0-9]*; do
|
||||
IFS= read -r -d '' _c < "$_d/cmdline" 2>/dev/null || continue
|
||||
case $_c in *steamwebhelper*|*steamrtarm64/steam|*gamescope*) ;; *) continue ;; esac
|
||||
{ IFS= read -r -d '' _c && { IFS= read -r -d '' _c1 || _c1=; }; } < "$_d/cmdline" 2>/dev/null || continue
|
||||
case $_c in FEX|*/FEX|FEXInterpreter|*/FEXInterpreter) _c=$_c1 ;; esac
|
||||
case $_c in *steamwebhelper*|*steamrtarm64/steam|*steamrt64/steam|*gamescope*) ;; *) continue ;; esac
|
||||
_t=("$_d"/task/*)
|
||||
_p=${_d#/proc/}
|
||||
[ "${_bl_pinned[$_p]:-}" = "${#_t[@]}" ] && client_single_core_matches "$BL_CLIENT_CPUS" "${_t[@]}" && continue
|
||||
@@ -963,17 +1051,42 @@ BUSCONF
|
||||
[ -n "$compat" ] && : > "$compat_stamp"
|
||||
(
|
||||
[ -z "$seed" ] || droiddeck-seed-redists "$steam_root" >/dev/null 2>&1 || true
|
||||
[ -z "$compat" ] || steam-compatibility "$steam_root" >/dev/null 2>&1 || true
|
||||
if [ -n "$compat" ]; then
|
||||
if [ "$steam_x64" = 1 ]; then
|
||||
[ -z "${_bl_x64_tool:-}" ] ||
|
||||
BL_COMPAT_TOOL=$_bl_x64_tool steam-compatibility "$steam_root" --x64 --live >/dev/null 2>&1 || true
|
||||
droiddeck-steam-x64 --map-direct --live >/dev/null 2>&1 || true
|
||||
else
|
||||
steam-compatibility "$steam_root" >/dev/null 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
) &
|
||||
library_job=$!
|
||||
fi
|
||||
fi
|
||||
if [ "$((beat % 3))" -eq 0 ] && [ -s "$compat_pending" ] && [ "$compat_restarts" -lt 3 ] && compat_settled; then
|
||||
_bl_new=$(sort -u "$compat_pending" | grep -vxF -f "$compat_restarted" || true)
|
||||
rm -f "$compat_pending"
|
||||
if [ -n "$_bl_new" ]; then
|
||||
compat_restarts=$((compat_restarts + 1))
|
||||
printf '%s\n' $_bl_new >> "$compat_restarted"
|
||||
if [ "$steam_x64" = 1 ]; then
|
||||
step "newly installed title(s) $(echo $_bl_new) set to an ARM64 Proton (Windows builds) or DroidDeck direct (Linux builds): restarting the Steam client once so it takes effect"
|
||||
else
|
||||
step "newly installed title(s) $(echo $_bl_new) set to the ARM64 Proton: restarting the Steam client once so it takes effect"
|
||||
fi
|
||||
: > "$HOME/.bl-restart-once"
|
||||
"${steam_client[@]}" -shutdown >/dev/null 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
if [ "$lossless_left" -gt 0 ] && [ "$((beat % 6))" -eq 0 ] && { [ -z "$lossless_job" ] || ! kill -0 "$lossless_job" 2>/dev/null; }; then
|
||||
lossless_left=$((lossless_left - 1))
|
||||
if [ -e "$lossless_owned" ] || [ -e "$lossless_asked" ]; then
|
||||
lossless_left=0
|
||||
elif ! pgrep -x wineserver >/dev/null 2>&1; then
|
||||
(
|
||||
# The probe reaches the x86-64 client through the arm64 client's steamclient.so, as the import watcher does.
|
||||
if [ "$steam_x64" = 1 ]; then export BL_STEAMCLIENT=$XDG_DATA_HOME/Steam/steamrtarm64/steamclient.so; fi
|
||||
answer=$(droiddeck-steam-games probe "$steam_root" 993090 2>/dev/null) || exit 0
|
||||
case $answer in
|
||||
*'"993090": true'*) mkdir -p "${lossless_owned%/*}" && : > "$lossless_owned" && echo "== Lossless Scaling: owned" ;;
|
||||
@@ -999,7 +1112,11 @@ BUSCONF
|
||||
_bl_counted=1
|
||||
fi
|
||||
if [ -n "${BL_STEAM_LANGUAGE:-}" ]; then
|
||||
droiddeck-steam-language "$HOME" "$BL_STEAM_LANGUAGE" || true
|
||||
if [ "$steam_x64" = 1 ]; then
|
||||
droiddeck-steam-language "${BL_X64_HOME:-$HOME/.droiddeck-x64}" "$BL_STEAM_LANGUAGE" || true
|
||||
else
|
||||
droiddeck-steam-language "$HOME" "$BL_STEAM_LANGUAGE" || true
|
||||
fi
|
||||
fi
|
||||
step "starting the Steam client${BL_STEAM_UI:+ ($BL_STEAM_UI UI)}"
|
||||
desktop_ui_pid=
|
||||
@@ -1008,7 +1125,7 @@ BUSCONF
|
||||
desktop_ui_pid=$!
|
||||
fi
|
||||
steam_started=$SECONDS
|
||||
"$steam_root/steamrtarm64/steam" "${_bl_ui[@]}" "${_bl_cdp[@]}" "${_bl_lang[@]}" -clientbeta "$steam_channel" \
|
||||
"${steam_client[@]}" "${_bl_ui[@]}" "${_bl_cdp[@]}" "${_bl_lang[@]}" -clientbeta "$steam_channel" \
|
||||
-no-cef-sandbox -cef-ozone-platform=x11 "${_bl_cef[@]}" "$@"
|
||||
rc=$?
|
||||
steam_ran=$((SECONDS - steam_started))
|
||||
@@ -1017,13 +1134,23 @@ BUSCONF
|
||||
wait "$desktop_ui_pid" 2>/dev/null || true
|
||||
fi
|
||||
echo "== steam exited rc=$rc"
|
||||
if [ -n "${BL_ADDED_GAMES:-}" ] && [ -f "$BL_ADDED_GAMES" ]; then
|
||||
droiddeck-steam-shortcuts "$steam_root" "$BL_ADDED_GAMES" || true
|
||||
fi
|
||||
collect_steam_logs
|
||||
if [ -f "$HOME/.config/droiddeck/fex-wanted" ] && [ -x /usr/local/bin/droiddeck-fex ]; then
|
||||
/usr/local/bin/droiddeck-fex status >/dev/null 2>&1 || true
|
||||
fi
|
||||
if [ -n "${BL_ADDED_GAMES:-}" ] && [ -f "$BL_ADDED_GAMES" ]; then
|
||||
if [ "$steam_x64" = 0 ]; then
|
||||
droiddeck-steam-shortcuts "$steam_root" "$BL_ADDED_GAMES" || true
|
||||
elif [ -n "${_bl_x64_tool:-}" ]; then
|
||||
BL_COMPAT_TOOL=$_bl_x64_tool droiddeck-steam-shortcuts "$steam_root" "$BL_ADDED_GAMES" || true
|
||||
fi
|
||||
fi
|
||||
# The x86-64 client rewrote config.vdf from memory on exit, over the live passes' mapping.
|
||||
if [ "$steam_x64" = 1 ]; then
|
||||
[ -z "${_bl_x64_tool:-}" ] ||
|
||||
BL_COMPAT_TOOL=$_bl_x64_tool steam-compatibility "$steam_root" --x64 >/dev/null 2>&1 || true
|
||||
droiddeck-steam-x64 --map-direct || true
|
||||
fi
|
||||
if [ -f "$HOME/.bl-stop-requested" ]; then
|
||||
rm -f "$HOME/.bl-stop-requested" "$HOME/.bl-restart-once"
|
||||
break
|
||||
|
||||
@@ -5,6 +5,7 @@ import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
@@ -119,7 +120,7 @@ def method(obj, slot, result, *args):
|
||||
|
||||
|
||||
def probe(steam_root, ids):
|
||||
library = C.CDLL(str(Path(steam_root) / "steamrtarm64/steamclient.so"))
|
||||
library = C.CDLL(os.environ.get("BL_STEAMCLIENT") or str(Path(steam_root) / "steamrtarm64/steamclient.so"))
|
||||
library.CreateInterface.argtypes = [C.c_char_p, C.c_void_p]
|
||||
library.CreateInterface.restype = C.c_void_p
|
||||
client = library.CreateInterface(b"SteamClient020", None)
|
||||
@@ -173,7 +174,8 @@ def request_restart(steam_root):
|
||||
"""The client reads manifests and shortcuts only at start, so an import needs one restart;
|
||||
the session's loop runs the importer between the exit and the next start."""
|
||||
Path(os.environ.get("HOME", "/root"), ".bl-restart-once").touch()
|
||||
subprocess.run([str(Path(steam_root) / "steamrtarm64/steam"), "-shutdown"],
|
||||
command = shlex.split(os.environ.get("BL_STEAM_SHUTDOWN", "")) or [str(Path(steam_root) / "steamrtarm64/steam"), "-shutdown"]
|
||||
subprocess.run(command,
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=30)
|
||||
|
||||
|
||||
@@ -213,9 +215,10 @@ def watch(steam_root, listing):
|
||||
elif candidates and (key != probed or now >= next_probe):
|
||||
probed, next_probe = key, now + 300
|
||||
try:
|
||||
probe_env = dict(os.environ, HOME=os.environ["BL_STEAM_IPC_HOME"]) if os.environ.get("BL_STEAM_IPC_HOME") else None
|
||||
result = subprocess.run([sys.executable, __file__, "probe", steam_root,
|
||||
*map(str, sorted(set(candidates.values())))],
|
||||
capture_output=True, text=True, timeout=15)
|
||||
capture_output=True, text=True, timeout=15, env=probe_env)
|
||||
if result.returncode != 0:
|
||||
status = "ownership probe failed: " + (result.stderr.strip()[-300:] or str(result.returncode))
|
||||
failures += 1
|
||||
|
||||
@@ -33,7 +33,12 @@ if [ -n "$repair" ]; then
|
||||
[ "$(sha1sum "$part" | cut -d' ' -f1)" = "$sum" ] || rm -f "$part"
|
||||
done
|
||||
fi
|
||||
[ -x "$steam_root/steamrtarm64/steam" ] && [ -f "$stamp" ] && exit 0
|
||||
sync=
|
||||
if [ "${1:-}" = --sync ]; then
|
||||
case "${2:-}" in publicbeta|steamdeck_publicbeta) sync=$2 ;; *) sync=$steam_channel ;; esac
|
||||
manifest=steam_client_${sync}_linuxarm64
|
||||
fi
|
||||
[ -z "$sync" ] && [ -x "$steam_root/steamrtarm64/steam" ] && [ -f "$stamp" ] && exit 0
|
||||
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
@@ -51,6 +56,14 @@ for candidate in $cdn_list; do
|
||||
[ "$candidate" = "$cdn" ] || cdn_order+=("$candidate")
|
||||
done
|
||||
version=$(awk -F'"' '$2 == "version" { print $4; exit }' "$work/manifest")
|
||||
if [ -n "$sync" ]; then
|
||||
installed=$(awk -F'"' '$2 == "version" { print $4; exit }' "$steam_root/package/$manifest.manifest" 2>/dev/null || true)
|
||||
if [ -x "$steam_root/steamrtarm64/steam" ] && [ "$installed" = "$version" ]; then
|
||||
chmod -R a+x "$steam_root/steamrtarm64" "$steam_root/linuxarm64" 2>/dev/null || true
|
||||
exit 0
|
||||
fi
|
||||
echo "== STEP $(date -u +%H:%M:%S) updating the arm64 Steam client to $version (was ${installed:-none}) for the x86-64 client"
|
||||
fi
|
||||
awk -F'"' '
|
||||
/^\t"/ && NF >= 3 && $4 == "" { block = $2 }
|
||||
$2 == "file" { file[block] = $4 }
|
||||
@@ -86,7 +99,12 @@ find "$steam_root" -depth -name '*\\*' | while read -r odd; do
|
||||
mv -f "$odd" "$fixed"
|
||||
fi
|
||||
done
|
||||
echo "$steam_channel" > "$steam_root/package/beta"
|
||||
chmod -R a+x "$steam_root/steamrtarm64" "$steam_root/linuxarm64" 2>/dev/null || true
|
||||
if [ -n "$sync" ]; then
|
||||
cp -f "$work/manifest" "$steam_root/package/$manifest.manifest"
|
||||
else
|
||||
echo "$steam_channel" > "$steam_root/package/beta"
|
||||
fi
|
||||
ln -sfn "$steam_root/steamrtarm64" "$steam_root/steamrtarm32"
|
||||
chmod +x "$steam_root/steamrtarm64/steam" 2>/dev/null || true
|
||||
mkdir -p "$HOME/.steam"
|
||||
|
||||
@@ -12,15 +12,22 @@ case $target in
|
||||
esac
|
||||
|
||||
if [ "$ui" = desktop ] && [ "${BL_DESKTOP:-}" = 1 ]; then
|
||||
steam_root=${XDG_DATA_HOME:-${HOME:-/root}/.local/share}/Steam
|
||||
export LD_LIBRARY_PATH=$steam_root/steamrtarm64:$steam_root/steamrtarm64/panorama${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
|
||||
if [ "${BL_STEAM_CLIENT_ARCH:-}" = x86_64 ]; then
|
||||
client_home=${BL_X64_HOME:-${HOME:-/root}/.droiddeck-x64}
|
||||
client=(/usr/local/bin/droiddeck-steam-x64 --exec)
|
||||
else
|
||||
steam_root=${XDG_DATA_HOME:-${HOME:-/root}/.local/share}/Steam
|
||||
export LD_LIBRARY_PATH=$steam_root/steamrtarm64:$steam_root/steamrtarm64/panorama${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
|
||||
client_home=$HOME
|
||||
client=("$steam_root/steamrtarm64/steam")
|
||||
fi
|
||||
mkdir -p "${XDG_CACHE_HOME:-$HOME/.cache}/droiddeck"
|
||||
exec 9>"${XDG_CACHE_HOME:-$HOME/.cache}/droiddeck/steam-desktop.lock"
|
||||
if ! flock -n 9; then
|
||||
for ((attempt = 0; attempt < 180; attempt++)); do
|
||||
pid=$(cat "$HOME/.steam/steam.pid" 2>/dev/null || true)
|
||||
if [ -p "$HOME/.steam/steam.pipe" ] && [[ "$pid" =~ ^[0-9]+$ ]] && kill -0 "$pid" 2>/dev/null; then
|
||||
exec "$steam_root/steamrtarm64/steam" -nobigpicture -no-cef-sandbox \
|
||||
pid=$(cat "$client_home/.steam/steam.pid" 2>/dev/null || true)
|
||||
if [ -p "$client_home/.steam/steam.pipe" ] && [[ "$pid" =~ ^[0-9]+$ ]] && kill -0 "$pid" 2>/dev/null; then
|
||||
exec "${client[@]}" -nobigpicture -no-cef-sandbox \
|
||||
-cef-ozone-platform=x11 -cef-disable-gpu "${url:-steam://open/library}"
|
||||
fi
|
||||
sleep 0.5
|
||||
|
||||
@@ -11,4 +11,5 @@ if [ "${BL_DESKTOP:-}" = 1 ]; then
|
||||
done
|
||||
exec /usr/local/bin/droiddeck-steam-launch "$ui" ${url:+"$url"}
|
||||
fi
|
||||
[ "${BL_STEAM_CLIENT_ARCH:-}" = x86_64 ] && exec /usr/local/bin/droiddeck-steam-x64 --exec "$@"
|
||||
exec "${HOME:-/root}/.local/share/Steam/steamrtarm64/steam" "$@"
|
||||
@@ -344,9 +344,21 @@ def main():
|
||||
spec.loader.exec_module(compat)
|
||||
cfg = os.path.join(steam_root, "config", "config.vdf")
|
||||
if os.path.isfile(cfg) and (ours or routes):
|
||||
compat.register_default(cfg, apps=[str(int(g["appid"]) & 0xFFFFFFFF) for g in games if g.get("exe") and not g.get("native")] + [str(appid) for appid in set(routes.values())],
|
||||
protect=compat.adopt_extras(os.path.join(steam_root, "compatibilitytools.d")))
|
||||
print("droiddeck-steam-shortcuts: mapped them to %s" % compat.TOOL)
|
||||
tools = os.path.join(steam_root, "compatibilitytools.d")
|
||||
x64_tool = os.environ.get("BL_COMPAT_TOOL")
|
||||
own = {}
|
||||
if x64_tool:
|
||||
protect = {compat.first_key(os.path.join(tools, e, "compatibilitytool.vdf"), ["compatibilitytools", "compat_tools"]) or e: e
|
||||
for e in (os.listdir(tools) if os.path.isdir(tools) else [])}
|
||||
# Its own state: the arm64 client's state.json lists which of that client's titles follow its default.
|
||||
own = {"default": x64_tool,
|
||||
"directory": os.path.join(os.path.dirname(os.path.abspath(steam_root)), "droiddeck-compat"),
|
||||
"linux_tool": "droiddeck-direct"}
|
||||
else:
|
||||
protect = compat.adopt_extras(tools)
|
||||
used = compat.register_default(cfg, apps=[str(int(g["appid"]) & 0xFFFFFFFF) for g in games if g.get("exe") and not g.get("native")] + [str(appid) for appid in set(routes.values())],
|
||||
protect=protect, **own)
|
||||
print("droiddeck-steam-shortcuts: mapped them to %s" % used)
|
||||
except Exception as e:
|
||||
print("droiddeck-steam-shortcuts: compat mapping skipped (%s)" % e)
|
||||
return 0
|
||||
|
||||
+969
@@ -0,0 +1,969 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
FEX_TAG=fex-2610-r4
|
||||
FEX_SHA256=0b8b55b663390e35a85871bbd32985bf5ee4f9fbf3a70906255d914ad0257cdf
|
||||
FEX_URL=https://github.com/Droid-Deck/DroidDeck-Components/releases/download/$FEX_TAG/fex.tzst
|
||||
ROOTFS_URL=https://github.com/Droid-Deck/DroidDeck-Components/releases/download/fex-rootfs-ubuntu-24.04-2026-08-11/Ubuntu_24_04.sqsh
|
||||
ROOTFS_SHA256=2854b06d3ff1b8f6e526135bfb6dd5b7b30ab3ab73e79ae933a3d9fed959a178
|
||||
CDN=https://client-update.fastly.steamstatic.com
|
||||
# Must match the -clientbeta droiddeck-session starts this client with (steam_channel).
|
||||
X64_CHANNEL=steamdeck_publicbeta
|
||||
MANIFEST=steam_client_${X64_CHANNEL}_ubuntu12
|
||||
|
||||
REAL_HOME=${HOME:-/root}
|
||||
X64_HOME=${BL_X64_HOME:-$REAL_HOME/.droiddeck-x64}
|
||||
ROOTFS=$X64_HOME/rootfs
|
||||
STEAM_X64=$X64_HOME/.local/share/Steam
|
||||
ARM_STEAM=${XDG_DATA_HOME:-$REAL_HOME/.local/share}/Steam
|
||||
LOG=$X64_HOME/steam-x64.log
|
||||
mkdir -p "$X64_HOME"
|
||||
step() { echo "== STEP $(date -u +%H:%M:%S) $*" | tee -a "$LOG"; }
|
||||
|
||||
x64_default_dir() {
|
||||
local d
|
||||
while IFS= read -r d; do
|
||||
[ -f "$d/.droiddeck-arm64-proton" ] && { echo "$d"; return; }
|
||||
done < <(ls -d "$STEAM_X64"/compatibilitytools.d/DroidDeck-Proton* 2>/dev/null | sort -V -r
|
||||
ls -d "$STEAM_X64"/compatibilitytools.d/GE-Proton*-aarch64 2>/dev/null | sort -V -r)
|
||||
echo "$STEAM_X64/compatibilitytools.d/droiddeck-proton-arm64"
|
||||
}
|
||||
x64_default_tool() {
|
||||
sed -n 's/^[[:space:]]*"\([^"]*\)"[[:space:]]*$/\1/p' "$(x64_default_dir)/compatibilitytool.vdf" 2>/dev/null |
|
||||
grep -v -x -e compatibilitytools -e compat_tools | head -n 1
|
||||
}
|
||||
|
||||
x64_client_parts() {
|
||||
awk -F'"' '
|
||||
/^\t"/ && NF >= 3 && $4 == "" { block = $2 }
|
||||
$2 == "file" { file[block] = $4 }
|
||||
$2 == "sha2" { sha[block] = $4 }
|
||||
END { for (b in file) if (b ~ /_all$/ || b ~ /_ubuntu12$/) print b, file[b], sha[b] }
|
||||
' "$1" | sort
|
||||
}
|
||||
|
||||
x64_sync_client() {
|
||||
local chan cur version work total i block file sum old
|
||||
chan=$(cat "$STEAM_X64/package/beta" 2>/dev/null || echo "$X64_CHANNEL")
|
||||
old=$STEAM_X64/package/steam_client_${chan}_ubuntu12.manifest
|
||||
cur=$(awk -F'"' '$2 == "version" { print $4; exit }' "$old" 2>/dev/null || true)
|
||||
work=$(mktemp -d)
|
||||
if ! curl -fsSL "$CDN/steam_client_${chan}_ubuntu12" -o "$work/manifest"; then
|
||||
rm -rf "$work"; return 0
|
||||
fi
|
||||
version=$(awk -F'"' '$2 == "version" { print $4; exit }' "$work/manifest")
|
||||
if [ -z "$version" ] || [ "$version" = "$cur" ]; then
|
||||
rm -rf "$work"; return 0
|
||||
fi
|
||||
x64_client_parts "$work/manifest" > "$work/parts"
|
||||
if [ -f "$old" ]; then
|
||||
x64_client_parts "$old" | awk '{ print $3 }' > "$work/have"
|
||||
grep -vwF -f "$work/have" "$work/parts" > "$work/todo" || true
|
||||
else
|
||||
cp "$work/parts" "$work/todo"
|
||||
fi
|
||||
total=$(grep -c . "$work/todo" || true)
|
||||
step "updating the x86-64 Steam client to $version (was ${cur:-none}, $total part(s))"
|
||||
i=0
|
||||
while read -r block file sum; do
|
||||
i=$((i + 1))
|
||||
step "downloading Steam: $block ($i/$total)"
|
||||
if ! curl -fsSL "$CDN/$file" -o "$work/$file" || ! echo "$sum $work/$file" | sha256sum -c --quiet; then
|
||||
step "could not update the x86-64 client; it updates itself"
|
||||
rm -rf "$work"; return 0
|
||||
fi
|
||||
unzip -qo "$work/$file" -d "$STEAM_X64"
|
||||
rm -f "$work/$file"
|
||||
done < "$work/todo"
|
||||
cp -f "$work/manifest" "$old"
|
||||
echo "$version" > "$STEAM_X64/package/droiddeck-installed"
|
||||
chmod +x "$STEAM_X64/steam.sh" "$STEAM_X64/steamrt64/steam" "$STEAM_X64/ubuntu12_32/steam" 2>/dev/null || true
|
||||
rm -rf "$work"
|
||||
}
|
||||
|
||||
# The client rewrites config.vdf from memory as it exits: the mapping is written only while no x86 client runs.
|
||||
x64_map_direct() {
|
||||
local mode=write
|
||||
[ "${1:-}" = --live ] && mode=live
|
||||
[ -f "$STEAM_X64/config/config.vdf" ] || return 0
|
||||
if [ "$mode" = write ] && pgrep -f 'steamrt64/steam( |$)' >/dev/null 2>&1; then return 0; fi
|
||||
python3 - "$mode" "$STEAM_X64/config/config.vdf" "$STEAM_X64/appcache/appinfo.vdf" "$X64_HOME/direct-auto.json" \
|
||||
"$X64_HOME/direct-sniper" "$STEAM_X64/steamapps:/mnt/droiddeck-sd/x86-64/steamapps" "$(x64_default_tool)" \
|
||||
"$REAL_HOME/.bl-compat-pending" ${BL_X64_DIRECT_APPS:-550} \
|
||||
<<'PY' || { [ "$mode" = live ] || step "could not map titles to DroidDeck direct"; }
|
||||
# Steam does not swap an installed build when the tool changes: a title installed for Windows stays on Proton.
|
||||
import json, os, re, struct, sys
|
||||
mode, path, appinfo, auto_file, sniper_file, steamapps, proton, pending = sys.argv[1:9]
|
||||
extra = sys.argv[9:]
|
||||
WINDOWS_DEPOTS = {}
|
||||
KNOWN = set()
|
||||
|
||||
|
||||
def read_kv(buf, pos, strings):
|
||||
out = {}
|
||||
while True:
|
||||
t = buf[pos]
|
||||
pos += 1
|
||||
if t == 0x08:
|
||||
return out, pos
|
||||
if strings is not None:
|
||||
key = strings[struct.unpack_from("<I", buf, pos)[0]]
|
||||
pos += 4
|
||||
else:
|
||||
end = buf.index(b"\0", pos)
|
||||
key = buf[pos:end].decode("utf-8", "replace")
|
||||
pos = end + 1
|
||||
if t == 0x00:
|
||||
out[key], pos = read_kv(buf, pos, strings)
|
||||
elif t == 0x01:
|
||||
end = buf.index(b"\0", pos)
|
||||
out[key] = buf[pos:end].decode("utf-8", "replace")
|
||||
pos = end + 1
|
||||
elif t in (0x02, 0x03, 0x04, 0x06):
|
||||
pos += 4
|
||||
elif t in (0x07, 0x0A):
|
||||
pos += 8
|
||||
else:
|
||||
raise ValueError("type %#x" % t)
|
||||
|
||||
|
||||
def linux_games(file):
|
||||
"""{appid: runtime} for the games with a Linux build in the client's appinfo cache."""
|
||||
try:
|
||||
buf = open(file, "rb").read()
|
||||
except OSError:
|
||||
return {}
|
||||
magic = struct.unpack_from("<I", buf, 0)[0]
|
||||
strings, pos = None, 8
|
||||
if magic == 0x07564429:
|
||||
table = struct.unpack_from("<q", buf, 8)[0]
|
||||
count, p = struct.unpack_from("<I", buf, table)[0], table + 4
|
||||
strings = []
|
||||
for _ in range(count):
|
||||
end = buf.index(b"\0", p)
|
||||
strings.append(buf[p:end].decode("utf-8", "replace"))
|
||||
p = end + 1
|
||||
pos = 16
|
||||
elif magic != 0x07564428:
|
||||
return {}
|
||||
games = {}
|
||||
while True:
|
||||
try:
|
||||
appid, size = struct.unpack_from("<II", buf, pos)
|
||||
except struct.error:
|
||||
break
|
||||
if appid == 0:
|
||||
break
|
||||
KNOWN.add(str(appid))
|
||||
try:
|
||||
info = read_kv(buf, pos + 8 + 60, strings)[0].get("appinfo", {})
|
||||
except (ValueError, IndexError, struct.error):
|
||||
info = {}
|
||||
pos += 8 + size
|
||||
common = info.get("common", {})
|
||||
if str(common.get("type", "")).lower() != "game" or "linux" not in str(common.get("oslist", "")):
|
||||
continue
|
||||
runtime = "scout"
|
||||
for m in (info.get("config", {}).get("app_mappings") or {}).values():
|
||||
if isinstance(m, dict) and m.get("platform") == "linux":
|
||||
tool = str(m.get("tool", "")).lower()
|
||||
runtime = "sniper" if "sniper" in tool else "soldier" if "soldier" in tool else runtime
|
||||
games[str(appid)] = runtime
|
||||
WINDOWS_DEPOTS[str(appid)] = {
|
||||
d for d, v in (info.get("depots") or {}).items()
|
||||
if isinstance(v, dict) and "windows" in str((v.get("config") or {}).get("oslist", ""))
|
||||
and "linux" not in str((v.get("config") or {}).get("oslist", ""))
|
||||
}
|
||||
return games
|
||||
|
||||
|
||||
def manifest(app):
|
||||
"""The app's appmanifest text from the first of the client's libraries (internal storage, the
|
||||
card) holding one, or None."""
|
||||
for library in steamapps.split(":"):
|
||||
try:
|
||||
return open(os.path.join(library, "appmanifest_%s.acf" % app), encoding="utf-8", errors="replace").read()
|
||||
except OSError:
|
||||
pass
|
||||
return None
|
||||
|
||||
|
||||
def installed_apps():
|
||||
found = set()
|
||||
for library in steamapps.split(":"):
|
||||
try:
|
||||
found |= {m.group(1) for m in map(re.compile(r"appmanifest_(\d+)\.acf$").match, os.listdir(library)) if m}
|
||||
except OSError:
|
||||
pass
|
||||
return found
|
||||
|
||||
|
||||
def new_linux_build(app):
|
||||
"""For a title the appinfo cache does not know yet (bought while the client runs): installed as
|
||||
itself, not as a Windows build through a compatibility tool, and not one of Valve's runtimes or
|
||||
Protons, which the client installs as apps too."""
|
||||
text = manifest(app) or ""
|
||||
if re.search(r'"platform_override_source"\s*"windows"', text, re.I):
|
||||
return False
|
||||
folder = re.search(r'"installdir"\s*"([^"]*)"', text)
|
||||
return not re.match(r"steam ?linux ?runtime|proton|steamworks shared", folder.group(1) if folder else "", re.I)
|
||||
|
||||
|
||||
def windows_installed(app):
|
||||
"""Whether the installed build of `app` is its Windows one (a Windows depot among those installed),
|
||||
in any of the client's libraries (internal storage, the card)."""
|
||||
text = manifest(app)
|
||||
if text is None:
|
||||
return False
|
||||
found = block(text, "InstalledDepots")
|
||||
if not found:
|
||||
return False
|
||||
installed = set(re.findall(r'"(\d+)"\s*\{', text[found[1]:found[2]]))
|
||||
return bool(installed & WINDOWS_DEPOTS.get(app, set()))
|
||||
|
||||
|
||||
def block(text, key):
|
||||
"""(start of the key, index after its opening brace, index of its closing brace) or None."""
|
||||
m = re.search(r'"%s"\s*\{' % re.escape(key), text)
|
||||
if not m:
|
||||
return None
|
||||
depth, k = 1, m.end()
|
||||
while depth:
|
||||
c = text[k]
|
||||
depth += c == "{"
|
||||
depth -= c == "}"
|
||||
k += 1
|
||||
return m.start(), m.end(), k - 1
|
||||
|
||||
|
||||
games = linux_games(appinfo)
|
||||
for app in extra:
|
||||
games.setdefault(app, "scout")
|
||||
s = open(path, encoding="utf-8", errors="surrogateescape").read()
|
||||
if not block(s, "CompatToolMapping"):
|
||||
st = block(s, "Steam")
|
||||
if not st:
|
||||
sys.exit("no Steam section")
|
||||
s = s[:st[1]] + '\n\t\t\t\t"CompatToolMapping"\n\t\t\t\t{\n\t\t\t\t}' + s[st[1]:]
|
||||
|
||||
|
||||
def entries(inner):
|
||||
"""{app: its entry's span in `inner`, as block() gives it}, read once for the whole mapping."""
|
||||
spans, pos = {}, 0
|
||||
for m in re.finditer(r'"(\d+)"\s*\{', inner):
|
||||
if m.start() < pos:
|
||||
continue
|
||||
depth, k = 1, m.end()
|
||||
while depth and k < len(inner):
|
||||
depth += {"{": 1, "}": -1}.get(inner[k], 0)
|
||||
k += 1
|
||||
spans.setdefault(m.group(1), (m.start(), m.end(), k - 1))
|
||||
pos = k
|
||||
return spans
|
||||
|
||||
|
||||
def decide(app, inner, old):
|
||||
"""(the tool `app` goes to, or None when its entry stays; its entry's span `old` in `inner`; the
|
||||
tool that entry names, None without one)."""
|
||||
on_windows = windows_installed(app)
|
||||
name = None
|
||||
if old:
|
||||
name = re.search(r'"name"\s*"([^"]*)"', inner[old[1]:old[2]])
|
||||
name = name.group(1) if name else ""
|
||||
automatic = name in ("", "droiddeck-direct", "droiddeck-proton-arm64", "droiddeck-fex") or name.startswith("proton_")
|
||||
if not automatic and app not in extra:
|
||||
return None, old, name
|
||||
if on_windows and (name == proton or not proton):
|
||||
return None, old, name
|
||||
elif on_windows and not proton:
|
||||
return None, old, name
|
||||
return (proton if on_windows else "droiddeck-direct"), old, name
|
||||
|
||||
|
||||
if mode == "live":
|
||||
_, open_, close = block(s, "CompatToolMapping")
|
||||
inner = s[open_:close]
|
||||
spans = entries(inner)
|
||||
new = []
|
||||
for app in sorted(installed_apps(), key=int):
|
||||
if app not in games and (app in KNOWN or not new_linux_build(app)):
|
||||
continue
|
||||
tool, _, name = decide(app, inner, spans.get(app))
|
||||
if tool == "droiddeck-direct" and name != tool:
|
||||
new.append(app)
|
||||
if new:
|
||||
open(pending, "a").write("".join("%s\n" % a for a in new))
|
||||
print("droiddeck-steam-x64: installed while the client runs, for DroidDeck direct at its restart: %s" % " ".join(new))
|
||||
sys.exit(0)
|
||||
_, open_, close = block(s, "CompatToolMapping")
|
||||
inner = s[open_:close]
|
||||
spans = entries(inner)
|
||||
mapped, windows, added, dropped = [], [], [], []
|
||||
for app in sorted(games, key=int):
|
||||
tool, old, _ = decide(app, inner, spans.get(app))
|
||||
if tool is None:
|
||||
continue
|
||||
if old:
|
||||
dropped.append(old)
|
||||
added.append('\n\t\t\t\t\t"%s"\n\t\t\t\t\t{\n\t\t\t\t\t\t"name"\t\t"%s"\n'
|
||||
'\t\t\t\t\t\t"config"\t\t""\n\t\t\t\t\t\t"priority"\t\t"250"\n\t\t\t\t\t}' % (app, tool))
|
||||
(mapped if tool == "droiddeck-direct" else windows).append(app)
|
||||
for old in sorted(dropped, reverse=True):
|
||||
inner = inner[:old[0]] + inner[old[2] + 1:]
|
||||
s = s[:open_] + "".join(reversed(added)) + inner + s[close:]
|
||||
open(path, "w", encoding="utf-8", errors="surrogateescape").write(s)
|
||||
json.dump(mapped, open(auto_file, "w"))
|
||||
open(sniper_file, "w").write("".join("%s\n" % a for a in mapped if games[a] != "scout"))
|
||||
print("droiddeck-steam-x64: %d Linux title(s) on DroidDeck direct (%d on the newer runtime)%s"
|
||||
% (len(mapped), sum(games[a] != "scout" for a in mapped),
|
||||
"; %d installed as Windows games kept on %s" % (len(windows), proton) if windows else ""))
|
||||
PY
|
||||
}
|
||||
|
||||
x64_prepare() {
|
||||
if [ ! -x /usr/local/bin/FEX ] || [ "$(cat /usr/local/share/fex-emu/.droiddeck-tag 2>/dev/null)" != "$FEX_TAG" ]; then
|
||||
step "downloading FEX ($FEX_TAG)"
|
||||
tmp=$(mktemp -d)
|
||||
curl -fL --progress-bar "$FEX_URL" -o "$tmp/fex.tzst"
|
||||
if [ "$FEX_SHA256" != PENDING ]; then echo "$FEX_SHA256 $tmp/fex.tzst" | sha256sum -c --quiet; fi
|
||||
zstd -dc "$tmp/fex.tzst" | tar -C / -x
|
||||
rm -rf "$tmp"
|
||||
mkdir -p /usr/local/share/fex-emu && echo "$FEX_TAG" > /usr/local/share/fex-emu/.droiddeck-tag
|
||||
fi
|
||||
step "FEX ready ($FEX_TAG)"
|
||||
# The client's opt-in to its SteamRT3 build; without it, it re-executes through steam.sh, whose checks fail under proot.
|
||||
mkdir -p "$STEAM_X64" && : > "$STEAM_X64/.steam-enable-steamrt64-client"
|
||||
|
||||
if [ ! -f "$ROOTFS/.droiddeck-complete" ]; then
|
||||
step "downloading FEX's Ubuntu 24.04 x86 rootfs"
|
||||
# Resumes a part-done download; a finished one answers 416, which is not a failure here.
|
||||
curl -fL --progress-bar -C - "$ROOTFS_URL" -o "$X64_HOME/rootfs.sqsh" || {
|
||||
rc=$?
|
||||
[ "$rc" = 22 ] && [ -s "$X64_HOME/rootfs.sqsh" ] || { step "rootfs download failed (curl $rc)"; exit 1; }
|
||||
}
|
||||
if ! echo "$ROOTFS_SHA256 $X64_HOME/rootfs.sqsh" | sha256sum -c --quiet >/dev/null 2>&1; then
|
||||
rm -f "$X64_HOME/rootfs.sqsh"; step "rootfs download did not match its checksum; try again"; exit 1
|
||||
fi
|
||||
step "unpacking the rootfs"
|
||||
rm -rf "$ROOTFS"
|
||||
/usr/local/bin/unsquashfs -no-xattrs -no-progress -ignore-errors -d "$ROOTFS" "$X64_HOME/rootfs.sqsh" >>"$LOG" 2>&1 || true
|
||||
[ -x "$ROOTFS/usr/bin/bash" ] || { step "rootfs unpack failed (no usr/bin/bash); see $LOG"; exit 1; }
|
||||
rm -f "$X64_HOME/rootfs.sqsh"
|
||||
touch "$ROOTFS/.droiddeck-complete"
|
||||
fi
|
||||
# FEX falls back to the guest's own /etc/ld.so.preload (arm64 libraries) when the rootfs has none. The x86
|
||||
# session shim provides System V IPC, which Android kernels lack and the client's tier0 needs to start.
|
||||
: > "$ROOTFS/etc/ld.so.preload"
|
||||
for lib in libblsession libfakeinput; do
|
||||
have=0
|
||||
# 32-bit libfakeinput crashes SDL2 games (a NULL udev attribute reaches strdup), so only the x86_64 copy
|
||||
# is preloaded, by full path: with $LIB, FEX falls through to the session's own i386 copy.
|
||||
arches="x86_64 i386"; [ "$lib" = libfakeinput ] && arches=x86_64
|
||||
rm -f "$ROOTFS/usr/local/lib/i386-linux-gnu/libfakeinput.so"
|
||||
for arch in $arches; do
|
||||
[ -f "/usr/local/lib/droiddeck-fex/$arch/$lib.so" ] || continue
|
||||
mkdir -p "$ROOTFS/usr/local/lib/$arch-linux-gnu"
|
||||
cp -f "/usr/local/lib/droiddeck-fex/$arch/$lib.so" "$ROOTFS/usr/local/lib/$arch-linux-gnu/$lib.so"
|
||||
have=1
|
||||
done
|
||||
if [ "$have" = 1 ] && [ "$lib" = libfakeinput ]; then
|
||||
echo "/usr/local/lib/x86_64-linux-gnu/$lib.so" >> "$ROOTFS/etc/ld.so.preload"
|
||||
elif [ "$have" = 1 ]; then echo "/usr/local/\$LIB/$lib.so" >> "$ROOTFS/etc/ld.so.preload"
|
||||
else step "warning: no x86 build of $lib (/usr/local/lib/droiddeck-fex/x86_64/$lib.so)"; fi
|
||||
done
|
||||
rm -f "$ROOTFS/usr/local/lib/libblsession-x86_64.so" "$ROOTFS/usr/local/lib/libfakeinput-x86_64.so"
|
||||
unconfirmed=$STEAM_X64/package/droiddeck-unconfirmed
|
||||
if [ -d "${unconfirmed%/*}" ] && ! grep -qx tracked "$unconfirmed" 2>/dev/null; then echo tracked > "$unconfirmed"; fi
|
||||
x64_repair=
|
||||
if [ "${BL_X64_REPAIR:-0}" = 1 ]; then
|
||||
x64_repair=requested
|
||||
elif [ -f "$unconfirmed" ] && ! grep -qx repaired "$unconfirmed" && [ "$(grep -cx start "$unconfirmed")" -ge 2 ]; then
|
||||
x64_repair="the client was started $(grep -cx start "$unconfirmed") times without showing anything"
|
||||
fi
|
||||
if [ -n "$x64_repair" ]; then
|
||||
step "repairing the x86-64 Steam client ($x64_repair)"
|
||||
rm -f "$STEAM_X64/package/droiddeck-installed" "$STEAM_X64/.crash" "$STEAM_X64/steam.pid" \
|
||||
"$STEAM_X64"/package/steam_client_*.installed
|
||||
fi
|
||||
if [ ! -x "$STEAM_X64/steamrt64/steam" ] || [ ! -f "$STEAM_X64/package/droiddeck-installed" ]; then
|
||||
step "downloading the x86-64 Steam client ($MANIFEST)"
|
||||
work=$(mktemp -d)
|
||||
curl -fsSL "$CDN/$MANIFEST" -o "$work/manifest"
|
||||
version=$(awk -F'"' '$2 == "version" { print $4; exit }' "$work/manifest")
|
||||
awk -F'"' '
|
||||
/^\t"/ && NF >= 3 && $4 == "" { block = $2 }
|
||||
$2 == "file" { file[block] = $4 }
|
||||
$2 == "sha2" { sha[block] = $4 }
|
||||
END { for (b in file) if (b ~ /_all$/ || b ~ /_ubuntu12$/) print b, file[b], sha[b] }
|
||||
' "$work/manifest" | sort > "$work/parts"
|
||||
[ -s "$work/parts" ] || { step "no client components in $MANIFEST"; exit 1; }
|
||||
mkdir -p "$STEAM_X64/package"
|
||||
total=$(grep -c . "$work/parts")
|
||||
i=0
|
||||
while read -r block file sum; do
|
||||
i=$((i + 1))
|
||||
step "client: $block ($i/$total)"
|
||||
curl -fsSL "$CDN/$file" -o "$work/$file"
|
||||
echo "$sum $work/$file" | sha256sum -c --quiet
|
||||
unzip -qo "$work/$file" -d "$STEAM_X64"
|
||||
rm -f "$work/$file"
|
||||
done < "$work/parts"
|
||||
cp -f "$work/manifest" "$STEAM_X64/package/$MANIFEST.manifest"
|
||||
rm -rf "$work"
|
||||
echo "$X64_CHANNEL" > "$STEAM_X64/package/beta"
|
||||
echo "$version" > "$STEAM_X64/package/droiddeck-installed"
|
||||
chmod +x "$STEAM_X64/steam.sh" "$STEAM_X64/steamrt64/steam" "$STEAM_X64/ubuntu12_32/steam" 2>/dev/null || true
|
||||
fi
|
||||
[ -n "$x64_repair" ] && printf 'tracked\nrepaired\n' > "$unconfirmed"
|
||||
x64_sync_client
|
||||
scout=$STEAM_X64/ubuntu12_32
|
||||
if [ -f "$scout/steam-runtime.tar.xz" ] &&
|
||||
{ [ ! -x "$scout/steam-runtime/run.sh" ] ||
|
||||
! cmp -s "$scout/steam-runtime.tar.xz.checksum" "$scout/steam-runtime/checksum"; }; then
|
||||
step "unpacking Valve's scout runtime for native Linux games"
|
||||
rm -rf "$scout/steam-runtime.new"
|
||||
mkdir -p "$scout/steam-runtime.new"
|
||||
if tar -xJf "$scout/steam-runtime.tar.xz" -C "$scout/steam-runtime.new" && [ -x "$scout/steam-runtime.new/steam-runtime/run.sh" ]; then
|
||||
rm -rf "$scout/steam-runtime"
|
||||
mv "$scout/steam-runtime.new/steam-runtime" "$scout/steam-runtime"
|
||||
cp -f "$scout/steam-runtime.tar.xz.checksum" "$scout/steam-runtime/checksum" 2>/dev/null || true
|
||||
else
|
||||
step "could not unpack the scout runtime; native Linux games will not start"
|
||||
fi
|
||||
rm -rf "$scout/steam-runtime.new"
|
||||
fi
|
||||
[ -L "$STEAM_X64/steamapps" ] && rm -f "$STEAM_X64/steamapps"
|
||||
mkdir -p "$STEAM_X64/steamapps"
|
||||
# FEX looks in the rootfs first: an empty dev/dri there hides the session's KGSL node, which x86 programs spin on.
|
||||
mkdir -p "$ROOTFS/dev/dri"
|
||||
mkdir -p "$X64_HOME/.steam"
|
||||
ln -sfn "$STEAM_X64" "$X64_HOME/.steam/root"
|
||||
ln -sfn "$STEAM_X64" "$X64_HOME/.steam/steam"
|
||||
ln -sfn "$STEAM_X64/ubuntu12_32" "$X64_HOME/.steam/bin32"
|
||||
ln -sfn "$STEAM_X64/ubuntu12_64" "$X64_HOME/.steam/bin64"
|
||||
ln -sfn "$STEAM_X64/linux32" "$X64_HOME/.steam/sdk32"
|
||||
ln -sfn "$STEAM_X64/linux64" "$X64_HOME/.steam/sdk64"
|
||||
# The client's bwrap probe (steam-runtime-check-requirements) needs user namespaces, which no Android app has.
|
||||
srt_real=$STEAM_X64/steamrt64/pv-runtime/steam-runtime-steamrt
|
||||
srt_shim=$X64_HOME/steamrt-shim
|
||||
if [ -d "$srt_real" ]; then
|
||||
rm -rf "$srt_shim"
|
||||
mkdir -p "$srt_shim/bin"
|
||||
for e in "$srt_real"/* "$srt_real"/.[!.]*; do
|
||||
[ -e "$e" ] || continue
|
||||
[ "$(basename "$e")" = bin ] || ln -s "$e" "$srt_shim/$(basename "$e")"
|
||||
done
|
||||
for e in "$srt_real"/bin/*; do ln -s "$e" "$srt_shim/bin/$(basename "$e")"; done
|
||||
rm -f "$srt_shim/bin/steam-runtime-check-requirements"
|
||||
printf '#!/bin/sh
|
||||
exit 0
|
||||
' > "$srt_shim/bin/steam-runtime-check-requirements"
|
||||
chmod 755 "$srt_shim/bin/steam-runtime-check-requirements"
|
||||
rm -f "$srt_shim/bin/steam-runtime-launch-client"
|
||||
cat > "$srt_shim/bin/steam-runtime-launch-client" <<'LAUNCH'
|
||||
#!/bin/sh
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--) shift; break ;;
|
||||
--directory=*) cd "${1#--directory=}" || exit 127 ;;
|
||||
--env=*) export "${1#--env=}" ;;
|
||||
--unset-env=*) unset "${1#--unset-env=}" ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
[ $# -gt 0 ] || exit 0
|
||||
exec "$@"
|
||||
LAUNCH
|
||||
chmod 755 "$srt_shim/bin/steam-runtime-launch-client"
|
||||
fi
|
||||
# Valve's platform libraries ship without soname links (pressure-vessel makes them); ldconfig adds them here.
|
||||
srt_libs=$X64_HOME/steamrt-libs
|
||||
rm -rf "$srt_libs"
|
||||
mkdir -p "$srt_libs"
|
||||
for d in "$STEAM_X64"/steamrt64/pv-runtime/steam-runtime-steamrt/steamrt3c_platform_*/files/lib/x86_64-linux-gnu \
|
||||
"$STEAM_X64"/steamrt64/pv-runtime/steam-runtime-steamrt/steamrt3c_platform_*/files/usr/lib/x86_64-linux-gnu; do
|
||||
[ -d "$d" ] || continue
|
||||
for f in "$d"/*.so*; do [ -e "$srt_libs/$(basename "$f")" ] || ln -s "$f" "$srt_libs/"; done
|
||||
done
|
||||
FEX_ROOTFS=$ROOTFS /usr/local/bin/FEX "$ROOTFS/usr/sbin/ldconfig.real" -n "$srt_libs" >>"$LOG" 2>&1 || step "ldconfig on $srt_libs failed"
|
||||
# The rootfs's HarfBuzz needs a newer FreeType than some games bundle (Counter-Strike 2): use Valve's runtime one.
|
||||
sniper_compat=$X64_HOME/sniper-compat
|
||||
rm -rf "$sniper_compat"
|
||||
mkdir -p "$sniper_compat"
|
||||
hb=$(ls "$srt_libs"/libharfbuzz.so.0.* 2>/dev/null | head -n 1)
|
||||
if [ -n "$hb" ]; then ln -s "$hb" "$sniper_compat/libharfbuzz.so.0"; else step "warning: no HarfBuzz in Valve's runtime for the newer-runtime titles"; fi
|
||||
# LD_LIBRARY_PATH beats the system folders whatever its order: Valve's older glibc must not shadow the rootfs's.
|
||||
for f in "$srt_libs"/*; do
|
||||
n=$(basename "$f")
|
||||
if [ -e "$ROOTFS/usr/lib/x86_64-linux-gnu/$n" ] || [ -e "$ROOTFS/lib/x86_64-linux-gnu/$n" ]; then rm -f "$f"; fi
|
||||
done
|
||||
tool=$STEAM_X64/compatibilitytools.d/droiddeck-direct
|
||||
mkdir -p "$tool"
|
||||
rm -f "$tool/droiddeck-proton-wrap" "$tool/toolmanifest.vdf.droiddeck-orig"
|
||||
cat > "$tool/compatibilitytool.vdf" <<'VDF'
|
||||
"compatibilitytools"
|
||||
{
|
||||
"compat_tools"
|
||||
{
|
||||
"droiddeck-direct"
|
||||
{
|
||||
"install_path" "."
|
||||
"display_name" "DroidDeck direct (no container)"
|
||||
"from_oslist" "linux"
|
||||
"to_oslist" "linux"
|
||||
}
|
||||
}
|
||||
}
|
||||
VDF
|
||||
cat > "$tool/toolmanifest.vdf" <<'VDF'
|
||||
"manifest"
|
||||
{
|
||||
"version" "2"
|
||||
"commandline" "/run %verb%"
|
||||
}
|
||||
VDF
|
||||
printf '%s\n' "$REAL_HOME/.droiddeck-vac-diagnostics" > "$tool/vac-marker"
|
||||
cat > "$tool/run" <<'RUN'
|
||||
#!/bin/sh
|
||||
verb=$1; shift
|
||||
rt=$HOME/.local/share/Steam/ubuntu12_32/steam-runtime.old
|
||||
[ -x "$rt/run.sh" ] || rt=$HOME/.local/share/Steam/ubuntu12_32/steam-runtime
|
||||
# -condebug only while VAC diagnostics are on (the marker is in the real home, not this client's).
|
||||
marker=$(cat "${0%/*}/vac-marker" 2>/dev/null)
|
||||
case "$*" in *hl2.sh*|*hl2_linux*|*srcds*) [ -n "$marker" ] && [ -f "$marker" ] && set -- "$@" -condebug ;; esac
|
||||
# game-gpu.env is rewritten whenever the launcher runs; game-gpu.local is the user's and is read after it.
|
||||
gpu=$HOME/game-gpu.env
|
||||
if [ -f "$gpu" ] && [ "${BL_X64_GAME_SOFTWARE:-0}" != 1 ]; then
|
||||
. "$gpu"
|
||||
[ -f "$HOME/game-gpu.local" ] && . "$HOME/game-gpu.local"
|
||||
else
|
||||
export mesa_glthread=false
|
||||
fi
|
||||
case $verb in
|
||||
run|waitforexitandrun)
|
||||
# Titles Valve gives a newer runtime (sniper, soldier) need newer libraries than scout's: the rootfs's.
|
||||
if grep -qx "${STEAM_COMPAT_APP_ID:-${SteamAppId:-none}}" "$HOME/direct-sniper" 2>/dev/null; then
|
||||
[ -e "$HOME/sniper-compat/libharfbuzz.so.0" ] &&
|
||||
export LD_PRELOAD="$HOME/sniper-compat/libharfbuzz.so.0${LD_PRELOAD:+:$LD_PRELOAD}"
|
||||
case $1 in
|
||||
*.sh)
|
||||
if grep -q '^[[:space:]]*\. /etc/os-release' "$1" 2>/dev/null; then
|
||||
script=$1; shift
|
||||
exec bash -c "$(sed 's|^\([[:space:]]*\)\. /etc/os-release|\1VERSION_CODENAME=sniper|' "$script")" "$script" "$@"
|
||||
fi ;;
|
||||
esac
|
||||
exec "$@"
|
||||
fi
|
||||
exec "$rt/run.sh" "$@" ;;
|
||||
*) exec "$@" ;;
|
||||
esac
|
||||
RUN
|
||||
chmod 755 "$tool/run"
|
||||
if [ ! -f "$STEAM_X64/config/config.vdf" ] && ! pgrep -f 'steamrt64/steam( |$)' >/dev/null 2>&1; then
|
||||
mkdir -p "$STEAM_X64/config"
|
||||
printf '"InstallConfigStore"\n{\n\t"Software"\n\t{\n\t\t"Valve"\n\t\t{\n\t\t\t"Steam"\n\t\t\t{\n\t\t\t\t"CompatToolMapping"\n\t\t\t\t{\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n' \
|
||||
> "$STEAM_X64/config/config.vdf"
|
||||
fi
|
||||
x64_map_direct
|
||||
# Each wrapper execs droiddeck-x64-arm-proton through an arm64 binary, which FEX hands straight to the CPU.
|
||||
arm_tools=$ARM_STEAM/compatibilitytools.d
|
||||
mkdir -p "$X64_HOME/arm64"
|
||||
cp -f /usr/bin/env "$X64_HOME/arm64/env"
|
||||
for w in "$STEAM_X64"/compatibilitytools.d/*/.droiddeck-arm64-proton; do
|
||||
[ -e "$w" ] || continue
|
||||
d=${w%/.droiddeck-arm64-proton}
|
||||
[ -d "$arm_tools/${d##*/}" ] && [ "${d##*/}" != droiddeck-fex ] || rm -rf "$d"
|
||||
done
|
||||
for src in "$arm_tools"/*/; do
|
||||
src=${src%/}; name=${src##*/}
|
||||
[ -f "$src/compatibilitytool.vdf" ] && [ -f "$src/toolmanifest.vdf" ] || continue
|
||||
# A droiddeck-fex wrapper made the arm64 client install Valve's FEX when this client probed its tools after logon.
|
||||
case $name in droiddeck-direct|droiddeck-fex) continue ;; esac
|
||||
dst=$STEAM_X64/compatibilitytools.d/$name
|
||||
mkdir -p "$dst"
|
||||
rm -f "$dst/droiddeck-proton-wrap" "$dst/toolmanifest.vdf.droiddeck-orig"
|
||||
: > "$dst/.droiddeck-arm64-proton"
|
||||
python3 - "$src/compatibilitytool.vdf" "$dst/compatibilitytool.vdf" <<'PY' || { rm -rf "$dst"; continue; }
|
||||
import re, sys
|
||||
s = open(sys.argv[1], encoding="utf-8", errors="replace").read()
|
||||
m = re.search(r'"compat_tools"\s*\{\s*"([^"]+)"', s)
|
||||
if not m:
|
||||
sys.exit(1)
|
||||
# The x86-64 client ignores a tool named arm64 or aarch64 ("for a different target platform linux arm64").
|
||||
key = re.sub(r"arm64|aarch64", "a64", m.group(1))
|
||||
d = re.search(r'"display_name"\s*"([^"]*)"', s)
|
||||
name = d.group(1) if d else key
|
||||
open(sys.argv[2], "w").write(
|
||||
'"compatibilitytools"\n{\n "compat_tools"\n {\n "%s"\n {\n "install_path" "."\n'
|
||||
' "display_name" "%s"\n "from_oslist" "windows"\n "to_oslist" "linux"\n }\n }\n}\n'
|
||||
% (key, name))
|
||||
PY
|
||||
cat > "$dst/toolmanifest.vdf" <<'VDF'
|
||||
"manifest"
|
||||
{
|
||||
"version" "2"
|
||||
"commandline" "/run %verb%"
|
||||
}
|
||||
VDF
|
||||
printf '#!/bin/sh\n# The arm64 client'"'"'s %s, run natively (droiddeck-x64-arm-proton).\nexec "%s" /usr/local/bin/droiddeck-x64-arm-proton "%s" "$@"\n' \
|
||||
"$name" "$X64_HOME/arm64/env" "$name" > "$dst/run"
|
||||
chmod 755 "$dst/run"
|
||||
done
|
||||
x64_sync_login
|
||||
# Each client keeps its own libraries; written only while no x86 client runs, as it rewrites these on exit.
|
||||
if ! pgrep -f 'steamrt64/steam( |$)' >/dev/null 2>&1; then
|
||||
listing_ok=0
|
||||
if python3 - "$STEAM_X64" "${BL_X64_STEAM_LIBRARIES:-}" "$STEAM_X64/config/libraryfolders.vdf" "$STEAM_X64/steamapps/libraryfolders.vdf" <<'PY'; then
|
||||
import json, os, re, sys
|
||||
keep = {os.path.realpath(sys.argv[1])}
|
||||
# Without the session's list nothing is known about the card: leave the folders as they are.
|
||||
if not sys.argv[2]:
|
||||
sys.exit(3)
|
||||
try:
|
||||
keep |= {os.path.realpath(str(e["path"])) for e in json.load(open(sys.argv[2], encoding="utf-8"))}
|
||||
except (OSError, ValueError, KeyError, TypeError):
|
||||
sys.exit(3)
|
||||
for path in sys.argv[3:]:
|
||||
if not os.path.isfile(path):
|
||||
continue
|
||||
s = open(path, encoding="utf-8", errors="surrogateescape").read()
|
||||
out, removed, i = [], [], 0
|
||||
for m in re.finditer(r'^\t"(\d+)"\s*\n\t\{', s, re.M):
|
||||
if m.start() < i:
|
||||
continue
|
||||
depth, k = 1, m.end()
|
||||
while depth and k < len(s):
|
||||
depth += s[k] == "{"
|
||||
depth -= s[k] == "}"
|
||||
k += 1
|
||||
block = s[m.start():k]
|
||||
p = re.search(r'"path"\s*"([^"]*)"', block)
|
||||
if p and os.path.realpath(p.group(1)) not in keep:
|
||||
out.append(s[i:m.start()])
|
||||
i = k + (1 if s[k:k + 1] == "\n" else 0)
|
||||
removed.append(p.group(1))
|
||||
if not removed:
|
||||
continue
|
||||
out.append(s[i:])
|
||||
open(path, "w", encoding="utf-8", errors="surrogateescape").write("".join(out))
|
||||
print("droiddeck-steam-x64: no longer shared with the arm64 client: %s" % ", ".join(removed))
|
||||
PY
|
||||
listing_ok=1
|
||||
elif [ $? = 3 ]; then
|
||||
step "no library list from the session: the x86-64 client's library folders are left as they are"
|
||||
else
|
||||
step "could not check the x86-64 client's library folders"
|
||||
fi
|
||||
if [ "$listing_ok" = 1 ]; then
|
||||
BL_STEAM_LIBRARIES=$BL_X64_STEAM_LIBRARIES droiddeck-steam-library "$STEAM_X64" ||
|
||||
step "could not add the card to the x86-64 client's library folders"
|
||||
fi
|
||||
fi
|
||||
# default-tool is the default this script set: titles still on it move along; a user's choice is kept.
|
||||
default=$(x64_default_dir)
|
||||
if [ -f "$default/compatibilitytool.vdf" ] && [ -f "$STEAM_X64/config/config.vdf" ] &&
|
||||
! pgrep -f 'steamrt64/steam( |$)' >/dev/null 2>&1; then
|
||||
python3 - "$STEAM_X64/config/config.vdf" "$default/compatibilitytool.vdf" "$X64_HOME/default-tool" <<'PY' || step "could not make ARM64 Proton the default"
|
||||
import os, re, sys
|
||||
path, vdf, record = sys.argv[1:4]
|
||||
tool = re.search(r'"compat_tools"\s*\{\s*"([^"]+)"', open(vdf).read()).group(1)
|
||||
s = open(path, encoding="utf-8", errors="surrogateescape").read()
|
||||
m = re.search(r'"CompatToolMapping"\s*\{', s)
|
||||
if not m:
|
||||
sys.exit(0)
|
||||
depth, k = 1, m.end()
|
||||
while depth:
|
||||
depth += s[k] == "{"
|
||||
depth -= s[k] == "}"
|
||||
k += 1
|
||||
block = s[m.end():k]
|
||||
try:
|
||||
previous = open(record).read().strip() or None
|
||||
except OSError:
|
||||
previous = None
|
||||
z = re.search(r'^\s*"0"\s*\{([^{}]*)\}', block, re.M)
|
||||
if z:
|
||||
name = re.search(r'"name"\s*"([^"]*)"', z.group(1))
|
||||
name = name.group(1) if name else ""
|
||||
set_here = re.search(r'"priority"\s*"75"', z.group(1)) is not None
|
||||
if previous is None and set_here and name.endswith("-a64"):
|
||||
previous = name
|
||||
if "arm64" not in z.group(1) and name != previous:
|
||||
sys.exit(0)
|
||||
if name == tool and previous == tool:
|
||||
sys.exit(0)
|
||||
block = block[:z.start()] + block[z.end():]
|
||||
moved = 0
|
||||
if previous and previous != tool:
|
||||
block, moved = re.subn(r'("name"\s*")%s(")' % re.escape(previous), lambda x: x.group(1) + tool + x.group(2), block)
|
||||
entry = ('\n\t\t\t\t\t"0"\n\t\t\t\t\t{\n\t\t\t\t\t\t"name"\t\t"%s"\n' % tool +
|
||||
'\t\t\t\t\t\t"config"\t\t""\n\t\t\t\t\t\t"priority"\t\t"75"\n\t\t\t\t\t}')
|
||||
s = s[:m.end()] + entry + block + s[k:]
|
||||
open(path, "w", encoding="utf-8", errors="surrogateescape").write(s)
|
||||
open(record, "w").write(tool + "\n")
|
||||
if moved:
|
||||
print("droiddeck-steam-x64: default %s -> %s, with the %d titles on it" % (previous, tool, moved))
|
||||
PY
|
||||
fi
|
||||
if [ -d "$ARM_STEAM/config/uioverrides" ] && [ ! -e "$STEAM_X64/config/uioverrides" ]; then
|
||||
ln -s "$ARM_STEAM/config/uioverrides" "$STEAM_X64/config/uioverrides"
|
||||
fi
|
||||
if [ -f "$ARM_STEAM/.cef-enable-remote-debugging" ]; then
|
||||
: > "$STEAM_X64/.cef-enable-remote-debugging"
|
||||
else
|
||||
rm -f "$STEAM_X64/.cef-enable-remote-debugging"
|
||||
fi
|
||||
if [ -f "$ARM_STEAM/config/config.vdf" ] && [ -f "$STEAM_X64/config/config.vdf" ] &&
|
||||
! pgrep -f 'steamrt64/steam( |$)' >/dev/null 2>&1; then
|
||||
python3 - "$ARM_STEAM/config/config.vdf" "$STEAM_X64/config/config.vdf" <<'PY' || step "could not copy the startup movie choice"
|
||||
import re, sys
|
||||
movie = re.search(r'\n([ \t]*)"StartupMovie"\s*\{[^{}]*\}', open(sys.argv[1], encoding="utf-8", errors="replace").read())
|
||||
if not movie:
|
||||
sys.exit(0)
|
||||
path = sys.argv[2]
|
||||
s = open(path, encoding="utf-8", errors="surrogateescape").read()
|
||||
old = re.search(r'\n[ \t]*"StartupMovie"\s*\{[^{}]*\}', s)
|
||||
if old:
|
||||
if old.group(0).split(None, 1)[1] == movie.group(0).split(None, 1)[1]:
|
||||
sys.exit(0)
|
||||
s = s[:old.start()] + s[old.end():]
|
||||
steam = re.search(r'"Valve"\s*\{\s*"Steam"\s*\{', s)
|
||||
if not steam:
|
||||
sys.exit(0)
|
||||
s = s[:steam.end()] + movie.group(0) + s[steam.end():]
|
||||
open(path, "w", encoding="utf-8", errors="surrogateescape").write(s)
|
||||
PY
|
||||
fi
|
||||
# FEX takes its rootfs from FEXServer, and one started without FEX_ROOTFS serves none: stop it while no x86 client runs.
|
||||
if ! pgrep -f 'steamrt64/steam( |$)' >/dev/null 2>&1; then
|
||||
FEX_ROOTFS=$ROOTFS /usr/local/bin/FEXServer -k >/dev/null 2>&1 || true
|
||||
fi
|
||||
}
|
||||
|
||||
x64_gpu() {
|
||||
[ "${BL_X64_SOFTWARE:-0}" != 1 ] && [ -d /usr/local/share/fex-emu/GuestThunks ] && [ -d /usr/local/lib/fex-emu/HostThunks ]
|
||||
}
|
||||
|
||||
x64_webhelper_gpu() {
|
||||
x64_gpu && [ "${BL_X64_CLIENT_SOFTWARE:-0}" != 1 ] && [ "${BL_X64_CEF_GPU:-1}" != 0 ]
|
||||
}
|
||||
|
||||
x64_env() {
|
||||
# droiddeck-x64-arm-proton restores this arm64 environment before Proton runs.
|
||||
export -p | grep -v -E '^declare -x (PWD|OLDPWD|SHLVL|_)=' > "$X64_HOME/arm-session.env.new" || true
|
||||
mv -f "$X64_HOME/arm-session.env.new" "$X64_HOME/arm-session.env"
|
||||
unset LD_LIBRARY_PATH LD_PRELOAD STEAM_RUNTIME STEAM_RUNTIME_PREFER_HOST_LIBRARIES
|
||||
gpu_vars="GALLIUM_DRIVER MESA_LOADER_DRIVER_OVERRIDE VK_ICD_FILENAMES VK_DRIVER_FILES LIBGL_KOPPER_DRI2 ZINK_DEBUG ZINK_DESCRIPTORS TU_DEBUG MESA_NO_ERROR mesa_glthread"
|
||||
rm -f "$X64_HOME/game-gpu.env"
|
||||
if x64_gpu; then
|
||||
printf '{"ThunksDB": {"GL": 1, "Vulkan": 1}}\n' > "$X64_HOME/thunks.json"
|
||||
{
|
||||
echo "export FEX_THUNKCONFIG='$X64_HOME/thunks.json'"
|
||||
echo "unset LIBGL_ALWAYS_SOFTWARE LIBGL_DRI3_DISABLE GALLIUM_DRIVER"
|
||||
for v in $gpu_vars; do
|
||||
eval "val=\${$v-}"; [ -n "$val" ] && printf "export %s='%s'\n" "$v" "$val"
|
||||
done
|
||||
} > "$X64_HOME/game-gpu.env"
|
||||
fi
|
||||
if x64_gpu && [ "${BL_X64_CLIENT_SOFTWARE:-0}" != 1 ]; then
|
||||
export FEX_THUNKCONFIG=$X64_HOME/thunks.json
|
||||
unset LIBGL_ALWAYS_SOFTWARE LIBGL_DRI3_DISABLE
|
||||
else
|
||||
unset FEX_THUNKCONFIG $gpu_vars
|
||||
export LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=llvmpipe
|
||||
# Over DRI3 the X server hands out the GPU node, and Mesa's software path loops on KMS dumb buffers on it.
|
||||
export LIBGL_DRI3_DISABLE=1
|
||||
fi
|
||||
[ "${BL_X64_FP_OFF:-0}" = 1 ] && export PROOT_FP_OFF=1
|
||||
export FEX_TSOENABLED=${FEX_TSOENABLED:-1} FEX_VECTORTSOENABLED=${FEX_VECTORTSOENABLED:-0} \
|
||||
FEX_MEMCPYSETTSOENABLED=${FEX_MEMCPYSETTSOENABLED:-0} FEX_HALFBARRIERTSOENABLED=${FEX_HALFBARRIERTSOENABLED:-0} \
|
||||
FEX_X87REDUCEDPRECISION=${FEX_X87REDUCEDPRECISION:-1} FEX_MULTIBLOCK=${FEX_MULTIBLOCK:-1}
|
||||
export HOME=$X64_HOME
|
||||
export XDG_DATA_HOME=$X64_HOME/.local/share XDG_CONFIG_HOME=$X64_HOME/.config XDG_CACHE_HOME=$X64_HOME/.cache
|
||||
export FEX_ROOTFS=$ROOTFS
|
||||
export STEAM_EXTRA_COMPAT_TOOLS_PATHS=
|
||||
export STEAM_RUNTIME=1
|
||||
[ -d "$X64_HOME/steamrt-shim" ] && export STEAM_RUNTIME_STEAMRT=$X64_HOME/steamrt-shim
|
||||
# The client starts commands via steam-runtime-launch-client; Valve's needs a session-bus service, the shim's runs them.
|
||||
[ -d "$X64_HOME/steamrt-shim/bin" ] && export PATH=$X64_HOME/steamrt-shim/bin:$PATH
|
||||
export LD_LIBRARY_PATH=$STEAM_X64/steamrt64:$STEAM_X64/steamrt64/panorama:$X64_HOME/steamrt-libs
|
||||
# After an update the client re-executes itself through pressure-vessel-wrap (bwrap) unless this guard is set.
|
||||
export STEAM_STEAMRT_RECURSION_GUARD=1
|
||||
# proot is a tracer: tier0 takes it for a debugger and breaks into it with int3 on its first failed assertion.
|
||||
export BL_WEBHELPER_HIDE_TRACER=1
|
||||
}
|
||||
|
||||
x64_exec() {
|
||||
x64_env
|
||||
cd "$STEAM_X64"
|
||||
# The client checksums its files at start and reinstalls over edited ones, so the session shim (preload/net.c)
|
||||
# swaps the web helper at exec. The arm64 helper only comes up against a client of the same build.
|
||||
if [ "${BL_X64_X86_WEBHELPER:-0}" != 1 ] && [ -x /usr/local/bin/droiddeck-x64-arm-webhelper ] &&
|
||||
[ -x "$ARM_STEAM/steamrtarm64/steamwebhelper" ]; then
|
||||
local chan x86_build arm_build
|
||||
chan=$(cat "$STEAM_X64/package/beta" 2>/dev/null || echo "$X64_CHANNEL")
|
||||
x86_build=$(awk -F'"' '$2 == "version" { print $4; exit }' "$STEAM_X64/package/steam_client_${chan}_ubuntu12.manifest" 2>/dev/null || true)
|
||||
arm_build=$(awk -F'"' '$2 == "version" { print $4; exit }' "$ARM_STEAM/package/steam_client_${chan}_linuxarm64.manifest" 2>/dev/null || true)
|
||||
if [ -n "$x86_build" ] && [ "$x86_build" = "$arm_build" ]; then
|
||||
export BL_X64_ARM_WEBHELPER=/usr/local/bin/droiddeck-x64-arm-webhelper
|
||||
else
|
||||
echo "== x86-64 client build ${x86_build:-?}, arm64 web helper's ${arm_build:-?}: keeping the x86 web helper" >&2
|
||||
fi
|
||||
fi
|
||||
if [ -z "${BL_X64_ARM_WEBHELPER:-}" ] && x64_webhelper_gpu; then
|
||||
# Not --in-process-gpu (the preload's default): a GPU crash there takes the whole helper down.
|
||||
export BL_WEBHELPER_ARGS="--ignore-gpu-blocklist --use-gl=angle --use-angle=gl --ozone-platform=x11"
|
||||
[ -x /usr/local/bin/droiddeck-x64-webhelper ] && export BL_X64_ARM_WEBHELPER=/usr/local/bin/droiddeck-x64-webhelper
|
||||
elif [ -z "${BL_X64_ARM_WEBHELPER:-}" ]; then
|
||||
export BL_WEBHELPER_ARGS=stock
|
||||
local a args=() soft=0
|
||||
for a in "$@"; do
|
||||
case $a in
|
||||
-cef-force-gpu|-cef-ozone-platform=*|-cef-use-gl=*|-cef-use-angle=*) soft=1 ;;
|
||||
*) args+=("$a") ;;
|
||||
esac
|
||||
done
|
||||
[ "$soft" = 1 ] && set -- "${args[@]}" -cef-disable-gpu
|
||||
fi
|
||||
mkdir -p "$STEAM_X64/logs"
|
||||
touch "$STEAM_X64/logs/bootstrap_log.txt"
|
||||
( tail -n0 -F --pid=$$ "$STEAM_X64/logs/bootstrap_log.txt" 2>/dev/null |
|
||||
grep --line-buffered -oE 'Downloading update \([0-9,]+ of [0-9,]+ KB\)' | sed -u 's/,//g' >&2 ) &
|
||||
exec "${BL_FEX:-/usr/local/bin/FEX}" "$STEAM_X64/steamrt64/steam" "$@"
|
||||
}
|
||||
|
||||
# Steam renews its token every few days and refuses old copies: copy the newest every start, never while a client runs.
|
||||
x64_sync_login() {
|
||||
pgrep -f 'steamrt64/steam( |$)' >/dev/null 2>&1 && return 0
|
||||
pgrep -f 'steamrtarm64/steam( |$)' >/dev/null 2>&1 && return 0
|
||||
python3 - "$ARM_STEAM" "$STEAM_X64" "$REAL_HOME/.steam/registry.vdf" "$X64_HOME/.steam/registry.vdf" <<'PY' || step "could not share the sign-in between the clients"
|
||||
import os, re, shutil, sys
|
||||
arm, x64, arm_reg, x64_reg = sys.argv[1:5]
|
||||
FILES = ("config/loginusers.vdf", "local.vdf")
|
||||
|
||||
|
||||
def stamp(root):
|
||||
if not all(os.path.isfile(os.path.join(root, f)) for f in FILES):
|
||||
return None
|
||||
# A client that refused its token leaves an empty ConnectCache: newest, but copying it signs the other out.
|
||||
text = open(os.path.join(root, "local.vdf"), encoding="utf-8", errors="surrogateescape").read()
|
||||
if not re.search(r'"ConnectCache"\s*\{\s*"[^"]+"\s*"[^"]+"', text):
|
||||
return None
|
||||
return os.path.getmtime(os.path.join(root, "local.vdf"))
|
||||
|
||||
|
||||
a, x = stamp(arm), stamp(x64)
|
||||
if a is None and x is None:
|
||||
sys.exit(0)
|
||||
if a is not None and x is not None and abs(a - x) < 1:
|
||||
sys.exit(0)
|
||||
if x is None or (a is not None and a > x):
|
||||
src, dst, sreg, dreg, who = arm, x64, arm_reg, x64_reg, "arm64"
|
||||
else:
|
||||
src, dst, sreg, dreg, who = x64, arm, x64_reg, arm_reg, "x86-64"
|
||||
for f in FILES:
|
||||
os.makedirs(os.path.dirname(os.path.join(dst, f)), exist_ok=True)
|
||||
# copy2 keeps the time stamp, so both match until one client signs in again.
|
||||
shutil.copy2(os.path.join(src, f), os.path.join(dst, f))
|
||||
if os.path.isfile(sreg):
|
||||
st = open(sreg, encoding="utf-8", errors="surrogateescape").read()
|
||||
if not os.path.isfile(dreg):
|
||||
os.makedirs(os.path.dirname(dreg), exist_ok=True)
|
||||
shutil.copy2(sreg, dreg)
|
||||
else:
|
||||
dt = open(dreg, encoding="utf-8", errors="surrogateescape").read()
|
||||
for key in ("AutoLoginUser", "RememberPassword"):
|
||||
v = re.search(r'"%s"\s*"([^"]*)"' % key, st)
|
||||
if v and re.search(r'"%s"\s*"' % key, dt):
|
||||
dt = re.sub(r'("%s"\s*")[^"]*(")' % key, lambda m: m.group(1) + v.group(1) + m.group(2), dt, count=1)
|
||||
open(dreg, "w", encoding="utf-8", errors="surrogateescape").write(dt)
|
||||
print("droiddeck-steam-x64: sign-in shared from the %s client (the newer one)" % who)
|
||||
PY
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
--sync-login) x64_sync_login; exit 0 ;;
|
||||
--prepare) x64_prepare; exit 0 ;;
|
||||
--exec) shift; x64_exec "$@" ;;
|
||||
--gpu) x64_gpu; exit $? ;;
|
||||
--webhelper-gpu) x64_webhelper_gpu; exit $? ;;
|
||||
--default-tool) x64_default_tool; exit 0 ;;
|
||||
--map-direct) shift; x64_map_direct "$@"; exit 0 ;;
|
||||
esac
|
||||
|
||||
if pgrep -f 'steamrtarm64/steam( |$)' >/dev/null 2>&1; then
|
||||
step "shutting down the arm64 client first"
|
||||
"$ARM_STEAM/steamrtarm64/steam" -shutdown >/dev/null 2>&1 || true
|
||||
for _ in $(seq 1 30); do pgrep -f 'steamrtarm64/steam( |$)' >/dev/null 2>&1 || break; sleep 1; done
|
||||
fi
|
||||
x64_prepare
|
||||
step "FEX, rootfs and client ready"
|
||||
if [ -n "${BL_FEXSERVER_LOG:-}" ]; then
|
||||
FEX_ROOTFS=$ROOTFS "$(dirname "${BL_FEX:-/usr/local/bin/FEX}")/FEXServer" -f -p 600 >"$BL_FEXSERVER_LOG" 2>&1 &
|
||||
sleep 1
|
||||
fi
|
||||
# The client's connection status comes from NetworkManager on the system bus; a desktop has no system bus.
|
||||
x64_bus= x64_nm= x64_pin=
|
||||
x64_cleanup() {
|
||||
[ -n "$x64_pin" ] && kill "$x64_pin" 2>/dev/null
|
||||
[ -n "$x64_nm" ] && kill "$x64_nm" 2>/dev/null
|
||||
[ -n "$x64_bus" ] && kill "$x64_bus" 2>/dev/null
|
||||
return 0
|
||||
}
|
||||
trap x64_cleanup EXIT
|
||||
if ! pgrep -f 'dbus-daemon --config-file=/usr/local/share/droiddeck/system-bus.conf' >/dev/null 2>&1 \
|
||||
&& command -v dbus-daemon >/dev/null 2>&1 && command -v droiddeck-netmanager >/dev/null 2>&1; then
|
||||
mkdir -p /run/dbus /usr/local/share/droiddeck
|
||||
cat > /usr/local/share/droiddeck/system-bus.conf <<'BUSCONF'
|
||||
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
<type>system</type>
|
||||
<listen>unix:path=/run/dbus/system_bus_socket</listen>
|
||||
<auth>EXTERNAL</auth>
|
||||
<policy context="default">
|
||||
<allow user="*"/>
|
||||
<allow own="*"/>
|
||||
<allow send_destination="*"/>
|
||||
<allow receive_sender="*"/>
|
||||
</policy>
|
||||
</busconfig>
|
||||
BUSCONF
|
||||
rm -f /run/dbus/system_bus_socket
|
||||
dbus-daemon --config-file=/usr/local/share/droiddeck/system-bus.conf --nofork --nopidfile &
|
||||
x64_bus=$!
|
||||
for _ in $(seq 1 50); do [ -S /run/dbus/system_bus_socket ] && break; sleep 0.1; done
|
||||
if [ -S /run/dbus/system_bus_socket ]; then
|
||||
droiddeck-netmanager &
|
||||
x64_nm=$!
|
||||
step "network: system bus up, NetworkManager stand-in running"
|
||||
else
|
||||
step "network: the system bus did not come up; the client will show no connection"
|
||||
fi
|
||||
fi
|
||||
# Left by a killed client: .crash opens the update UI on its spinner; stale Singleton* locks can blank the UI.
|
||||
if ! pgrep -f 'steamrt64/steam( |$)' >/dev/null 2>&1; then
|
||||
for f in "$STEAM_X64/.crash" "$STEAM_X64/steam.pid" "$STEAM_X64/config/htmlcache/SingletonLock" \
|
||||
"$STEAM_X64/config/htmlcache/SingletonCookie" "$STEAM_X64/config/htmlcache/SingletonSocket"; do
|
||||
{ [ -e "$f" ] || [ -L "$f" ]; } && rm -f "$f"
|
||||
done
|
||||
fi
|
||||
if [ -n "${BL_CLIENT_CPUS:-}" ] && command -v taskset >/dev/null 2>&1; then
|
||||
(
|
||||
while sleep 5; do
|
||||
for pid in $(ps -A -o PID,ARGS | awk '($2 ~ /^(.*\/)?FEX(Interpreter)?$/) && ($3 ~ /steamrt64\/steam$/ || $3 ~ /steamwebhelper$/) {print $1} $2 ~ /steamrtarm64\/steamwebhelper$/ {print $1}'); do
|
||||
taskset -a -p -c "$BL_CLIENT_CPUS" "$pid" >/dev/null 2>&1
|
||||
done
|
||||
done
|
||||
) &
|
||||
x64_pin=$!
|
||||
fi
|
||||
for attempt in 1 2 3 4 5; do
|
||||
# The branch on disk must match -clientbeta before every start, or the client loops on rc=42.
|
||||
echo "$X64_CHANNEL" > "$STEAM_X64/package/beta"
|
||||
step "starting the x86-64 SteamRT3 client under FEX (attempt $attempt): $*"
|
||||
rc=0
|
||||
if [ "${BL_X64_X86_WEBHELPER:-0}" != 1 ] || x64_webhelper_gpu; then cef=(-cef-force-gpu -cef-ozone-platform=x11 -cef-use-gl=angle -cef-use-angle=vulkan); else cef=(-cef-disable-gpu); fi
|
||||
( x64_exec -clientbeta "$X64_CHANNEL" -no-cef-sandbox "${cef[@]}" "$@" ) >>"$LOG" 2>&1 || rc=$?
|
||||
step "client exited rc=$rc"
|
||||
[ "$rc" = 42 ] || break
|
||||
done
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
# Runs natively: droiddeck-steam-x64's x86 wrappers start it through an arm64 binary, which FEX hands to the CPU.
|
||||
tool=$1; shift
|
||||
x64_home=$HOME
|
||||
|
||||
# The game overlay tags the game's windows with the Steam app ID; without it gamescope never shows them.
|
||||
overlay=0
|
||||
case ${LD_PRELOAD:-} in *gameoverlayrenderer.so*) overlay=1 ;; esac
|
||||
|
||||
for v in $(compgen -e); do
|
||||
case $v in FEX_*) unset "$v" ;; esac
|
||||
done
|
||||
unset LD_LIBRARY_PATH LD_PRELOAD STEAM_RUNTIME_STEAMRT STEAM_STEAMRT_RECURSION_GUARD \
|
||||
LIBGL_ALWAYS_SOFTWARE LIBGL_DRI3_DISABLE GALLIUM_DRIVER BL_WEBHELPER_HIDE_TRACER PROOT_FP_OFF
|
||||
|
||||
game_display=${DISPLAY:-}
|
||||
if [ -f "$x64_home/arm-session.env" ]; then
|
||||
. "$x64_home/arm-session.env"
|
||||
else
|
||||
export HOME=/root
|
||||
fi
|
||||
[ -z "$game_display" ] || export DISPLAY=$game_display
|
||||
# Proton takes its Steam client parts from the client's install folder; the x86-64 client's are x86.
|
||||
export BL_X64_STEAM_ROOT=${STEAM_COMPAT_CLIENT_INSTALL_PATH:-}
|
||||
export STEAM_COMPAT_CLIENT_INSTALL_PATH=$HOME/.local/share/Steam
|
||||
arm_overlay=$STEAM_COMPAT_CLIENT_INSTALL_PATH/steamrtarm64/gameoverlayrenderer.so
|
||||
if [ "$overlay" = 1 ] && [ -f "$arm_overlay" ]; then
|
||||
export LD_PRELOAD=$arm_overlay${LD_PRELOAD:+:$LD_PRELOAD}
|
||||
fi
|
||||
|
||||
dir=$HOME/.local/share/Steam/compatibilitytools.d/$tool
|
||||
manifest=$dir/toolmanifest.vdf
|
||||
[ -f "$manifest" ] || { echo "droiddeck-x64-arm-proton: no tool $dir" >&2; exit 127; }
|
||||
if ! grep -q droiddeck-proton-wrap "$manifest" 2>/dev/null; then
|
||||
python3 - "${dir%/*}" <<'PY' >&2 || true
|
||||
import importlib.machinery, importlib.util, sys
|
||||
path = "/usr/local/bin/steam-compatibility"
|
||||
spec = importlib.util.spec_from_file_location("compat", path, loader=importlib.machinery.SourceFileLoader("compat", path))
|
||||
compat = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(compat)
|
||||
compat.adopt_extras(sys.argv[1])
|
||||
PY
|
||||
fi
|
||||
cmd=$(sed -n 's/^[[:space:]]*"commandline"[[:space:]]*"\([^"]*\)".*/\1/p' "$manifest" | head -n 1)
|
||||
entry=${cmd%% *}
|
||||
exec "$dir/${entry#/}" "$@"
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
# The arm64 client's web helper for the x86-64 client, run natively: FEX hands this arm64 program to the CPU.
|
||||
x64_home=$HOME
|
||||
arm=/root/.local/share/Steam/steamrtarm64
|
||||
|
||||
for v in $(compgen -e); do
|
||||
case $v in FEX_*) unset "$v" ;; esac
|
||||
done
|
||||
unset LD_PRELOAD LIBGL_ALWAYS_SOFTWARE LIBGL_DRI3_DISABLE BL_WEBHELPER_HIDE_TRACER BL_X64_ARM_WEBHELPER
|
||||
if [ -f "$x64_home/arm-session.env" ]; then
|
||||
eval "$(grep -E '^declare -x (VK_ICD_FILENAMES|VK_DRIVER_FILES|GALLIUM_DRIVER|MESA_LOADER_DRIVER_OVERRIDE|LIBGL_KOPPER_DRI2|TU_DEBUG|ZINK_DEBUG|ZINK_DESCRIPTORS|MESA_NO_ERROR|MESA_DISK_CACHE_DATABASE)=' "$x64_home/arm-session.env")"
|
||||
fi
|
||||
export LD_LIBRARY_PATH=$arm:$arm/panorama LIBGL_KOPPER_DISABLE=true
|
||||
|
||||
args=()
|
||||
for a in "$@"; do
|
||||
case $a in --disable-gpu|--disable-gpu-compositing) ;; *) args+=("$a") ;; esac
|
||||
done
|
||||
cd "$arm" || exit 1
|
||||
exec "$arm/steamwebhelper" "${args[@]}" --ignore-gpu-blocklist
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
# Steam's compositor draws each browser window from its X pixmap: frames must reach X, not gamescope's WSI layer.
|
||||
# gamescope sets vk_xwayland_wait_ready=false for its children; kopper swapchains flashed black even with the wait.
|
||||
unset BL_X64_ARM_WEBHELPER
|
||||
# The shim already added the GPU flags (preload/webhelper.c) to these arguments.
|
||||
export BL_WEBHELPER_ARGS=stock DISABLE_GAMESCOPE_WSI=1 vk_xwayland_wait_ready=true LIBGL_KOPPER_DISABLE=true
|
||||
if [ -x ./steamwebhelper ]; then
|
||||
exec ./steamwebhelper "$@"
|
||||
fi
|
||||
exec "$HOME/.local/share/Steam/steamrt64/steamwebhelper" "$@"
|
||||
@@ -210,6 +210,34 @@ bl_idtech3() {
|
||||
}
|
||||
"""
|
||||
|
||||
# Source games report VAC-secure or insecure only in their console, written to console.log only with -condebug.
|
||||
# The app keeps the switch and the records in /root: the x86-64 client runs games with its own HOME.
|
||||
BL_VACDIAG_SETUP = """
|
||||
bl_vacdiag() {
|
||||
[ -f /root/.droiddeck-vac-diagnostics ] || return 0
|
||||
[ "${verb:-}" = waitforexitandrun ] || return 0
|
||||
local exe= a dir added=no app=${SteamAppId:-${STEAM_COMPAT_APP_ID:-0}}
|
||||
for a in "$@"; do case $a in *.exe|*.EXE) exe=$a ;; esac; done
|
||||
[ -n "$exe" ] || return 0
|
||||
dir=$(dirname "$exe")
|
||||
# Source: <mod>/gameinfo.txt beside the exe. Source 2: game/bin/win64/<exe> with game/<mod>/gameinfo.gi.
|
||||
if ls "$dir"/*/gameinfo.txt >/dev/null 2>&1 || ls "$dir"/../../*/gameinfo.gi >/dev/null 2>&1; then
|
||||
case " $* " in
|
||||
*" -condebug "*) echo "droiddeck-proton: vac-diag: app $app already has -condebug" >&2 ;;
|
||||
*) BL_EXTRA_ARGS+=(-condebug); added=yes
|
||||
echo "droiddeck-proton: vac-diag: app $app is a Source title; launched with -condebug" >&2 ;;
|
||||
esac
|
||||
else
|
||||
added=not-source
|
||||
echo "droiddeck-proton: vac-diag: app $app is not a Source title; it keeps no console log to read" >&2
|
||||
fi
|
||||
case " $* " in
|
||||
*" -insecure "*) echo "droiddeck-proton: vac-diag: app $app has -insecure in its launch options - it can never be VAC-secure this way" >&2 ;;
|
||||
esac
|
||||
printf '%s\tapp %s\tcondebug %s\t%s\n' "$(date +%s)" "$app" "$added" "${exe##*/}" >> /root/.droiddeck-vac-launches
|
||||
}
|
||||
"""
|
||||
|
||||
BL_DIRECTAUDIO_SETUP = """
|
||||
bl_directaudio() {
|
||||
base=$1
|
||||
@@ -305,6 +333,7 @@ if [ -n "$depot" ]; then
|
||||
bl_directaudio "$depot"
|
||||
bl_game_cpus
|
||||
bl_idtech3 "$@"
|
||||
bl_vacdiag "$@"
|
||||
bl_libpath
|
||||
BL_STORE_PROTON="$depot/proton"; export BL_STORE_PROTON
|
||||
bl_store_launch "$@"
|
||||
@@ -320,7 +349,7 @@ LAUNCHER_TEMPLATE = LAUNCHER_SH
|
||||
def launcher_sh(sources=SOURCES):
|
||||
return (LAUNCHER_TEMPLATE % " ".join('"%s"' % n for n in sources)).replace(
|
||||
"verb=$1; shift", "verb=$1; shift\n" + BL_DIRECTAUDIO_SETUP + BL_GAME_CPUS_SETUP + BL_IDTECH3_SETUP
|
||||
+ BL_COMPONENTS_SETUP + BL_LIBPATH_SETUP + BL_STORE_SETUP, 1)
|
||||
+ BL_VACDIAG_SETUP + BL_COMPONENTS_SETUP + BL_LIBPATH_SETUP + BL_STORE_SETUP, 1)
|
||||
|
||||
|
||||
LAUNCHER_SH = launcher_sh()
|
||||
@@ -359,6 +388,7 @@ bl_components "$here"
|
||||
bl_directaudio "$here"
|
||||
bl_game_cpus
|
||||
bl_idtech3 "$@"
|
||||
bl_vacdiag "$@"
|
||||
bl_libpath
|
||||
BL_STORE_PROTON="$here/%s"; export BL_STORE_PROTON
|
||||
bl_store_launch "$@"
|
||||
@@ -586,7 +616,7 @@ def adopt_extras(tools):
|
||||
body = (EXTRA_WRAPPER_SH % entry_point).replace(
|
||||
'here=$(dirname "$0")',
|
||||
'here=$(dirname "$0")\n' + BL_DIRECTAUDIO_SETUP + BL_GAME_CPUS_SETUP + BL_IDTECH3_SETUP
|
||||
+ BL_COMPONENTS_SETUP + BL_LIBPATH_SETUP + BL_STORE_SETUP, 1)
|
||||
+ BL_VACDIAG_SETUP + BL_COMPONENTS_SETUP + BL_LIBPATH_SETUP + BL_STORE_SETUP, 1)
|
||||
write_changed(wrapper, body, 0o755)
|
||||
write_changed(manifest, EXTRA_MANIFEST_VDF)
|
||||
write_changed(compat_vdf, EXTRA_COMPAT_TOOL_VDF % (name, display_name(entry)))
|
||||
@@ -1154,7 +1184,8 @@ def live_helper_running(directory=None):
|
||||
return False
|
||||
|
||||
|
||||
def register_default(config_path, apps=(), protect=(), default=None, catalog=None, directory=None, settle=False, picks=()):
|
||||
def register_default(config_path, apps=(), protect=(), default=None, catalog=None, directory=None, settle=False, picks=(),
|
||||
linux_tool=FEX_TOOL):
|
||||
"""Writes the mapping: the "0" default and every title that follows it (see plan_mapping).
|
||||
With settle, the default itself is decided first (see choose_default): before the client
|
||||
starts, config.vdf holds what the client last kept, menu changes included."""
|
||||
@@ -1178,9 +1209,12 @@ def register_default(config_path, apps=(), protect=(), default=None, catalog=Non
|
||||
default = state.get("default") if state.get("default") in names else TOOL
|
||||
steam_root = os.path.dirname(os.path.dirname(os.path.abspath(config_path)))
|
||||
overrides = requested_games(game_requests(directory), catalog)
|
||||
native = native_targets(steam_root, set(apps) | set(picks))
|
||||
if linux_tool != FEX_TOOL:
|
||||
native = {app: linux_tool if tool == FEX_TOOL else tool for app, tool in native.items()}
|
||||
changes, auto = plan_mapping(
|
||||
current, apps, names, default, followers(state, current),
|
||||
native_targets(steam_root, set(apps) | set(picks)), picks,
|
||||
native, picks,
|
||||
overrides, state.get("auto", {}).keys() if isinstance(state.get("auto"), dict) else (),
|
||||
state.get("native", ()))
|
||||
for app, tool in changes.items():
|
||||
@@ -1245,8 +1279,71 @@ def remove_tool(tool_dir):
|
||||
shutil.rmtree(tool_dir)
|
||||
|
||||
|
||||
def local_tools(steam_root):
|
||||
"""The names of the compatibility tools installed in steam_root/compatibilitytools.d."""
|
||||
names = set()
|
||||
tools = os.path.join(steam_root, "compatibilitytools.d")
|
||||
try:
|
||||
entries = os.listdir(tools)
|
||||
except OSError:
|
||||
return names
|
||||
for entry in entries:
|
||||
try:
|
||||
with open(os.path.join(tools, entry, "compatibilitytool.vdf"), encoding="utf-8", errors="replace") as f:
|
||||
m = re.search(r'"compat_tools"\s*\{\s*"([^"]+)"', f.read())
|
||||
except OSError:
|
||||
continue
|
||||
if m:
|
||||
names.add(m.group(1).lower())
|
||||
return names
|
||||
|
||||
|
||||
def x64_repoint(steam_root, tool, live=False):
|
||||
"""The x86-64 client (droiddeck-steam-x64): its tools are arm64 wrappers that script makes and
|
||||
its Linux titles run as Linux builds (FEX), so only the entries the client aimed at a Proton it
|
||||
cannot start are repointed, to `tool`. Tools in its own compatibilitytools.d are kept: the
|
||||
wrappers include proton-cachyos-*-a64, which starts with "proton" like Valve's own.
|
||||
Returns the app ids repointed."""
|
||||
config = os.path.join(steam_root, "config", "config.vdf")
|
||||
if not tool or not os.path.isfile(config):
|
||||
return []
|
||||
with open(config, encoding="utf-8", errors="replace") as f:
|
||||
original = f.read()
|
||||
tokens = tokenize(original)
|
||||
mapping = mapping_block(tokens)
|
||||
if mapping is None:
|
||||
return []
|
||||
keep = local_tools(steam_root)
|
||||
moved = []
|
||||
current = read_mapping(tokens, mapping)
|
||||
if "0" not in current:
|
||||
set_mapping(tokens, mapping, "0", tool)
|
||||
for app, name in current.items():
|
||||
named = name.lower()
|
||||
# A tool named arm64 is never this client's (its wrappers are -a64), so this legacy name is always repointed.
|
||||
legacy = named == "droiddeck-proton-arm64"
|
||||
if (named.startswith("proton") or legacy) and named != tool.lower() \
|
||||
and (legacy or named not in keep):
|
||||
set_mapping(tokens, mapping, app, tool)
|
||||
if app != "0":
|
||||
moved.append(app)
|
||||
text = serialize(tokens)
|
||||
if text != serialize(tokenize(original)):
|
||||
write_changed(config, text)
|
||||
print("steam-compatibility: x86-64 client's Proton entries point at %s" % tool)
|
||||
# Steam reads a mapping changed while it runs only at its next start; the session restarts it (.bl-compat-pending).
|
||||
if moved and live:
|
||||
with open(os.path.join(os.path.expanduser("~"), ".bl-compat-pending"), "a") as f:
|
||||
f.write("".join("%s\n" % a for a in moved))
|
||||
print("steam-compatibility: repointed while the client runs: %s" % " ".join(moved))
|
||||
return moved
|
||||
|
||||
|
||||
def main():
|
||||
steam_root = sys.argv[1]
|
||||
if "--x64" in sys.argv[2:]:
|
||||
x64_repoint(steam_root, os.environ.get("BL_COMPAT_TOOL"), "--live" in sys.argv[2:])
|
||||
return
|
||||
tools = os.path.join(steam_root, "compatibilitytools.d")
|
||||
os.makedirs(tools, exist_ok=True)
|
||||
legacy = os.path.join(tools, LEGACY_TOOL)
|
||||
|
||||
@@ -91,7 +91,8 @@ static int enabled(void) {
|
||||
if (cached < 0) {
|
||||
const char *off = getenv("BL_NO_DIR_CACHE");
|
||||
cached = strcmp(program_invocation_short_name, "steam") == 0 &&
|
||||
strstr(program_invocation_name, "steamrtarm64") != NULL && !(off && strcmp(off, "1") == 0);
|
||||
(strstr(program_invocation_name, "steamrtarm64") != NULL ||
|
||||
strstr(program_invocation_name, "steamrt64") != NULL) && !(off && strcmp(off, "1") == 0);
|
||||
if (cached) pthread_atfork(NULL, NULL, after_fork);
|
||||
}
|
||||
return cached && !forked;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <linux/netlink.h>
|
||||
#include <netinet/in.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -309,11 +310,39 @@ static int maybe_answer_lsof(const char *path, char *const argv[]) {
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
static char **web_helper_redirect(const char *path, char *const argv[], const char **launcher) {
|
||||
const char *want = getenv("BL_X64_ARM_WEBHELPER");
|
||||
if (!want || !*want || !path) return NULL;
|
||||
const char *base = strrchr(path, '/');
|
||||
if (strcmp(base ? base + 1 : path, "steamwebhelper") != 0) return NULL;
|
||||
if (!strstr(path, "/steamrt64/")) {
|
||||
char cwd[PATH_MAX];
|
||||
size_t n;
|
||||
if (path[0] == '/' || !getcwd(cwd, sizeof(cwd))) return NULL;
|
||||
n = strlen(cwd);
|
||||
if (n < 10 || strcmp(cwd + n - 10, "/steamrt64") != 0) return NULL;
|
||||
}
|
||||
int argc = 0;
|
||||
while (argv && argv[argc]) argc++;
|
||||
char **out = calloc((size_t)argc + 2, sizeof(char *));
|
||||
if (!out) return NULL;
|
||||
out[0] = (char *)want;
|
||||
for (int i = 1; i < argc; i++) out[i] = argv[i];
|
||||
*launcher = want;
|
||||
return out;
|
||||
}
|
||||
|
||||
int execve(const char *path, char *const argv_in[], char *const envp[]) {
|
||||
char *const *argv = bl_webhelper_argv(path, argv_in);
|
||||
static int (*real)(const char *, char *const[], char *const[]);
|
||||
if (!real) real = (int (*)(const char *, char *const[], char *const[]))dlsym(RTLD_NEXT, "execve");
|
||||
maybe_answer_lsof(path, argv);
|
||||
const char *launcher = NULL;
|
||||
char **redirected = web_helper_redirect(path, argv, &launcher);
|
||||
if (redirected) {
|
||||
real(launcher, redirected, envp);
|
||||
free(redirected);
|
||||
}
|
||||
bl_binfmt_before(path, argv, envp);
|
||||
real(path, argv, envp);
|
||||
return bl_binfmt_retry(path, argv, envp, errno);
|
||||
@@ -349,6 +378,12 @@ int execv(const char *path, char *const argv_in[]) {
|
||||
static int (*real)(const char *, char *const[]);
|
||||
if (!real) real = (int (*)(const char *, char *const[]))dlsym(RTLD_NEXT, "execv");
|
||||
maybe_answer_lsof(path, argv);
|
||||
const char *launcher = NULL;
|
||||
char **redirected = web_helper_redirect(path, argv, &launcher);
|
||||
if (redirected) {
|
||||
real(launcher, redirected);
|
||||
free(redirected);
|
||||
}
|
||||
bl_binfmt_before(path, argv, environ);
|
||||
real(path, argv);
|
||||
return bl_binfmt_retry(path, argv, environ, errno);
|
||||
|
||||
@@ -538,11 +538,11 @@ static FILE *synthesize(const char *table) {
|
||||
return out;
|
||||
}
|
||||
|
||||
int bl_status_without_tracer(const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
int bl_status_without_tracer(const char *path, int flags, const void *caller) __attribute__((visibility("hidden")));
|
||||
|
||||
static FILE *open_stream(fopen_fn real, const char *path, const char *mode) {
|
||||
static FILE *open_stream(fopen_fn real, const char *path, const char *mode, const void *caller) {
|
||||
int status = mode && mode[0] == 'r' && !strchr(mode, '+')
|
||||
? bl_status_without_tracer(path, O_RDONLY | O_CLOEXEC) : -1;
|
||||
? bl_status_without_tracer(path, O_RDONLY | O_CLOEXEC, caller) : -1;
|
||||
if (status >= 0) {
|
||||
FILE *copy = fdopen(status, "r");
|
||||
if (copy == NULL) close(status);
|
||||
@@ -560,11 +560,11 @@ static FILE *open_stream(fopen_fn real, const char *path, const char *mode) {
|
||||
FILE *fopen(const char *path, const char *mode) {
|
||||
static fopen_fn real;
|
||||
if (real == NULL) real = (fopen_fn) dlsym(RTLD_NEXT, "fopen");
|
||||
return open_stream(real, path, mode);
|
||||
return open_stream(real, path, mode, __builtin_return_address(0));
|
||||
}
|
||||
|
||||
FILE *fopen64(const char *path, const char *mode) {
|
||||
static fopen_fn real;
|
||||
if (real == NULL) real = (fopen_fn) dlsym(RTLD_NEXT, "fopen64");
|
||||
return open_stream(real, path, mode);
|
||||
return open_stream(real, path, mode, __builtin_return_address(0));
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int bl_status_without_tracer(const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
int bl_status_without_tracer(const char *path, int flags, const void *caller) __attribute__((visibility("hidden")));
|
||||
int bl_writable_retry(int dirfd, const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
int bl_ntsync_open(const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
int bl_dircache_create(int dirfd, const char *path, int flags, mode_t mode,
|
||||
@@ -51,7 +51,7 @@ int open(const char *path, int flags, ...) {
|
||||
errno = EACCES;
|
||||
return -1;
|
||||
}
|
||||
if ((fd = bl_status_without_tracer(path, flags)) >= 0) return fd;
|
||||
if ((fd = bl_status_without_tracer(path, flags, __builtin_return_address(0))) >= 0) return fd;
|
||||
if ((fd = bl_ntsync_open(path, flags)) != -2) return fd;
|
||||
if (real_open == NULL) real_open = dlsym(RTLD_NEXT, "open");
|
||||
if (real_open == NULL) {
|
||||
@@ -76,7 +76,7 @@ int openat(int dirfd, const char *path, int flags, ...) {
|
||||
errno = EACCES;
|
||||
return -1;
|
||||
}
|
||||
if ((fd = bl_status_without_tracer(path, flags)) >= 0) return fd;
|
||||
if ((fd = bl_status_without_tracer(path, flags, __builtin_return_address(0))) >= 0) return fd;
|
||||
if ((fd = bl_ntsync_open(path, flags)) != -2) return fd;
|
||||
if (real_openat == NULL) real_openat = dlsym(RTLD_NEXT, "openat");
|
||||
if (real_openat == NULL) {
|
||||
|
||||
@@ -42,7 +42,8 @@ static int enabled(void) {
|
||||
if (cached >= 0) return cached;
|
||||
off = getenv("BL_NO_PATH_CACHE");
|
||||
cached = strcmp(program_invocation_short_name, "steam") == 0 &&
|
||||
strstr(program_invocation_name, "steamrtarm64") != NULL &&
|
||||
(strstr(program_invocation_name, "steamrtarm64") != NULL ||
|
||||
strstr(program_invocation_name, "steamrt64") != NULL) &&
|
||||
!(off != NULL && off[0] == '1');
|
||||
return cached;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
static int in_steam_dirs(const char *path) {
|
||||
return path != NULL && (strstr(path, "/Steam/steamrtarm64/") != NULL
|
||||
return path != NULL && (strstr(path, "/Steam/steamrtarm64/") != NULL || strstr(path, "/Steam/steamrt64/") != NULL
|
||||
|| strstr(path, "/Steam/ubuntu12_64/") != NULL || strstr(path, "/Steam/linuxarm64/") != NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/* In Deck mode (-steamos3) the x86-64 client's SteamOS audio manager passes libpulse the NULL operation of a
|
||||
* failed request, and libpulse aborts on it ("Assertion 'o' failed ... pa_operation_get_state()"). */
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
#define _GNU_SOURCE
|
||||
#include <dlfcn.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct pa_operation pa_operation;
|
||||
|
||||
#define PA_OPERATION_CANCELLED 2
|
||||
|
||||
/* A libpulse loaded with RTLD_LOCAL (Wine's winepulse.so) is not in RTLD_NEXT's scope. */
|
||||
static void *libpulse(const char *name) {
|
||||
void *fn = dlsym(RTLD_NEXT, name);
|
||||
if (!fn) {
|
||||
void *handle = dlopen("libpulse.so.0", RTLD_LAZY | RTLD_NOLOAD);
|
||||
if (handle) {
|
||||
fn = dlsym(handle, name);
|
||||
dlclose(handle);
|
||||
}
|
||||
}
|
||||
return fn;
|
||||
}
|
||||
|
||||
int pa_operation_get_state(pa_operation *o) {
|
||||
static int (*next)(pa_operation *);
|
||||
if (!o)
|
||||
return PA_OPERATION_CANCELLED;
|
||||
if (!next)
|
||||
next = (int (*)(pa_operation *))libpulse("pa_operation_get_state");
|
||||
return next ? next(o) : PA_OPERATION_CANCELLED;
|
||||
}
|
||||
|
||||
void pa_operation_unref(pa_operation *o) {
|
||||
static void (*next)(pa_operation *);
|
||||
if (!o)
|
||||
return;
|
||||
if (!next)
|
||||
next = (void (*)(pa_operation *))libpulse("pa_operation_unref");
|
||||
if (next)
|
||||
next(o);
|
||||
}
|
||||
|
||||
void pa_operation_cancel(pa_operation *o) {
|
||||
static void (*next)(pa_operation *);
|
||||
if (!o)
|
||||
return;
|
||||
if (!next)
|
||||
next = (void (*)(pa_operation *))libpulse("pa_operation_cancel");
|
||||
if (next)
|
||||
next(o);
|
||||
}
|
||||
#else
|
||||
typedef int pulseguard_arm_build_has_nothing_to_do;
|
||||
#endif
|
||||
@@ -2,14 +2,18 @@
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <linux/futex.h>
|
||||
#include <linux/magic.h>
|
||||
#include <pthread.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/vfs.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef SYS_openat2
|
||||
@@ -18,6 +22,17 @@
|
||||
|
||||
#define BL_RESOLVE_BENEATH 0x08
|
||||
#define BL_RESOLVE_IN_ROOT 0x10
|
||||
// The kernel's MAXSYMLINKS.
|
||||
#define BL_MAX_SYMLINKS 40
|
||||
#define BL_PROC_ROOT_INO 1
|
||||
|
||||
#ifdef SYS_newfstatat
|
||||
#define BL_SYS_FSTATAT SYS_newfstatat
|
||||
typedef struct stat bl_stat;
|
||||
#else
|
||||
#define BL_SYS_FSTATAT SYS_fstatat64
|
||||
typedef struct stat64 bl_stat;
|
||||
#endif
|
||||
|
||||
struct bl_open_how {
|
||||
uint64_t flags;
|
||||
@@ -76,6 +91,151 @@ static struct robust_list_head *thread_robust_head(void) {
|
||||
return head;
|
||||
}
|
||||
|
||||
// Magic links are procfs links below a process's directory; procfs's root holds only plain ones (self, thread-self, mounts).
|
||||
static int is_magic_link(int dirfd, char *link, size_t parent_len) {
|
||||
int fd = (int)real_syscall(SYS_openat, (long)dirfd, (long)link, (long)(O_PATH | O_NOFOLLOW | O_CLOEXEC), 0L);
|
||||
if (fd < 0) {
|
||||
return 0;
|
||||
}
|
||||
struct statfs fs;
|
||||
int procfs = real_syscall(SYS_fstatfs, (long)fd, (long)&fs) == 0 && fs.f_type == PROC_SUPER_MAGIC;
|
||||
real_syscall(SYS_close, (long)fd);
|
||||
if (!procfs) {
|
||||
return 0;
|
||||
}
|
||||
char saved = link[parent_len];
|
||||
link[parent_len] = 0;
|
||||
bl_stat parent;
|
||||
long result = real_syscall(BL_SYS_FSTATAT, (long)dirfd, (long)(parent_len ? link : "."), (long)&parent, 0L);
|
||||
link[parent_len] = saved;
|
||||
return result != 0 || parent.st_ino != BL_PROC_ROOT_INO;
|
||||
}
|
||||
|
||||
// RESOLVE_IN_ROOT walked one component at a time: absolute symlinks restart at dirfd and ".." stops there.
|
||||
static long openat_in_root(int dirfd, const char *path, int flags, long mode) {
|
||||
char resolved[PATH_MAX];
|
||||
char pending[PATH_MAX];
|
||||
size_t resolved_len = 0;
|
||||
int symlinks = 0;
|
||||
int have_root = 0;
|
||||
int root_on_procfs = 0;
|
||||
dev_t root_dev = 0;
|
||||
// O_NOFOLLOW and O_CREAT | O_EXCL leave a final symlink alone, unless a trailing slash follows it.
|
||||
int nofollow = (flags & O_NOFOLLOW) || (flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL);
|
||||
const char *rest = path;
|
||||
for (;;) {
|
||||
while (*rest == '/') {
|
||||
rest++;
|
||||
}
|
||||
if (!*rest) {
|
||||
break;
|
||||
}
|
||||
const char *name = rest;
|
||||
const char *end = name;
|
||||
while (*end && *end != '/') {
|
||||
end++;
|
||||
}
|
||||
size_t len = (size_t)(end - name);
|
||||
rest = end;
|
||||
while (*rest == '/') {
|
||||
rest++;
|
||||
}
|
||||
int last = !*rest;
|
||||
int trailing_slash = last && rest != end;
|
||||
if (len == 1 && name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
if (len == 2 && name[0] == '.' && name[1] == '.') {
|
||||
while (resolved_len > 0 && resolved[resolved_len - 1] != '/') {
|
||||
resolved_len--;
|
||||
}
|
||||
if (resolved_len > 0) {
|
||||
resolved_len--;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
size_t separator = resolved_len > 0;
|
||||
size_t candidate_len = resolved_len + separator + len;
|
||||
if (candidate_len + 1 >= PATH_MAX) {
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
if (separator) {
|
||||
resolved[resolved_len] = '/';
|
||||
}
|
||||
memcpy(resolved + resolved_len + separator, name, len);
|
||||
resolved[candidate_len] = 0;
|
||||
bl_stat st;
|
||||
int follow = !last || trailing_slash || !nofollow;
|
||||
long stat_result = follow ? real_syscall(BL_SYS_FSTATAT, (long)dirfd, (long)resolved, (long)&st, (long)AT_SYMLINK_NOFOLLOW) : -1;
|
||||
if (stat_result == 0 && S_ISLNK(st.st_mode)) {
|
||||
if (++symlinks > BL_MAX_SYMLINKS) {
|
||||
errno = ELOOP;
|
||||
return -1;
|
||||
}
|
||||
if (!have_root) {
|
||||
bl_stat root;
|
||||
struct statfs root_fs;
|
||||
if (real_syscall(BL_SYS_FSTATAT, (long)dirfd, (long)".", (long)&root, 0L) != 0) {
|
||||
return -1;
|
||||
}
|
||||
root_dev = root.st_dev;
|
||||
root_on_procfs = real_syscall(SYS_fstatfs, (long)dirfd, (long)&root_fs) == 0 && root_fs.f_type == PROC_SUPER_MAGIC;
|
||||
have_root = 1;
|
||||
}
|
||||
if ((st.st_dev != root_dev || root_on_procfs) && is_magic_link(dirfd, resolved, resolved_len)) {
|
||||
// RESOLVE_IN_ROOT refuses magic links.
|
||||
errno = EXDEV;
|
||||
return -1;
|
||||
}
|
||||
size_t rest_len = strlen(end);
|
||||
if (rest_len + 1 >= PATH_MAX) {
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
char *tail = pending + PATH_MAX - rest_len - 1;
|
||||
memmove(tail, end, rest_len + 1);
|
||||
long target_len = real_syscall(SYS_readlinkat, (long)dirfd, (long)resolved, (long)pending, (long)(PATH_MAX - rest_len));
|
||||
if (target_len <= 0) {
|
||||
if (target_len == 0) {
|
||||
errno = ENOENT;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
if ((size_t)target_len + rest_len >= PATH_MAX) {
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
memmove(pending + target_len, tail, rest_len + 1);
|
||||
if (pending[0] == '/') {
|
||||
resolved_len = 0;
|
||||
}
|
||||
rest = pending;
|
||||
continue;
|
||||
}
|
||||
if (last) {
|
||||
resolved_len = candidate_len;
|
||||
if (trailing_slash) {
|
||||
resolved[resolved_len++] = '/';
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (stat_result != 0) {
|
||||
return -1;
|
||||
}
|
||||
if (!S_ISDIR(st.st_mode)) {
|
||||
errno = ENOTDIR;
|
||||
return -1;
|
||||
}
|
||||
resolved_len = candidate_len;
|
||||
}
|
||||
if (resolved_len == 0) {
|
||||
resolved[resolved_len++] = '.';
|
||||
}
|
||||
resolved[resolved_len] = 0;
|
||||
return real_syscall(SYS_openat, (long)dirfd, (long)resolved, (long)flags, mode);
|
||||
}
|
||||
|
||||
static long openat2_via_openat(const long *args) {
|
||||
const char *path = (const char *)args[1];
|
||||
const struct bl_open_how *how = (const struct bl_open_how *)args[2];
|
||||
@@ -83,6 +243,9 @@ static long openat2_via_openat(const long *args) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if ((how->resolve & BL_RESOLVE_IN_ROOT) && (int)args[0] != AT_FDCWD) {
|
||||
return openat_in_root((int)args[0], path, (int)how->flags, (long)how->mode);
|
||||
}
|
||||
if (how->resolve & BL_RESOLVE_IN_ROOT) {
|
||||
while (*path == '/') {
|
||||
path++;
|
||||
|
||||
@@ -145,7 +145,8 @@ static int steam_client(void) {
|
||||
static int cached = -1;
|
||||
if (cached < 0)
|
||||
cached = strcmp(program_invocation_short_name, "steam") == 0 &&
|
||||
strstr(program_invocation_name, "steamrtarm64") != NULL;
|
||||
(strstr(program_invocation_name, "steamrtarm64") != NULL ||
|
||||
strstr(program_invocation_name, "steamrt64") != NULL);
|
||||
return cached;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <ctype.h>
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/syscall.h>
|
||||
@@ -31,9 +33,16 @@ static int is_status_path(const char *path) {
|
||||
return strcmp(rest, "/status") == 0;
|
||||
}
|
||||
|
||||
static int is_web_helper(void) {
|
||||
return strcmp(program_invocation_short_name, "steamwebhelper") == 0 ||
|
||||
strcmp(program_invocation_short_name, "vrwebhelper") == 0;
|
||||
static int is_web_helper(const void *caller) {
|
||||
if (strcmp(program_invocation_short_name, "steamwebhelper") != 0 &&
|
||||
strcmp(program_invocation_short_name, "vrwebhelper") != 0)
|
||||
return 0;
|
||||
const char *hide = getenv("BL_WEBHELPER_HIDE_TRACER");
|
||||
Dl_info info;
|
||||
if (hide && hide[0] == '1' && caller && dladdr(caller, &info) && info.dli_fname
|
||||
&& strstr(info.dli_fname, "libtier0_s.so"))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int write_all(int fd, const char *data, size_t len) {
|
||||
@@ -47,13 +56,13 @@ static int write_all(int fd, const char *data, size_t len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_status_without_tracer(const char *path, int flags) {
|
||||
__attribute__((visibility("hidden"))) int bl_status_without_tracer(const char *path, int flags, const void *caller) {
|
||||
char text[STATUS_MAX];
|
||||
size_t len = 0;
|
||||
int saved = errno;
|
||||
int out = -1;
|
||||
|
||||
if ((flags & O_ACCMODE) != O_RDONLY || !is_status_path(path) || is_web_helper()) return -1;
|
||||
if ((flags & O_ACCMODE) != O_RDONLY || !is_status_path(path) || is_web_helper(caller)) return -1;
|
||||
int in = (int)syscall(SYS_openat, AT_FDCWD, path, O_RDONLY | O_CLOEXEC);
|
||||
if (in < 0) goto done;
|
||||
for (;;) {
|
||||
|
||||
Reference in new issue
Block a user