Skip to content

Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.

engine: an install refuses to finish without Wine's core files, and a broken copy of the bundled engine reinstalls itself (#118)

Gauthier Piarrette3ff6d1bb9654
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swift
index 578ff57..6d71237 100644
--- a/Sources/HighballApp/AppState.swift
+++ b/Sources/HighballApp/AppState.swift
@@ -566,7 +566,9 @@ final class AppState {
var engineUpdate: EngineManifest? {
guard !engines.isEmpty, let url = Self.bundledManifest,
let m = try? EngineManifest.load(from: url),
- !engines.contains(where: { $0.id == m.id }) else { return nil }
+ // An installed copy missing its Wine files counts as not installed: it fails every
+ // launch (highball#118), and installing it again over itself is the repair.
+ !engines.contains(where: { $0.id == m.id && $0.isComplete }) else { return nil }
return m
}
diff --git a/Sources/HighballKit/EngineStore.swift b/Sources/HighballKit/EngineStore.swift
index 0d05673..4069d61 100644
--- a/Sources/HighballKit/EngineStore.swift
+++ b/Sources/HighballKit/EngineStore.swift
@@ -182,6 +182,17 @@ public struct EngineStore: Sendable {
saved.acceptedLicenses = Self.acceptances(requested: accepted, installed: (try? installedEngines()) ?? [])
try saved.save(to: staging.appending(path: "manifest.json"))
try linkRuntime(staging)
+ // The unpacked tree must be a whole engine before it replaces anything: an archive that
+ // unpacked short (a full disk, a file the archive lacks) used to install all the same and
+ // fail every launch afterwards (highball#118). The archive was checksummed, so the fault
+ // is local; the staging tree goes and the next attempt starts over.
+ if manifest.components["wine"] != nil {
+ let missing = InstalledEngine(manifest: saved, root: staging).missingFiles
+ if !missing.isEmpty {
+ try? FileManager.default.removeItem(at: staging)
+ throw HighballError.failed("The engine unpacked incomplete, \(missing.joined(separator: ", ")) missing. Check the free space on this disk and try again.")
+ }
+ }
try? FileManager.default.removeItem(at: root)
try FileManager.default.moveItem(at: staging, to: root)
try stripQuarantine(root)
@@ -419,6 +430,22 @@ public struct InstalledEngine: Sendable {
public var renderersDir: URL { root.appending(path: "renderers", directoryHint: .isDirectory) }
public var wineBinary: URL { engineDir.appending(path: "bin/wine") }
public var wineserverBinary: URL { engineDir.appending(path: "bin/wineserver") }
+
+ /// Files no engine runs without: the Wine loader, its server, the kernel DLLs of both
+ /// halves and the Unix side of ntdll. An engine missing any of them fails every launch
+ /// with "could not load kernel32.dll" (highball#118, an unpack that stopped early), so an
+ /// install refuses to finish without them and the app reinstalls its own when they are gone.
+ public static let requiredFiles = [
+ "engine/bin/wine", "engine/bin/wineserver",
+ "engine/lib/wine/x86_64-windows/kernel32.dll", "engine/lib/wine/x86_64-windows/ntdll.dll",
+ "engine/lib/wine/i386-windows/kernel32.dll", "engine/lib/wine/x86_64-unix/ntdll.so",
+ ]
+ /// Which of `requiredFiles` are absent, relative to the engine's root.
+ public var missingFiles: [String] {
+ Self.requiredFiles.filter { !FileManager.default.fileExists(atPath: root.appending(path: $0).path) }
+ }
+ public var isComplete: Bool { missingFiles.isEmpty }
+
public var winetricks: URL? {
let t = root.appending(path: "tools/winetricks")
return FileManager.default.fileExists(atPath: t.path) ? t : nil
diff --git a/Sources/highball/main.swift b/Sources/highball/main.swift
index 077fb53..f7105f8 100644
--- a/Sources/highball/main.swift
+++ b/Sources/highball/main.swift
@@ -46,7 +46,8 @@ struct Engine: AsyncParsableCommand {
case .notShipped: return nil
}
}.joined(separator: ",")
- print("\(e.id)\t\(v)\trenderers: \(renderers)")
+ let health = e.isComplete ? "" : "\tINCOMPLETE, missing: \(e.missingFiles.joined(separator: ", "))"
+ print("\(e.id)\t\(v)\trenderers: \(renderers)\(health)")
}
}
}
diff --git a/Tests/HighballKitTests/EngineExtractTests.swift b/Tests/HighballKitTests/EngineExtractTests.swift
index 05edf24..c1945c7 100644
--- a/Tests/HighballKitTests/EngineExtractTests.swift
+++ b/Tests/HighballKitTests/EngineExtractTests.swift
@@ -19,3 +19,23 @@ final class EngineExtractTests: XCTestCase {
XCTAssertNil(EngineStore.directoryCollision(at: empty, sourceIsDirectory: true), "an empty directory is just a placeholder")
}
}
+
+/// An engine missing its Wine files fails every launch with "could not load kernel32.dll"
+/// (highball#118), so it must never count as installed.
+final class EngineCompletenessTests: XCTestCase {
+ func testMissingFilesNamesWhatAnEngineCannotRunWithout() throws {
+ let root = FileManager.default.temporaryDirectory.appending(path: "engine-complete-\(UUID().uuidString)")
+ defer { try? FileManager.default.removeItem(at: root) }
+ let engine = InstalledEngine(manifest: EngineManifest(id: "t", displayName: "t", arch: "x86_64", minMacOS: "14.0", components: [:]), root: root)
+ XCTAssertEqual(engine.missingFiles, InstalledEngine.requiredFiles, "an empty root lacks everything")
+ XCTAssertFalse(engine.isComplete)
+ for f in InstalledEngine.requiredFiles {
+ let url = root.appending(path: f)
+ try FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)
+ try Data().write(to: url)
+ }
+ XCTAssertTrue(engine.isComplete)
+ try FileManager.default.removeItem(at: root.appending(path: "engine/lib/wine/x86_64-windows/kernel32.dll"))
+ XCTAssertEqual(engine.missingFiles, ["engine/lib/wine/x86_64-windows/kernel32.dll"])
+ }
+}