SteamDeck: a standalone launcher for the native ARM64 Linux Steam client

Lifts Bannerlator's Linux/gamescope runtime out into an app of its own: the
Wayland compositor, the proot session, the runtime installer, the fake-evdev
controller path and the PulseAudio server, with none of the Wine, container or
store machinery around them.

One activity installs the runtime from the same winlator-contents catalog and a
second one runs the session: compositor on a SurfaceView, gamescope and Valve's
native arm64 client under proot, a physical pad republished into the fake-input
rings, and the session's milestones on screen until the first frame arrives.
This commit is contained in:
The412Banner committed 2026-09-19 13:39:17 -04:00
commit 4022351e22
210 files changed
+73587

No files matched your search

@@ -0,0 +1,58 @@
#!/bin/bash
# Marks Steam's shared redistributables as already run in every Proton prefix.
#
# A game whose depot lists _CommonRedist makes the client run the real installer inside the
# prefix on first launch. Those are x86 bundles, so they run under FEX, and the 2019 one leaves
# a task behind every time: its main thread exits while a helper stays blocked reading a pipe it
# also holds the write end of, so the process never reaps and the client keeps waiting on it.
#
# The client skips a "Run Process" block whose HasRunKey is already set, which is the same escape
# WineUtils.seedVcRedistRegistryIfDllsPresent() takes for the app's own containers. The names and
# versions come out of the install scripts rather than a list kept here, because Valve revises
# them; a prefix already carrying the same set is left alone.
set -u
steam_root=${1:?steam root}
redist="$steam_root/steamapps/common/Steamworks Shared/_CommonRedist"
[ -d "$redist" ] || exit 0
# Every process an install script would run becomes the registry value the client writes once it
# has run it. Names sit one level inside "Run Process", the key they share a level further in.
block=$(find "$redist" -name installscript.vdf -print0 2>/dev/null | sort -z | xargs -0 -r awk -v now="$(date +%s)" '
function emit(key, name, path) {
path = key
sub(/^HKEY_LOCAL_MACHINE\\\\/, "", path)
if (path == key)
return
printf "\n[%s] %d\n\"%s\"=dword:00000001\n", path, now, name
# The client writes these from 32-bit steam.exe, so its own copy lands under Wow6432Node;
# both spellings are seeded because the reader picks by its own word size.
sub(/^Software\\\\/, "Software\\\\\\\\Wow6432Node\\\\\\\\", path)
printf "\n[%s] %d\n\"%s\"=dword:00000001\n", path, now, name
}
FNR == 1 { depth = 0; name = ""; key = "" }
/^[[:space:]]*\{/ { depth++; next }
/^[[:space:]]*\}/ {
if (depth == 3 && name != "" && key != "")
emit(key, name)
depth--
next
}
{
n = split($0, part, "\"")
if (n >= 5 && tolower(part[2]) == "hasrunkey") { key = part[4]; next }
if (n >= 3 && depth == 2) { name = part[2]; key = "" }
}
')
[ -n "$block" ] || exit 0
stamp=$(printf '%s' "$block" | cksum)
for reg in "$steam_root"/steamapps/compatdata/*/pfx/system.reg \
/mnt/bannerlator-sd/steamapps/compatdata/*/pfx/system.reg; do
[ -f "$reg" ] || continue
seeded=$(dirname "$reg")/.bannerlator-redists
[ "$(cat "$seeded" 2>/dev/null)" = "$stamp" ] && continue
printf '%s\n' "$block" >>"$reg" || continue
printf '%s\n' "$stamp" >"$seeded"
echo "== seeded redist markers into $reg"
done
+186
View File
@@ -0,0 +1,186 @@
#!/bin/bash
# The Linux runtime's session. Bannerlator execs this under proot with the output size and mode;
# the first pass starts gamescope, which execs this script again inside it for the program:
# bannerlator-session desktop the file manager
# bannerlator-session run <path> a Linux program (AppImage, script or ELF)
# bannerlator-session steam [steam-url] the native Steam client
# BL_WIDTH / BL_HEIGHT size the output, BL_FPS limits it, BL_LOG collects everything said here.
set -u
export HOME=${HOME:-/root}
mode=${1:-desktop}
shift || true
# One line per milestone, greppable as "== STEP", so a first run reads as a narrative rather than
# something to be reconstructed from Steam's own chatter. The app shows these while it waits.
step() { echo "== STEP $(date -u +%H:%M:%S) $*"; }
if [ -n "${BL_LOG:-}" ] && [ -z "${BL_INSIDE:-}" ]; then
mkdir -p "$(dirname "$BL_LOG")" 2>/dev/null
# The client alone writes megabytes an hour; one earlier log is kept, not every session's.
if [ "$(stat -c %s "$BL_LOG" 2>/dev/null || echo 0)" -gt 8388608 ]; then
mv -f "$BL_LOG" "$BL_LOG.1"
fi
exec >>"$BL_LOG" 2>&1
echo "== bannerlator-session $(date) mode=$mode $*"
echo "== uid=$(id -u) size=${BL_WIDTH:-?}x${BL_HEIGHT:-?} fps=${BL_FPS:-0} icd=${VK_ICD_FILENAMES:-none}"
echo "== gamescope: $(gamescope --version 2>&1 | head -1)"
echo "== rootfs: $(cat /.version 2>/dev/null || echo unversioned)"
fi
# Until the runtime is stable, Steam's own logs are copied beside the session log at exit so a
# failed launch can be handed over as one folder.
collect_steam_logs() {
[ -n "${BL_DEBUG_DIR:-}" ] || return 0
local steam_root=${XDG_DATA_HOME:-$HOME/.local/share}/Steam
mkdir -p "$BL_DEBUG_DIR" 2>/dev/null || return 0
[ -d "$steam_root/logs" ] && cp -r "$steam_root/logs" "$BL_DEBUG_DIR/steam-logs" 2>/dev/null
[ -f "$HOME/.steam/steam/logs/steamwebhelper.log" ] && cp "$HOME/.steam/steam/logs/steamwebhelper.log" "$BL_DEBUG_DIR/" 2>/dev/null
[ -f "$steam_root/steam.pid" ] && cp "$steam_root/steam.pid" "$BL_DEBUG_DIR/" 2>/dev/null
echo "== steam logs copied to $BL_DEBUG_DIR"
}
export XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
export XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
mkdir -p "$XDG_DATA_HOME" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME"
if [ -z "${BL_INSIDE:-}" ]; then
# The compositor may still be starting, and a socket left by an earlier session is not
# a compositor: probe until a connection succeeds.
for _ in $(seq 1 100); do
wayland-info >/dev/null 2>&1 && break
sleep 0.1
done
width=${BL_WIDTH:-1280}
height=${BL_HEIGHT:-720}
args=(--backend wayland --expose-wayland -f -W "$width" -H "$height" -w "$width" -h "$height")
# -r is what gamescope advertises as the refresh rate, and what a game reads as the display's.
# Left unset it defaults to 60, so a 120 Hz panel offers only 60 Hz in game settings. The FPS
# limiter wins when it is on (it is a deliberate cap); otherwise use the panel's own rate.
if [ "${BL_FPS:-0}" -gt 0 ]; then
args+=(-r "$BL_FPS")
elif [ "${BL_REFRESH:-0}" -gt 0 ]; then
args+=(-r "$BL_REFRESH")
fi
[ "$mode" = steam ] && args+=(-e)
export BL_INSIDE=1
exec gamescope "${args[@]}" -- "$0" "$mode" "$@"
fi
# gamescope manages X windows: toolkits go through Xwayland, not gamescope's own Wayland socket.
export GDK_BACKEND=x11 QT_QPA_PLATFORM=xcb SDL_VIDEODRIVER=x11
# gamescope's reaper waits for every process left under it before the compositor comes down. A
# process a game left behind - a Wine service blocked on a server that is already gone - is
# reparented there when the client exits, and the screen stays black on it for good. Nothing of
# the session outlives the program it was started for.
reap_orphans() {
local round p stat pid left
for round in 1 2 3 4 5; do
left=
for p in /proc/[0-9]*; do
pid=${p#/proc/}
[ "$pid" = "$$" ] && continue
stat=$(cat "$p/stat" 2>/dev/null) || continue
stat=${stat##*) }
set -- $stat
[ "${2:-}" = "$PPID" ] && left="$left $pid"
done
[ -n "$left" ] || return 0
echo "== leaving behind:$left"
kill -9 $left 2>/dev/null
sleep 0.2
done
}
case $mode in
desktop)
exec pcmanfm
;;
run)
target=${1:?program path}
shift
case ${target,,} in
*.appimage)
export APPIMAGE_EXTRACT_AND_RUN=1
chmod +x "$target" 2>/dev/null
exec "$target" "$@"
;;
*.sh)
exec bash "$target" "$@"
;;
*)
chmod +x "$target" 2>/dev/null
cd "$(dirname "$target")" && exec "$target" "$@"
;;
esac
;;
steam)
step "checking the Steam client (first run downloads it, ~1-2 min with nothing on screen)"
bannerlator-steam-install || exit $?
step "Steam client ready"
steam_root=$XDG_DATA_HOME/Steam
# Register the card library (bound at /mnt/bannerlator-sd) with the client - internal storage is
# its main library already - and the ARM64 Proton that lets it launch the Windows ones.
step "registering the app's game library with Steam"
bannerlator-steam-library "$steam_root" || true
step "setting up the ARM64 Proton compatibility tool"
bannerlator-steam-compat "$steam_root" || true
# Steam runs a game's shared redistributables inside its prefix on first launch; marking
# them as already run keeps those x86 installers from starting under emulation at all.
bannerlator-seed-redists "$steam_root" || true
# The compatibility tool runs Valve's arm64 Proton, which the client fetches like any depot.
# Asked for on the command line the first time, so a Windows title has it before it is needed.
if [ ! -f "$steam_root/steamapps/appmanifest_4427310.acf" ]; then
step "asking the client to fetch the ARM64 Proton"
set -- "$@" steam://install/4427310
fi
# The tool is registered before the client starts and finds the depot at launch time, so
# nothing here waits for a download. What can still change under a running client is which
# titles are installed: a title installed this session gets the client's own per-app Proton
# choice, which it cannot start. Refresh the per-app entries every so often; the registrar is
# idempotent, so a repeat costs nothing.
(
for _ in $(seq 1 240); do
sleep 15
bannerlator-steam-compat "$steam_root" >/dev/null 2>&1 || true
done
) &
# Debug aid while the runtime is being brought up: an app id dropped in ~/.bl-autolaunch is
# handed to the client as a rungameid URL, so a launch can be reproduced without touching the
# screen. Removed once the runtime is stable.
if [ -s "$HOME/.bl-autolaunch" ]; then
_bl_app=$(cat "$HOME/.bl-autolaunch")
# A bare app id runs the game; a full steam:// URL is passed through, which is how a
# validate or an install is driven without touching the screen.
case $_bl_app in
steam://*) _bl_url=$_bl_app ;;
*) _bl_url=steam://rungameid/$_bl_app ;;
esac
echo "== autolaunch $_bl_url"
set -- "$@" "$_bl_url"
fi
export STEAM_RUNTIME=1
export LD_LIBRARY_PATH=$steam_root/steamrtarm64:$steam_root/steamrtarm64/panorama${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
export SDL_VIDEO_X11_DGAMOUSE=0
# Native-Linux x86 games go through Valve's FEX compat tool, which runs FEX with FEX_PORTABLE=1
# - that makes FEX look for its config next to the binary, while the tool writes one into the
# app's compatdata instead. FEX therefore starts with no rootfs, every x86_64 library lookup
# falls through to the host, and the guest shell dies on libreadline before the game is reached.
# FEX_ROOTFS names it outright and is read whatever the config situation.
[ -d /usr/share/guestos/fex-mesa ] && export FEX_ROOTFS=/usr/share/guestos/fex-mesa
# The client exits 42 when it has updated itself and wants a fresh start (steam.sh does this).
while :; do
step "starting the Steam client"
"$steam_root/steamrtarm64/steam" -gamepadui -clientbeta publicbeta \
-no-cef-sandbox -cef-force-gpu -cef-ozone-platform=x11 \
-cef-use-gl=angle -cef-use-angle=vulkan "$@"
rc=$?
echo "== steam exited rc=$rc"
collect_steam_logs
[ "$rc" -eq 42 ] || break
done
reap_orphans
exit "$rc"
;;
*)
echo "bannerlator-session: unknown mode '$mode'" >&2
exit 64
;;
esac
@@ -0,0 +1,285 @@
#!/usr/bin/python3
# Makes the ARM64 Proton the client already downloaded usable here, and sets it as the default tool
# for Windows titles (CompatToolMapping "0" in config.vdf) when the user has not chosen one. Run
# before the client starts; it rewrites config.vdf on exit.
#
# bannerlator-steam-compat <steam root>
#
# Valve ships a native aarch64 Proton (arm64ec Wine with FEX as the x86 layer) as an ordinary depot,
# which is exactly what this runtime wants. Its toolmanifest declares require_tool_appid 4185400 -
# Steam Linux Runtime 4 for arm64 - so Steam stacks pressure-vessel underneath it, and
# pressure-vessel needs unprivileged user namespaces, which an Android app does not get. Steam then
# drops the launch on the floor: no window, no log, straight back to the library.
#
# So the depot is re-registered here as a compatibility tool of our own: every entry symlinked so
# nothing is copied and Steam still updates the real depot, but with a toolmanifest that leaves out
# require_tool_appid. Proton takes its base directory from dirname(sys.argv[0]) without resolving
# it, so it reads files/ through those symlinks and runs directly on this rootfs.
import os
import re
import shutil
import sys
TOOL = "bannerlator-proton-arm64"
# Valve's own ARM64 Proton, by the name the client registers it under. Used only to bootstrap a
# fresh install: naming it is what makes the client offer it and fetch the depot.
SEED_TOOL = "proton-experimental-arm64"
# The ARM64 Proton depot the client downloads for itself, as a compatibility-tool appid.
# The session asks the client to install it on the command line the first time (steam://install),
# so a new client has it before a Windows title is first launched. It is deliberately NOT named as
# this tool's dependency: a dependency is composed with its own dependencies, and this depot
# requires 4185400, the arm64 Steam Linux Runtime, whose container needs user namespaces Android
# does not give - the launch would be wrapped in it and die before this tool ever ran.
PROTON_ARM64_APPID = "4427310"
LAUNCHER = "bannerlator-proton"
# The extra Steam library the app mounts the installed games into (see bannerlator-steam-library).
# installed_apps() scans it too; it lives only in the sibling script, so define it here as well.
LIBRARY = "/mnt/bannerlator" # the card library is LIBRARY + "-sd"; internal storage is steam_root itself
# The client lists its own "Proton Experimental (ARM64)" and "Proton 11.0 (ARM64)" in the same
# Compatibility dropdown, and those are the two that cannot start a game here. Ours has to be
# unmistakable at a glance, or a user picks a neighbour and gets a launch that fails silently.
# Newest first: whichever the client has downloaded is used.
SOURCES = ("Proton Experimental (ARM64)", "Proton 11.0 (ARM64)")
# Written by us; everything else in the depot is symlinked through.
OWN_FILES = ("toolmanifest.vdf", "compatibilitytool.vdf", "bannerlator-proton")
# The client assigns a Proton to a Windows title by itself, as a per-app CompatToolMapping entry at
# priority 250 - which outranks the "0" default, so setting that default alone changes nothing. Every
# Proton it can pick is one this runtime cannot start: the ARM64 ones want pressure-vessel (see
# above) and the x86_64 ones want pressure-vessel and FEX on top. Ours is the only one that runs
# here, so every Proton mapping is repointed at it. Tools that are not Proton are left alone.
COMPAT_TOOL_VDF = """"compatibilitytools"
{
"compat_tools"
{
"%s"
{
"install_path" "."
"display_name" "Bannerlator Proton (ARM64)"
"from_oslist" "windows"
"to_oslist" "linux"
}
}
}
"""
TOOL_MANIFEST_VDF = """"manifest"
{
"version" "2"
"commandline" "/%s %%verb%%"
"use_sessions" "1"
"compatmanager_layer_name" "proton"
}
""" % LAUNCHER
# Resolves the depot at launch time, so the tool can be registered before the depot exists and
# survives the client updating or replacing it. Proton takes its base directory from
# dirname(sys.argv[0]) without resolving it, so it is run from the depot itself.
LAUNCHER_SH = """#!/bin/bash
# Bannerlator Proton (ARM64): runs the ARM64 Proton the Steam client downloaded, without the
# Steam Linux Runtime container its own manifest asks for (no user namespaces on Android).
verb=$1; shift
steam_root=${STEAM_COMPAT_CLIENT_INSTALL_PATH:-${XDG_DATA_HOME:-$HOME/.local/share}/Steam}
# The client preloads its overlay library into every game. In a gamescope session the overlay is
# the client's own window, so the library draws nothing - but it stands in front of open() and
# read() on /dev/input, lets Wine open the session's pad and answers every read of it with nothing:
# a controller that never reports, and Wine's HID thread spinning a core on it. Dropped here;
# anything else in LD_PRELOAD is kept.
kept=
IFS=': '
for lib in ${LD_PRELOAD:-}; do
case $lib in */gameoverlayrenderer.so) ;; *) kept=${kept:+$kept:}$lib ;; esac
done
unset IFS
if [ -n "$kept" ]; then export LD_PRELOAD="$kept"; else unset LD_PRELOAD; fi
for name in %s; do
depot="$steam_root/steamapps/common/$name"
if [ -d "$depot/files/bin-arm64" ] && [ -x "$depot/proton" ]; then
exec "$depot/proton" "$verb" "$@"
fi
done
echo "bannerlator-proton: no ARM64 Proton depot yet - the client downloads one as this tool's dependency; retry the launch once it has" >&2
exit 1
""" % " ".join('"%s"' % n for n in SOURCES)
TOKEN = re.compile(r'\s*(?:"((?:[^"\\]|\\.)*)"|([{}])|//[^\n]*)')
def tokenize(text):
tokens = []
pos = 0
while pos < len(text):
m = TOKEN.match(text, pos)
if not m or m.end() == pos:
break
pos = m.end()
if m.group(2):
tokens.append(m.group(2))
elif m.group(1) is not None:
tokens.append('"' + m.group(1) + '"')
return tokens
def find_block(tokens, path):
"""Index of the '{' opening the block at path, or None."""
depth, want, i = 0, 0, 0
while i < len(tokens):
t = tokens[i]
if t == "{":
depth += 1
elif t == "}":
depth -= 1
if depth < want:
return None
elif depth == want and i + 1 < len(tokens) and tokens[i + 1] == "{":
if t.lower() == '"%s"' % path[want].lower():
if want == len(path) - 1:
return i + 1
want += 1
i += 1
return None
def block_end(tokens, start):
depth = 0
for i in range(start, len(tokens)):
if tokens[i] == "{":
depth += 1
elif tokens[i] == "}":
depth -= 1
if depth == 0:
return i
return len(tokens)
def serialize(tokens):
out, depth, i = [], 0, 0
while i < len(tokens):
t = tokens[i]
if t == "}":
depth -= 1
out.append("\t" * depth + "}")
i += 1
elif i + 1 < len(tokens) and tokens[i + 1] == "{":
out.append("\t" * depth + t)
out.append("\t" * depth + "{")
depth += 1
i += 2
else:
out.append("\t" * depth + t + "\t\t" + tokens[i + 1])
i += 2
return "\n".join(out) + "\n"
# Steam's own tools and runtimes live in steamapps beside the games; they are not titles and must
# not be mapped to a compatibility tool.
NOT_GAMES = frozenset((
"228980", # Steamworks Common Redistributables
"1070560", # Steam Linux Runtime 1.0 (scout)
"1391110", # Steam Linux Runtime 2.0 (soldier)
"1493710", # Proton Experimental
"3127680", # FEX
"4183110", # Steam Linux Runtime 4.0
"4185400", # Steam Linux Runtime 4.0 - Arm64
"4427310", # Proton Experimental (ARM64)
"4628740", # Proton 11.0 (ARM64)
))
def installed_apps(steam_root):
"""App ids of the titles the client has installed, tools and runtimes excluded."""
apps = set()
for library in (steam_root, LIBRARY + "-sd"):
steamapps = os.path.join(library, "steamapps")
try:
names = os.listdir(steamapps)
except OSError:
continue
for name in names:
m = re.fullmatch(r"appmanifest_(\d+)\.acf", name)
if m and m.group(1) not in NOT_GAMES:
apps.add(m.group(1))
return sorted(apps, key=int)
def register_default(config_path, apps=(), name=None):
"""Writes the mapping. `name` defaults to our own tool; the first-run seed passes Valve's."""
tool = name or TOOL
with open(config_path, encoding="utf-8", errors="replace") as f:
tokens = tokenize(f.read())
steam = find_block(tokens, ["InstallConfigStore", "Software", "Valve", "Steam"])
if steam is None:
return
mapping = find_block(tokens[steam + 1:], ["CompatToolMapping"])
entry = ['"0"', "{", '"name"', '"%s"' % tool, '"config"', '""', '"priority"', '"75"', "}"]
if mapping is None:
end = block_end(tokens, steam)
tokens[end:end] = ['"CompatToolMapping"', "{"] + entry + ["}"]
else:
mapping += steam + 1
# Repoint every per-app entry the client aimed at a Proton it cannot actually start.
for i in range(mapping, block_end(tokens, mapping)):
named = tokens[i + 1].strip('"').lower()
if tokens[i] == '"name"' and named.startswith("proton") and named != tool:
tokens[i + 1] = '"%s"' % tool
if find_block(tokens[mapping + 1:], ["0"]) is None:
tokens[mapping + 1:mapping + 1] = entry
# The "0" default only decides how a title is installed, so it settles new downloads and
# leaves anything already installed as a Linux build running as one. An entry per installed
# app is what the client's own Compatibility checkbox writes, and is what makes it switch.
for app in apps:
if find_block(tokens[mapping + 1:], [app]) is not None:
continue
tokens[mapping + 1:mapping + 1] = [
'"%s"' % app, "{", '"name"', '"%s"' % tool, '"config"', '""', '"priority"', '"250"', "}"]
tmp = config_path + ".bannerlator"
with open(tmp, "w", encoding="utf-8") as f:
f.write(serialize(tokens))
os.replace(tmp, config_path)
def find_source(steam_root):
"""The ARM64 Proton depot the client has downloaded, or None."""
common = os.path.join(steam_root, "steamapps", "common")
for name in SOURCES:
depot = os.path.join(common, name)
# bin-arm64 is what makes it the native build rather than the x86_64 one.
if os.path.isdir(os.path.join(depot, "files", "bin-arm64")):
return depot
return None
def build_tool(tool_dir):
"""Our own manifests and the launcher. The depot is found at launch time, not here."""
if os.path.islink(tool_dir):
os.unlink(tool_dir)
elif os.path.isdir(tool_dir):
# Earlier versions mirrored the depot in here as symlinks; start clean.
shutil.rmtree(tool_dir)
os.makedirs(tool_dir)
with open(os.path.join(tool_dir, "toolmanifest.vdf"), "w", encoding="utf-8") as f:
f.write(TOOL_MANIFEST_VDF)
with open(os.path.join(tool_dir, "compatibilitytool.vdf"), "w", encoding="utf-8") as f:
f.write(COMPAT_TOOL_VDF % TOOL)
launcher = os.path.join(tool_dir, LAUNCHER)
with open(launcher, "w", encoding="utf-8") as f:
f.write(LAUNCHER_SH)
os.chmod(launcher, 0o755)
def main():
steam_root = sys.argv[1]
tools = os.path.join(steam_root, "compatibilitytools.d")
os.makedirs(tools, exist_ok=True)
build_tool(os.path.join(tools, TOOL))
depot = find_source(steam_root)
print("bannerlator-steam-compat: registered %s (%s)" % (
TOOL, "depot %s present" % os.path.basename(depot) if depot else
"no ARM64 Proton depot yet; the session asks the client to fetch it"))
config = os.path.join(steam_root, "config", "config.vdf")
if os.path.isfile(config):
apps = installed_apps(steam_root)
register_default(config, apps)
print("bannerlator-steam-compat: default and %d installed title(s) set to %s" % (len(apps), TOOL))
if __name__ == "__main__":
main()
@@ -0,0 +1,61 @@
#!/bin/bash
# Fetches the native arm64 Steam client from Valve's client-update CDN into ~/.local/share/Steam.
# The client is not redistributable, so the runtime ships this script instead of the client.
set -eu
cdn=https://client-update.fastly.steamstatic.com
manifest=steam_client_publicbeta_linuxarm64
steam_root=${XDG_DATA_HOME:-$HOME/.local/share}/Steam
stamp=$steam_root/package/bannerlator-installed
[ -x "$steam_root/steamrtarm64/steam" ] && [ -f "$stamp" ] && exit 0
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
curl -fsSL "$cdn/$manifest" -o "$work/manifest"
version=$(awk -F'"' '$2 == "version" { print $4; exit }' "$work/manifest")
# Every component block: its name, then the plain zip's file name and sha256.
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 ~ /_linuxarm64_linuxarm64$/) print b, file[b], sha[b] }
' "$work/manifest" | sort > "$work/parts"
[ -s "$work/parts" ] || { echo "bannerlator-steam-install: no client components in $manifest" >&2; exit 1; }
total=$(grep -c . "$work/parts" 2>/dev/null || echo 0)
mkdir -p "$steam_root/package"
while read -r block file sum; do
i=$((${i:-0} + 1))
echo "== STEP $(date -u +%H:%M:%S) downloading Steam: $block ($i/$total)"
curl -fsSL "$cdn/$file" -o "$work/$file"
echo "$sum $work/$file" | sha256sum -c --quiet
unzip -qo "$work/$file" -d "$steam_root"
rm -f "$work/$file"
done < "$work/parts"
# Some entries are zipped with Windows separators; unzip keeps the backslash in the file name.
find "$steam_root" -depth -name '*\\*' | while read -r odd; do
fixed=${odd//\\//}
mkdir -p "$(dirname "$fixed")"
if [ -d "$odd" ]; then
cp -a "$odd/." "$fixed/" && rm -rf "$odd"
else
mv -f "$odd" "$fixed"
fi
done
echo publicbeta > "$steam_root/package/beta"
echo "$version" > "$stamp"
ln -sfn "$steam_root/steamrtarm64" "$steam_root/steamrtarm32"
chmod +x "$steam_root/steamrtarm64/steam" 2>/dev/null || true
# What Valve's steam.sh sets up before it runs the client (it has no arm64 branch itself).
mkdir -p "$HOME/.steam"
ln -sfn "$steam_root" "$HOME/.steam/root"
ln -sfn "$steam_root" "$HOME/.steam/steam"
ln -sfn "$steam_root/steamrtarm64" "$HOME/.steam/bin64"
ln -sfn "$steam_root/linuxarm64" "$HOME/.steam/sdk64"
# The arm64 client runs every game through $HOME/.steam/sdkarm64/steam-launch-wrapper. Valve's
# steam.sh has no arm64 branch to create it, and without it a launch dies in /bin/sh before Proton
# is ever invoked - "No such file or directory", no Proton log, and the only other clue is an
# unrelated-looking installscript assertion. Same target as sdk64; the client picks the name by
# architecture.
ln -sfn "$steam_root/linuxarm64" "$HOME/.steam/sdkarm64"
ln -sfn "$steam_root/steamrtarm64" "$HOME/.steam/binarm64"
ln -sfn "$steam_root/linux32" "$HOME/.steam/sdk32"
@@ -0,0 +1,104 @@
#!/usr/bin/python3
# Registers the card the app installs to (bound at /mnt/bannerlator-sd) as a library folder of the
# native Steam client, so they show as installed there instead of being downloaded a second time.
#
# bannerlator-steam-library <steam root>
#
# Ported from WinNative's gamescope runtime (GPL-3.0).
import os
import re
import sys
# The client's own library is internal storage (its steamapps/common is bound to the app's root);
# the card is the one extra library folder.
LIBRARIES = (("/mnt/bannerlator-sd", "Bannerlator (card)"),)
def register(steam_root, library, label):
"""Adds one library folder to the client's list; the client then offers it as an install
location as well as reading the games already in it. Registered even when empty: a new user
should be able to install straight into it."""
steamapps = os.path.join(library, "steamapps")
if not os.path.isdir(steamapps):
return 0
apps = sorted(
int(m.group(1))
for m in (re.fullmatch(r"appmanifest_(\d+)\.acf", n) for n in os.listdir(steamapps))
if m
)
marker = os.path.join(library, "libraryfolder.vdf")
if not os.path.isfile(marker):
with open(marker, "w", encoding="utf-8") as f:
f.write('"libraryfolder"\n{\n\t"contentid"\t\t"%d"\n\t"label"\t\t"%s"\n}\n'
% (int.from_bytes(os.urandom(8), "little"), label))
steamapps_dir = os.path.join(steam_root, "steamapps")
path = os.path.join(steamapps_dir, "libraryfolders.vdf")
text = ""
if os.path.isfile(path):
with open(path, encoding="utf-8", errors="replace") as f:
text = f.read()
if re.search(r'"path"\s+"%s"' % re.escape(library), text):
return len(apps)
indexes = [int(i) for i in re.findall(r'^\t"(\d+)"\s*$', text, re.M)]
if not text.strip():
text = ('"libraryfolders"\n{\n\t"0"\n\t{\n\t\t"path"\t\t"%s"\n\t\t"label"\t\t""\n\t}\n}\n'
% steam_root)
indexes = [0]
entry = ['\t"%d"' % (max(indexes) + 1), "\t{", '\t\t"path"\t\t"%s"' % library,
'\t\t"label"\t\t"%s"' % label, '\t\t"apps"', "\t\t{"]
entry += ['\t\t\t"%d"\t\t"0"' % app for app in apps]
entry += ["\t\t}", "\t}"]
closing = text.rstrip().rfind("}")
if closing < 0:
return len(apps)
text = text[:closing] + "\n".join(entry) + "\n" + text[closing:]
os.makedirs(steamapps_dir, exist_ok=True)
with open(path, "w", encoding="utf-8") as f:
f.write(text)
print("bannerlator-steam-library: registered %s with %d game(s)" % (library, len(apps)))
return len(apps)
RETIRED = ("/mnt/bannerlator",)
def forget(steam_root, library):
"""Removes a library folder earlier builds registered and this one no longer binds, so the
client does not keep offering a location that is not there."""
path = os.path.join(steam_root, "steamapps", "libraryfolders.vdf")
if not os.path.isfile(path):
return
with open(path, encoding="utf-8", errors="replace") as f:
lines = f.read().split("\n")
out, block, depth = [], None, 0
for line in lines:
if depth == 1 and re.fullmatch(r'\t"\d+"', line):
block = [line]
continue
if block is not None:
block.append(line)
depth += line.count("{") - line.count("}")
if depth == 1:
if not re.search(r'"path"\s+"%s"' % re.escape(library), "\n".join(block)):
out.extend(block)
block = None
continue
depth += line.count("{") - line.count("}")
out.append(line)
text = "\n".join(out)
if text != "\n".join(lines):
with open(path, "w", encoding="utf-8") as f:
f.write(text)
print("bannerlator-steam-library: forgot %s" % library)
def main():
steam_root = sys.argv[1]
for library in RETIRED:
forget(steam_root, library)
for library, label in LIBRARIES:
register(steam_root, library, label)
if __name__ == "__main__":
main()