diff --git a/Mist/Helpers/InstallMediaCreator.swift b/Mist/Helpers/InstallMediaCreator.swift index 7f20f20..203700e 100644 --- a/Mist/Helpers/InstallMediaCreator.swift +++ b/Mist/Helpers/InstallMediaCreator.swift @@ -14,12 +14,19 @@ struct InstallMediaCreator { /// Create the macOS Install Media at the specified mount point. /// /// - Parameters: - /// - url: The URL of the `createinstallmedia` binary to execute. - /// - mountPoint: The URL of the mount point (target volume). + /// - url: The URL of the `createinstallmedia` binary to execute. + /// - mountPoint: The URL of the mount point (target volume). + /// - sierraOrOlder: `true` if the installer is macOS Sierra or older, otherwise `false`. /// /// - Throws: An `Error` if the command failed to execute. - static func create(_ url: URL, mountPoint: URL) async throws { - let arguments: [String] = [url.path, "--volume", mountPoint.path, "--nointeraction"] + static func create(_ url: URL, mountPoint: URL, sierraOrOlder: Bool) async throws { + var arguments: [String] = [url.path, "--volume", mountPoint.path, "--nointeraction"] + + if sierraOrOlder { + let applicationPath: String = url.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent().path + arguments += ["--applicationpath", applicationPath] + } + let client: XPCClient = XPCClient.forMachService(named: .helperIdentifier) let request: HelperToolCommandRequest = HelperToolCommandRequest(type: .createinstallmedia, arguments: arguments, environment: [:]) let response: HelperToolCommandResponse = try await client.sendMessage(request, to: XPCRoute.commandRoute) diff --git a/Mist/Helpers/TaskManager.swift b/Mist/Helpers/TaskManager.swift index cae90d3..36232c4 100644 --- a/Mist/Helpers/TaskManager.swift +++ b/Mist/Helpers/TaskManager.swift @@ -441,7 +441,7 @@ class TaskManager: ObservableObject { try await DiskImageMounter.mount(temporaryImageURL, mountPoint: installer.temporaryISOMountPointURL) }, MistTask(type: .create, description: "macOS Installer in temporary Disk Image") { - try await InstallMediaCreator.create(createInstallMediaURL, mountPoint: installer.temporaryISOMountPointURL) + try await InstallMediaCreator.create(createInstallMediaURL, mountPoint: installer.temporaryISOMountPointURL, sierraOrOlder: installer.sierraOrOlder) }, MistTask(type: .unmount, description: "temporary Disk Image") { if FileManager.default.fileExists(atPath: installer.temporaryISOMountPointURL.path) { @@ -513,7 +513,7 @@ class TaskManager: ObservableObject { let mountPointURL: URL = URL(fileURLWithPath: volume.path) let tasks: [MistTask] = [ MistTask(type: .create, description: "Bootable Installer") { - try await InstallMediaCreator.create(createInstallMediaURL, mountPoint: mountPointURL) + try await InstallMediaCreator.create(createInstallMediaURL, mountPoint: mountPointURL, sierraOrOlder: installer.sierraOrOlder) } ]