mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 13:55:58 +00:00
With Second library on Automatic, every writable Games folder is now a Steam library: it gets the same private prefix and tool binds as the card, the app hands the session the list (BL_STEAM_LIBRARIES), and droiddeck-steam-library registers, relabels and forgets entries from it. Steam offers them in the install dialog as "<folder> (<volume>)", and Proton mapping, esync, the redist seeder, desktop entries and the compat beat read every registered library instead of only the card. Games folder libraries stop at the fast path's bind budget. Steam's preallocation on Android's FUSE storage either failed outright (NTFS answers EPERM, so installs were cancelled as "not enough disk space") or zero-filled the whole download first (exFAT, minutes for a small game). After fallocate is refused, the Steam client's ftruncate extension of its own staging files is reported as done; the writes that follow fill the file. A 76 MB install to a USB SSD now preallocates instantly instead of taking about 3.5 minutes. A library that is not there is left out of the list and forgotten until it returns, imports whose folder is missing are set aside rather than offered as broken installs, and the front end refreshes when storage is mounted or removed.
159 lines
8.0 KiB
Bash
Executable File
159 lines
8.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# Marks Steam's shared redistributables as already run in every Proton prefix, and in the
|
|
# template Proton makes new prefixes from.
|
|
#
|
|
# 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.
|
|
#
|
|
# Games also carry install scripts of their own (<game>/_CommonRedist/vcredist/2022/installscript.vdf
|
|
# and the like), often with another version in the value name; those are read too. And the VC++
|
|
# 2015-2022 runtime is recorded as installed the way Microsoft's installers look for it: on ARM64
|
|
# Proton the x64 bundle otherwise stops with "Microsoft Visual C++ 2015-2022 Redistributable (arm64)
|
|
# is required", while Proton's own msvcp140/vcruntime140 already serve the game.
|
|
set -u
|
|
steam_root=${1:?steam root}
|
|
LIBRARIES=${DROIDDECK_LIBRARIES-/mnt/droiddeck /mnt/droiddeck-sd}
|
|
|
|
redist="$steam_root/steamapps/common/Steamworks Shared/_CommonRedist"
|
|
|
|
# Every process an install script would run, as the registry key and value the client writes once
|
|
# it has run it. Names sit one level inside "Run Process", the key they share a level further in.
|
|
read_scripts() { xargs -0 -r awk '
|
|
# A block whose HasRunKey is set is one process; its name is the key the block opened under, at
|
|
# whatever depth - an install script nests it under "Run Process", the client'"'"'s evaluator script
|
|
# for a game wraps the same blocks once more.
|
|
FNR == 1 { depth = 0; pending = "" }
|
|
/^[[:space:]]*\{/ { depth++; name[depth] = pending; key[depth] = ""; pending = ""; next }
|
|
/^[[:space:]]*\}/ {
|
|
if (depth > 0 && key[depth] != "" && name[depth] != "")
|
|
printf "%s\t%s\n", key[depth], name[depth]
|
|
if (depth > 0) depth--
|
|
next
|
|
}
|
|
{
|
|
n = split($0, part, "\"")
|
|
if (n >= 5 && tolower(part[2]) == "hasrunkey") { key[depth] = part[4]; next }
|
|
if (n == 3) pending = part[2]
|
|
}
|
|
'; }
|
|
pairs=$(find "$redist" -name installscript.vdf -print0 2>/dev/null | sort -z | read_scripts)
|
|
# The client downloads the scripts with the first game that wants them, which is too late for that
|
|
# game; until then the set they held when this was written stands in. (WinNative's list.)
|
|
[ -n "$pairs" ] || pairs=$(sed 's/^\([^ ]*\) /HKEY_LOCAL_MACHINE\\\\Software\\\\Valve\\\\Steam\\\\Apps\\\\CommonRedist\\\\\1\t/' <<'KNOWN'
|
|
DirectX\\Jun2010 dxsetup
|
|
.NET\\4.8 4.8
|
|
vcredist\\2008 x86 SP1
|
|
vcredist\\2008 x64 SP1
|
|
vcredist\\2010 x86
|
|
vcredist\\2010 x64
|
|
vcredist\\2013 x86 12.0.30501
|
|
vcredist\\2013 x64 12.0.30501
|
|
vcredist\\2015 x86 Update 3 14.0.24215.0
|
|
vcredist\\2015 x64 Update 3 14.0.24215.0
|
|
vcredist\\2017 x86 14.10.25008.0
|
|
vcredist\\2017 x64 14.10.25008.0
|
|
vcredist\\2019 x86 14.28.29334.0
|
|
vcredist\\2019 x64 14.28.29334.0
|
|
vcredist\\2022 x86 14.51.36247.0
|
|
vcredist\\2022 x64 14.51.36247.0
|
|
KNOWN
|
|
)
|
|
|
|
# The games' own scripts. Finding them walks every game folder, so the list is kept until a game is
|
|
# installed, updated or removed (its appmanifest changes) - this runs every quarter minute.
|
|
cache="$steam_root/.droiddeck-game-scripts"
|
|
libraries="$steam_root"
|
|
for library in $LIBRARIES; do libraries="$libraries
|
|
$library"; done
|
|
libraries=$(printf '%s\n%s\n' "$libraries" "$(sed -n 's/^[[:space:]]*"path"[[:space:]]*"\(.*\)"[[:space:]]*$/\1/p' "$steam_root/steamapps/libraryfolders.vdf" 2>/dev/null)" | awk 'NF && !seen[$0]++')
|
|
sig=$(while IFS= read -r library; do ls -l --time-style=+%s "$library"/steamapps/appmanifest_*.acf 2>/dev/null; done <<<"$libraries" | cksum)
|
|
if [ "$(head -n 1 "$cache" 2>/dev/null)" != "$sig" ]; then
|
|
{
|
|
printf '%s\n' "$sig"
|
|
while IFS= read -r library; do
|
|
[ -d "$library/steamapps/common" ] || continue
|
|
find "$library/steamapps/common" -mindepth 2 -maxdepth 5 -iname 'installscript*.vdf' \
|
|
-not -path '*/Steamworks Shared/*' 2>/dev/null
|
|
done <<<"$libraries" | sort -u
|
|
} >"$cache.tmp" && mv -f "$cache.tmp" "$cache"
|
|
fi
|
|
game_pairs=$(tail -n +2 "$cache" 2>/dev/null | tr '\n' '\0' | read_scripts)
|
|
# DROIDDECK_SEED_SCRIPTS: more scripts, one path a line - droiddeck-game-env passes the client's
|
|
# evaluator script for the game about to run its installers, read before the client looks.
|
|
if [ -n "${DROIDDECK_SEED_SCRIPTS:-}" ]; then
|
|
game_pairs=$(printf '%s\n%s\n' "$game_pairs" "$(printf '%s\n' "$DROIDDECK_SEED_SCRIPTS" | tr '\n' '\0' | read_scripts)")
|
|
fi
|
|
[ -n "$(printf '%s' "$game_pairs" | tr -d '[:space:]')" ] && pairs=$(printf '%s\n%s\n' "$pairs" "$game_pairs" | sort -u | sed '/^$/d')
|
|
|
|
# The VC++ 2015-2022 runtime as its installers check for it, for each architecture and both registry
|
|
# views. The version is the newest the scripts above know, so any 2015-2022 bundle finds itself
|
|
# already installed and exits without asking for anything.
|
|
VCRT_MAJOR=14 VCRT_MINOR=51 VCRT_BUILD=36247
|
|
vcrt() {
|
|
local view arch
|
|
for view in 'Software' 'Software\\Wow6432Node'; do
|
|
for arch in x86 x64 arm64; do
|
|
printf '\n[%s\\\\Microsoft\\\\VisualStudio\\\\14.0\\\\VC\\\\Runtimes\\\\%s] %d\n' "$view" "$arch" "$1"
|
|
printf '"Bld"=dword:%08x\n"Installed"=dword:00000001\n"Major"=dword:%08x\n"Minor"=dword:%08x\n"Rbld"=dword:00000000\n' \
|
|
"$VCRT_BUILD" "$VCRT_MAJOR" "$VCRT_MINOR"
|
|
printf '"Version"="v%d.%d.%d.00"\n' "$VCRT_MAJOR" "$VCRT_MINOR" "$VCRT_BUILD"
|
|
done
|
|
done
|
|
}
|
|
|
|
# The stamp is the set of names, taken before the block below dates its keys: stamped from the
|
|
# dated block it never matched, and every prefix had the whole block appended again on every beat.
|
|
stamp=$(printf '%s vcrt %s.%s.%s' "$pairs" "$VCRT_MAJOR" "$VCRT_MINOR" "$VCRT_BUILD" | cksum)
|
|
|
|
block=$(printf '%s\n' "$pairs" | awk -F'\t' -v now="$(date +%s)" '
|
|
{
|
|
path = $1
|
|
sub(/^HKEY_LOCAL_MACHINE\\\\/, "", path)
|
|
if (path == $1)
|
|
next
|
|
printf "\n[%s] %d\n\"%s\"=dword:00000001\n", path, now, $2
|
|
# 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.
|
|
# Joined rather than sub()stituted: gawk and mawk read backslashes in a replacement differently.
|
|
if (substr(path, 1, 10) != "Software\\\\")
|
|
next
|
|
printf "\n[%s] %d\n\"%s\"=dword:00000001\n", "Software\\\\Wow6432Node\\\\" substr(path, 11), now, $2
|
|
}
|
|
')
|
|
block="$block
|
|
$(vcrt "$(date +%s)")"
|
|
|
|
# Proton builds a new prefix from its template, and the client runs the install scripts in that
|
|
# prefix moments later, so the template carries the markers too. Its date is kept: Proton reads a
|
|
# changed one as a new template and upgrades every prefix made from the old.
|
|
for reg in "$steam_root"/steamapps/common/Proton*/files/share/default_pfx*/system.reg \
|
|
/mnt/droiddeck-sd/steamapps/common/Proton*/files/share/default_pfx*/system.reg \
|
|
/root/Games/*/steamapps/common/Proton*/files/share/default_pfx*/system.reg \
|
|
"$steam_root"/compatibilitytools.d/*/files/share/default_pfx*/system.reg \
|
|
"$steam_root"/steamapps/compatdata/*/pfx/system.reg \
|
|
/mnt/droiddeck-sd/steamapps/compatdata/*/pfx/system.reg \
|
|
/root/Games/*/steamapps/compatdata/*/pfx/system.reg; do
|
|
[ -f "$reg" ] || continue
|
|
seeded=$(dirname "$reg")/.droiddeck-redists
|
|
legacy=$(dirname "$reg")/.bannerlator-redists
|
|
if [ -f "$legacy" ] && [ ! -f "$seeded" ]; then
|
|
mv -f "$legacy" "$seeded"
|
|
fi
|
|
[ "$(cat "$seeded" 2>/dev/null)" = "$stamp" ] && continue
|
|
dated=$(mktemp) || continue
|
|
touch -r "$reg" "$dated"
|
|
if printf '%s\n' "$block" >>"$reg"; then
|
|
printf '%s\n' "$stamp" >"$seeded"
|
|
echo "== seeded redist markers into $reg"
|
|
fi
|
|
touch -r "$dated" "$reg"
|
|
rm -f "$dated"
|
|
done
|