Skip to content

armgit / soju

Public Imported from GitHub
0

Play Windows games on Apple Silicon Macs. Free, open-source app that installs the official Battle.net, Steam, Epic and GOG launchers and lists your games in one library.

feat: add Soju desktop app and automatic Steam rendering setup (#32)

Mikekc8b3409076b1
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000000..f97fb6b2b95
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,3 @@
+
+# Unified diffs preserve blank context lines with a leading space.
+*.patch -whitespace
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml
new file mode 100644
index 00000000000..eb57db3fcc9
--- /dev/null
+++ b/.github/workflows/check.yml
@@ -0,0 +1,19 @@
+name: Validate scripts and desktop app
+on:
+ push:
+ branches: [main]
+ pull_request:
+permissions:
+ contents: read
+jobs:
+ check:
+ runs-on: macos-15
+ steps:
+ - uses: actions/checkout@v4
+ - name: Shell syntax and regressions
+ run: |
+ bash -n install.sh
+ for script in scripts/*.sh scripts/soju; do bash -n "$script"; done
+ python3 -m unittest discover -s tests -q
+ - name: Build and verify the native app
+ run: bash scripts/build-app.sh
diff --git a/.gitignore b/.gitignore
index 37c4da21ffb..f9620fae736 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,8 @@ drive_c/
# macOS
.DS_Store
.omc/
+
+# Generated app and Python caches
+dist/
+__pycache__/
+*.pyc
diff --git a/NOTICE b/NOTICE
index 1bbd7b7426b..65bef3b36fe 100644
--- a/NOTICE
+++ b/NOTICE
@@ -3,13 +3,13 @@ Soju: third-party components and their licenses
Bundled in this repository:
- third_party/steam-on-m1-wine/steamwebhelper-wrapper.c: MIT, Copyright (c) 2026 notpop
(see third_party/steam-on-m1-wine/LICENSE and NOTICE)
-- patches/winemac-no-dock-icon.patch: a patch against Wine's winemac.drv (Wine is LGPL-2.1+);
+- patches/winemac-no-dock-icon.patch and patches/steam-winemac.patch: a patch against Wine's winemac.drv (Wine is LGPL-2.1+);
the patch itself is offered under LGPL-2.1+ to match.
-Built or downloaded by the scripts (never redistributed by this repository):
+Built or downloaded by the scripts (open-source component releases include corresponding sources):
- Wine 11.0: LGPL-2.1+ / GPL components, built from CodeWeavers' published sources
(media.codeweavers.com/pub/crossover/source/)
-- DXMT: LGPL-2.1+, Copyright (c) 2023-2026 Feifan He for CodeWeavers
+- DXMT pinned notpop fork: MIT, Copyright (c) 2023 Feifan He
(built from the notpop fork of github.com/3Shain/dxmt)
- wine-mono: MIT (dotnet parts MIT/BSD-like); MoltenVK: Apache-2.0; gnutls: LGPL-2.1+;
freetype: FTL/GPL-2.0 dual
@@ -21,3 +21,7 @@ Built or downloaded by the scripts (never redistributed by this repository):
Trademarks: Battle.net and Diablo are trademarks of Blizzard Entertainment.
Steam is a trademark of Valve Corporation. This project is not affiliated with
CodeWeavers, Apple, Blizzard, or Valve.
+
+Steam prebuilt release: Wine 11.0 winemac (LGPL-2.1+), DXMT (MIT),
+LLVM 15.0.7 (Apache-2.0 with LLVM exceptions), wrapper (MIT).
+Bundled DirectX-header notices are retained. See docs/STEAM-PREBUILTS.md.
diff --git a/README.ko.md b/README.ko.md
index 47dfe47c1a6..63dc0227fff 100644
--- a/README.ko.md
+++ b/README.ko.md
@@ -73,7 +73,9 @@ brew install BCD1210/soju/soju
soju install # 이후: soju battlenet / soju d2r / soju steam / soju epic / soju gog
```
-설치기는 프리빌드 엔진(~350MB)을 받고, 애플 무료 GPTK 다운로드(애플이 재배포 금지한 파일 1개)를 안내한 뒤, 원하는 런처를 묻습니다. Battle.net, Steam, Epic Games Launcher, GOG GALAXY 중 아무 조합이나 고르면 각각 공식 설치기로 별도 보틀에 설치하고, 런처마다 더블클릭용 앱을 `~/Applications`에 만들어 줍니다(`Battle.net.app`, `Steam (Windows).app`, `Epic Games Launcher.app`, `GOG GALAXY.app`). 비대화형: `curl -fsSL https://soju.snack-wrap.com/install.sh | SOJU_PLATFORMS=battlenet,epic,gog bash`. 로그인하고 플레이하세요.
+설치기는 **다운로드 전에 원하는 런처부터 선택**합니다. Steam만 선택하면 CX 엔진과 애플 GPTK를 받지 않습니다. Steam 그래픽 구성요소는 SHA-256으로 검증한 뒤 Soju 전용 Wine 11.0 환경에 자동으로 설치합니다. Battle.net·Epic·GOG는 공통 CX 엔진과 사용자가 별도로 받은 애플 GPTK를 사용합니다. 각 런처의 보틀·로그인·게임은 독립적으로 유지합니다.
+
+[Soju 맥 앱 다운로드](https://github.com/BCD1210/soju/releases/download/v1.4.0/Soju-1.4.0-macos-arm64.zip) — 네이티브 앱 프리뷰에서 설치·실행·구성요소 업데이트·진단을 한 화면에서 관리할 수 있습니다. [설치 안내와 요구 사항](docs/DESKTOP.md)을 확인해 주세요.
## 일상 명령
diff --git a/README.md b/README.md
index 1931c1d7996..05061f4681a 100644
--- a/README.md
+++ b/README.md
@@ -78,7 +78,9 @@ brew install BCD1210/soju/soju
soju install # then: soju battlenet / soju d2r / soju steam / soju epic / soju gog
```
-The installer downloads the prebuilt engine (~350 MB), walks you through Apple's free GPTK download (the one file Apple forbids redistributing), then asks which launchers you want, any combination of Battle.net, Steam, Epic Games Launcher and GOG GALAXY, installs each with its official installer into its own bottle, and drops a double-clickable app per launcher in `~/Applications` (`Battle.net.app`, `Steam (Windows).app`, `Epic Games Launcher.app`, `GOG GALAXY.app`). Non-interactive: `curl -fsSL https://soju.snack-wrap.com/install.sh | SOJU_PLATFORMS=battlenet,epic,gog bash`. Log in and play.
+The installer asks which launchers you want **before downloading anything**. Steam-only installs skip the CX engine and Apple GPTK. Steam rendering components are downloaded with SHA-256 verification and installed in a Soju-owned Wine 11.0 runtime. Battle.net, Epic and GOG use the shared CX engine and your separately downloaded Apple GPTK. Each official client keeps its own bottle and shortcut in `~/Applications`.
+
+[Download Soju for Mac](https://github.com/BCD1210/soju/releases/download/v1.4.0/Soju-1.4.0-macos-arm64.zip) — the native desktop preview brings installation, launching, component updates and diagnostics into one window. See [desktop setup and requirements](docs/DESKTOP.md).
## Everyday commands
diff --git a/README.zh.md b/README.zh.md
index bc53b31573c..601edd630d9 100644
--- a/README.zh.md
+++ b/README.zh.md
@@ -77,7 +77,9 @@ brew install BCD1210/soju/soju
soju install # 然后:soju battlenet / soju d2r / soju steam / soju epic / soju gog
```
-安装器会下载预编译引擎(约 350 MB),引导你下载 Apple 免费的 GPTK(唯一一个 Apple 禁止再分发的文件),然后询问你要装哪些登录器(任意组合:战网、Steam、Epic Games Launcher、GOG GALAXY),用各自的官方安装包装进各自独立的 bottle,并在 `~/Applications` 里为每个登录器生成可双击的 app(`Battle.net.app`、`Steam (Windows).app`、`Epic Games Launcher.app`、`GOG GALAXY.app`)。非交互模式:`curl -fsSL https://soju.snack-wrap.com/install.sh | SOJU_PLATFORMS=battlenet,epic,gog bash`。登录,开玩。
+安装器会**先询问要安装哪些启动器,再下载对应组件**。仅选择 Steam 时,不会下载 CX 引擎或 Apple GPTK。Steam 图形组件经过 SHA-256 校验后,自动安装到 Soju 专用的 Wine 11.0 环境中。战网、Epic 和 GOG 使用共享 CX 引擎及用户单独下载的 Apple GPTK。各客户端的 bottle、账户和游戏分别保留。
+
+[下载 Soju Mac 应用](https://github.com/BCD1210/soju/releases/download/v1.4.0/Soju-1.4.0-macos-arm64.zip):原生桌面预览版在一个窗口中提供安装、启动、组件更新和诊断。[安装说明与要求](docs/DESKTOP.md)。
## 日常维护
diff --git a/VERSION b/VERSION
new file mode 100644
index 00000000000..88c5fb891dc
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+1.4.0
diff --git a/app/Icon.swift b/app/Icon.swift
new file mode 100644
index 00000000000..877925a8595
--- /dev/null
+++ b/app/Icon.swift
@@ -0,0 +1,27 @@
+import AppKit
+let output = CommandLine.arguments[1]
+let dir = URL(fileURLWithPath: output).appendingPathComponent("Soju.iconset")
+try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
+for size in [16, 32, 128, 256, 512] {
+ for scale in [1, 2] {
+ let pixels = size * scale
+ let rep = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: pixels, pixelsHigh: pixels,
+ bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true, isPlanar: false,
+ colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0)!
+ NSGraphicsContext.saveGraphicsState()
+ NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: rep)
+ let n = CGFloat(pixels)
+ NSColor(calibratedRed: 0.12, green: 0.34, blue: 0.28, alpha: 1).setFill()
+ NSBezierPath(roundedRect: NSRect(x: n * 0.08, y: n * 0.08, width: n * 0.84, height: n * 0.84),
+ xRadius: n * 0.2, yRadius: n * 0.2).fill()
+ let text = NSAttributedString(string: "S", attributes: [
+ .font: NSFont.systemFont(ofSize: n * 0.63, weight: .bold),
+ .foregroundColor: NSColor(calibratedRed: 0.94, green: 0.97, blue: 0.86, alpha: 1)])
+ let ts = text.size()
+ text.draw(at: NSPoint(x: (n - ts.width) / 2, y: (n - ts.height) / 2))
+ NSGraphicsContext.restoreGraphicsState()
+ let suffix = scale == 2 ? "@2x" : ""
+ try rep.representation(using: .png, properties: [:])!.write(to:
+ dir.appendingPathComponent("icon_\(size)x\(size)\(suffix).png"))
+ }
+}
diff --git a/app/Soju.swift b/app/Soju.swift
new file mode 100644
index 00000000000..a9a45b6e684
--- /dev/null
+++ b/app/Soju.swift
@@ -0,0 +1,307 @@
+import SwiftUI
+import AppKit
+
+enum Launcher: String, CaseIterable, Identifiable {
+ case battlenet, steam, epic, gog
+ var id: String { rawValue }
+ var title: String {
+ switch self {
+ case .battlenet: return "Battle.net"
+ case .steam: return "Steam"
+ case .epic: return "Epic Games"
+ case .gog: return "GOG GALAXY"
+ }
+ }
+ var detail: String {
+ self == .steam ? "Windows library · D3D11 with DXMT" : "Windows library · Apple D3DMetal"
+ }
+ var symbol: String {
+ switch self {
+ case .battlenet: return "bolt.circle.fill"
+ case .steam: return "gamecontroller.fill"
+ case .epic: return "shield.lefthalf.filled"
+ case .gog: return "square.grid.2x2.fill"
+ }
+ }
+ var executable: String {
+ switch self {
+ case .battlenet: return "bottle/drive_c/Program Files (x86)/Battle.net/Battle.net.exe"
+ case .steam: return "steam-bottle/drive_c/Program Files (x86)/Steam/steam.exe"
+ case .epic: return "epic-bottle/drive_c/Program Files/Epic Games/Launcher/Portal/Binaries/Win64/EpicGamesLauncher.exe"
+ case .gog: return "gog-bottle/drive_c/Program Files/GOG Galaxy/GalaxyClient.exe"
+ }
+ }
+}
+
+@MainActor final class SojuModel: ObservableObject {
+ @Published var installed: Set<Launcher> = []
+ @Published var busy = false
+ @Published var activity = "Ready when you are."
+ @Published var log = "Choose a launcher to get started. Existing installations are detected automatically."
+ @Published var failed = false
+ @Published var selection: Set<Launcher> = [.battlenet]
+ @Published var launching: Set<Launcher> = []
+ let base = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent(".battlenet-macos")
+ let root = Bundle.main.resourceURL!.appendingPathComponent("soju")
+ private var operation: Process?
+ private var launches: [Launcher: Process] = [:]
+ private var logReader: FileHandle?
+ private var poller: Timer?
+ var version: String { Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "dev" }
+
+ init() { refresh() }
+
+ func refresh() {
+ installed = Set(Launcher.allCases.filter {
+ FileManager.default.fileExists(atPath: base.appendingPathComponent($0.executable).path)
+ })
+ }
+
+ private func task(_ args: [String], logName: String) throws -> (Process, URL) {
+ let dir = base.appendingPathComponent("logs")
+ try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
+ let url = dir.appendingPathComponent(logName + ".log")
+ try Data().write(to: url, options: .atomic)
+ let output = try FileHandle(forWritingTo: url)
+ let p = Process()
+ p.executableURL = URL(fileURLWithPath: "/bin/bash")
+ p.arguments = [root.appendingPathComponent("scripts/desktop-action.sh").path] + args
+ p.currentDirectoryURL = root
+ var env = ProcessInfo.processInfo.environment
+ env["PATH"] = "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
+ env["SOJU_BASE"] = base.path
+ env["SOJU_NONINTERACTIVE"] = "1"
+ env["TERM"] = "dumb"
+ for key in ["ENGINE", "WINEPREFIX", "WINEDLLOVERRIDES", "DYLD_FALLBACK_LIBRARY_PATH"] { env.removeValue(forKey: key) }
+ p.environment = env
+ p.standardInput = FileHandle.nullDevice
+ p.standardOutput = output
+ p.standardError = output
+ return (p, url)
+ }
+
+ func run(_ args: [String], title: String) {
+ guard !busy else { return }
+ busy = true; failed = false; activity = title; log = ""
+ do {
+ let (p, url) = try task(args, logName: "desktop")
+ logReader = try FileHandle(forReadingFrom: url)
+ operation = p
+ p.terminationHandler = { [weak self] process in
+ DispatchQueue.main.async {
+ guard let self else { return }
+ self.readLog()
+ self.poller?.invalidate(); self.poller = nil
+ try? self.logReader?.close(); self.logReader = nil
+ self.busy = false; self.operation = nil
+ self.failed = process.terminationStatus != 0
+ self.activity = self.failed ? "Needs attention — see the details below." : "Finished."
+ self.refresh()
+ }
+ }
+ try p.run()
+ poller = Timer.scheduledTimer(withTimeInterval: 0.4, repeats: true) { [weak self] _ in
+ DispatchQueue.main.async { self?.readLog() }
+ }
+ } catch {
+ busy = false; failed = true; activity = "Could not start the operation."
+ log = error.localizedDescription
+ }
+ }
+
+ private func readLog() {
+ guard let reader = logReader else { return }
+ let data = reader.readDataToEndOfFile()
+ guard !data.isEmpty else { return }
+ let text = String(decoding: data, as: UTF8.self)
+ .replacingOccurrences(of: "\u{001B}\\[[0-9;]*[A-Za-z]", with: "", options: .regularExpression)
+ .replacingOccurrences(of: "\r", with: "\n")
+ log = String((log + text).suffix(60000))
+ }
+
+ func installSelection() {
+ let selected = Launcher.allCases.filter { selection.contains($0) }.map(\.rawValue)
+ guard !selected.isEmpty else { return }
+ run(["install", selected.joined(separator: ",")], title: "Installing selected launchers…")
+ }
+
+ func launch(_ launcher: Launcher) {
+ guard !launching.contains(launcher), !busy else { return }
+ do {
+ let (p, url) = try task(["launch", launcher.rawValue], logName: "desktop-" + launcher.rawValue)
+ launching.insert(launcher); launches[launcher] = p
+ p.terminationHandler = { [weak self] process in
+ DispatchQueue.main.async {
+ guard let self else { return }
+ self.launching.remove(launcher); self.launches.removeValue(forKey: launcher)
+ if process.terminationStatus != 0 && !self.busy {
+ self.failed = true; self.activity = launcher.title + " needs attention."
+ if let data = try? Data(contentsOf: url) { self.log = String(decoding: data.suffix(60000), as: UTF8.self) }
+ }
+ self.refresh()
+ }
+ }
+ try p.run()
+ activity = "Opening " + launcher.title + "…"
+ } catch {
+ launching.remove(launcher); launches.removeValue(forKey: launcher)
+ failed = true; activity = "Could not open " + launcher.title
+ log = error.localizedDescription
+ }
+ }
+
+ func addGPTK() {
+ let panel = NSOpenPanel()
+ panel.title = "Choose the mounted Game Porting Toolkit volume or payload"
+ panel.message = "Download Apple's evaluation environment, open its DMG, then select the mounted volume."
+ panel.canChooseDirectories = true; panel.canChooseFiles = false
+ panel.directoryURL = URL(fileURLWithPath: "/Volumes")
+ guard panel.runModal() == .OK, let url = panel.url else { return }
+ run(["gptk", url.path], title: "Installing Apple GPTK…")
+ }
+
+ func copyLog() {
+ NSPasteboard.general.clearContents()
+ NSPasteboard.general.setString(log, forType: .string)
+ }
+}
+
+struct SojuView: View {
+ @EnvironmentObject var model: SojuModel
+ @Environment(\.colorScheme) private var scheme
+ private var green: Color { scheme == .dark ? Color(red: 0.42, green: 0.83, blue: 0.67) : Color(red: 0.12, green: 0.34, blue: 0.28) }
+ private let columns = [GridItem(.flexible(), spacing: 16), GridItem(.flexible(), spacing: 16)]
+
+ var body: some View {
+ VStack(alignment: .leading, spacing: 20) {
+ HStack(alignment: .top) {
+ VStack(alignment: .leading, spacing: 7) {
+ HStack(spacing: 10) {
+ Image(systemName: "leaf.fill").foregroundStyle(green)
+ Text("Soju").font(.system(size: 30, weight: .bold, design: .rounded))
+ Text("OPEN SOURCE").font(.system(size: 10, weight: .bold)).tracking(1.5)
+ .padding(.horizontal, 9).padding(.vertical, 5)
+ .background(green.opacity(0.09), in: Capsule()).foregroundStyle(green)
+ }
+ Text("Your Windows launchers. At home on your Mac.").foregroundStyle(.secondary)
+ }
+ Spacer()
+ Menu {
+ Button("Project & releases") { open("https://github.com/BCD1210/soju/releases") }
+ Button("Report compatibility") { open("https://github.com/BCD1210/soju/issues/new?template=compatibility.yml") }
+ Button("Open local logs") { NSWorkspace.shared.open(model.base.appendingPathComponent("logs")) }
+ } label: { Image(systemName: "ellipsis.circle").font(.title2) }.menuStyle(.borderlessButton).fixedSize()
+ }
+ LazyVGrid(columns: columns, spacing: 16) {
+ ForEach(Launcher.allCases) { launcher in
+ card(launcher)
+ }
+ }
+ HStack(spacing: 12) {
+ Button(action: model.installSelection) {
+ Label("Install selected", systemImage: "arrow.down.circle")
+ }.buttonStyle(.borderedProminent).tint(green)
+ .disabled(model.busy || model.selection.isEmpty)
+ Button("Diagnose") { model.run(["doctor"], title: "Checking your setup…") }
+ .disabled(model.busy)
+ Button("Update components") { model.run(["update"], title: "Checking component updates…") }
+ .disabled(model.busy)
+ Spacer()
+ Menu("Apple GPTK") {
+ Button("Download from Apple") { open("https://developer.apple.com/games/game-porting-toolkit/") }
+ Button("Add mounted toolkit…", action: model.addGPTK)
+ }.disabled(model.busy).fixedSize()
+ }
+ VStack(alignment: .leading, spacing: 10) {
+ HStack(spacing: 8) {
+ if model.busy { ProgressView().controlSize(.small) }
+ else { Image(systemName: model.failed ? "exclamationmark.circle" : "checkmark.circle").foregroundStyle(model.failed ? Color.orange : green) }
+ Text(model.activity).font(.system(size: 12, weight: .medium))
+ Spacer()
+ Button("Copy log", action: model.copyLog).buttonStyle(.plain).foregroundStyle(.secondary)
+ }
+ ScrollViewReader { proxy in
+ ScrollView {
+ Text(model.log).font(.system(size: 11, design: .monospaced))
+ .textSelection(.enabled).frame(maxWidth: .infinity, alignment: .leading)
+ Color.clear.frame(height: 1).id("end")
+ }.frame(minHeight: 115, maxHeight: .infinity)
+ .onChange(of: model.log) { proxy.scrollTo("end", anchor: .bottom) }
+ }
+ }.padding(14).background(Color.primary.opacity(0.035), in: RoundedRectangle(cornerRadius: 12))
+ HStack {
+ Text("Steam installs without Apple GPTK. Each launcher keeps its own library and login.")
+ Spacer()
+ Text("v" + model.version)
+ }.font(.system(size: 10)).foregroundStyle(.secondary)
+ }.padding(28).frame(minWidth: 820, idealWidth: 900, minHeight: 650, idealHeight: 720)
+ .background(Color(nsColor: .windowBackgroundColor))
+ .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in model.refresh() }
+ }
+
+ private func card(_ launcher: Launcher) -> some View {
+ let installed = model.installed.contains(launcher)
+ return VStack(alignment: .leading, spacing: 14) {
+ HStack {
+ Image(systemName: launcher.symbol).font(.system(size: 25)).foregroundStyle(green)
+ .frame(width: 46, height: 46).background(green.opacity(0.08), in: RoundedRectangle(cornerRadius: 12))
+ VStack(alignment: .leading, spacing: 4) {
+ Text(launcher.title).font(.system(size: 17, weight: .semibold))
+ Text(installed ? "Installed" : "Not installed").font(.system(size: 11))
+ .foregroundStyle(installed ? green : Color.secondary)
+ }
+ Spacer()
+ Toggle("Select " + launcher.title, isOn: Binding(
+ get: { model.selection.contains(launcher) },
+ set: { if $0 { model.selection.insert(launcher) } else { model.selection.remove(launcher) } }
+ )).labelsHidden().toggleStyle(.checkbox).disabled(model.busy)
+ .accessibilityLabel("Select " + launcher.title)
+ }
+ Text(launcher.detail).font(.system(size: 11)).foregroundStyle(.secondary)
+ HStack {
+ Text(launcher == .steam ? "Steam account" : launcher == .gog ? "GOG account" : launcher == .epic ? "Epic account" : "Blizzard account")
+ .font(.system(size: 10)).foregroundStyle(.tertiary)
+ Spacer()
+ if installed {
+ Button(model.launching.contains(launcher) ? "Running" : "Open") { model.launch(launcher) }
+ .disabled(model.busy || model.launching.contains(launcher))
+ .accessibilityLabel("Open " + launcher.title)
+ } else {
+ Button("Install") { model.run(["install", launcher.rawValue], title: "Installing " + launcher.title + "…") }
+ .disabled(model.busy).accessibilityLabel("Install " + launcher.title)
+ }
+ }
+ }.padding(18).background(Color(nsColor: .controlBackgroundColor), in: RoundedRectangle(cornerRadius: 16))
+ .overlay(RoundedRectangle(cornerRadius: 16).stroke(green.opacity(0.12), lineWidth: 1))
+ }
+
+ private func open(_ url: String) { NSWorkspace.shared.open(URL(string: url)!) }
+}
+
+final class SojuDelegate: NSObject, NSApplicationDelegate {
+ var isBusy: (() -> Bool)?
+ func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
+ if isBusy?() == true {
+ let alert = NSAlert()
+ alert.messageText = "An operation is still running"
+ alert.informativeText = "Let the current installation or update finish before quitting Soju."
+ alert.runModal()
+ return .terminateCancel
+ }
+ return .terminateNow
+ }
+}
+
+@main struct SojuApp: App {
+ @NSApplicationDelegateAdaptor(SojuDelegate.self) var delegate
+ @StateObject private var model = SojuModel()
+ var body: some Scene {
+ Window("Soju", id: "main") {
+ SojuView().environmentObject(model).onAppear {
+ delegate.isBusy = { model.busy }
+ NSApp.setActivationPolicy(.regular)
+ NSApp.activate(ignoringOtherApps: true)
+ }
+ }.defaultSize(width: 900, height: 720)
+ }
+}
diff --git a/docs/DESKTOP.md b/docs/DESKTOP.md
new file mode 100644
index 00000000000..135b89029d4
--- /dev/null
+++ b/docs/DESKTOP.md
@@ -0,0 +1,49 @@
+# Soju for Mac
+
+[Download v1.4.0](https://github.com/BCD1210/soju/releases/download/v1.4.0/Soju-1.4.0-macos-arm64.zip)
+
+1. Unzip and move **Soju.app** into Applications or ~/Applications.
+2. Open it and select Battle.net, Steam, Epic Games or GOG GALAXY.
+3. Click **Install selected**. Existing installations are detected.
+4. Use **Open**, **Diagnose**, and **Update components** from the same window.
+
+![Soju desktop](assets/soju-desktop.png)
+
+This is the first native desktop preview. The app is ad-hoc signed, not
+Developer ID signed or notarized. If macOS blocks the downloaded app, review
+the source and use macOS Privacy & Security's Open Anyway flow if you trust it.
+A local source build is also available: `bash scripts/install-app.sh`.
+Soju does not collect telemetry or upload diagnostic logs. Copy log is manual.
+
+## Requirements
+
+- Apple Silicon; the app UI runs on macOS 14 or later.
+- Rosetta 2, Apple's Command Line Tools and Homebrew for launcher installation.
+- The current Steam rendering package requires **macOS 26+ and Wine 11.0**.
+ It was verified on M4 Pro / macOS 26.5. D3D11 support is not a guarantee that
+ every game works; anti-cheat and individual game requirements still apply.
+- Battle.net, Epic and GOG use the CX engine and a separate Apple GPTK download.
+ Steam does not need either.
+
+For Apple GPTK, install the selected non-Steam launcher to prepare the engine,
+download Apple's evaluation environment, open its DMG, then choose
+**Apple GPTK → Add mounted toolkit**. Retry installation if it stopped.
+
+The official clients retain their own login, library, downloads and game updates.
+Soju does not handle store passwords. Close launchers and games before updating
+their runtime. Closing Soju does not force running launchers or games to quit.
+
+## Updates and recovery
+
+**Update components** checks the CX engine and configures the pinned Steam
+components. Get new app releases from the project menu → Project & releases.
+The app does not replace itself automatically.
+
+Steam uses `~/.battlenet-macos/steam-runtime`; Homebrew's Wine app is preserved.
+Existing Steam users can migrate with `soju steam-games` after closing Steam.
+The installer retains the previous private runtime and a dated prefix settings
+backup. Failed setup restores the prefix settings automatically.
+
+Logs stay in `~/.battlenet-macos/logs`. Review logs before sharing them.
+Launcher shortcuts use a managed script copy, so moving the desktop app later
+does not invalidate existing shortcuts.
diff --git a/docs/STEAM-GAMES.md b/docs/STEAM-GAMES.md
index 97d4430ff05..2d7c3563f25 100644
--- a/docs/STEAM-GAMES.md
+++ b/docs/STEAM-GAMES.md
@@ -54,12 +54,16 @@ Hard-won facts, in the order they burned us:
the first two argv entries (NSProcessInfo sees pre-rewrite argv; scanning all
args would also hide the helper via its `-steampath=` argument).
+## Automatic setup
+
+`soju steam-install` now downloads verified prebuilt DXMT, the patched Wine driver and wrapper. Existing users can close Steam and run `soju steam-games`. A private Wine runtime preserves the Homebrew app. This component release requires macOS 26+ and Wine 11.0. See [sources and validation](STEAM-PREBUILTS.md).
+
## Building the artifacts
Based on notpop's `07-build-dxmt-fork.sh` / `08-patch-wine-visibility.sh`, with
three fixes we needed on macOS 26.5 / current Homebrew:
-- meson must be 1.10.x (`python3 -m venv … && pip install 'meson==1.10.*'`,
+- meson must be 1.10.2 (`python3 -m venv … && pip install 'meson==1.10.2'`,
pass `MESON=`), Homebrew's 1.12 breaks the DXMT build.
- `src/util/com/com_guid.cpp` needs `#include <iomanip>` (newer mingw).
- The prebuilt LLVM 15 x86_64 tree references zstd: build an x86_64
@@ -69,7 +73,7 @@ three fixes we needed on macOS 26.5 / current Homebrew:
- The Dock-icon patch on top of the visibility rebuild lives in
`transformProcessToForeground:` (see `scripts/setup-steam-games.sh` header).
-DXMT is LGPL-2.1+ (Copyright Feifan He for CodeWeavers); the wrapper is MIT
+The pinned DXMT fork is MIT (Copyright Feifan He), with separate notices for bundled DirectX headers; the wrapper is MIT
(vendored in `third_party/`); our winemac patch is published as
`patches/winemac-no-dock-icon.patch` (LGPL-2.1+, matching Wine). The same patch adds
`WINE_DOCK_REOPEN_CMD`: when the Dock icon is clicked and no Wine window is visible, winemac runs
@@ -84,6 +88,6 @@ Artifacts land in `~/.battlenet-macos/steam-support/` and
```bash
scripts/create-steam-bottle.sh # wine-stable + wrapper + Steam
-scripts/setup-steam-games.sh # DXMT + winemac wiring (needs built artifacts)
+scripts/setup-steam-games.sh # verified download + private DXMT/winemac runtime
scripts/play.sh steam # play
```
diff --git a/docs/STEAM-PREBUILTS.md b/docs/STEAM-PREBUILTS.md
new file mode 100644
index 00000000000..1ad6db8b50d
--- /dev/null
+++ b/docs/STEAM-PREBUILTS.md
@@ -0,0 +1,41 @@
+# Steam support release v1
+
+The package contains only these open-source components:
+
+- DXMT: notpop/dxmt commit `924a607e3eee06fad5be6f176d8510bb08bc418d`,
+ plus `patches/steam-dxmt-build.patch` (MIT; bundled DirectX headers retain their own notices).
+- Wine 11.0 winemac: `db11d0fe6a169c457e23d007e20404643d067aa8`,
+ plus `patches/steam-winemac.patch`, built with public driver symbols
+ (LGPL-2.1-or-later).
+- Steam webhelper wrapper: vendored notpop source (MIT).
+- LLVM 15.0.7: `8dfdcc7b7bf66834a761bd8de445840ef68e4d1a`
+ (Apache-2.0 with LLVM exceptions), statically linked into the renderer.
+
+[Binary and corresponding source release](https://github.com/BCD1210/soju/releases/tag/steam-support-v1)
+
+No Apple GPTK, game files, store clients, accounts or credentials are included.
+Clients are downloaded from their official installers separately. The manifest
+in `resources/steam-support.json` pins both the archive and every extracted file
+with SHA-256. Links, traversal, duplicate files and unexpected payloads are
+rejected before installation.
+
+## Build
+
+On Apple Silicon with Xcode's Metal toolchain and Homebrew build tools:
+
+```bash
+brew install cmake ninja bison flex gettext mingw-w64 python
+SOJU_STEAM_BUILD="$PWD/steam-build" bash scripts/build-steam-support.sh
+```
+
+The script pins Meson 1.10.2, builds x86_64 LLVM with zstd disabled, applies the
+published patches, and stages binaries without touching installed Wine or games.
+The source release includes exact DXMT, Wine, LLVM and DirectX-header snapshots,
+the Wine 8.16 toolchain source, licenses and a rebuild script.
+
+## Validation
+
+On M4 Pro / macOS 26.5: Wine 11.0 private-runtime migration, registry setup,
+D3D11 hardware device/swapchain creation and 180 presented frames using the
+DXMT winemetal module. The smoke test source is `tests/steam_d3d11_smoke.c`.
+The current native component deployment target is macOS 26.0.
diff --git a/docs/assets/soju-desktop.png b/docs/assets/soju-desktop.png
new file mode 100644
index 00000000000..251188df983
Binary files /dev/null and b/docs/assets/soju-desktop.png differ
diff --git a/docs/guides/steam-windows-client-apple-silicon.html b/docs/guides/steam-windows-client-apple-silicon.html
index 378770adef2..67ef1bb345b 100644
--- a/docs/guides/steam-windows-client-apple-silicon.html
+++ b/docs/guides/steam-windows-client-apple-silicon.html
@@ -48,11 +48,12 @@ break it on macOS Wine:</p>
<p>The fix (from <a href="https://github.com/notpop/steam-on-m1-wine">notpop's
steam-on-m1-wine</a>, MIT) is a tiny wrapper around <code>steamwebhelper.exe</code>
that forces <code>--disable-gpu --single-process</code>, plus launching Steam with
-<code>-no-cef-sandbox -cef-single-process</code>. Soju builds and redeploys the
+<code>-no-cef-sandbox -cef-single-process</code>. Soju downloads a verified prebuilt copy and redeploys the
wrapper automatically. Steam updates keep restoring the original, so this must
happen on every launch.</p>
<h2>Making games actually render (DXMT)</h2>
+<p><code>soju steam-install</code> now downloads verified DXMT and patched Wine components automatically. Existing users can close Steam and run <code>soju steam-games</code>. This build needs macOS 26+ and Wine 11.0; it preserves the Homebrew Wine app.</p>
<p>The Steam client and games have opposite needs in the same Wine prefix:
the client needs vanilla wined3d (it restart-loops on DXMT), while D3D11 games
need <a href="https://github.com/3Shain/dxmt">DXMT</a> (D3D11→Metal). Soju's
diff --git a/docs/index.html b/docs/index.html
index bb3256650a6..40b0f685a86 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -72,7 +72,7 @@ poster="assets/soju-launcher-demo-poster.jpg" aria-label="Soju launcher preview"
<h2 id="launchers-title">One toolkit. Four Windows launchers.</h2>
<div class="platforms">
<article class="platform"><h3>Battle.net</h3><p>Sign in, manage downloads and launch supported Blizzard games.</p><code>soju battlenet</code></article>
-<article class="platform"><h3>Steam</h3><p>Run the Windows client in its own Wine environment. D3D11 games need additional DXMT setup.</p><code>soju steam</code></article>
+<article class="platform"><h3>Steam</h3><p>Run the Windows client in its own Wine environment. Verified D3D11 components are installed automatically.</p><code>soju steam</code></article>
<article class="platform"><h3>Epic Games Launcher</h3><p>Sign in, install games and return to the launcher from its tray.</p><code>soju epic</code></article>
<article class="platform"><h3>GOG GALAXY</h3><p>Access your account and library. Game compatibility is still being explored.</p><code>soju gog</code></article>
</div>
@@ -82,8 +82,11 @@ You use each store's own interface and library.</p>
<section id="install" aria-labelledby="install-title">
<h2 id="install-title">Choose your launchers. Get set up.</h2>
-<p>The installer offers any combination of the four launchers and creates
-their shortcuts in <code>~/Applications</code>.</p>
+<p><a class="btn" href="https://github.com/BCD1210/soju/releases/download/v1.4.0/Soju-1.4.0-macos-arm64.zip">Download Soju for Mac</a></p>
+<p>The native desktop preview installs, opens, updates and diagnoses all four launchers in one window.
+Apple Silicon · app UI: macOS 14+ · Steam component build: macOS 26+.
+<a href="https://github.com/BCD1210/soju/blob/main/docs/DESKTOP.md">Setup and signing notes</a>.</p>
+<p>Prefer the terminal? Select launchers before any downloads. Steam-only installs skip the CX engine and Apple GPTK.</p>
<pre><code>curl -fsSL https://soju.snack-wrap.com/install.sh | bash</code></pre>
<p>Or install the CLI through Homebrew:</p>
<pre><code>brew install BCD1210/soju/soju
diff --git a/install.sh b/install.sh
index 0a9aab5cdea..ee4a3cb5751 100644
--- a/install.sh
+++ b/install.sh
@@ -4,21 +4,59 @@
# curl -fsSL https://soju.snack-wrap.com/install.sh | SOJU_PLATFORMS=battlenet,epic,gog bash (non-interactive selection)
#
# What it does:
-# 1. Downloads the prebuilt GPL Wine engine (built from CodeWeavers' published sources)
-# 2. Asks you to download Apple's Game Porting Toolkit once (Apple forbids redistribution)
-# 3. Asks which launchers you want (any combination) and installs each one with
-# its official installer into its own bottle
+# 1. Asks which launchers you want before downloading anything
+# 2. Installs only their dependencies (Steam skips the CX engine and Apple GPTK)
+# 3. Installs each official client into its own bottle
# 4. Creates a double-clickable app in ~/Applications for each launcher
set -euo pipefail
REPO="BCD1210/soju"
-BASE="$HOME/.battlenet-macos"
-ENGINE="$BASE/cx26-engine"
+BASE="${SOJU_BASE:-$HOME/.battlenet-macos}"
+export SOJU_BASE="$BASE"
+ENGINE="${ENGINE:-$BASE/cx26-engine}"
BOTTLE="$BASE/bottle"
TTY=/dev/tty
say(){ printf '\n\033[1m%s\033[0m\n' "$*"; }
+# ---------- 1. Choose launchers before any download ----------
+ALL="battlenet steam epic gog"
+if [ -n "${SOJU_PLATFORMS:-}" ]; then
+ PLATFORMS="$(echo "$SOJU_PLATFORMS" | tr ',' ' ')"
+else
+ say "[1/4] Which launchers do you want? (numbers separated by spaces, Enter = Battle.net only)"
+ cat <<'EOT'
+ 1) Battle.net (Diablo II: Resurrected etc.)
+ 2) Steam (Windows client on Homebrew wine-stable, D3D11 games via DXMT)
+ 3) Epic Games Launcher
+ 4) GOG GALAXY
+EOT
+ read -r -p " Your choice [1]: " choice < "$TTY" || choice=1
+ [ -n "$choice" ] || choice=1
+ PLATFORMS=""
+ for c in $choice; do
+ case "$c" in
+ 1|battlenet) PLATFORMS="$PLATFORMS battlenet" ;;
+ 2|steam) PLATFORMS="$PLATFORMS steam" ;;
+ 3|epic) PLATFORMS="$PLATFORMS epic" ;;
+ 4|gog) PLATFORMS="$PLATFORMS gog" ;;
+ *) echo "Unknown choice: $c"; exit 64 ;;
+ esac
+ done
+fi
+for p in $PLATFORMS; do case " $ALL " in *" $p "*) ;; *) echo "Unknown platform: $p"; exit 1;; esac; done
+[ -n "${PLATFORMS// /}" ] || { echo "Nothing selected."; exit 64; }
+echo " Installing:$PLATFORMS"
+
+NEEDS_CX=0; NEEDS_STEAM=0
+for p in $PLATFORMS; do
+ case "$p" in steam) NEEDS_STEAM=1 ;; *) NEEDS_CX=1 ;; esac
+done
+if [ "${1:-}" = "--plan" ]; then
+ printf 'platforms=%s\ncx_engine=%s\napple_gptk=%s\nsteam_runtime=%s\n' "$PLATFORMS" "$NEEDS_CX" "$NEEDS_CX" "$NEEDS_STEAM"
+ exit 0
+fi
+
[ "$(uname -m)" = "arm64" ] || { echo "This installer is for Apple Silicon Macs only."; exit 1; }
/usr/bin/pgrep -q oahd || { echo "Rosetta 2 is required: softwareupdate --install-rosetta"; exit 1; }
@@ -52,13 +90,14 @@ carry_gptk(){ # from, to
fi
done
}
-# ---------- 1. Engine ----------
+# ---------- 2. Engine (Battle.net / Epic / GOG only) ----------
+if [ "$NEEDS_CX" = 1 ]; then
# bin/wine alone can be left behind by an interrupted extract; only an engine
# that actually starts counts as present.
if [ -x "$ENGINE/bin/wine" ] && DYLD_FALLBACK_LIBRARY_PATH="$ENGINE/lib:/usr/lib" "$ENGINE/bin/wine" --version >/dev/null 2>&1; then
- say "[1/4] Engine already present - skipping"
+ say "[2/4] Engine already present - skipping"
else
- say "[1/4] Downloading prebuilt engine (~350MB, GPL - built from CodeWeavers' published Wine sources)"
+ say "[2/4] Downloading prebuilt engine (~350MB, GPL - built from CodeWeavers' published Wine sources)"
# The engine ships on its own "engine-*" release, which is not necessarily the
# newest release: scan all releases and take the first (newest) engine asset.
URL=$(curl -fsSL "https://api.github.com/repos/$REPO/releases?per_page=30" \
@@ -84,6 +123,8 @@ else
echo "Engine OK: $v"
fi
+fi # NEEDS_CX
+
# ---------- Soju scripts ----------
# The bottle scripts live in the repo; fetch a copy next to the engine so the
# one-line installer can use them (a checkout running install.sh uses itself).
@@ -105,7 +146,8 @@ else
fi
chmod +x "$SOJU_DIR"/scripts/*.sh "$SOJU_DIR"/scripts/soju 2>/dev/null || true
-# ---------- 2. Apple GPTK ----------
+# ---------- Apple GPTK (Battle.net / Epic / GOG only) ----------
+if [ "$NEEDS_CX" = 1 ]; then
# scripts/get-gptk.sh finds the payload (mounted toolkit dmg, or CrossOver),
# verifies every file (Apple's signature on the Mach-O parts, known Apple
# builds for the PE shims) and installs it. See the notes in that script.
@@ -127,6 +169,7 @@ else
3) Come back to this window and press Enter
EOT
while true; do
+ [ "${SOJU_NONINTERACTIVE:-0}" != 1 ] || { echo " GPTK not mounted. Use Add GPTK in Soju, then install again."; break; }
read -r -p " Press Enter when the dmg is mounted, or paste the path of the mounted volume (s to skip): " ans < "$TTY" || ans=s
[ "$ans" = "s" ] && { echo " Skipped - the last lines of this installer say how to add it later"; break; }
ans=${ans//\\ / }; ans=${ans%"${ans##*[! ]}"} # a path dragged into Terminal comes escaped
@@ -141,34 +184,9 @@ EOT
fi
fi
+fi # NEEDS_CX
+
# ---------- 3. Launchers ----------
-ALL="battlenet steam epic gog"
-if [ -n "${SOJU_PLATFORMS:-}" ]; then
- PLATFORMS="$(echo "$SOJU_PLATFORMS" | tr ',' ' ')"
-else
- say "[3/4] Which launchers do you want? (numbers separated by spaces, Enter = Battle.net only)"
- cat <<'EOT'
- 1) Battle.net (Diablo II: Resurrected etc.)
- 2) Steam (Windows client on Homebrew wine-stable, D3D11 games via DXMT)
- 3) Epic Games Launcher
- 4) GOG GALAXY
-EOT
- read -r -p " Your choice [1]: " choice < "$TTY" || choice=1
- [ -n "$choice" ] || choice=1
- PLATFORMS=""
- for c in $choice; do
- case "$c" in
- 1|battlenet) PLATFORMS="$PLATFORMS battlenet" ;;
- 2|steam) PLATFORMS="$PLATFORMS steam" ;;
- 3|epic) PLATFORMS="$PLATFORMS epic" ;;
- 4|gog) PLATFORMS="$PLATFORMS gog" ;;
- *) echo " Ignoring unknown choice: $c" ;;
- esac
- done
-fi
-for p in $PLATFORMS; do case " $ALL " in *" $p "*) ;; *) echo "Unknown platform: $p"; exit 1;; esac; done
-[ -n "$PLATFORMS" ] || { echo "Nothing selected."; exit 1; }
-echo " Installing:$PLATFORMS"
export ENGINE
for p in $PLATFORMS; do
@@ -185,21 +203,22 @@ for p in $PLATFORMS; do
say "Steam already installed - skipping"
else
say "Steam: Homebrew wine-stable + Steam installer"
- bash "$SOJU_DIR/scripts/create-steam-bottle.sh"
- fi ;;
+ WINEPREFIX="$BASE/steam-bottle" bash "$SOJU_DIR/scripts/create-steam-bottle.sh"
+ fi
+ WINEPREFIX="$BASE/steam-bottle" bash "$SOJU_DIR/scripts/setup-steam-games.sh" ;;
epic)
if [ -f "$BASE/epic-bottle/drive_c/Program Files/Epic Games/Launcher/Portal/Binaries/Win64/EpicGamesLauncher.exe" ]; then
say "Epic Games Launcher already installed - skipping"
else
say "Epic Games Launcher: creating the bottle + running Epic's installer"
- bash "$SOJU_DIR/scripts/create-epic-bottle.sh"
+ WINEPREFIX="$BASE/epic-bottle" bash "$SOJU_DIR/scripts/create-epic-bottle.sh"
fi ;;
gog)
if [ -f "$BASE/gog-bottle/drive_c/Program Files/GOG Galaxy/GalaxyClient.exe" ]; then
say "GOG GALAXY already installed - skipping"
else
say "GOG GALAXY: creating the bottle + running GOG's installer"
- bash "$SOJU_DIR/scripts/create-gog-bottle.sh"
+ WINEPREFIX="$BASE/gog-bottle" bash "$SOJU_DIR/scripts/create-gog-bottle.sh"
fi ;;
esac
# The client EXE does not prove its helper build completed.
@@ -213,11 +232,11 @@ say "[4/4] Creating apps in ~/Applications"
make_app(){ # name, play.sh mode, bundle id
local APP="$HOME/Applications/$1.app"
mkdir -p "$APP/Contents/MacOS"
- cat > "$APP/Contents/MacOS/launcher" <<EOF
-#!/bin/bash
-export ENGINE="$ENGINE"
-exec "$SOJU_DIR/scripts/play.sh" $2
-EOF
+ {
+ printf '#!/bin/bash\n'
+ printf 'export ENGINE=%q\nexport SOJU_BASE=%q\n' "$ENGINE" "$BASE"
+ printf 'exec /bin/bash %q %q\n' "$SOJU_DIR/scripts/play.sh" "$2"
+ } > "$APP/Contents/MacOS/launcher"
chmod +x "$APP/Contents/MacOS/launcher"
cat > "$APP/Contents/Info.plist" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
@@ -244,7 +263,7 @@ done
say "Done! 🍶 Double-click the app(s) above, log in, install and play."
echo "Command line: $SOJU_DIR/scripts/soju (battlenet | d2r | kill | epic | epic-kill | gog | gog-kill | steam | steam-kill | doctor | update)"
-GPTK_OK || echo "NOTE: GPTK was skipped - before launching a game, mount the GPTK dmg and run: $SOJU_DIR/scripts/soju gptk"
+[ "$NEEDS_CX" = 0 ] || GPTK_OK || echo "NOTE: GPTK was skipped - before launching a game, mount the GPTK dmg and run: $SOJU_DIR/scripts/soju gptk"
echo
echo "Something broke? Run 'soju doctor' and paste its output in an issue: https://github.com/BCD1210/soju/issues"
echo "Worked for you? A star helps other Mac gamers find this: https://github.com/BCD1210/soju"
diff --git a/patches/steam-dxmt-build.patch b/patches/steam-dxmt-build.patch
new file mode 100644
index 00000000000..f08c299f344
--- /dev/null
+++ b/patches/steam-dxmt-build.patch
@@ -0,0 +1,21 @@
+diff --git a/meson.build b/meson.build
+index e10c901..908e1eb 100644
+--- a/meson.build
++++ b/meson.build
+@@ -5,6 +5,7 @@ project('dxmt', ['c', 'cpp'], version : 'v0.1', meson_version: '>=1.3.0', defaul
+ 'b_ndebug=if-release',
+ ])
+
++add_languages('c', 'cpp', native: true)
+ fs = import('fs')
+
+ dxmt_crossbuild = meson.is_cross_build()
+diff --git a/src/util/com/com_guid.cpp b/src/util/com/com_guid.cpp
+index 11bf4a7..e08c507 100644
+--- a/src/util/com/com_guid.cpp
++++ b/src/util/com/com_guid.cpp
+@@ -1,3 +1,4 @@
++#include <iomanip>
+ /*
+ * This file is part of DXMT, Copyright (c) 2023 Feifan He
+ *
diff --git a/patches/steam-winemac.patch b/patches/steam-winemac.patch
new file mode 100644
index 00000000000..528da0f9438
--- /dev/null
+++ b/patches/steam-winemac.patch
@@ -0,0 +1,80 @@
+diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
+index 2a9dab2..13e054b 100644
+--- a/dlls/winemac.drv/cocoa_app.m
++++ b/dlls/winemac.drv/cocoa_app.m
+@@ -230,6 +230,34 @@ - (void) transformProcessToForeground:(BOOL)activateIfTransformed
+ NSString* title;
+ NSMenuItem* item;
+
++ /* Soju: suppress Dock icons for processes listed in WINE_NO_DOCK_ICON
++ (semicolon-separated exe names). Modeled on CrossOver's hack 24141. */
++ {
++ const char* nodock = getenv("WINE_NO_DOCK_ICON");
++ if (nodock)
++ {
++ /* The Windows exe path may sit in any argv slot (the loader
++ rewrites argv after NSProcessInfo snapshots it), so match
++ the basename of every argument against the list. */
++ NSArray* list = [[[NSString stringWithUTF8String:nodock] lowercaseString] componentsSeparatedByString:@";"];
++ NSCharacterSet* seps = [NSCharacterSet characterSetWithCharactersInString:@"/\\"];
++ BOOL blocked = NO;
++ NSArray* args = [[NSProcessInfo processInfo] arguments];
++ NSUInteger limit = MIN((NSUInteger)2, args.count);
++ for (NSUInteger i = 0; i < limit; i++)
++ {
++ NSString* base = [[[args[i] componentsSeparatedByCharactersInSet:seps] lastObject] lowercaseString];
++ if (base.length && [list containsObject:base]) { blocked = YES; break; }
++ }
++ if (blocked)
++ {
++ if (activateIfTransformed)
++ [self tryToActivateIgnoringOtherApps:YES];
++ return;
++ }
++ }
++ }
++
+ [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
+
+ if (activateIfTransformed)
+@@ -2232,6 +2260,40 @@ - (BOOL) applicationShouldHandleReopen:(NSApplication*)theApplication hasVisible
+ // Note that "flag" is often wrong. WineWindows are NSPanels and NSPanels
+ // don't count as "visible windows" for this purpose.
+ [self unminimizeWindowIfNoneVisible];
++
++ /* Soju: WINE_DOCK_REOPEN_CMD: Windows apps that "close to the tray"
++ (Steam) hide their window; there is no tray on macOS, so a Dock click
++ would do nothing. If nothing is visible after the unminimize attempt,
++ run the command (e.g. "steam.exe steam://open/main") to bring it back. */
++ {
++ const char* cmd = getenv("WINE_DOCK_REOPEN_CMD");
++ if (cmd && *cmd)
++ {
++ BOOL anyVisible = NO;
++ for (NSWindow* w in [NSApp windows])
++ {
++ /* Only count windows a user can actually see. Tray-parked apps
++ (Epic Games Launcher) keep tiny transparent helper windows
++ parked far off-screen, and those are still "visible" to AppKit. */
++ if ([w isKindOfClass:[WineWindow class]] && [w isVisible] && ![w isMiniaturized]
++ && [w alphaValue] > 0.0 && w.frame.size.width > 1 && w.frame.size.height > 1)
++ {
++ BOOL onScreen = NO;
++ for (NSScreen* screen in [NSScreen screens])
++ if (NSIntersectsRect(w.frame, screen.frame)) { onScreen = YES; break; }
++ if (onScreen) { anyVisible = YES; break; }
++ }
++ }
++ if (!anyVisible)
++ {
++ NSTask* task = [[NSTask alloc] init];
++ task.launchPath = @"/bin/sh";
++ task.arguments = @[@"-c", [NSString stringWithUTF8String:cmd]];
++ @try { [task launch]; } @catch (NSException* e) { NSLog(@"WINE_DOCK_REOPEN_CMD failed: %@", e); }
++ [task release];
++ }
++ }
++ }
+ return YES;
+ }
+
diff --git a/resources/steam-support.json b/resources/steam-support.json
new file mode 100644
index 00000000000..a513d0c727c
--- /dev/null
+++ b/resources/steam-support.json
@@ -0,0 +1,23 @@
+{
+ "version": "steam-support-v1",
+ "wine_version": "wine-11.0",
+ "minimum_macos": "26.0",
+ "url": "https://github.com/BCD1210/soju/releases/download/steam-support-v1/soju-steam-support-v1.tar.gz",
+ "sha256": "5e3588b0c0a47eb01ef0ddfd7f15b0cbd2f4c02dc4e885eacb785b6a42199a84",
+ "source_url": "https://github.com/BCD1210/soju/releases/download/steam-support-v1/soju-steam-support-v1-sources.tar.gz",
+ "files": {
+ "SOURCES.txt": "af7bdac603cff3455b62096801b611ea3b927f5df6dd2348f85d04eca9a25abe",
+ "dxmt-x64/d3d10core.dll": "263bdd2a68ed2b07b12016decb0b6d8735ff7ecda09a8ecae43369378a122062",
+ "dxmt-x64/d3d11.dll": "2d1183bc5bf187e238ce564940c658d0357a985886a543e402aac29c161b7872",
+ "dxmt-x64/dxgi.dll": "b413bf4725a134901cefa5c9d25178e4a982e9e5cc686b76937834be14f58474",
+ "dxmt-x64/winemetal.dll": "54856fc868022fd1b4390c8fd5fd9f81b65db12f4b1ca6f14e7a3a26f9198bce",
+ "dxmt-x64/winemetal.so": "f36df00f748bc9e30964451f04f4be8cc07c46400a6957470e7fcc8c131b6b3f",
+ "licenses/DXMT-MIT.txt": "6b928413c6308c106f3e0080bd94b6427b56d587d400fd40e6cbfbab7d9c4ae1",
+ "licenses/DirectX-headers.txt": "f38e6194bd3bfa1b654f118e5acefe0aead437bbe669eee43957ccc65a7127f1",
+ "licenses/LLVM.txt": "8d85c1057d742e597985c7d4e6320b015a9139385cff4cbae06ffc0ebe89afee",
+ "licenses/Wine-LGPL.txt": "e237fa56668030e928551ddd60f05df5fe957f75eab874bbd017e085ed722e7c",
+ "licenses/wrapper-MIT.txt": "9678fa46fccba251d0444f19d73a4ca76118f33dbc711c8a4c73e7b63c62a1fa",
+ "steamwebhelper-wrapper.exe": "1142b7e16ded45f93c30fac278874ffd94577f1926a0e043779f79216936c080",
+ "winemac-patched.so": "750784fccc7a0f6cd77a4bc4b372f81c09ba29bc62e79897b38240b142808547"
+ }
+}
diff --git a/scripts/build-app.sh b/scripts/build-app.sh
new file mode 100755
index 00000000000..bb54f6dcc9d
--- /dev/null
+++ b/scripts/build-app.sh
@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+# Native Apple Silicon app; build outputs never contain Wine, games or Apple GPTK.
+set -euo pipefail
+ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+OUT="${SOJU_APP_OUTPUT:-$ROOT/dist}"
+VERSION=$(cat "$ROOT/VERSION")
+mkdir -p "$OUT"
+STAGE=$(mktemp -d "$OUT/.app-build.XXXXXX")
+trap 'rm -rf "$STAGE"' EXIT
+APP="$STAGE/Soju.app"
+mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources/soju"
+swiftc -swift-version 5 -parse-as-library -O -target arm64-apple-macosx14.0 \
+ "$ROOT/app/Soju.swift" -o "$APP/Contents/MacOS/Soju"
+for dir in scripts tools patches third_party resources; do
+ ditto "$ROOT/$dir" "$APP/Contents/Resources/soju/$dir"
+done
+for file in install.sh VERSION LICENSE NOTICE; do
+ cp "$ROOT/$file" "$APP/Contents/Resources/soju/"
+done
+find "$APP" -name __pycache__ -type d -prune -exec rm -rf {} +
+python3 - "$APP" "$VERSION" <<'PY'
+import plistlib, sys
+from pathlib import Path
+p=Path(sys.argv[1])/"Contents/Info.plist"
+p.write_bytes(plistlib.dumps({
+ "CFBundleName": "Soju", "CFBundleDisplayName": "Soju",
+ "CFBundleIdentifier": "app.soju.desktop", "CFBundleExecutable": "Soju",
+ "CFBundlePackageType": "APPL", "CFBundleShortVersionString": sys.argv[2],
+ "CFBundleVersion": sys.argv[2], "LSMinimumSystemVersion": "14.0",
+ "NSHighResolutionCapable": True,
+ "NSHumanReadableCopyright": "Soju contributors — GPL-3.0-or-later",
+ "LSApplicationCategoryType": "public.app-category.games"
+}))
+PY
+swift "$ROOT/app/Icon.swift" "$STAGE"
+iconutil -c icns "$STAGE/Soju.iconset" -o "$APP/Contents/Resources/Soju.icns"
+/usr/libexec/PlistBuddy -c "Add :CFBundleIconFile string Soju" "$APP/Contents/Info.plist"
+codesign --force --sign - "$APP"
+codesign --verify --deep --strict "$APP"
+[ ! -d "$OUT/Soju.app" ] || rm -rf "$OUT/Soju.app"
+mv "$APP" "$OUT/Soju.app"
+ditto -c -k --sequesterRsrc --keepParent "$OUT/Soju.app" "$OUT/Soju-$VERSION-macos-arm64.zip"
+(cd "$OUT" && shasum -a 256 "Soju-$VERSION-macos-arm64.zip" > "Soju-$VERSION-macos-arm64.zip.sha256")
+echo "Built $OUT/Soju.app"
diff --git a/scripts/build-steam-support.sh b/scripts/build-steam-support.sh
new file mode 100755
index 00000000000..c5f218576cd
--- /dev/null
+++ b/scripts/build-steam-support.sh
@@ -0,0 +1,81 @@
+#!/usr/bin/env bash
+# Build redistribution-safe Steam components without touching installed Wine or bottles.
+set -euo pipefail
+ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+BUILD="${SOJU_STEAM_BUILD:-$HOME/.battlenet-macos/steam-build}"
+export PATH="/opt/homebrew/opt/bison/bin:/opt/homebrew/opt/flex/bin:/opt/homebrew/bin:$PATH"
+JOBS="${SOJU_BUILD_JOBS:-8}"
+mkdir -p "$BUILD"
+cd "$BUILD"
+clone(){
+ if [ "${SOJU_SOURCE_ARCHIVE:-0}" = 1 ]; then [ -d "$2" ] || { echo "Extract $2 from the source release first"; exit 1; }
+ else [ -d "$2/.git" ] || git clone --depth 1 --branch "$3" "$1" "$2"; fi
+}
+clone https://github.com/notpop/dxmt.git dxmt debug/present-path-tracing
+if [ "${SOJU_SOURCE_ARCHIVE:-0}" != 1 ]; then
+ git -C dxmt checkout --detach 924a607e3eee06fad5be6f176d8510bb08bc418d
+ git -C dxmt submodule update --init --recursive
+fi
+clone https://github.com/llvm/llvm-project.git llvm-project llvmorg-15.0.7
+clone https://github.com/wine-mirror/wine.git wine wine-11.0
+apply_once(){
+ git -C "$1" apply --reverse --check "$2" 2>/dev/null || git -C "$1" apply "$2"
+}
+apply_once wine "$ROOT/patches/steam-winemac.patch"
+apply_once dxmt "$ROOT/patches/steam-dxmt-build.patch"
+export MACOSX_DEPLOYMENT_TARGET=26.0
+[ -x venv/bin/meson ] || { python3 -m venv venv; venv/bin/pip install 'meson==1.10.2'; }
+mkdir -p dxmt/toolchains/wine
+if [ ! -x dxmt/toolchains/wine/bin/winebuild ]; then
+ curl -fL --retry 3 https://github.com/3Shain/wine/releases/download/v8.16-3shain/wine.tar.gz -o wine-toolchain.tar.gz
+ tar -xzf wine-toolchain.tar.gz -C dxmt/toolchains/wine
+fi
+if [ ! -f dxmt/toolchains/llvm/lib/libLLVMCore.a ]; then
+ cmake -G Ninja -S llvm-project/llvm -B llvm-build \
+ -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
+ -DLLVM_ENABLE_PROJECTS='' -DLLVM_TARGETS_TO_BUILD='X86;AArch64' \
+ -DLLVM_BUILD_TOOLS=OFF -DLLVM_BUILD_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF \
+ -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_ENABLE_RTTI=ON \
+ -DLLVM_ENABLE_ZSTD=OFF -DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_LIBXML2=OFF \
+ -DCMAKE_INSTALL_PREFIX="$BUILD/dxmt/toolchains/llvm"
+ cmake --build llvm-build --parallel "$JOBS"
+ cmake --install llvm-build
+fi
+cd dxmt
+[ -f build/build.ninja ] || ../venv/bin/meson setup build --cross-file build-win64.txt \
+ -Dnative_llvm_path=toolchains/llvm -Dwine_install_path=toolchains/wine --buildtype release
+../venv/bin/meson compile -C build -j "$JOBS"
+cd ../wine
+mkdir -p build
+cd build
+[ -f Makefile ] || arch -x86_64 ../configure --enable-win64 --disable-tests --without-freetype \
+ CFLAGS='-fvisibility=default -O2 -Wno-error -mmacosx-version-min=14.0' \
+ CXXFLAGS='-fvisibility=default -O2 -Wno-error -mmacosx-version-min=14.0'
+arch -x86_64 make -j"$JOBS" dlls/winemac.drv/winemac.so
+cd "$BUILD"
+mkdir -p output/dxmt-x64 output/licenses
+for dll in d3d11 dxgi d3d10core winemetal; do
+ f=$(find dxmt/build -name "$dll.dll" -type f | head -1)
+ [ -n "$f" ]; cp "$f" "output/dxmt-x64/$dll.dll"
+done
+cp dxmt/build/src/winemetal/unix/winemetal.so output/dxmt-x64/
+cp wine/build/dlls/winemac.drv/winemac.so output/winemac-patched.so
+x86_64-w64-mingw32-gcc -O2 -Wall -municode -DUNICODE -D_UNICODE \
+ -o output/steamwebhelper-wrapper.exe "$ROOT/third_party/steam-on-m1-wine/steamwebhelper-wrapper.c" -static -lshell32 -mwindows
+cp "$ROOT/third_party/steam-on-m1-wine/LICENSE" output/licenses/wrapper-MIT.txt
+cp wine/COPYING.LIB output/licenses/Wine-LGPL.txt
+cp dxmt/LICENSE output/licenses/DXMT-MIT.txt
+cp llvm-project/llvm/LICENSE.TXT output/licenses/LLVM.txt
+cp dxmt/include/native/directx/COPYING.MinGW-w64.txt output/licenses/DirectX-headers.txt
+if [ "${SOJU_SOURCE_ARCHIVE:-0}" = 1 ]; then
+ cp SOURCE-REVISIONS.txt output/SOURCES.txt
+else
+ {
+ printf 'DXMT: '; git -C dxmt rev-parse HEAD
+ printf 'Wine: '; git -C wine rev-parse HEAD
+ printf 'LLVM: '; git -C llvm-project rev-parse HEAD
+ printf 'Soju scripts and patches: '; git -C "$ROOT" rev-parse HEAD
+ } > output/SOURCES.txt
+fi
+printf 'Artifacts: %s/output\n' "$BUILD"
diff --git a/scripts/create-steam-bottle.sh b/scripts/create-steam-bottle.sh
index 071e12dbc41..45e345b9450 100755
--- a/scripts/create-steam-bottle.sh
+++ b/scripts/create-steam-bottle.sh
@@ -1,6 +1,5 @@
#!/usr/bin/env bash
-# Install Steam (Windows build): for Steam games such as the Steam edition of
-# D2R (Infernal Edition).
+# Install the Windows Steam client and its verified rendering components.
#
# Important: unlike Battle.net, Steam runs on Homebrew wine-stable, not the CX
# source engine. CX-derived builds cannot render Steam's CEF UI (black screen);
@@ -10,12 +9,13 @@
# Verified 2026-08-27 on M4 Pro / macOS 26.5: login screen renders.
set -euo pipefail
-export WINEPREFIX="${WINEPREFIX:-$HOME/.battlenet-macos/steam-bottle}"
-SUPPORT="$HOME/.battlenet-macos/steam-support"
-WORK="${WORK:-$HOME/.battlenet-macos/build}"; mkdir -p "$WORK" "$SUPPORT"
+BASE="${SOJU_BASE:-$HOME/.battlenet-macos}"
+export WINEPREFIX="${WINEPREFIX:-$BASE/steam-bottle}"
+WORK="${WORK:-$BASE/build}"; mkdir -p "$WORK"
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+source "$REPO_ROOT/scripts/steam-runtime.sh"
WINESTABLE_APP="/Applications/Wine Stable.app"
-WINE="$WINESTABLE_APP/Contents/Resources/wine/bin/wine"
+WINE="$STEAM_WINE_ROOT/bin/wine"
# ---------- 1. wine-stable ----------
if [ ! -x "$WINE" ]; then
@@ -27,27 +27,23 @@ if [ ! -x "$WINE" ]; then
fi
"$WINE" --version
-# ---------- 2. webhelper wrapper ----------
-# Forces Steam's CEF into --disable-gpu --single-process to avoid the black screen.
-if [ ! -f "$SUPPORT/steamwebhelper-wrapper.exe" ]; then
- echo "==> Building the wrapper (mingw-w64)"
- command -v x86_64-w64-mingw32-gcc >/dev/null || brew install mingw-w64
- x86_64-w64-mingw32-gcc -O2 -Wall -municode -DUNICODE -D_UNICODE \
- -o "$SUPPORT/steamwebhelper-wrapper.exe" \
- "$REPO_ROOT/third_party/steam-on-m1-wine/steamwebhelper-wrapper.c" \
- -static -lshell32 -mwindows
+# ---------- 2. Verified wrapper and rendering components ----------
+python3 "$REPO_ROOT/scripts/fetch-steam-support.py"
+if [ -f "$WINEPREFIX/drive_c/Program Files (x86)/Steam/steam.exe" ]; then
+ echo "Steam already installed."
+ exit 0
fi
# ---------- 3. Prefix + Steam install ----------
echo "==> Initializing the prefix: $WINEPREFIX"
"$WINE" wineboot -u >/dev/null 2>&1 || true
-"$WINESTABLE_APP/Contents/Resources/wine/bin/wineserver" -w 2>/dev/null || true
+"$STEAM_WINE_ROOT/bin/wineserver" -w 2>/dev/null || true
SETUP="$WORK/SteamSetup.exe"
[ -f "$SETUP" ] || { curl -fL "https://cdn.cloudflare.steamstatic.com/client/installer/SteamSetup.exe" -o "$SETUP.part" && mv -f "$SETUP.part" "$SETUP"; }
echo "==> Installing Steam silently"
"$WINE" "$SETUP" /S >/dev/null 2>&1 || true
-"$WINESTABLE_APP/Contents/Resources/wine/bin/wineserver" -w 2>/dev/null || true
+"$STEAM_WINE_ROOT/bin/wineserver" -w 2>/dev/null || true
[ -f "$WINEPREFIX/drive_c/Program Files (x86)/Steam/steam.exe" ] || { echo "Install failed"; exit 1; }
# ---------- 4. Finish ----------
diff --git a/scripts/desktop-action.sh b/scripts/desktop-action.sh
new file mode 100755
index 00000000000..0bd47e54a52
--- /dev/null
+++ b/scripts/desktop-action.sh
@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+# The native app passes arguments directly, never shell-interpolated user input.
+set -euo pipefail
+ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+BASE="${SOJU_BASE:-$HOME/.battlenet-macos}"
+export SOJU_BASE="$BASE"
+ACTION="${1:-}"; shift || true
+case "$ACTION" in
+ doctor) exec bash "$ROOT/scripts/doctor.sh" "$@" ;;
+ launch)
+ case "${1:-}" in battlenet|steam|epic|gog) exec bash "$ROOT/scripts/play.sh" "$1" ;;
+ *) echo "Choose one of the four launchers."; exit 64 ;; esac ;;
+ install)
+ export SOJU_PLATFORMS="${1:?Choose at least one launcher}"
+ if ! xcode-select -p >/dev/null 2>&1; then
+ echo "Install Apple's Command Line Tools first: xcode-select --install"; exit 1
+ fi
+ if ! command -v brew >/dev/null; then
+ echo "Install Homebrew from https://brew.sh, then retry."; exit 1
+ fi
+ # Shortcuts point at a stable managed copy even if the downloaded app moves.
+ MANAGED="$BASE/desktop-scripts"
+ mkdir -p "$MANAGED"
+ ditto "$ROOT" "$MANAGED"
+ exec bash "$MANAGED/install.sh" ;;
+ gptk)
+ [ -x "$BASE/cx26-engine/bin/wine" ] || {
+ echo "Install Battle.net, Epic or GOG first to prepare its engine, then add GPTK."; exit 1;
+ }
+ exec bash "$ROOT/scripts/get-gptk.sh" "${1:?Select the mounted toolkit}" ;;
+ update)
+ echo "Soju $(cat "$ROOT/VERSION") — component update"
+ echo "App updates: https://github.com/BCD1210/soju/releases"
+ result=0
+ if [ -x "$BASE/cx26-engine/bin/wine" ]; then
+ SOJU_UPDATE_ENGINE=1 bash "$ROOT/scripts/update.sh" --scripts-updated || result=1
+ fi
+ if [ -f "$BASE/steam-bottle/drive_c/Program Files (x86)/Steam/steam.exe" ]; then
+ bash "$ROOT/scripts/setup-steam-games.sh" || result=1
+ fi
+ echo "Component update finished."
+ exit "$result" ;;
+ *) echo "Unknown desktop action: $ACTION"; exit 64 ;;
+esac
diff --git a/scripts/doctor.sh b/scripts/doctor.sh
index c70d66b0631..f6e7fc8c9be 100755
--- a/scripts/doctor.sh
+++ b/scripts/doctor.sh
@@ -8,7 +8,8 @@ ENGINE="${ENGINE:-$BASE/cx26-engine}"
REPO="BCD1210/soju"
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SOJU="$ROOT/scripts/soju"
-WINESTABLE="/Applications/Wine Stable.app/Contents/Resources/wine/bin/wine"
+source "$ROOT/scripts/steam-runtime.sh"
+WINESTABLE="$STEAM_WINE_ROOT/bin/wine"
nok=0; nwarn=0; nfail=0
pass(){ printf ' ok %s\n' "$*"; nok=$((nok+1)); }
@@ -16,7 +17,15 @@ warn(){ printf ' warn %s\n' "$*"; nwarn=$((nwarn+1)); }
fail(){ printf ' FAIL %s\n' "$*"; nfail=$((nfail+1)); }
info(){ printf ' - %s\n' "$*"; }
-echo "soju doctor"
+SCOPE="${1:-installed}"
+case "$SCOPE" in installed|all|steam|battlenet|epic|gog) ;; *) echo "Usage: soju doctor [steam|battlenet|epic|gog|all]"; exit 64 ;; esac
+NEEDS_CX=0
+case "$SCOPE" in
+ all|battlenet|epic|gog) NEEDS_CX=1 ;;
+ installed)
+ if [ -x "$ENGINE/bin/wine" ] || [ -d "$BASE/bottle" ] || [ -d "$BASE/epic-bottle" ] || [ -d "$BASE/gog-bottle" ]; then NEEDS_CX=1; fi ;;
+esac
+echo "soju doctor ($SCOPE)"
echo
echo "System"
@@ -28,6 +37,7 @@ free_gb=$(df -g "$HOME" | awk 'NR==2 {print $4}')
if [ "${free_gb:-0}" -lt 20 ]; then warn "only ${free_gb}GB free on the home volume (games are big)"; else pass "${free_gb}GB free disk"; fi
echo
+if [ "$NEEDS_CX" = 1 ]; then
echo "Engine ($ENGINE)"
if [ -x "$ENGINE/bin/wine" ]; then
v=$(DYLD_FALLBACK_LIBRARY_PATH="$ENGINE/lib:/usr/lib" "$ENGINE/bin/wine" --version 2>/dev/null || true)
@@ -67,11 +77,21 @@ else
fi
echo
+else
+ info "CX engine / Apple GPTK not required for the selected installation"
+fi
echo "Bottles ($BASE)"
[ -f "$BASE/bottle/drive_c/Program Files (x86)/Battle.net/Battle.net.exe" ] \
&& pass "Battle.net bottle" || info "Battle.net not installed (soju install)"
if [ -f "$BASE/steam-bottle/drive_c/Program Files (x86)/Steam/steam.exe" ]; then
pass "Steam bottle"
+ if [ -f "$BASE/steam-runtime/.soju-runtime" ] && [ -f "$BASE/steam-bottle/.soju-steam-games" ]; then
+ pass "Soju private Steam runtime / D3D11 components installed"
+ elif [ -f "$BASE/steam-support/winemac-patched.so" ]; then
+ info "Legacy Steam renderer present; close Steam and run soju steam-games to migrate"
+ else
+ warn "Steam game rendering not configured: soju steam-games"
+ fi
[ -x "$WINESTABLE" ] && pass "Homebrew wine-stable present" \
|| fail "Steam bottle exists but wine-stable is gone: brew install --cask wine-stable"
else
diff --git a/scripts/fetch-steam-support.py b/scripts/fetch-steam-support.py
new file mode 100755
index 00000000000..2dc43daee7b
--- /dev/null
+++ b/scripts/fetch-steam-support.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python3
+"""Fetch pinned components. Verify before extraction or replacement."""
+import hashlib
+import json
+import os
+from pathlib import Path, PurePosixPath
+import shutil
+import subprocess
+import sys
+import tarfile
+import tempfile
+
+MANIFEST = Path(__file__).resolve().parent.parent / "resources/steam-support.json"
+
+def digest(path):
+ h = hashlib.sha256()
+ with open(path, "rb") as f:
+ for block in iter(lambda: f.read(1024 * 1024), b""): h.update(block)
+ return h.hexdigest()
+
+def verified(directory, manifest):
+ return all((directory / name).is_file() and not (directory / name).is_symlink()
+ and digest(directory / name) == sha for name, sha in manifest["files"].items())
+
+def unpack(archive, dest, manifest):
+ """Only regular allowlisted files; reject links, duplicates and traversal."""
+ seen = set()
+ with tarfile.open(archive, "r:gz") as tar:
+ for member in tar:
+ name = member.name[2:] if member.name.startswith("./") else member.name
+ path = PurePosixPath(name)
+ if path.is_absolute() or ".." in path.parts:
+ raise ValueError("Unsafe archive path")
+ if member.isdir(): continue
+ if not member.isfile() or name not in manifest["files"] or name in seen:
+ raise ValueError("Unexpected archive entry: " + name)
+ if member.size > 150 * 1024 * 1024:
+ raise ValueError("Oversized archive entry")
+ seen.add(name)
+ target = dest / name
+ target.parent.mkdir(parents=True, exist_ok=True)
+ with tar.extractfile(member) as src, target.open("wb") as out:
+ shutil.copyfileobj(src, out)
+ if seen != set(manifest["files"]) or not verified(dest, manifest):
+ raise ValueError("Incomplete or corrupt Steam components")
+
+def fetch(base, manifest):
+ support = base / "steam-support"
+ target = support / "prebuilt"
+ if verified(target, manifest):
+ print("Steam components verified (" + manifest["version"] + ")")
+ return target
+ support.mkdir(parents=True, exist_ok=True)
+ with tempfile.TemporaryDirectory(prefix=".download-", dir=support) as work:
+ work = Path(work); archive = work / "support.tar.gz"; stage = work / "payload"
+ stage.mkdir()
+ print("Downloading Steam components: " + manifest["version"], flush=True)
+ subprocess.run(["/usr/bin/curl", "--fail", "--location", "--proto", "=https",
+ "--retry", "3", "--connect-timeout", "20", "--max-time", "900",
+ manifest["url"], "--output", str(archive)], check=True)
+ if digest(archive) != manifest["sha256"]:
+ raise ValueError("Download checksum mismatch; existing files unchanged")
+ unpack(archive, stage, manifest)
+ (stage / ".soju-support-version").write_text(manifest["version"] + "\n")
+ backup = support / "prebuilt.previous"
+ if backup.exists(): shutil.rmtree(backup)
+ if target.exists(): target.rename(backup)
+ try: stage.rename(target)
+ except OSError:
+ if backup.exists(): backup.rename(target)
+ raise
+ if backup.exists(): shutil.rmtree(backup)
+ return target
+
+if __name__ == "__main__":
+ try:
+ manifest = json.loads(MANIFEST.read_text())
+ base = Path(os.environ.get("SOJU_BASE", str(Path.home() / ".battlenet-macos")))
+ if sys.argv[1:] == ["--check"]:
+ sys.exit(0 if verified(base / "steam-support/prebuilt", manifest) else 1)
+ fetch(base, manifest)
+ except (OSError, ValueError, subprocess.CalledProcessError, tarfile.TarError) as e:
+ print("Steam components: " + str(e), file=sys.stderr)
+ sys.exit(1)
diff --git a/scripts/install-app.sh b/scripts/install-app.sh
new file mode 100755
index 00000000000..2b12398f20d
--- /dev/null
+++ b/scripts/install-app.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+set -euo pipefail
+ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+[ -f "$ROOT/app/Soju.swift" ] || {
+ echo "Download the desktop app from https://github.com/BCD1210/soju/releases"; exit 1;
+}
+bash "$ROOT/scripts/build-app.sh"
+APP="$HOME/Applications/Soju.app"
+mkdir -p "$HOME/Applications"
+if pgrep -f '/Soju.app/Contents/MacOS/Soju$' >/dev/null; then
+ echo "Quit Soju before replacing the app. Built app: $ROOT/dist/Soju.app"; exit 1
+fi
+[ ! -d "$APP" ] || mv "$APP" "$HOME/Applications/Soju.previous-$(date +%s).app"
+ditto "$ROOT/dist/Soju.app" "$APP"
+open "$APP"
diff --git a/scripts/play.sh b/scripts/play.sh
index 8f5225111d6..7e0ae7db0a0 100755
--- a/scripts/play.sh
+++ b/scripts/play.sh
@@ -14,18 +14,19 @@
# macOS strips DYLD_* when exec'ing them.
set -euo pipefail
-ENGINE="${ENGINE:-$HOME/.battlenet-macos/cx26-engine}"
+ENGINE="${ENGINE:-${SOJU_BASE:-$HOME/.battlenet-macos}/cx26-engine}"
MODE="${1:-battlenet}"
+source "$(dirname "${BASH_SOURCE[0]}")/steam-runtime.sh"
# Bottle (virtual C: drive) path: per-mode default (Battle.net and Steam use separate bottles)
if [[ "$MODE" == steam* ]]; then
- export WINEPREFIX="${WINEPREFIX:-$HOME/.battlenet-macos/steam-bottle}"
+ export WINEPREFIX="${WINEPREFIX:-${SOJU_BASE:-$HOME/.battlenet-macos}/steam-bottle}"
elif [[ "$MODE" == epic* ]]; then
- export WINEPREFIX="${WINEPREFIX:-$HOME/.battlenet-macos/epic-bottle}"
+ export WINEPREFIX="${WINEPREFIX:-${SOJU_BASE:-$HOME/.battlenet-macos}/epic-bottle}"
elif [[ "$MODE" == gog* ]]; then
- export WINEPREFIX="${WINEPREFIX:-$HOME/.battlenet-macos/gog-bottle}"
+ export WINEPREFIX="${WINEPREFIX:-${SOJU_BASE:-$HOME/.battlenet-macos}/gog-bottle}"
else
- export WINEPREFIX="${WINEPREFIX:-$HOME/.battlenet-macos/bottle}"
+ export WINEPREFIX="${WINEPREFIX:-${SOJU_BASE:-$HOME/.battlenet-macos}/bottle}"
fi
export WINEDEBUG="${WINEDEBUG:-fixme-all}"
@@ -34,8 +35,8 @@ export WINEDEBUG="${WINEDEBUG:-fixme-all}"
# pressed" / "keyboard dead, mouse fine" reports: the log shows which window a
# KEY_RELEASE went to. Noisy (mouse moves too); leave it off otherwise.
if [[ "${SOJU_KEYLOG:-0}" == 1 ]]; then
- mkdir -p "$HOME/.battlenet-macos/logs"
- KEYLOG="$HOME/.battlenet-macos/logs/keys-$MODE-$(date +%Y%m%d-%H%M%S).log"
+ mkdir -p "${SOJU_BASE:-$HOME/.battlenet-macos}/logs"
+ KEYLOG="${SOJU_BASE:-$HOME/.battlenet-macos}/logs/keys-$MODE-$(date +%Y%m%d-%H%M%S).log"
export WINEDEBUG="fixme-all,+key,+event"
exec 2>>"$KEYLOG"
echo "soju keylog $(date) mode=$MODE prefix=$WINEPREFIX" >&2
@@ -133,7 +134,7 @@ case "$MODE" in
# its "minimized" state and the window comes back unresponsive. A Dock-icon
# click therefore replays the tray double-click into the launcher instead
# (tools/soju-epic-restore.c, built by create-epic-bottle.sh).
- export WINE_DOCK_REOPEN_CMD="'$ENGINE/bin/wine' '$HOME/.battlenet-macos/epic-support/soju-epic-restore.exe'"
+ export WINE_DOCK_REOPEN_CMD="'$ENGINE/bin/wine' '${SOJU_BASE:-$HOME/.battlenet-macos}/epic-support/soju-epic-restore.exe'"
# The EOS overlay (EOSOVH-*-Shipping.dll, loaded by the EOS SDK into every
# game, plus a CEF renderer tree beside it) is off by default, like Steam's
# gameoverlayrenderer. It draws inside the game's own process, so when one
@@ -184,7 +185,7 @@ case "$MODE" in
# same WM_COPYDATA "restore" message a second GalaxyClient.exe instance
# would send, without paying for a whole second client start-up
# (tools/soju-gog-restore.c, built by create-gog-bottle.sh).
- export WINE_DOCK_REOPEN_CMD="'$ENGINE/bin/wine' '$HOME/.battlenet-macos/gog-support/soju-gog-restore.exe'"
+ export WINE_DOCK_REOPEN_CMD="'$ENGINE/bin/wine' '${SOJU_BASE:-$HOME/.battlenet-macos}/gog-support/soju-gog-restore.exe'"
exec "$ENGINE/bin/wine" "$GOG" "${@:2}"
;;
gog-kill) # Stop everything in the GOG bottle
@@ -198,8 +199,8 @@ case "$MODE" in
# wrapper (forces --disable-gpu --single-process) + -no-cef-sandbox
# -cef-single-process. Source: github.com/notpop/steam-on-m1-wine (MIT),
# vendored in third_party/.
- WINESTABLE="/Applications/Wine Stable.app/Contents/Resources/wine/bin/wine"
- WINESTABLE_SERVER="/Applications/Wine Stable.app/Contents/Resources/wine/bin/wineserver"
+ WINESTABLE="$STEAM_WINE_ROOT/bin/wine"
+ WINESTABLE_SERVER="$STEAM_WINE_ROOT/bin/wineserver"
[[ -x "$WINESTABLE" ]] || { echo "wine-stable not found, brew install --cask wine-stable"; exit 1; }
ST="$WINEPREFIX/drive_c/Program Files (x86)/Steam/steam.exe"
[[ -f "$ST" ]] || { echo "Steam not found, run scripts/create-steam-bottle.sh first"; exit 1; }
@@ -207,7 +208,7 @@ case "$MODE" in
find "$WINEPREFIX/drive_c/users/"*/AppData/Local/Steam/htmlcache -maxdepth 2 \
\( -name "Singleton*" -o -name "*.lock" \) -delete 2>/dev/null || true
# 2) Redeploy the wrapper (Steam updates restore the original, so check every launch)
- WRAP="$HOME/.battlenet-macos/steam-support/steamwebhelper-wrapper.exe"
+ WRAP="$STEAM_SUPPORT/steamwebhelper-wrapper.exe"
for d in "$WINEPREFIX/drive_c/Program Files (x86)/Steam/bin/cef"/cef.win*; do
[[ -f "$d/steamwebhelper.exe" ]] || continue
if [[ $(stat -f%z "$d/steamwebhelper.exe") -gt 500000 ]]; then
@@ -274,7 +275,7 @@ case "$MODE" in
# wineserver here does nothing and leaves steam.exe alive, which then keeps
# respawning steamwebhelper (it looks like "Steam relaunches itself").
pkill -f "soju-reaper.sh $WINEPREFIX" 2>/dev/null || true
- "/Applications/Wine Stable.app/Contents/Resources/wine/bin/wineserver" -k 2>/dev/null || true
+ "$STEAM_WINE_ROOT/bin/wineserver" -k 2>/dev/null || true
sleep 2; [ -x "$SWEEP" ] && "$SWEEP"
;;
*) echo "usage: play.sh [battlenet|d2r|epic|epic-kill|gog|gog-kill|steam|kill|steam-kill]"; exit 1;;
diff --git a/scripts/setup-steam-games.sh b/scripts/setup-steam-games.sh
index 2569bf72b2b..e535f3e5ac2 100755
--- a/scripts/setup-steam-games.sh
+++ b/scripts/setup-steam-games.sh
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Enable D3D11 rendering for Steam games: wires DXMT + the patched winemac.
#
-# Prerequisites: create-steam-bottle.sh done, and the DXMT artifacts present in
+# Prerequisite: create-steam-bottle.sh. Verified components are downloaded into
# ~/.battlenet-macos/steam-support/ (dxmt-x64/{d3d11,dxgi,d3d10core,winemetal}.dll
# + winemetal.so, winemac-patched.so).
# See docs/STEAM-GAMES.md for how to build the artifacts (based on
@@ -22,29 +22,89 @@
# WINE_NO_DOCK_ICON support (single Dock icon)
set -euo pipefail
-SUP="$HOME/.battlenet-macos/steam-support"
-export WINEPREFIX="${WINEPREFIX:-$HOME/.battlenet-macos/steam-bottle}"
-WAPP="/Applications/Wine Stable.app/Contents/Resources/wine"
+ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+BASE="${SOJU_BASE:-$HOME/.battlenet-macos}"
+export WINEPREFIX="${WINEPREFIX:-$BASE/steam-bottle}"
+source "$ROOT/scripts/steam-runtime.sh"
+SUP="$BASE/steam-support/prebuilt"
+python3 - "$ROOT/resources/steam-support.json" <<'PYVERSION'
+import json, platform, sys
+m=json.load(open(sys.argv[1]))
+version=lambda s: tuple(map(int,s.split('.')))
+if version(platform.mac_ver()[0]) < version(m['minimum_macos']):
+ sys.exit('This Steam component build requires macOS '+m['minimum_macos']+' or later.')
+PYVERSION
+python3 "$ROOT/scripts/fetch-steam-support.py"
+B="$WINEPREFIX/drive_c/windows"
+[ -d "$B/system32" ] || { echo "Install Steam first: soju steam-install"; exit 1; }
+unset DYLD_FALLBACK_LIBRARY_PATH WINEDLLOVERRIDES WINEMSYNC ROSETTA_ADVERTISE_AVX
+unset CX_ACTIVE_GRAPHICS_BACKEND CX_GRAPHICS_BACKEND CX_APPLEGPTK_LIBD3DSHARED_PATH
+export WINEDEBUG=-all
+VERSION=$(cat "$SUP/.soju-support-version")
+TARGET="$BASE/steam-runtime"
+if [ "${1:-}" != --repair ] && [ -f "$TARGET/.soju-runtime" ] && \
+ [ "$(cat "$WINEPREFIX/.soju-steam-games" 2>/dev/null || true)" = "$VERSION" ] && \
+ [ "$(cat "$TARGET/.soju-runtime")" = "$VERSION" ]; then
+ echo "Steam rendering is ready ($VERSION)."
+ exit 0
+fi
+SOURCE="$STEAM_WINE_ROOT"
+[ -x "$SOURCE/bin/wine" ] || { echo "Install wine-stable first: soju steam-install"; exit 1; }
+[ "$("$SOURCE/bin/wine" --version)" = wine-11.0 ] || {
+ echo "This Steam component release requires Wine 11.0. Existing runtime unchanged."; exit 1;
+}
+# Never migrate a live Wine Stable / private Steam session to another server.
+if ps -axo comm= | grep -E '(Wine Stable.app|/steam-runtime)/.*wineserver$' >/dev/null; then
+ echo "Close Windows Steam and its games, then run soju steam-games again."
+ exit 1
+fi
+NEW=$(mktemp -d "$BASE/.steam-runtime.XXXXXX")
+BACKUP=""; BACKUP_READY=0
+rollback(){
+ status=$?
+ if [ "$status" != 0 ] && [ "$BACKUP_READY" = 1 ]; then
+ "$NEW/bin/wineserver" -k 2>/dev/null || true
+ "$NEW/bin/wineserver" -w 2>/dev/null || true
+ cp "$BACKUP/user.reg" "$WINEPREFIX/user.reg"
+ for D in d3d11 dxgi d3d10core winemetal; do
+ if [ -f "$BACKUP/$D.dll" ]; then cp "$BACKUP/$D.dll" "$B/system32/$D.dll"
+ else rm -f "$B/system32/$D.dll"; fi
+ done
+ if [ -f "$BACKUP/renderer-version" ]; then cp "$BACKUP/renderer-version" "$WINEPREFIX/.soju-steam-games"
+ else rm -f "$WINEPREFIX/.soju-steam-games"; fi
+ echo "Setup failed; the previous prefix configuration was restored."
+ fi
+ rm -rf "$NEW"
+}
+trap rollback EXIT
+printf 'Preparing the Soju Steam runtime (existing Wine app is preserved)\n'
+ditto "$SOURCE" "$NEW"
+WAPP="$NEW"
WLIB="$WAPP/lib/wine"
WINE="$WAPP/bin/wine"
-B="$WINEPREFIX/drive_c/windows"
-
-[ -x "$WINE" ] || { echo "wine-stable not found, run create-steam-bottle.sh first"; exit 1; }
-for f in dxmt-x64/d3d11.dll dxmt-x64/dxgi.dll dxmt-x64/d3d10core.dll dxmt-x64/winemetal.dll dxmt-x64/winemetal.so winemac-patched.so; do
- [ -f "$SUP/$f" ] || { echo "Missing artifact: $SUP/$f, see the build steps in docs/STEAM-GAMES.md"; exit 1; }
-done
echo "==> 1/5 Backing up vanilla dlls (first run only)"
for D in d3d11 dxgi d3d10core; do
[ -f "$WLIB/x86_64-windows/$D.dll.vanilla" ] || cp -f "$WLIB/x86_64-windows/$D.dll" "$WLIB/x86_64-windows/$D.dll.vanilla"
done
-echo "==> 2/5 Wiring the bundle: x86_64=DXMT, winemetal (builtin+unix), patched winemac"
+echo "==> 2/5 Wiring the private runtime: x86_64=DXMT, winemetal (builtin+unix), patched winemac"
cp -f "$SUP/dxmt-x64/"{d3d11.dll,dxgi.dll,d3d10core.dll,winemetal.dll} "$WLIB/x86_64-windows/"
cp -f "$SUP/dxmt-x64/winemetal.so" "$WLIB/x86_64-unix/"
+[ -f "$WLIB/x86_64-unix/winemac.so.vanilla" ] || cp "$WLIB/x86_64-unix/winemac.so" "$WLIB/x86_64-unix/winemac.so.vanilla"
cp -f "$SUP/winemac-patched.so" "$WLIB/x86_64-unix/winemac.so"
# i386 stays vanilla (protects the 32-bit steam.exe composer)
+BACKUP="$BASE/steam-support/prefix-backup-$(date +%Y%m%d-%H%M%S)"
+mkdir -p "$BACKUP"
+cp "$WINEPREFIX/user.reg" "$BACKUP/user.reg"
+for D in d3d11 dxgi d3d10core winemetal; do
+ [ ! -f "$B/system32/$D.dll" ] || cp "$B/system32/$D.dll" "$BACKUP/$D.dll"
+done
+[ ! -f "$WINEPREFIX/.soju-steam-games" ] || cp "$WINEPREFIX/.soju-steam-games" "$BACKUP/renderer-version"
+BACKUP_READY=1
+echo "Recovery copy: $BACKUP"
+
echo "==> 3/5 Prefix: winemetal placeholder + marker-stripped vanilla natives for Steam"
cp -f "$WLIB/x86_64-windows/winemetal.dll" "$B/system32/winemetal.dll"
for D in d3d11 dxgi d3d10core; do
@@ -80,5 +140,15 @@ n = d.replace('DISABLEDXMAXIMIZEDWINDOWEDMODE', '')
if n != d: open(p, 'w', encoding='utf-8', errors='surrogateescape').write(n)
EOF
+"$WINE" --version >/dev/null
+printf '%s\n' "$VERSION" > "$NEW/.soju-runtime"
+printf '%s\n' "$VERSION" > "$WINEPREFIX/.soju-steam-games"
+[ ! -d "$TARGET.previous" ] || rm -rf "$TARGET.previous"
+[ ! -d "$TARGET" ] || mv "$TARGET" "$TARGET.previous"
+if ! mv "$NEW" "$TARGET"; then
+ [ ! -d "$TARGET.previous" ] || mv "$TARGET.previous" "$TARGET"
+ exit 1
+fi
+BACKUP_READY=0
echo "Done. Launch with scripts/play.sh steam, to pin windowed mode, use the"
echo "in-game setting or the Steam launch option '-screen-fullscreen 0' (Unity titles)."
diff --git a/scripts/soju b/scripts/soju
index b39bc348f5b..defbdee37cc 100755
--- a/scripts/soju
+++ b/scripts/soju
@@ -13,10 +13,12 @@ ROOT="$(cd "$(dirname "$SELF")/.." && pwd)"
usage() {
cat <<'EOF'
-soju: free Battle.net / Diablo II: Resurrected / Epic / GOG / Steam on Apple Silicon
+soju: open-source Windows launchers on Apple Silicon
Usage:
- soju install Set up the Wine engine, Apple GPTK and Battle.net
+ soju install Choose and install any of the four launchers
+ soju app Build, install and open the native Soju app
+ soju --version Print the Soju version
soju battlenet Launch Battle.net (default bottle)
soju d2r Launch Diablo II: Resurrected directly
soju kill Stop everything in the Battle.net bottle
@@ -29,7 +31,7 @@ Usage:
soju gog-kill Stop everything in the GOG bottle
soju steam-install Set up the Steam bottle (wine-stable + wrapper + Steam)
- soju steam-games Wire DXMT so D3D11 games render (needs built artifacts)
+ soju steam-games Download and configure verified D3D11 components
soju steam Launch Steam
soju steam-kill Stop everything in the Steam bottle
@@ -44,10 +46,12 @@ EOF
}
case "${1:-}" in
+ --version) cat "$ROOT/VERSION" ;;
+ app) exec bash "$ROOT/scripts/install-app.sh" ;;
install) shift; exec bash "$ROOT/install.sh" "$@" ;;
epic-install) shift; exec bash "$ROOT/scripts/create-epic-bottle.sh" "$@" ;;
gog-install) shift; exec bash "$ROOT/scripts/create-gog-bottle.sh" "$@" ;;
- steam-install) shift; exec bash "$ROOT/scripts/create-steam-bottle.sh" "$@" ;;
+ steam-install) shift; export SOJU_PLATFORMS=steam; exec bash "$ROOT/install.sh" "$@" ;;
steam-games) shift; exec bash "$ROOT/scripts/setup-steam-games.sh" "$@" ;;
gptk) shift; exec bash "$ROOT/scripts/get-gptk.sh" "$@" ;;
sweep) shift; exec bash "$ROOT/scripts/soju-sweep.sh" "$@" ;;
diff --git a/scripts/steam-runtime.sh b/scripts/steam-runtime.sh
new file mode 100755
index 00000000000..998116ccf36
--- /dev/null
+++ b/scripts/steam-runtime.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+# Existing users retain Wine Stable until a verified private runtime is ready.
+SOJU_STEAM_BASE="${SOJU_BASE:-$HOME/.battlenet-macos}"
+STEAM_WINE_ROOT="${SOJU_STEAM_WINE:-/Applications/Wine Stable.app/Contents/Resources/wine}"
+if [ -z "${SOJU_STEAM_WINE:-}" ] && [ -f "$SOJU_STEAM_BASE/steam-runtime/.soju-runtime" ]; then
+ STEAM_WINE_ROOT="$SOJU_STEAM_BASE/steam-runtime"
+fi
+STEAM_SUPPORT="$SOJU_STEAM_BASE/steam-support"
+if [ -d "$STEAM_SUPPORT/prebuilt" ]; then STEAM_SUPPORT="$STEAM_SUPPORT/prebuilt"; fi
diff --git a/scripts/update.sh b/scripts/update.sh
index b6888146357..87f794498b6 100755
--- a/scripts/update.sh
+++ b/scripts/update.sh
@@ -50,7 +50,11 @@ fi
# ---------- 2. Engine ----------
say "[2/2] Checking the engine"
if [ ! -x "$ENGINE/bin/wine" ]; then
- echo " no engine at $ENGINE (run: soju install)"; exit 0
+ if [ -f "$BASE/steam-bottle/drive_c/Program Files (x86)/Steam/steam.exe" ]; then
+ echo " Steam-only installation: CX engine / GPTK not needed"
+ exec bash "$ROOT/scripts/setup-steam-games.sh"
+ fi
+ echo " no launchers installed (run: soju install)"; exit 0
fi
# The asset is named wine-engine-*.tar.xz from engine-v1.4 on. Older
diff --git a/tests/steam_d3d11_smoke.c b/tests/steam_d3d11_smoke.c
new file mode 100644
index 00000000000..b65045d4d13
--- /dev/null
+++ b/tests/steam_d3d11_smoke.c
@@ -0,0 +1,54 @@
+#define COBJMACROS
+#include <windows.h>
+#include <d3d11.h>
+#include <stdio.h>
+
+/* Hardware rendering smoke test. No store account or installed game is needed. */
+int wmain(void) {
+ HINSTANCE instance = GetModuleHandleW(NULL);
+ WNDCLASSW wc = {0};
+ wc.lpfnWndProc = DefWindowProcW;
+ wc.hInstance = instance;
+ wc.lpszClassName = L"SojuGraphicsCheck";
+ RegisterClassW(&wc);
+ HWND window = CreateWindowW(wc.lpszClassName, L"Soju D3D11 rendering check",
+ WS_OVERLAPPEDWINDOW | WS_VISIBLE, 180, 140, 640, 420, NULL, NULL, instance, NULL);
+ if (!window) return 1;
+ DXGI_SWAP_CHAIN_DESC desc = {0};
+ desc.BufferDesc.Width = 640; desc.BufferDesc.Height = 420;
+ desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ desc.SampleDesc.Count = 1;
+ desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
+ desc.BufferCount = 2; desc.OutputWindow = window; desc.Windowed = TRUE;
+ desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
+ ID3D11Device *device = NULL;
+ ID3D11DeviceContext *context = NULL;
+ IDXGISwapChain *swap = NULL;
+ HRESULT hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL,
+ 0, NULL, 0, D3D11_SDK_VERSION, &desc, &swap, &device, NULL, &context);
+ if (FAILED(hr)) { printf("Device/swapchain failed: %08lx\n", hr); return 2; }
+ if (!GetModuleHandleW(L"winemetal.dll")) { printf("DXMT winemetal module not loaded\n"); return 6; }
+ ID3D11Texture2D *buffer = NULL;
+ ID3D11RenderTargetView *target = NULL;
+ hr = IDXGISwapChain_GetBuffer(swap, 0, &IID_ID3D11Texture2D, (void **)&buffer);
+ if (FAILED(hr)) return 3;
+ hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)buffer, NULL, &target);
+ if (FAILED(hr)) return 4;
+ ID3D11Texture2D_Release(buffer);
+ for (int frame = 0; frame < 180; frame++) {
+ MSG message;
+ while (PeekMessageW(&message, NULL, 0, 0, PM_REMOVE)) {
+ TranslateMessage(&message); DispatchMessageW(&message);
+ }
+ float color[4] = {0.12f, 0.5f + 0.2f * (frame % 60) / 60, 0.35f, 1};
+ ID3D11DeviceContext_ClearRenderTargetView(context, target, color);
+ hr = IDXGISwapChain_Present(swap, 1, 0);
+ if (FAILED(hr)) { printf("Present failed: %08lx\n", hr); return 5; }
+ Sleep(33);
+ }
+ printf("PASS: hardware D3D11 device, swapchain and 180 presented frames.\n");
+ ID3D11RenderTargetView_Release(target); IDXGISwapChain_Release(swap);
+ ID3D11DeviceContext_Release(context); ID3D11Device_Release(device);
+ DestroyWindow(window);
+ return 0;
+}
diff --git a/tests/test_installation.py b/tests/test_installation.py
new file mode 100644
index 00000000000..2bd0ef0b5b7
--- /dev/null
+++ b/tests/test_installation.py
@@ -0,0 +1,155 @@
+import hashlib
+import importlib.util
+import io
+import json
+import os
+from pathlib import Path
+import subprocess
+import tarfile
+import tempfile
+import unittest
+from unittest.mock import patch
+
+ROOT = Path(__file__).resolve().parent.parent
+spec = importlib.util.spec_from_file_location("fetch_support", ROOT / "scripts/fetch-steam-support.py")
+fetcher = importlib.util.module_from_spec(spec)
+spec.loader.exec_module(fetcher)
+
+class InstallerPlanTests(unittest.TestCase):
+ def plan(self, choices):
+ with tempfile.TemporaryDirectory() as temp:
+ base = Path(temp) / "untouched"
+ result = subprocess.run(["/bin/bash", str(ROOT / "install.sh"), "--plan"],
+ env={**os.environ, "SOJU_PLATFORMS": choices, "SOJU_BASE": str(base)},
+ capture_output=True, text=True)
+ self.assertFalse(base.exists(), "Selection must precede filesystem changes")
+ return result
+
+ def test_steam_needs_no_cx_or_gptk(self):
+ result = self.plan("steam")
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertIn("cx_engine=0", result.stdout)
+ self.assertIn("apple_gptk=0", result.stdout)
+ self.assertIn("steam_runtime=1", result.stdout)
+
+ def test_mixed_selection_requests_both_runtimes(self):
+ result = self.plan("steam,epic")
+ self.assertEqual(result.returncode, 0)
+ self.assertIn("cx_engine=1", result.stdout)
+ self.assertIn("steam_runtime=1", result.stdout)
+
+ def test_cx_selection_skips_steam_runtime(self):
+ result = self.plan("battlenet,epic,gog")
+ self.assertEqual(result.returncode, 0)
+ self.assertIn("steam_runtime=0", result.stdout)
+
+ def test_invalid_selection_has_no_side_effects(self):
+ self.assertNotEqual(self.plan("steam,unknown").returncode, 0)
+ self.assertNotEqual(self.plan(" ").returncode, 0)
+
+class ArtifactTests(unittest.TestCase):
+ data = b"MZ-test-component"
+ def manifest(self):
+ return {"version": "test-v1", "files": {"dxmt-x64/d3d11.dll": hashlib.sha256(self.data).hexdigest()}}
+
+ def archive(self, path, entries):
+ with tarfile.open(path, "w:gz") as tar:
+ for name, kind in entries:
+ item = tarfile.TarInfo(name)
+ if kind == "link":
+ item.type = tarfile.SYMTYPE; item.linkname = "/tmp/escape"
+ tar.addfile(item)
+ else:
+ item.size = len(self.data)
+ tar.addfile(item, io.BytesIO(self.data))
+
+ def test_extracts_only_verified_files(self):
+ with tempfile.TemporaryDirectory() as t:
+ d = Path(t); dest = d/"out"; dest.mkdir()
+ self.archive(d/"test.tgz", [("dxmt-x64/d3d11.dll", "file")])
+ fetcher.unpack(d/"test.tgz", dest, self.manifest())
+ self.assertTrue(fetcher.verified(dest, self.manifest()))
+
+ def test_rejects_traversal_links_duplicates_and_unknown_payloads(self):
+ cases = [
+ [("../escape", "file")],
+ [("/tmp/escape", "file")],
+ [("dxmt-x64/d3d11.dll", "link")],
+ [("dxmt-x64/d3d11.dll", "file"), ("dxmt-x64/d3d11.dll", "file")],
+ [("unapproved.exe", "file")],
+ ]
+ for entries in cases:
+ with self.subTest(entries=entries), tempfile.TemporaryDirectory() as t:
+ d=Path(t); (d/"out").mkdir()
+ self.archive(d/"test.tgz", entries)
+ with self.assertRaises(ValueError):
+ fetcher.unpack(d/"test.tgz", d/"out", self.manifest())
+
+ def test_rejects_incomplete_or_corrupt_payload(self):
+ with tempfile.TemporaryDirectory() as t:
+ d=Path(t); (d/"out").mkdir()
+ self.archive(d/"test.tgz", [])
+ with self.assertRaises(ValueError):
+ fetcher.unpack(d/"test.tgz", d/"out", self.manifest())
+ self.archive(d/"test.tgz", [("dxmt-x64/d3d11.dll", "file")])
+ m=self.manifest(); m["files"]["dxmt-x64/d3d11.dll"]="0"*64
+ with self.assertRaises(ValueError):
+ fetcher.unpack(d/"test.tgz", d/"out", m)
+
+ def test_bad_download_preserves_previous_installation(self):
+ with tempfile.TemporaryDirectory() as t:
+ base=Path(t); target=base/"steam-support/prebuilt"
+ target.mkdir(parents=True); (target/"keep.txt").write_text("old installation")
+ m={**self.manifest(), "url":"https://example.invalid/support.tgz", "sha256":"0"*64}
+ def download(args, **kwargs):
+ Path(args[-1]).write_bytes(b"truncated archive")
+ with patch.object(fetcher.subprocess, "run", side_effect=download):
+ with self.assertRaises(ValueError): fetcher.fetch(base,m)
+ self.assertEqual((target/"keep.txt").read_text(),"old installation")
+ self.assertEqual(list((base/"steam-support").iterdir()),[target])
+
+ def test_valid_cache_is_offline_and_detects_tampering(self):
+ with tempfile.TemporaryDirectory() as t:
+ base=Path(t); target=base/"steam-support/prebuilt"
+ (target/"dxmt-x64").mkdir(parents=True)
+ p=target/"dxmt-x64/d3d11.dll"; p.write_bytes(self.data)
+ with patch.object(fetcher.subprocess,"run",side_effect=AssertionError("network")):
+ self.assertEqual(fetcher.fetch(base,self.manifest()),target)
+ p.write_bytes(b"tampered")
+ self.assertFalse(fetcher.verified(target,self.manifest()))
+
+class RecoveryTests(unittest.TestCase):
+ def recover(self, ready):
+ temp = tempfile.TemporaryDirectory()
+ self.addCleanup(temp.cleanup)
+ d=Path(temp.name); prefix=d/"prefix"; backup=d/"backup"; new=d/"new"
+ system=prefix/"drive_c/windows/system32"
+ system.mkdir(parents=True); backup.mkdir(); (new/"bin").mkdir(parents=True)
+ (new/"bin/wineserver").write_text("#!/bin/bash\nexit 0\n")
+ (new/"bin/wineserver").chmod(0o755)
+ (prefix/"user.reg").write_text("changed")
+ (system/"d3d11.dll").write_text("changed")
+ if ready:
+ (backup/"user.reg").write_text("original settings")
+ (backup/"d3d11.dll").write_text("original DLL")
+ (backup/"renderer-version").write_text("previous renderer")
+ script=(ROOT/"scripts/setup-steam-games.sh").read_text()
+ recovery=script[script.index("rollback(){"):script.index("trap rollback EXIT")]
+ subprocess.run(["/bin/bash", "-c", recovery+"\nfalse; rollback"], check=True,
+ env={**os.environ, "NEW":str(new), "BACKUP":str(backup), "BACKUP_READY":str(ready),
+ "WINEPREFIX":str(prefix), "B":str(prefix/"drive_c/windows")}, capture_output=True)
+ return prefix, system
+
+ def test_failed_setup_restores_settings_and_renderer(self):
+ prefix,system=self.recover(1)
+ self.assertEqual((prefix/"user.reg").read_text(),"original settings")
+ self.assertEqual((system/"d3d11.dll").read_text(),"original DLL")
+ self.assertEqual((prefix/".soju-steam-games").read_text(),"previous renderer")
+
+ def test_failed_backup_does_not_delete_original_files(self):
+ prefix,system=self.recover(0)
+ self.assertEqual((prefix/"user.reg").read_text(),"changed")
+ self.assertEqual((system/"d3d11.dll").read_text(),"changed")
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/test_regressions.py b/tests/test_regressions.py
index 2733a200b55..51c42ef09a1 100644
--- a/tests/test_regressions.py
+++ b/tests/test_regressions.py
@@ -262,7 +262,7 @@ sys.exit(7 if os.environ.get('FAIL_BUILD') == '1' else 0)
def test_installer_repairs_helpers_for_existing_clients(self):
src = (ROOT / "install.sh").read_text()
- stage = src[src.index('ALL="battlenet steam epic gog"'):
+ stage = src[src.index("# ---------- 3. Launchers ----------"):
src.index("# ---------- 4. App bundles")]
with tempfile.TemporaryDirectory(prefix="soju-test-") as t:
d = Path(t)
@@ -274,7 +274,7 @@ sys.exit(7 if os.environ.get('FAIL_BUILD') == '1' else 0)
(d/"scripts/ensure-launcher-helper.sh").write_text('echo "REPAIR $1"\n')
pre = ('set -euo pipefail\nBASE='+shlex.quote(t)+
'\nBOTTLE="$BASE/bottle"\nENGINE="$BASE/engine"\nSOJU_DIR="$BASE"'
- '\nSOJU_PLATFORMS=epic,gog\nsay(){ echo "$*"; }\n')
+ '\nPLATFORMS="epic gog"\nsay(){ echo "$*"; }\n')
x = run(pre+stage)
self.assertEqual(x.returncode, 0, x.stderr)
self.assertIn("REPAIR epic", x.stdout)