Fix support for legacy bootable installers

This commit is contained in:
Nindi Gill 2023-06-13 17:41:25 +10:00
parent d2fb207499
commit 26b84e29c7
No known key found for this signature in database
GPG key ID: FF9A7FD590D4F4B1
2 changed files with 13 additions and 6 deletions

View file

@ -14,12 +14,19 @@ struct InstallMediaCreator {
/// Create the macOS Install Media at the specified mount point. /// Create the macOS Install Media at the specified mount point.
/// ///
/// - Parameters: /// - Parameters:
/// - url: The URL of the `createinstallmedia` binary to execute. /// - url: The URL of the `createinstallmedia` binary to execute.
/// - mountPoint: The URL of the mount point (target volume). /// - 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. /// - Throws: An `Error` if the command failed to execute.
static func create(_ url: URL, mountPoint: URL) async throws { static func create(_ url: URL, mountPoint: URL, sierraOrOlder: Bool) async throws {
let arguments: [String] = [url.path, "--volume", mountPoint.path, "--nointeraction"] 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 client: XPCClient = XPCClient.forMachService(named: .helperIdentifier)
let request: HelperToolCommandRequest = HelperToolCommandRequest(type: .createinstallmedia, arguments: arguments, environment: [:]) let request: HelperToolCommandRequest = HelperToolCommandRequest(type: .createinstallmedia, arguments: arguments, environment: [:])
let response: HelperToolCommandResponse = try await client.sendMessage(request, to: XPCRoute.commandRoute) let response: HelperToolCommandResponse = try await client.sendMessage(request, to: XPCRoute.commandRoute)

View file

@ -441,7 +441,7 @@ class TaskManager: ObservableObject {
try await DiskImageMounter.mount(temporaryImageURL, mountPoint: installer.temporaryISOMountPointURL) try await DiskImageMounter.mount(temporaryImageURL, mountPoint: installer.temporaryISOMountPointURL)
}, },
MistTask(type: .create, description: "macOS Installer in temporary Disk Image") { 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") { MistTask(type: .unmount, description: "temporary Disk Image") {
if FileManager.default.fileExists(atPath: installer.temporaryISOMountPointURL.path) { if FileManager.default.fileExists(atPath: installer.temporaryISOMountPointURL.path) {
@ -513,7 +513,7 @@ class TaskManager: ObservableObject {
let mountPointURL: URL = URL(fileURLWithPath: volume.path) let mountPointURL: URL = URL(fileURLWithPath: volume.path)
let tasks: [MistTask] = [ let tasks: [MistTask] = [
MistTask(type: .create, description: "Bootable Installer") { MistTask(type: .create, description: "Bootable Installer") {
try await InstallMediaCreator.create(createInstallMediaURL, mountPoint: mountPointURL) try await InstallMediaCreator.create(createInstallMediaURL, mountPoint: mountPointURL, sierraOrOlder: installer.sierraOrOlder)
} }
] ]