Skip to content

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

feat(setup): download Apple's graphics from the Setup Assistant

raymondchinscc22530cc4e7
diff --git a/app/Package.swift b/app/Package.swift
index 282e7e3..1e49495 100644
--- a/app/Package.swift
+++ b/app/Package.swift
@@ -22,7 +22,7 @@ let package = Package(
targets: [
.executableTarget(
name: "BridgeplayApp",
- dependencies: [.product(name: "Sparkle", package: "Sparkle"), "BridgeplayUI"],
+ dependencies: [.product(name: "Sparkle", package: "Sparkle"), "BridgeplayUI", "BridgeplayInstallerCore"],
path: "Sources/BridgeplayApp",
resources: (hasPayload ? [.copy("Resources/payload")] : []) + [
.process("Resources/Localization"),
diff --git a/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings b/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings
index bbe2ddd..be4f8fc 100644
--- a/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings
+++ b/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings
@@ -1196,6 +1196,22 @@
}
}
},
+ "About 500 MB. Also installs Steam if this Mac doesn't have it yet." : {
+ "localizations" : {
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Circa 500 MB. Installa anche Steam se questo Mac non lo ha ancora."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "约 500 MB。如果这台 Mac 还没有 Steam,也会一并安装。"
+ }
+ }
+ }
+ },
"About Bridgeplay" : {
"localizations" : {
"it" : {
@@ -1628,18 +1644,18 @@
}
}
},
- "Apple's Game Porting Toolkit (D3DMetal) runs DirectX 11 and 12 games on Metal. The installer includes it under Apple's non-commercial license, or link your own copy from Apple." : {
+ "Apple's Game Porting Toolkit (D3DMetal) runs DirectX 11 and 12 games on Metal. Bridgeplay can download it for you under Apple's non-commercial license, or add your own copy from Apple." : {
"localizations" : {
"it" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Il Game Porting Toolkit di Apple (D3DMetal) esegue i giochi DirectX 11 e 12 su Metal. L'installer lo include con la licenza non commerciale di Apple, oppure collega una tua copia da Apple."
+ "value" : "Il Game Porting Toolkit di Apple (D3DMetal) esegue i giochi DirectX 11 e 12 su Metal. Bridgeplay può scaricarlo per te con la licenza non commerciale di Apple, oppure aggiungi una tua copia da Apple."
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Apple 的 Game Porting Toolkit(D3DMetal)可通过 Metal 运行 DirectX 11 和 12 游戏。安装器按 Apple 的非商业许可附带它,你也可以链接自己从 Apple 下载的副本。"
+ "value" : "Apple 的 Game Porting Toolkit(D3DMetal)可通过 Metal 运行 DirectX 11 和 12 游戏。Bridgeplay 可以按 Apple 的非商业许可为你下载它,你也可以添加自己从 Apple 下载的副本。"
}
}
}
@@ -4258,18 +4274,18 @@
}
}
},
- "Download it from Apple" : {
+ "Download" : {
"localizations" : {
"it" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Scaricalo da Apple"
+ "value" : "Scarica"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "从 Apple 下载"
+ "value" : "下载"
}
}
}
@@ -4290,6 +4306,22 @@
}
}
},
+ "Download with Bridgeplay" : {
+ "localizations" : {
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Scarica con Bridgeplay"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "通过 Bridgeplay 下载"
+ }
+ }
+ }
+ },
"Downloaded missing components." : {
"localizations" : {
"it" : {
@@ -5650,6 +5682,22 @@
}
}
},
+ "Installing the Game Porting Toolkit" : {
+ "localizations" : {
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Installazione del Game Porting Toolkit"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "正在安装 Game Porting Toolkit"
+ }
+ }
+ }
+ },
"It will replace the DLLs used by CrossOver with ones that match your compatibility tool." : {
"localizations" : {
"it" : {
@@ -6914,6 +6962,22 @@
}
}
},
+ "Or download it from Apple" : {
+ "localizations" : {
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Oppure scaricalo da Apple"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "或从 Apple 下载"
+ }
+ }
+ }
+ },
"Other lines in gamefixes/default.conf are kept as they are." : {
"localizations" : {
"it" : {
@@ -10277,6 +10341,22 @@
}
}
},
+ "The Game Porting Toolkit wasn't added. %@" : {
+ "localizations" : {
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Il Game Porting Toolkit non è stato aggiunto. %@"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未能添加 Game Porting Toolkit。%@"
+ }
+ }
+ }
+ },
"The Valve file list %@" : {
"localizations" : {
"it" : {
diff --git a/app/Sources/BridgeplayApp/SetupAssistant.swift b/app/Sources/BridgeplayApp/SetupAssistant.swift
index ad52f57..31dae7e 100644
--- a/app/Sources/BridgeplayApp/SetupAssistant.swift
+++ b/app/Sources/BridgeplayApp/SetupAssistant.swift
@@ -1,4 +1,6 @@
import AppKit
+import BridgeplayInstallerCore
+import BridgeplayUI
import Foundation
// Drives the Setup Assistant: checks first, asks only when a check fails, and runs the
@@ -48,6 +50,9 @@ final class SetupAssistant {
var gptk: WinecxD3DMetal.Payload?
var gptkImages: [URL]
var skippedGraphics = false
+ // "Installing the Game Porting Toolkit" once the components download is done.
+ var gptkProgress: String?
+ @ObservationIgnored private var componentsRate = DownloadRate()
// Steam
var steamInstalled = SteamBundle.isPresent
@@ -207,6 +212,63 @@ final class SetupAssistant {
}
}
+ // The one-click installer's components zip, so the app alone is enough: BridgeplayInstallerCore
+ // checks its EdDSA signature and Apple's signature on GPTK, then runs its Install.command
+ // without the app step. That copies GPTK, the DXMT and DXVK archives and the configs, and
+ // installs Steam from Valve when it is missing.
+ func downloadGPTK() async {
+ if let refusal = MigrationLaunch.shared.refusal {
+ message = refusal
+ return
+ }
+ isWorking = true
+ defer { isWorking = false; gptkProgress = nil }
+ message = nil
+ if isPreview {
+ await pretendDownload(host: "github.com", total: 504_399_923) { gptkProgress = $0 }
+ gptk = WinecxD3DMetal.Payload(libRoot: WinecxD3DMetal.userFolder, version: nil)
+ steamInstalled = true
+ return
+ }
+ let meter = DownloadMeter.shared
+ let control = InstallerDownloadControl()
+ let work = FileManager.default.temporaryDirectory
+ .appending(path: "bridgeplay-components-\(UUID().uuidString)", directoryHint: .isDirectory)
+ defer {
+ try? FileManager.default.removeItem(at: work)
+ meter.clear()
+ }
+ do {
+ let components = try await InstallerComponents.latest()
+ componentsRate = DownloadRate()
+ meter.pauseControl = { $0 ? control.pause() : control.resume() }
+ let archive = try await components.downloadAcrossRelease(to: work, control: control) { value in
+ Task { @MainActor [weak self] in
+ // A report that lands after the download must not bring the bar back.
+ guard let self, self.isWorking, self.gptkProgress == nil else { return }
+ let total = value.total ?? components.length
+ let speed = meter.paused ? nil : self.componentsRate.add(value.received)
+ meter.update(host: components.archiveHost, received: value.received, total: total, speed: speed,
+ remaining: speed.flatMap { $0 > 0 ? Double(total - value.received) / $0 : nil })
+ }
+ }
+ meter.clear()
+ gptkProgress = String(localized: "Installing the Game Porting Toolkit")
+ try await Task.detached(priority: .userInitiated) {
+ try InstallerComponents.install(archive: archive, work: work, status: { AppLog.note("setup: Install.command: \($0)") })
+ }.value
+ } catch {
+ AppLog.note("setup: components failed: \(error.localizedDescription)")
+ // The script's own reason, without the core's generic sentence in front of it.
+ let detail = if case InstallerError.componentsFailure(let reason)? = error as? InstallerError { reason }
+ else { error.localizedDescription }
+ message = String(localized: "The Game Porting Toolkit wasn't added. \(detail)")
+ }
+ gptk = WinecxD3DMetal.locate()
+ steamInstalled = SteamBundle.isPresent
+ if gptk != nil { gptkImages = [] }
+ }
+
// MARK: Steam
func installSteam() async {
diff --git a/app/Sources/BridgeplayApp/Support/PinnedDownload.swift b/app/Sources/BridgeplayApp/Support/PinnedDownload.swift
index 0c98a19..bf6d4bb 100644
--- a/app/Sources/BridgeplayApp/Support/PinnedDownload.swift
+++ b/app/Sources/BridgeplayApp/Support/PinnedDownload.swift
@@ -185,6 +185,8 @@ final class DownloadMeter {
private(set) var remaining: TimeInterval?
private(set) var paused = false
@ObservationIgnored fileprivate weak var relay: ProgressRelay?
+ // Pauses a download that has no ProgressRelay (the installer components' own session).
+ @ObservationIgnored var pauseControl: ((Bool) -> Void)?
var fraction: Double? { host != nil && total > 0 ? Double(received) / Double(total) : nil }
// "Downloading from github.com", for the row above the bar.
@@ -202,12 +204,13 @@ final class DownloadMeter {
host = nil
paused = false
relay = nil
+ pauseControl = nil
}
func togglePause() {
guard host != nil else { return }
paused.toggle()
- paused ? relay?.suspend() : relay?.resume()
+ if let pauseControl { pauseControl(paused) } else { paused ? relay?.suspend() : relay?.resume() }
AppLog.note("download \(paused ? "paused" : "resumed") at \(received) of \(total) bytes")
}
}
diff --git a/app/Sources/BridgeplayApp/Views/SetupAssistantView.swift b/app/Sources/BridgeplayApp/Views/SetupAssistantView.swift
index 2eaf706..e908f7b 100644
--- a/app/Sources/BridgeplayApp/Views/SetupAssistantView.swift
+++ b/app/Sources/BridgeplayApp/Views/SetupAssistantView.swift
@@ -189,14 +189,22 @@ struct SetupAssistantView: View {
@ViewBuilder
private var graphicsStep: some View {
StepHeader(step: model.step, title: "Add Apple's game graphics",
- detail: "Apple's Game Porting Toolkit (D3DMetal) runs DirectX 11 and 12 games on Metal. The installer includes it under Apple's non-commercial license, or link your own copy from Apple.")
+ detail: "Apple's Game Porting Toolkit (D3DMetal) runs DirectX 11 and 12 games on Metal. Bridgeplay can download it for you under Apple's non-commercial license, or add your own copy from Apple.")
SetupCard {
if let gptk = model.gptk {
WizardRow(row: StatusRow(title: String(localized: "Game Porting Toolkit"),
value: String(localized: "Ready from \(gptk.libRoot.path(percentEncoded: false))."),
tone: .ok, trailing: gptk.version))
} else {
- WizardRow(row: StatusRow(title: String(localized: "Download it from Apple"),
+ // Apple's files unmodified, from Bridgeplay's installer release; Steam comes along when it's missing.
+ WizardRow(row: StatusRow(title: String(localized: "Download with Bridgeplay"),
+ value: DownloadMeter.shared.title ?? model.gptkProgress
+ ?? String(localized: "About 500 MB. Also installs Steam if this Mac doesn't have it yet."),
+ action: StatusAction(label: String(localized: "Download"), isProminent: true, isEnabled: !model.isWorking) {
+ Task { await model.downloadGPTK() }
+ }), symbol: "arrow.down.circle")
+ SetupHairline()
+ WizardRow(row: StatusRow(title: String(localized: "Or download it from Apple"),
value: String(localized: "Sign in, then download the latest Game Porting Toolkit .dmg."),
action: StatusAction(label: String(localized: "Open Apple Downloads")) {
NSWorkspace.shared.open(URL(string: "https://developer.apple.com/download/all/?q=Game%20Porting%20Toolkit")!)
@@ -205,13 +213,13 @@ struct SetupAssistantView: View {
if let image = model.gptkImages.first {
WizardRow(row: StatusRow(title: String(localized: "Use the one in Downloads"),
value: image.lastPathComponent,
- action: StatusAction(label: String(localized: "Use This"), isProminent: true, isEnabled: !model.isWorking) {
+ action: StatusAction(label: String(localized: "Use This"), isEnabled: !model.isWorking) {
Task { await model.importGPTK(image) }
}), number: 2)
} else {
WizardRow(row: StatusRow(title: String(localized: "Add the disk image"),
value: String(localized: "Drag the .dmg onto this window, or choose it."),
- action: StatusAction(label: String(localized: "Choose…"), isProminent: true, isEnabled: !model.isWorking) { chooseImage() }),
+ action: StatusAction(label: String(localized: "Choose…"), isEnabled: !model.isWorking) { chooseImage() }),
number: 2)
}
}
diff --git a/app/Sources/BridgeplayInstallerCore/InstallerComponents.swift b/app/Sources/BridgeplayInstallerCore/InstallerComponents.swift
index 25aa750..a6a72a1 100644
--- a/app/Sources/BridgeplayInstallerCore/InstallerComponents.swift
+++ b/app/Sources/BridgeplayInstallerCore/InstallerComponents.swift
@@ -16,6 +16,8 @@ public struct InstallerComponents: Sendable, Equatable {
static let maximumLength: Int64 = 2_147_483_648
public let length: Int64
+ /// Where the archive comes from, for "Downloading from …".
+ public var archiveHost: String { archiveURL.host() ?? "github.com" }
public let signature: Data
let verificationKey: Data
var archiveURL = Self.archiveURL
@@ -130,6 +132,7 @@ public struct InstallerComponents: Sendable, Equatable {
guard FileManager.default.isReadableFile(atPath: script.path) else {
throw InstallerError.invalidInstallation("The components download has no Install.command.")
}
+ try verifyAppleSigned(gptk: unpacked.appending(path: "Bridgeplay/gptk"))
var environment = ProcessInfo.processInfo.environment
environment["BRIDGEPLAY_INSTALL_APP"] = "0"
environment["BRIDGEPLAY_NONINTERACTIVE"] = "1"
@@ -139,6 +142,40 @@ public struct InstallerComponents: Sendable, Equatable {
}
}
+ /// GPTK ships unmodified: D3DMetal.framework and every other Mach-O file must carry Apple's
+ /// own signature, the check scripts/package-installer.sh makes before packaging.
+ static func verifyAppleSigned(gptk: URL, check: (URL) -> Bool = { appleSigned($0) }) throws {
+ let fail = { (path: String) in InstallerError.componentsFailure("\(path) is not signed by Apple.") }
+ let framework = gptk.appending(path: "external/D3DMetal.framework")
+ guard check(framework) else { throw fail("D3DMetal.framework") }
+ var machO = 0
+ let files = FileManager.default.enumerator(at: gptk, includingPropertiesForKeys: [.isRegularFileKey])
+ while let file = files?.nextObject() as? URL {
+ if file.lastPathComponent == framework.lastPathComponent {
+ files?.skipDescendants()
+ continue
+ }
+ guard (try? file.resourceValues(forKeys: [.isRegularFileKey]).isRegularFile) == true,
+ isMachO(file) else { continue }
+ guard check(file) else { throw fail(file.lastPathComponent) }
+ machO += 1
+ }
+ guard machO > 0 else { throw InstallerError.componentsFailure("The Game Porting Toolkit in the download is incomplete.") }
+ }
+
+ static func appleSigned(_ url: URL) -> Bool {
+ (try? run("/usr/bin/codesign", ["--verify", "--strict", "--deep", "-R=anchor apple", url.path])) != nil
+ }
+
+ static func isMachO(_ url: URL) -> Bool {
+ guard let handle = try? FileHandle(forReadingFrom: url) else { return false }
+ defer { try? handle.close() }
+ guard let head = try? handle.read(upToCount: 4), head.count == 4 else { return false }
+ // Mach-O in either byte order, and universal binaries.
+ return [[0xCF, 0xFA, 0xED, 0xFE], [0xFE, 0xED, 0xFA, 0xCF], [0xCE, 0xFA, 0xED, 0xFE], [0xFE, 0xED, 0xFA, 0xCE],
+ [0xCA, 0xFE, 0xBA, 0xBE]].contains(Array(head))
+ }
+
@discardableResult
static func run(_ executable: String, _ arguments: [String], environment: [String: String]? = nil,
line: @escaping @Sendable (String) -> Void = { _ in }) throws -> String {
diff --git a/app/Tests/BridgeplayInstallerCoreTests/InstallerComponentsTests.swift b/app/Tests/BridgeplayInstallerCoreTests/InstallerComponentsTests.swift
index 881f3cb..df04132 100644
--- a/app/Tests/BridgeplayInstallerCoreTests/InstallerComponentsTests.swift
+++ b/app/Tests/BridgeplayInstallerCoreTests/InstallerComponentsTests.swift
@@ -66,4 +66,31 @@ struct InstallerComponentsTests {
let output = try InstallerComponents.run("/bin/sh", ["-c", "printf '==> one\\n==> two\\n'"])
#expect(output == "==> one\n==> two\n")
}
+
+ @Test("GPTK passes only when D3DMetal.framework and every other Mach-O file are Apple-signed")
+ func appleSignedGPTK() throws {
+ let gptk = try scratch()
+ defer { try? FileManager.default.removeItem(at: gptk) }
+ let framework = gptk.appending(path: "external/D3DMetal.framework")
+ try FileManager.default.createDirectory(at: framework.appending(path: "Versions/A"), withIntermediateDirectories: true)
+ try Data([0xCF, 0xFA, 0xED, 0xFE, 0]).write(to: framework.appending(path: "Versions/A/D3DMetal"))
+ try FileManager.default.createDirectory(at: gptk.appending(path: "wine/x86_64-windows"), withIntermediateDirectories: true)
+ try Data("MZ".utf8).write(to: gptk.appending(path: "wine/x86_64-windows/d3d11.dll"))
+ // Only the framework so far: no other Mach-O file means libd3dshared.dylib is missing.
+ #expect(throws: InstallerError.self) { try InstallerComponents.verifyAppleSigned(gptk: gptk) { _ in true } }
+
+ let shared = gptk.appending(path: "external/libd3dshared.dylib")
+ try Data([0xCA, 0xFE, 0xBA, 0xBE, 0]).write(to: shared)
+ var checked: [String] = []
+ try InstallerComponents.verifyAppleSigned(gptk: gptk) { checked.append($0.lastPathComponent); return true }
+ // The framework as one bundle, then the dylib; the PE file and the framework's insides are skipped.
+ #expect(checked == ["D3DMetal.framework", "libd3dshared.dylib"])
+
+ #expect(throws: InstallerError.self) {
+ try InstallerComponents.verifyAppleSigned(gptk: gptk) { $0.lastPathComponent != "libd3dshared.dylib" }
+ }
+ #expect(throws: InstallerError.self) {
+ try InstallerComponents.verifyAppleSigned(gptk: gptk) { $0.lastPathComponent != "D3DMetal.framework" }
+ }
+ }
}
diff --git a/docs/NATIVE-INSTALLER.md b/docs/NATIVE-INSTALLER.md
index b51d8ac..19ae447 100644
--- a/docs/NATIVE-INSTALLER.md
+++ b/docs/NATIVE-INSTALLER.md
@@ -53,6 +53,11 @@ Prefixes, saves and Steam libraries are never touched. The components step write
Opening the installed app continues its Setup Assistant, which downloads the WineCX engine
and sets up Steam. Neither installer changes Sparkle's update feed.
+Bridgeplay.app does not need either installer. Its Setup Assistant's Graphics step offers
+Download, which fetches the same `Bridgeplay-Installer.zip` through `BridgeplayInstallerCore`
+(EdDSA check, then Apple's signature on every Mach-O file in `gptk/`) and runs its
+`Install.command` without the app step, so a Mac with only the app gets the same files.
+
On Finish, users may open Bridgeplay. When the installer was started from a mounted disk
image that `hdiutil` identifies exactly, it also offers to eject the image and move it to
Trash; a helper outside the volume does that after the installer exits. Failures keep the
diff --git a/installer/README.md b/installer/README.md
index 545c477..36cd8bc 100644
--- a/installer/README.md
+++ b/installer/README.md
@@ -7,7 +7,8 @@ configs from the folder it sits in, downloads Steam from Valve's CDN when
Assistant downloads the WineCX engine (dappermint/winecx-gptk's runtime) itself: the zip does
not carry it, because it bundles GPL libraries whose source neither project publishes (see
`NOTICE`). `Bridgeplay Installer.app` runs the same script without the app step
-([docs/NATIVE-INSTALLER.md](../docs/NATIVE-INSTALLER.md)).
+([docs/NATIVE-INSTALLER.md](../docs/NATIVE-INSTALLER.md)), and so does the app's own Setup
+Assistant when the user presses Download in its Graphics step.
Before copying Steam, `Install.command` verifies its strict code signature against Apple's
trust chain, Valve's Team ID, and the `com.valvesoftware.steam` bundle identifier.