Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
fix(run): say when a game starts a new prefix while an older one sits in another library
raymondchins2ff33e8780b5
diff --git a/AGENTS.md b/AGENTS.mdindex 82b22f0..1dc32c6 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -61,7 +61,7 @@ The checks the workflows run (`make -s <target>`):- **C and shell suites:** `sigcheck`, `callscheck`, `webpatch-fixtures`, `peicon-fixtures`,`panel-behavior`, `spawn-env`, `activatecheck`, `compatcheck`, `compatsvc-check`,`shortcutcheck`, `launch-shell`, `envcheck`, `buildcheck`, `settingscheck`, `routecheck`,- `bridgecheck`, `envpasscheck`, `gamedrivecheck`, `launchercheck`, `seedcheck`, `gamefixescheck`, `versioncheck`, `cicheck`,+ `bridgecheck`, `envpasscheck`, `prefixnotecheck`, `gamedrivecheck`, `launchercheck`, `seedcheck`, `gamefixescheck`, `versioncheck`, `cicheck`,`compat-reported-check`- **Hardware-free device checks:** `game-host-check`, `dualsense-check`, `steam-rumble-check`diff --git a/Makefile b/Makefileindex 18e2a2b..6f56410 100644--- a/Makefile+++ b/Makefile@@ -73,7 +73,7 @@ DEPS := $(OBJS:.o=.d)tests-list overlay-shim overlay-shim-install overlay-shim-tests \overlay-shim-bench iconmaker icon \appinfo helpers-install ntdll-resolve bridge runcheck compatcheck \- compatsvc-check shortcutcheck scriptcheck envcheck buildcheck settingscheck routecheck bridgecheck envpasscheck gamedrivecheck \+ compatsvc-check shortcutcheck scriptcheck envcheck buildcheck settingscheck routecheck bridgecheck envpasscheck prefixnotecheck gamedrivecheck \gamefixescheck launchercheck padcheck launch-shell activatecheck stamp-check versioncheck cicheck compat-reported-check FORCEAPP_PAYLOAD := app/Sources/BridgeplayApp/Resources/payload@@ -134,6 +134,10 @@ envpasscheck:@if [ ! -f dylib/tests/envpasscheck.sh ]; then $(call SKIP,envpasscheck,dylib/tests/envpasscheck.sh); exit 0; fi; \sh dylib/tests/envpasscheck.sh dylib/feats/compat_run.sh+prefixnotecheck:+ @if [ ! -f dylib/tests/prefixnotecheck.sh ]; then $(call SKIP,prefixnotecheck,dylib/tests/prefixnotecheck.sh); exit 0; fi; \+ sh dylib/tests/prefixnotecheck.sh dylib/feats/compat_run.sh+gamedrivecheck:@if [ ! -f dylib/tests/gamedrivecheck.sh ]; then $(call SKIP,gamedrivecheck,dylib/tests/gamedrivecheck.sh); exit 0; fi; \sh dylib/tests/gamedrivecheck.sh dylib/feats/compat_run.sh@@ -917,7 +921,7 @@ native-shim-tests:CI_CHECKS := mincheck l10ncheck \sigcheck callscheck webpatch-fixtures peicon-fixtures panel-behavior spawn-env \activatecheck compatcheck compatsvc-check shortcutcheck launch-shell envcheck \- buildcheck settingscheck routecheck bridgecheck envpasscheck gamedrivecheck launchercheck \+ buildcheck settingscheck routecheck bridgecheck envpasscheck prefixnotecheck gamedrivecheck launchercheck \seedcheck gamefixescheck versioncheck cicheck padcheck compat-reported-check np-native-tests native-shim-tests \app-tests native-installercheck game-host-check dualsense-check steam-rumble-checkdiff --git a/dylib/AGENTS.md b/dylib/AGENTS.mdindex 3e5f127..79b422e 100644--- a/dylib/AGENTS.md+++ b/dylib/AGENTS.md@@ -22,7 +22,7 @@ down for the user. The constructor in `core/loader.c` only does work in `steam_oallow-list in `gamefix_reason`, a row in [docs/GAMEFIXES.md](../docs/GAMEFIXES.md), anda passing `make gamefixescheck`.- Checks for the run script: `runcheck`, `envcheck`, `settingscheck`, `routecheck`,- `gamedrivecheck`, `launchercheck`, `gamefixescheck`.+ `gamedrivecheck`, `prefixnotecheck`, `launchercheck`, `gamefixescheck`.- **Tests** live in `dylib/tests/`. They run without Steam or Dobby; several `#include` the`.c` file under test for that reason. Add a new check as a Makefile target and to thecheck list in `.github/workflows/app.yml`.diff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.shindex dbd9830..cb83d0f 100755--- a/dylib/feats/compat_run.sh+++ b/dylib/feats/compat_run.sh@@ -1024,12 +1024,15 @@ first_launch_notice() {[ -d "$metal_cache" ] && return 0fiecho "=== first launch, notice shown ===" >> "$log" 2>&1 || true- # Posted by the Bridgeplay app, so it carries Bridgeplay's name and icon; osascript (shown- # as Script Editor) only when the app cannot be found.+ notify_user "Getting this game ready" "The first launch sets the game up and prepares its graphics. It can take a few minutes, and the screen may stay black until it is ready."+}++# Posted by the Bridgeplay app, so it carries Bridgeplay's name and icon; osascript (shown+# as Script Editor) only when the app cannot be found. Never holds up the launch.+notify_user() {(exec 8>&- 9>&-- title="Bridgeplay" subtitle="Getting this game ready"- body="The first launch sets the game up and prepares its graphics. It can take a few minutes, and the screen may stay black until it is ready."+ title="Bridgeplay" subtitle=$(alert_safe "$1") body=$(alert_safe "$2")open -n -g -b com.bridgeplay.Bridgeplay --args --notify "$title" "$subtitle" "$body" ||osascript -e "display notification \"$body\" with title \"$title\" subtitle \"$subtitle\"") >/dev/null 2>&1 &@@ -1103,6 +1106,54 @@ claim_prefix() {printf '%s\n%s\n' "$np_build" "$np_display" > "$STEAM_COMPAT_DATA_PATH/notproton-build" 2>/dev/null \|| echo "=== could not record build $np_build in the prefix ===" >> "$log" 2>&1 || true}+# Wine prefixes are only tested on APFS (and HFS+). Every run logs the file system so a+# report from an exFAT or network library says so; a new prefix there also tells the player.+volume_type() {+ device=$(stat -f %Sd "$1" 2>/dev/null) || return 1+ mount | sed -n "s|^/dev/$device on \(.*\) (\([^,)]*\).*|\2 \1|p" | head -1+}++note_prefix_volume() {+ vol=$(volume_type "$STEAM_COMPAT_DATA_PATH") || vol=""+ fs=${vol%% *}+ echo "volume: compatdata on ${fs:-unknown} (${vol#* })" >> "$log" 2>&1 || true+ case "$fs" in apfs|hfs|"") return 0 ;; esac+ echo "=== compatdata is on $fs, not APFS: Wine prefixes are only tested on APFS, games may hang or fail to start ===" \+ >> "$log" 2>&1 || true+ [ "$prefix_was_new" = 1 ] || return 0+ notify_user "This Steam library is not on APFS" "It is formatted $fs. Games run from it may hang or fail to start. Move the game to a library on an APFS drive for the best results."+}++# Steam keeps a game's prefix in the library that holds the game, so a game moved to another+# library starts over with an empty one: saves and launcher sign-ins kept only in the old+# prefix seem lost. Names the old one when a new prefix is about to be built.+steam_libraries() {+ for vdf in "$client_root/steamapps/libraryfolders.vdf" "$client_root/config/libraryfolders.vdf"; do+ [ -f "$vdf" ] || continue+ sed -nE 's/^[[:space:]]*"path"[[:space:]]*"(.*)"[[:space:]]*$/\1/p' "$vdf" | sed 's/\\\\/\\/g'+ return 0+ done+}++note_other_prefixes() {+ [ "$prefix_was_new" = 1 ] && [ "$app_id" != 0 ] || return 0+ here=$(cd -P -- "$STEAM_COMPAT_DATA_PATH" 2>/dev/null && pwd) || return 0+ old_prefix=""+ while IFS= read -r library; do+ [ -n "$library" ] || continue+ other="$library/steamapps/compatdata/$app_id"+ [ -f "$other/pfx/system.reg" ] || continue+ there=$(cd -P -- "$other" 2>/dev/null && pwd) || continue+ [ "$there" != "$here" ] || continue+ echo "=== an older prefix for this game is in another library: $other ===" >> "$log" 2>&1 || true+ [ -n "$old_prefix" ] || old_prefix=$other+ done <<EOF_LIBRARIES+$(steam_libraries)+EOF_LIBRARIES+ [ -n "$old_prefix" ] || return 0+ notify_user "This game starts with a new prefix" "Its earlier prefix is still in $old_prefix. Saves or launcher sign-ins kept only there are not in the new one."+}+# Steam cloud relatedmerge_user_dir() {src=$1@@ -1902,7 +1953,12 @@ if [ -n "$STEAM_COMPAT_DATA_PATH" ]; thenrefuse_other_buildstage_step="prefix arch check"refuse_foreign_prefix+ prefix_was_new=0+ [ -f "$WINEPREFIX/system.reg" ] || prefix_was_new=1claim_prefix+ find_client_root "$STEAM_COMPAT_CLIENT_INSTALL_PATH"+ note_prefix_volume+ note_other_prefixesecho "sync: WINEMSYNC=$WINEMSYNC from $msync_from" >> "$log" 2>&1 || trueif [ "${wine_unix##*/}" = aarch64-unix ]; thenecho "fex: FEX_X87REDUCEDPRECISION=$FEX_X87REDUCEDPRECISION from $fex_from" >> "$log" 2>&1 || truediff --git a/dylib/tests/prefixnotecheck.sh b/dylib/tests/prefixnotecheck.shnew file mode 100755index 0000000..81b140f--- /dev/null+++ b/dylib/tests/prefixnotecheck.sh@@ -0,0 +1,96 @@+#!/bin/sh+# A new prefix names an older one for the same game in another Steam library, and every run+# logs the file system of the library holding the prefix.+# shellcheck disable=SC2016 # the sh -ec program expands its own variables+set -e+SRC="${1:-$(dirname "$0")/../feats/compat_run.sh}"+[ -f "$SRC" ] || { echo "prefixnotecheck: $SRC not present, skipped"; exit 0; }++body=$(sed -n '/^volume_type() {/,/^}/p;/^note_prefix_volume() {/,/^}/p;/^steam_libraries() {/,/^}/p;/^note_other_prefixes() {/,/^}/p' "$SRC")+case "$body" in+ *note_prefix_volume*note_other_prefixes*) ;;+ *) echo "FAIL: the prefix notes were not found in $SRC"; exit 1 ;;+esac+body="$body"'+notify_user() { printf "%s|%s\n" "$1" "$2" >> "$notes"; }'++work=$(cd "$(mktemp -d)" && pwd -P)+trap 'rm -rf "$work"' EXIT++fails=0+ok() { printf ' ok %s\n' "$1"; }+bad() { printf ' FAIL %s\n want [%s]\n got [%s]\n' "$1" "$2" "$3"; fails=$((fails + 1)); }+is() { if [ "$2" = "$3" ]; then ok "$1"; else bad "$1" "$2" "$3"; fi; }+has() { if grep -qF -- "$2" "$3"; then ok "$1"; else bad "$1" "$2" "$(cat "$3")"; fi; }+lacks() { if grep -qF -- "$2" "$3"; then bad "$1" "no $2" "$(cat "$3")"; else ok "$1"; fi; }++client="$work/Steam"+one="$work/Library One"+two="$work/Library Two"+mkdir -p "$client/steamapps" "$one/steamapps/compatdata/42/pfx" "$two/steamapps/compatdata/42/pfx"+printf '"libraryfolders"\n{\n\t"0"\n\t{\n\t\t"path"\t\t"%s"\n\t}\n\t"1"\n\t{\n\t\t"path"\t\t"%s"\n\t}\n}\n' \+ "$one" "$two" > "$client/steamapps/libraryfolders.vdf"++run() { # run NEW FS [APPID]: the game's prefix is in Library Two+ : > "$work/log"+ : > "$work/notes"+ env log="$work/log" notes="$work/notes" client_root="$client" body="$body" fs="$2" \+ STEAM_COMPAT_DATA_PATH="$two/steamapps/compatdata/42" prefix_was_new="$1" app_id="${3:-42}" \+ sh -ec 'eval "$body"; volume_type() { [ -z "$fs" ] || echo "$fs /Volumes/Drive"; }+ note_prefix_volume; note_other_prefixes'+}++echo "== libraryfolders.vdf"+is "both libraries are read" "$one+$two" "$(env client_root="$client" body="$body" sh -ec 'eval "$body"; steam_libraries')"+printf '"libraryfolders"\n{\n\t"0"\n\t{\n\t\t"path"\t\t"/Volumes/A\\\\B"\n\t}\n}\n' > "$work/escaped.vdf"+mkdir -p "$work/escaped/steamapps"+cp "$work/escaped.vdf" "$work/escaped/steamapps/libraryfolders.vdf"+is "an escaped backslash is unescaped" '/Volumes/A\B' \+ "$(env client_root="$work/escaped" body="$body" sh -ec 'eval "$body"; steam_libraries')"+is "no libraryfolders.vdf lists nothing" "" \+ "$(env client_root="$work/none" body="$body" sh -ec 'eval "$body"; steam_libraries')"++echo "== an older prefix in another library"+: > "$one/steamapps/compatdata/42/pfx/system.reg"+run 1 apfs+has "the old prefix is logged" "an older prefix for this game is in another library: $one/steamapps/compatdata/42" "$work/log"+has "the player is told where it is" "This game starts with a new prefix|Its earlier prefix is still in $one/steamapps/compatdata/42." "$work/notes"+run 0 apfs+is "an existing prefix says nothing" "" "$(cat "$work/notes" "$work/log" | grep -v '^volume:' || true)"+run 1 apfs 7+is "another game's prefix does not count" "" "$(cat "$work/notes")"+rm "$one/steamapps/compatdata/42/pfx/system.reg"+run 1 apfs+is "an empty old prefix does not count" "" "$(cat "$work/notes")"++echo "== the game's own prefix is not another one"+: > "$two/steamapps/compatdata/42/pfx/system.reg"+ln -s "$two" "$work/Library Link"+printf '"libraryfolders"\n{\n\t"0"\n\t{\n\t\t"path"\t\t"%s"\n\t}\n}\n' "$work/Library Link" \+ > "$client/steamapps/libraryfolders.vdf"+run 1 apfs+is "the same folder through a link is skipped" "" "$(cat "$work/notes")"+rm "$two/steamapps/compatdata/42/pfx/system.reg"++echo "== file system"+run 0 apfs+has "APFS is logged" "volume: compatdata on apfs (/Volumes/Drive)" "$work/log"+lacks "APFS is not warned about" "not APFS" "$work/log"+run 0 hfs+lacks "HFS+ is not warned about" "not APFS" "$work/log"+run 0 exfat+has "exFAT is warned about in the log" "compatdata is on exfat, not APFS" "$work/log"+is "an existing prefix on exFAT does not notify" "" "$(cat "$work/notes")"+run 1 exfat+has "a new prefix on exFAT notifies" "This Steam library is not on APFS|It is formatted exfat." "$work/notes"+run 1 ""+has "an unknown file system is logged" "volume: compatdata on unknown" "$work/log"+is "an unknown file system does not notify" "" "$(cat "$work/notes")"++echo "== the real mount table"+real=$(env body="$body" sh -ec 'eval "$body"; volume_type /')+case "$real" in apfs\ /*|hfs\ /*) ok "/ is read as \"$real\"" ;; *) bad "/ reads as a file system and mount point" "apfs /" "$real" ;; esac++[ "$fails" -eq 0 ] || exit 1+echo "==> prefixnotecheck: new prefixes name an older one elsewhere, file systems are logged"