mirror of
https://github.com/ninxsoft/Mist.git
synced 2025-05-14 15:15:05 -04:00
Skip package creation for macOS 11+
This commit is contained in:
parent
3a79a93c11
commit
91f7f7f454
4 changed files with 13 additions and 138 deletions
|
@ -121,7 +121,6 @@
|
|||
39CF56312862A8C5006FB5D2 /* InstallMediaCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39CF56302862A8C5006FB5D2 /* InstallMediaCreator.swift */; };
|
||||
39CF56332862B7A2006FB5D2 /* PackageCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39CF56322862B7A2006FB5D2 /* PackageCreator.swift */; };
|
||||
39CF56352862D4BF006FB5D2 /* FileCompressor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39CF56342862D4BF006FB5D2 /* FileCompressor.swift */; };
|
||||
39CF56372862D580006FB5D2 /* FileSplitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39CF56362862D580006FB5D2 /* FileSplitter.swift */; };
|
||||
39CF56392862D75D006FB5D2 /* FileCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39CF56382862D75D006FB5D2 /* FileCreator.swift */; };
|
||||
39D68B892861369B00A7848C /* InstallerCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39D68B882861369B00A7848C /* InstallerCreator.swift */; };
|
||||
39FF05EE2859820900A86670 /* AppCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39FF05ED2859820900A86670 /* AppCommands.swift */; };
|
||||
|
@ -260,7 +259,6 @@
|
|||
39CF56302862A8C5006FB5D2 /* InstallMediaCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallMediaCreator.swift; sourceTree = "<group>"; };
|
||||
39CF56322862B7A2006FB5D2 /* PackageCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PackageCreator.swift; sourceTree = "<group>"; };
|
||||
39CF56342862D4BF006FB5D2 /* FileCompressor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileCompressor.swift; sourceTree = "<group>"; };
|
||||
39CF56362862D580006FB5D2 /* FileSplitter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileSplitter.swift; sourceTree = "<group>"; };
|
||||
39CF56382862D75D006FB5D2 /* FileCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileCreator.swift; sourceTree = "<group>"; };
|
||||
39D68B882861369B00A7848C /* InstallerCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallerCreator.swift; sourceTree = "<group>"; };
|
||||
39FF05ED2859820900A86670 /* AppCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppCommands.swift; sourceTree = "<group>"; };
|
||||
|
@ -365,7 +363,6 @@
|
|||
39CF56342862D4BF006FB5D2 /* FileCompressor.swift */,
|
||||
39CF56162861BE66006FB5D2 /* FileCopier.swift */,
|
||||
398734C728601FFC00B4C357 /* FileMover.swift */,
|
||||
39CF56362862D580006FB5D2 /* FileSplitter.swift */,
|
||||
39D68B882861369B00A7848C /* InstallerCreator.swift */,
|
||||
39CF56302862A8C5006FB5D2 /* InstallMediaCreator.swift */,
|
||||
39CF562E2862A797006FB5D2 /* ISOConverter.swift */,
|
||||
|
@ -770,7 +767,6 @@
|
|||
390451C22856E3F500E0B563 /* Hardware.swift in Sources */,
|
||||
39CF56092861AE7F006FB5D2 /* HelperToolCommandRequest.swift in Sources */,
|
||||
390451C82856E94900E0B563 /* FirmwareListRow.swift in Sources */,
|
||||
39CF56372862D580006FB5D2 /* FileSplitter.swift in Sources */,
|
||||
39CF4E732859C03D009E708C /* CatalogRow.swift in Sources */,
|
||||
390451E528574F0000E0B563 /* Catalog.swift in Sources */,
|
||||
3935F4852866B64900760AB0 /* MistTaskSection.swift in Sources */,
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
//
|
||||
// FileSplitter.swift
|
||||
// Mist
|
||||
//
|
||||
// Created by Nindi Gill on 22/6/2022.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Helper struct to split files into chunks.
|
||||
struct FileSplitter {
|
||||
|
||||
/// Split a file into chunks with the provided filename prefix.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - url: The URL of the file to be split.
|
||||
/// - currentDirectory: The directory in which to create the split files.
|
||||
/// - prefix: The filename prefix for the split files.
|
||||
///
|
||||
/// - Throws: An `Error` if the command failed to execute.
|
||||
static func split(_ url: URL, from currentDirectory: URL, prefix: String) async throws {
|
||||
let fileSize: UInt64 = try url.fileSize()
|
||||
let factor: UInt64 = 100
|
||||
let chunkSize: UInt64 = 1_024 * 1_024 * factor // 100 MB
|
||||
let totalFileChunks: UInt64 = UInt64(ceil(Double(fileSize) / Double(chunkSize)))
|
||||
let standardFileChunks: UInt64 = 8_000 / factor // 8000 MB
|
||||
let lastFileChunks: UInt64 = totalFileChunks % standardFileChunks
|
||||
let numberOfFiles: Int = Int(ceil((Double(totalFileChunks) / Double(standardFileChunks))))
|
||||
let readHandle: FileHandle = try FileHandle(forReadingFrom: url)
|
||||
|
||||
for file in 0..<numberOfFiles {
|
||||
let isLastFile: Bool = file == numberOfFiles - 1
|
||||
let numberOfChunks: UInt64 = isLastFile ? lastFileChunks : standardFileChunks
|
||||
let destination: URL = currentDirectory.appendingPathComponent("\(prefix)\(file)")
|
||||
try await DirectoryRemover.remove(destination)
|
||||
try Data().write(to: destination)
|
||||
let writeHandle: FileHandle = try FileHandle(forWritingTo: destination)
|
||||
var writeOffset: UInt64 = 0
|
||||
|
||||
for chunk in 0..<numberOfChunks {
|
||||
try Task.checkCancellation()
|
||||
try autoreleasepool {
|
||||
let readOffset: UInt64 = UInt64(file) * standardFileChunks * chunkSize + UInt64(chunk) * chunkSize
|
||||
try readHandle.seek(toOffset: readOffset)
|
||||
try writeHandle.seek(toOffset: writeOffset)
|
||||
let data: Data = readHandle.readData(ofLength: Int(chunkSize))
|
||||
try writeHandle.write(contentsOf: data)
|
||||
writeOffset += chunkSize
|
||||
}
|
||||
}
|
||||
|
||||
try writeHandle.close()
|
||||
}
|
||||
|
||||
readHandle.closeFile()
|
||||
}
|
||||
}
|
|
@ -203,7 +203,7 @@ class TaskManager: ObservableObject {
|
|||
(
|
||||
section: .package,
|
||||
// swiftlint:disable:next line_length
|
||||
tasks: packageTasks(for: installer, filename: packageFilename, identifier: packageIdentifier, sign: packageSign, identity: packageSigningIdentity, destination: destinationURL, temporaryDirectory: temporaryDirectoryURL)
|
||||
tasks: packageTasks(for: installer, filename: packageFilename, identifier: packageIdentifier, sign: packageSign, identity: packageSigningIdentity, destination: destinationURL, temporaryDirectory: temporaryDirectoryURL, cacheDirectory: cacheDirectoryURL)
|
||||
)
|
||||
]
|
||||
}
|
||||
|
@ -371,66 +371,36 @@ class TaskManager: ObservableObject {
|
|||
sign packageSign: Bool,
|
||||
identity packageSigningIdentity: String,
|
||||
destination destinationURL: URL,
|
||||
temporaryDirectory temporaryDirectoryURL: URL
|
||||
temporaryDirectory temporaryDirectoryURL: URL,
|
||||
cacheDirectory cacheDirectoryURL: URL
|
||||
) -> [MistTask] {
|
||||
|
||||
let temporaryPackageURL: URL = temporaryDirectoryURL.appendingPathComponent("\(installer.id).pkg")
|
||||
let identifier: String = packageIdentifier.stringWithSubstitutions(name: installer.name, version: installer.version, build: installer.build).replacingOccurrences(of: " ", with: "-")
|
||||
let packageURL: URL = destinationURL.appendingPathComponent(filename.stringWithSubstitutions(name: installer.name, version: installer.version, build: installer.build))
|
||||
let identity: String? = (packageSign && !packageSigningIdentity.isEmpty && packageSigningIdentity != "-") ? packageSigningIdentity : nil
|
||||
var tasks: [MistTask] = []
|
||||
|
||||
if installer.bigSurOrNewer {
|
||||
let packageDirectoryURL: URL = temporaryDirectoryURL.appendingPathComponent(installer.id)
|
||||
let payloadDirectoryURL: URL = packageDirectoryURL.appendingPathComponent("Payload")
|
||||
let zipURL: URL = temporaryDirectoryURL.appendingPathComponent("\(installer.id).zip")
|
||||
let splitPrefix: String = "\(installer.id).zip."
|
||||
let scriptsDirectoryURL: URL = packageDirectoryURL.appendingPathComponent("Scripts")
|
||||
let postinstallURL: URL = scriptsDirectoryURL.appendingPathComponent("postinstall")
|
||||
let scriptPermissions: Int = 0o755
|
||||
let sourceURL: URL = cacheDirectoryURL.appendingPathComponent("InstallAssistant.pkg")
|
||||
|
||||
tasks = [
|
||||
MistTask(type: .configure, description: "temporary Package directory") {
|
||||
try await DirectoryCreator.create(packageDirectoryURL)
|
||||
},
|
||||
MistTask(type: .compress, description: "macOS Installer") {
|
||||
try await FileCompressor.compress(installer.temporaryInstallerURL, to: zipURL)
|
||||
},
|
||||
MistTask(type: .configure, description: "temporary Payload directory") {
|
||||
try await DirectoryCreator.create(payloadDirectoryURL)
|
||||
},
|
||||
MistTask(type: .split, description: "compressed macOS Installer") {
|
||||
try await FileSplitter.split(zipURL, from: payloadDirectoryURL, prefix: splitPrefix)
|
||||
},
|
||||
MistTask(type: .remove, description: "compressed macOS Installer") {
|
||||
try await DirectoryRemover.remove(zipURL)
|
||||
},
|
||||
MistTask(type: .configure, description: "temporary Scripts directory") {
|
||||
try await DirectoryCreator.create(scriptsDirectoryURL)
|
||||
},
|
||||
MistTask(type: .create, description: "Postinstall Script") {
|
||||
try await FileCreator.create(postinstallURL, contents: installer.postinstall, permissions: scriptPermissions)
|
||||
},
|
||||
MistTask(type: .create, description: "Package") {
|
||||
try await PackageCreator.create(temporaryPackageURL, from: installer, identifier: identifier, root: payloadDirectoryURL, scripts: scriptsDirectoryURL, identity: identity)
|
||||
},
|
||||
MistTask(type: .remove, description: "temporary Package directory") {
|
||||
try await DirectoryRemover.remove(packageDirectoryURL)
|
||||
MistTask(type: .save, description: "Package to destination") {
|
||||
try await FileCopier.copy(sourceURL, to: packageURL)
|
||||
}
|
||||
]
|
||||
} else {
|
||||
let temporaryPackageURL: URL = temporaryDirectoryURL.appendingPathComponent("\(installer.id).pkg")
|
||||
let identifier: String = packageIdentifier.stringWithSubstitutions(name: installer.name, version: installer.version, build: installer.build).replacingOccurrences(of: " ", with: "-")
|
||||
let identity: String? = (packageSign && !packageSigningIdentity.isEmpty && packageSigningIdentity != "-") ? packageSigningIdentity : nil
|
||||
|
||||
tasks = [
|
||||
MistTask(type: .create, description: "Package") {
|
||||
try await PackageCreator.create(temporaryPackageURL, from: installer, identifier: identifier, identity: identity)
|
||||
},
|
||||
MistTask(type: .save, description: "Package to destination") {
|
||||
try await FileMover.move(temporaryPackageURL, to: packageURL)
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
tasks += [
|
||||
MistTask(type: .save, description: "Package to destination") {
|
||||
try await FileMover.move(temporaryPackageURL, to: packageURL)
|
||||
}
|
||||
]
|
||||
return tasks
|
||||
}
|
||||
|
||||
|
|
|
@ -168,40 +168,6 @@ struct Installer: Decodable, Hashable, Identifiable {
|
|||
var isoSize: Double {
|
||||
ceil(Double(size) / Double(UInt64.gigabyte)) + 1.5
|
||||
}
|
||||
var postinstall: String {
|
||||
"""
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
PRODUCT="\(id)"
|
||||
TEMP_DIR="\(String.temporaryDirectory)/$PRODUCT"
|
||||
ZIP="$TEMP_DIR/$PRODUCT.zip"
|
||||
APPS_DIR="/Applications"
|
||||
APP="$APPS_DIR/Install \(name).app"
|
||||
|
||||
# merge the split zip files
|
||||
cat "$ZIP."* > "$ZIP"
|
||||
|
||||
# remove installer app if it already exists
|
||||
if [[ -d "$APP" ]] ; then
|
||||
rm -rf "$APP"
|
||||
fi
|
||||
|
||||
# unpack the app bundle
|
||||
ditto -x -k "$ZIP" "$APPS_DIR"
|
||||
|
||||
# cleanup
|
||||
rm -rf "$TEMP_DIR"
|
||||
|
||||
# change ownership and permissions
|
||||
chown -R root:wheel "$APP"
|
||||
chmod -R 755 "$APP"
|
||||
|
||||
exit 0
|
||||
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
extension Installer: Equatable {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue