Feature shrink isos (#63)

* Resize / shrink ISOs

* Move correct ISO file

* Fix DMG volume name
This commit is contained in:
Nindi Gill 2023-06-22 18:57:38 +10:00 committed by GitHub
parent cf4e070fa4
commit 0100c1606f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 5 deletions

View file

@ -24,7 +24,9 @@ struct DiskImageCreator {
"-fs", "JHFS+",
"-layout", "SPUD",
"-size", "\(size)g",
"-volname", url.lastPathComponent.replacingOccurrences(of: ".dmg", with: ""),
"-volname", url
.lastPathComponent.replacingOccurrences(of: ".resized", with: "")
.replacingOccurrences(of: ".dmg", with: ""),
url.path
]
try await create(url, with: arguments)
@ -43,7 +45,9 @@ struct DiskImageCreator {
"hdiutil", "create",
"-fs", "HFS+",
"-srcFolder", source.path,
"-volname", url.lastPathComponent.replacingOccurrences(of: ".dmg", with: ""),
"-volname", url
.lastPathComponent.replacingOccurrences(of: ".resized", with: "")
.replacingOccurrences(of: ".dmg", with: ""),
url.path
]
try await create(url, with: arguments)

View file

@ -430,6 +430,7 @@ class TaskManager: ObservableObject {
let temporaryImageURL: URL = temporaryDirectoryURL.appendingPathComponent("\(installer.id).dmg")
let createInstallMediaURL: URL = installer.temporaryInstallerURL.appendingPathComponent("/Contents/Resources/createinstallmedia")
let temporaryResizedImageURL: URL = temporaryDirectoryURL.appendingPathComponent("\(installer.id).resized.dmg")
let temporaryCDRURL: URL = temporaryDirectoryURL.appendingPathComponent("\(installer.id).cdr")
let isoURL: URL = destinationURL.appendingPathComponent(filename.stringWithSubstitutions(name: installer.name, version: installer.version, build: installer.build))
@ -443,6 +444,9 @@ class TaskManager: ObservableObject {
MistTask(type: .create, description: "macOS Installer in temporary Disk Image") {
try await InstallMediaCreator.create(createInstallMediaURL, mountPoint: installer.temporaryISOMountPointURL, sierraOrOlder: installer.sierraOrOlder)
},
MistTask(type: .create, description: "resized Disk Image") {
try await DiskImageCreator.create(temporaryResizedImageURL, from: installer.temporaryISOMountPointURL)
},
MistTask(type: .unmount, description: "temporary Disk Image") {
if FileManager.default.fileExists(atPath: installer.temporaryISOMountPointURL.path) {
try await DiskImageUnmounter.unmount(installer.temporaryISOMountPointURL)
@ -458,11 +462,14 @@ class TaskManager: ObservableObject {
try await DiskImageUnmounter.unmount(url)
}
},
MistTask(type: .convert, description: "temporary Disk Image to ISO") {
try await ISOConverter.convert(temporaryImageURL, destination: temporaryCDRURL)
MistTask(type: .remove, description: "temporary Disk Image") {
try FileManager.default.removeItem(at: temporaryImageURL)
},
MistTask(type: .convert, description: "resized Disk Image to ISO") {
try await ISOConverter.convert(temporaryResizedImageURL, destination: temporaryCDRURL)
},
MistTask(type: .save, description: "ISO to destination") {
try await FileMover.move(temporaryImageURL, to: isoURL)
try await FileMover.move(temporaryCDRURL, to: isoURL)
}
]
}