Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

Run a prefix from another build of the same arch in place

NotProtonNot4fed9989f1b2
diff --git a/app/Sources/NotProtonApp/Model/PrefixTools.swift b/app/Sources/NotProtonApp/Model/PrefixTools.swift
index ed845d5..5dcd58c 100644
--- a/app/Sources/NotProtonApp/Model/PrefixTools.swift
+++ b/app/Sources/NotProtonApp/Model/PrefixTools.swift
@@ -98,7 +98,8 @@ enum PrefixTools {
arch == nil || named.tool.prefixArch == arch {
return named
}
- return byArch(served)
+ // Any build of the prefix's arch can run it, see note_other_build in compat_run.sh.
+ return byArch(served) ?? byArch(tools)
}
static func resolvedTool(
diff --git a/app/Sources/NotProtonApp/PrefixesModel.swift b/app/Sources/NotProtonApp/PrefixesModel.swift
index 33cb7f2..a93ef00 100644
--- a/app/Sources/NotProtonApp/PrefixesModel.swift
+++ b/app/Sources/NotProtonApp/PrefixesModel.swift
@@ -16,8 +16,7 @@ final class PrefixesModel {
private(set) var stale: Set<String> = []
- // True when no installed compatibility tool matches the version of CrossOver that last
- // booted the prefix.
+ // True when no installed compatibility tool runs the prefix's arch.
func isStale(_ prefix: WinePrefix) -> Bool {
stale.contains(prefix.id)
}
diff --git a/app/Tests/NotProtonAppTests/PrefixToolsTests.swift b/app/Tests/NotProtonAppTests/PrefixToolsTests.swift
index 5d3edca..cbf6650 100644
--- a/app/Tests/NotProtonAppTests/PrefixToolsTests.swift
+++ b/app/Tests/NotProtonAppTests/PrefixToolsTests.swift
@@ -1559,17 +1559,21 @@ struct PrefixLastBuildTests {
#expect(PrefixTools.tool(for: prefix, among: both, runners: runners)?.name == "notproton-fex-rosetta")
}
- @Test("A prefix another CrossOver updated gets no tool, so nothing runs over it")
- func noToolForAnotherWine() throws {
+ @Test("A prefix another CrossOver updated runs on an installed tool of its arch")
+ func anotherWineFallsBackToItsArch() throws {
let (dir, runners, prefix) = try makeWorld()
defer { try? FileManager.default.removeItem(at: dir) }
let release = try #require(SupportedRunners.all.first { $0.id == Self.release })
let tools = SupportedRunners.tools(for: [release])
try updated(prefix, "1787334674\n")
- #expect(PrefixTools.tool(for: prefix, among: tools, runners: runners) == nil)
+ #expect(PrefixTools.tool(for: prefix, among: tools, runners: runners)?.build == Self.release)
try updated(prefix, "1784112240\n")
#expect(PrefixTools.tool(for: prefix, among: tools, runners: runners)?.build == Self.release)
+
+ try "\(Self.preview)\nCrossOver Preview (Rosetta)\n".write(
+ to: prefix.root.appending(path: PrefixTools.buildRecordName), atomically: true, encoding: .utf8)
+ #expect(PrefixTools.tool(for: prefix, among: tools, runners: runners)?.build == Self.release)
}
}
diff --git a/app/Tests/NotProtonAppTests/PrefixesModelTests.swift b/app/Tests/NotProtonAppTests/PrefixesModelTests.swift
index d5b5310..1be90ff 100644
--- a/app/Tests/NotProtonAppTests/PrefixesModelTests.swift
+++ b/app/Tests/NotProtonAppTests/PrefixesModelTests.swift
@@ -125,18 +125,25 @@ struct PrefixesModelTests {
try Data(text.utf8).write(to: url)
}
- @Test("Only a prefix recorded for a build that is no longer set up is stale")
+ @Test("Only a prefix whose arch no installed tool runs is stale")
func flagsStalePrefixes() async throws {
- let (dir, library) = try makeLibrary(appIDs: ["1574480", "253750", "447700"])
+ let (dir, library) = try makeLibrary(appIDs: ["1574480", "253750", "447700", "71230"])
defer { try? FileManager.default.removeItem(at: dir) }
let compatdata = library.compatdata
try "\(Self.tool.build)\n\(Self.tool.display)\n".write(
to: compatdata.appending(path: "1574480/\(PrefixTools.buildRecordName)"),
atomically: true, encoding: .utf8)
- try "1.0.0.1\n".write(
- to: compatdata.appending(path: "253750/\(PrefixTools.buildRecordName)"),
- atomically: true, encoding: .utf8)
+ for (appID, machine) in [("253750", UInt16(0x8664)), ("71230", UInt16(0xAA64))] {
+ let root = compatdata.appending(path: appID)
+ try write("1.0.0.1\n", to: root.appending(path: PrefixTools.buildRecordName))
+ var bytes = [UInt8](repeating: 0, count: 0x40)
+ bytes[0x3c] = 0x40
+ bytes += [0x50, 0x45, 0x00, 0x00, UInt8(machine & 0xff), UInt8(machine >> 8)]
+ try FileManager.default.createDirectory(
+ at: root.appending(path: "pfx/drive_c/windows/system32"), withIntermediateDirectories: true)
+ try Data(bytes).write(to: root.appending(path: "pfx/drive_c/windows/system32/ntdll.dll"))
+ }
let model = PrefixesModel(libraries: { [library] }, installedTools: { [Self.tool] })
await model.load()
@@ -146,7 +153,10 @@ struct PrefixesModelTests {
}
#expect(model.isStale(try prefix("1574480")) == false)
#expect(model.lastTool(try prefix("1574480")) == Self.tool.display)
- #expect(model.isStale(try prefix("253750")) == true)
+ // Another build of the same arch updates the prefix in place.
+ #expect(model.isStale(try prefix("253750")) == false)
+ #expect(model.lastTool(try prefix("253750")) == Self.tool.display)
+ #expect(model.isStale(try prefix("71230")) == true)
#expect(model.isStale(try prefix("447700")) == false)
#expect(model.lastTool(try prefix("447700")) == nil)
}
diff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.sh
index f013e8c..1c00ebe 100755
--- a/dylib/feats/compat_run.sh
+++ b/dylib/feats/compat_run.sh
@@ -348,7 +348,10 @@ last_wine_build() {
done
}
-refuse_other_build() {
+# A prefix from another build of the same arch runs as is, in either direction. Its
+# .update-timestamp no longer matches wine.inf, and Wine reruns wine.inf on first start,
+# which replaces builtin DLLs and keeps native ones.
+note_other_build() {
record="$STEAM_COMPAT_DATA_PATH/notproton-build"
had_build=""
had_display=""
@@ -361,10 +364,7 @@ refuse_other_build() {
last_wine_build
fi
if [ -n "$had_build" ] && [ "$had_build" != "$np_build" ]; then
- echo "=== prefix was last run by build $had_build and this compatibility tool runs $np_build, rebuild the prefix in NotProton ===" >> "$log" 2>&1 || true
- had_display=$(alert_safe "${had_display:-CrossOver build $had_build}")
- show_alert "This game needs its prefix rebuilt" "This game's prefix was last run by $had_display, and this compatibility tool runs $(alert_safe "$np_display"). Rebuild the prefix in NotProton to run it here, or pick $had_display again in the game's Compatibility settings. You will not lose game saves by rebuilding the prefix."
- exit 1
+ echo "=== prefix was last run by build $had_build (${had_display:-unknown}), Wine updates it for $np_build ===" >> "$log" 2>&1 || true
fi
}
@@ -1174,7 +1174,7 @@ if [ -n "$STEAM_COMPAT_DATA_PATH" ]; then
printf '%s' "$WINEMSYNC" \
> "$STEAM_COMPAT_DATA_PATH/notproton-msync" 2>/dev/null || true
stage_step="prefix build check"
- refuse_other_build
+ note_other_build
stage_step="prefix arch check"
refuse_foreign_prefix
claim_prefix
diff --git a/dylib/tests/buildcheck.sh b/dylib/tests/buildcheck.sh
index c9cf614..7738a57 100644
--- a/dylib/tests/buildcheck.sh
+++ b/dylib/tests/buildcheck.sh
@@ -6,7 +6,7 @@ SRC="${1:-$(dirname "$0")/../feats/compat_run.sh}"
extract() { sed -n "/^$1() {\$/,/^}\$/p" "$SRC"; }
functions=""
-for name in alert_safe last_wine_build refuse_other_build claim_prefix; do
+for name in last_wine_build note_other_build claim_prefix; do
body=$(extract "$name")
[ -n "$body" ] || { echo "FAIL: $name not found in $SRC"; exit 1; }
functions="$functions
@@ -45,15 +45,16 @@ launch() {
np_build=$build
np_display="display of $build"
CX_ROOT="$np_support/runners/crossover-$build/CrossOver"
- log=/dev/null
- # shellcheck disable=SC2329 # called by the extracted refusal
+ log="$data/log"
+ # shellcheck disable=SC2329 # a switch must not raise a dialog
show_alert() { printf 'alert: %s\n' "$2"; }
eval "$functions"
- refuse_other_build
+ note_other_build
claim_prefix
) > "$data/out" 2>&1 && status=0 || status=$?
echo "status=$status"
- grep -o 'last run by [^,]*' "$data/out" || true
+ cat "$data/out"
+ grep -o 'last run by build [^=]*,' "$data/log" 2>/dev/null || true
[ ! -f "$data/notproton-build" ] || head -1 "$data/notproton-build"
}
@@ -62,27 +63,35 @@ is "a fresh prefix is claimed" "status=0
26.3.0.39832" "$(launch 26.3.0.39832 "" "")"
is "a prefix this build last updated is claimed" "status=0
26.3.0.39832" "$(launch 26.3.0.39832 "$(mtime 26.3.0.39832)" "")"
-is "a prefix another clone updated is refused and named" "status=1
-last run by CrossOver Preview (FEX)" "$(launch 26.3.0.39832 "$(mtime 27.0.0.40921-fex)" "")"
-is "a prefix no clone updated is refused" "status=1
-last run by another version of CrossOver" "$(launch 26.3.0.39832 1 "")"
+is "a prefix another clone updated runs and is claimed" "status=0
+last run by build 27.0.0.40921-fex (CrossOver Preview (FEX)),
+26.3.0.39832" "$(launch 26.3.0.39832 "$(mtime 27.0.0.40921-fex)" "")"
+is "a prefix no clone updated runs and is claimed" "status=0
+last run by build other (another version of CrossOver),
+26.3.0.39832" "$(launch 26.3.0.39832 1 "")"
is "updates the user disabled say nothing, so the prefix is claimed" "status=0
26.3.0.39832" "$(launch 26.3.0.39832 disable "")"
clone 27.0.0.40921 202608211200
-is "a prefix either of two clones updated names neither" "status=1
-last run by another version of CrossOver" "$(launch 26.3.0.39832 "$(mtime 27.0.0.40921)" "")"
+is "a prefix either of two clones updated names neither" "status=0
+last run by build other (another version of CrossOver),
+26.3.0.39832" "$(launch 26.3.0.39832 "$(mtime 27.0.0.40921)" "")"
echo "== prefixes with a record =="
is "the record wins over the Wine that updated the prefix" "status=0
27.0.0.40921-fex" "$(launch 27.0.0.40921-fex "$(mtime 26.3.0.39832)" "27.0.0.40921-fex
CrossOver Preview (FEX)
")"
-is "a record for another build is refused" "status=1
-last run by CrossOver Preview (FEX)
-27.0.0.40921-fex" "$(launch 26.3.0.39832 "" "27.0.0.40921-fex
+is "an older build takes over a newer build's prefix" "status=0
+last run by build 27.0.0.40921-fex (CrossOver Preview (FEX)),
+26.3.0.39832" "$(launch 26.3.0.39832 "" "27.0.0.40921-fex
CrossOver Preview (FEX)
")"
+is "a newer build takes over an older build's prefix" "status=0
+last run by build 26.3.0.39832 (CrossOver 26.3),
+27.0.0.40921-fex" "$(launch 27.0.0.40921-fex "" "26.3.0.39832
+CrossOver 26.3
+")"
echo "== alerts =="
alert=$(extract show_alert)