boot: validate --install-ipa before startup

This commit is contained in:
tastyheadphones
2026-03-20 11:08:47 +09:00
committed by zqxwce
parent 20d3f1a217
commit a36b797a6e

View File

@@ -45,7 +45,7 @@ struct VPhoneBootCLI: ParsableCommand {
var vphonedBin: String = ".vphoned.signed"
@Option(
help: "Automatically install the given IPA/TIPA after the guest control channel connects.",
help: "Automatically install the given IPA/TIPA after the guest control channel connects. Unavailable with --dfu.",
transform: URL.init(fileURLWithPath:)
)
var installIPA: URL?
@@ -59,6 +59,26 @@ struct VPhoneBootCLI: ParsableCommand {
installIPA?.standardizedFileURL
}
mutating func validate() throws {
if dfu, let packageURL = installPackageURL {
throw ValidationError(
"`--install-ipa` is unavailable with `--dfu` because DFU mode does not start the guest control channel: \(packageURL.path)"
)
}
guard let packageURL = installPackageURL else { return }
guard FileManager.default.fileExists(atPath: packageURL.path) else {
throw ValidationError("`--install-ipa` file does not exist: \(packageURL.path)")
}
guard VPhoneInstallPackage.isSupportedFile(packageURL) else {
throw ValidationError(
"`--install-ipa` only supports .ipa or .tipa packages: \(packageURL.lastPathComponent)"
)
}
}
/// Resolve final options by merging manifest values.
func resolveOptions() throws -> VPhoneVirtualMachine.Options {
let manifest = try VPhoneVirtualMachineManifest.load(from: config)