diff --git a/Mist/Helpers/InstallerCreator.swift b/Mist/Helpers/InstallerCreator.swift index 37a9f35..e5b5aef 100644 --- a/Mist/Helpers/InstallerCreator.swift +++ b/Mist/Helpers/InstallerCreator.swift @@ -19,6 +19,7 @@ enum InstallerCreator { /// /// - Throws: A `MistError` if the downloaded macOS Installer fails to generate. static func create(_ installer: Installer, mountPoint: URL, cacheDirectory: String) async throws { + let installerCacheDirectoryURL = URL(fileURLWithPath: cacheDirectory).appendingPathComponent(installer.id) let packageURL: URL if installer.sierraOrOlder { @@ -29,36 +30,61 @@ enum InstallerCreator { packageURL = URL(fileURLWithPath: "/Volumes/Install \(installer.name)").appendingPathComponent(package.filename.replacingOccurrences(of: ".dmg", with: ".pkg")) } else { if installer.containsInstallAssistantPackage { - packageURL = URL(fileURLWithPath: cacheDirectory).appendingPathComponent(installer.id).appendingPathComponent("InstallAssistant.pkg") + packageURL = installerCacheDirectoryURL.appendingPathComponent("InstallAssistant.pkg") + } else if installer.containsInstallAssistantAutoPackage { + packageURL = installerCacheDirectoryURL.appendingPathComponent("InstallAssistantAuto.pkg") } else { guard let url: URL = URL(string: installer.distributionURL) else { throw MistError.invalidURL(installer.distributionURL) } - packageURL = URL(fileURLWithPath: cacheDirectory).appendingPathComponent(installer.id).appendingPathComponent(url.lastPathComponent) + packageURL = installerCacheDirectoryURL.appendingPathComponent(url.lastPathComponent) } } try await DirectoryRemover.remove(installer.temporaryInstallerURL) - var argumentsArrays: [[String]] = [ - ["installer", "-pkg", packageURL.path, "-target", mountPoint.path] - ] - - // workaround for macOS High Sierra 10.13, macOS Mojave 10.14 and macOS Catalina 10.15 - if installer.highSierraOrNewer, !installer.bigSurOrNewer { + var argumentsArrays: [[String]] = [] + + let osVersion = ProcessInfo.processInfo.operatingSystemVersion + if + installer.highSierraOrNewer, !installer.bigSurOrNewer, + (osVersion.majorVersion > 15 || (osVersion.majorVersion == 15 && osVersion.minorVersion >= 6)) { + // Use special method for macOS >= 15.6 + let installAssistantExpansionDirectory = installerCacheDirectoryURL.appendingPathComponent("InstallAssistantAuto") + let payloadInstallerApp = installAssistantExpansionDirectory.appendingPathComponent("Payload/Install \(installer.name).app") + let sharedSupportDirectory = payloadInstallerApp.appendingPathComponent("Contents/SharedSupport") argumentsArrays += [ - ["ditto", "/Applications/Install \(installer.name).app", "\(mountPoint.path)/Applications/Install \(installer.name).app"], - ["rm", "-r", "/Applications/Install \(installer.name).app"] + ["pkgutil", "--expand-full", packageURL.path, installAssistantExpansionDirectory.path], + ["cp", installerCacheDirectoryURL.appendingPathComponent("AppleDiagnostics.chunklist").path, sharedSupportDirectory.path], + ["cp", installerCacheDirectoryURL.appendingPathComponent("AppleDiagnostics.dmg").path, sharedSupportDirectory.path], + ["cp", installerCacheDirectoryURL.appendingPathComponent("BaseSystem.chunklist").path, sharedSupportDirectory.path], + ["cp", installerCacheDirectoryURL.appendingPathComponent("BaseSystem.dmg").path, sharedSupportDirectory.path], + ["cp", installerCacheDirectoryURL.appendingPathComponent("InstallESDDmg.pkg").path, sharedSupportDirectory.appendingPathComponent("InstallESD.dmg").path], + ["ditto", payloadInstallerApp.path, mountPoint.appendingPathComponent("Applications").appendingPathComponent("Install \(installer.name).app").path], + ["rm", "-r", installAssistantExpansionDirectory.path] ] - } - - // workaround for macOS Catalina 10.15 and newer - if installer.catalinaOrNewer { + } else { + // Use /usr/sbin/installer for macOS < 15.6 argumentsArrays += [ - ["ditto", "\(mountPoint.path)Applications", "\(mountPoint.path)/Applications"], - ["rm", "-r", "\(mountPoint.path)Applications"] + ["installer", "-pkg", packageURL.path, "-target", mountPoint.path] ] + + // workaround for macOS High Sierra 10.13, macOS Mojave 10.14 and macOS Catalina 10.15 + if installer.highSierraOrNewer, !installer.bigSurOrNewer { + argumentsArrays += [ + ["ditto", "/Applications/Install \(installer.name).app", "\(mountPoint.path)/Applications/Install \(installer.name).app"], + ["rm", "-r", "/Applications/Install \(installer.name).app"] + ] + } + + // workaround for macOS Catalina 10.15 and newer + if installer.catalinaOrNewer { + argumentsArrays += [ + ["ditto", "\(mountPoint.path)Applications", "\(mountPoint.path)/Applications"], + ["rm", "-r", "\(mountPoint.path)Applications"] + ] + } } let variables: [String: String] = ["CM_BUILD": "CM_BUILD"] diff --git a/Mist/Model/Installer.swift b/Mist/Model/Installer.swift index e37cc85..d702cd4 100644 --- a/Mist/Model/Installer.swift +++ b/Mist/Model/Installer.swift @@ -740,6 +740,10 @@ struct Installer: Decodable, Hashable, Identifiable { var containsInstallAssistantPackage: Bool { packages.contains { $0.filename == "InstallAssistant.pkg" } } + + var containsInstallAssistantAutoPackage: Bool { + packages.contains { $0.filename == "InstallAssistantAuto.pkg" } + } var temporaryDiskImageMountPointURL: URL { URL(fileURLWithPath: "/Volumes/\(id)")