Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Merge upstream main into other-iphone-models

Jackybbf36000521c
diff --cc VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
index 4b687b96,ad450e11..6dc7162f
--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
@@@ -296,10 -359,26 +359,27 @@@ struct VPhoneCustomFirmwareInstaller
volumes: volumes,
work: work,
plan: plan,
+ priorGuest: priorGuest,
guestDevice: guestDevice(of: restore),
includeIdentity: mode == .full,
- boardDeviceTree: stageBoardDeviceTree(in: bundleDirectory, work: work),
- )
+ buildVersion: buildVersion,
+ boardDeviceTree: boardDeviceTree,
+ ))
+ // Selected patches this guest has nothing for, so the receipt does not
- // report them as missing forever: the board audio repair on an iPhone,
- // which has no board tree, and the build spoof with no value set. An
- // iPad whose board tree could not be recovered is not among them: its
- // repair is missing, and drift should keep saying so.
++ // report them as missing forever: the board audio repair on an
++ // iPhone17,3, which has no board tree, and the build spoof with no value
++ // set. A board-presenting guest whose board tree could not be recovered
++ // is not among them: its repair is missing, and drift should keep
++ // saying so.
+ var notApplicableGuest = Set<String>()
+ let device = configuredGuestDevice(in: bundleDirectory) ?? guestDevice(of: restore)
- if !device.isPad {
++ if !device.presentsBoard {
+ notApplicableGuest.insert(FirmwareGuestSystemPatchSet.prebootBoardAudio)
+ }
+ if buildVersion?.isEmpty ?? true {
+ notApplicableGuest.insert("system-systemversion-cfw-build_version")
+ }
+ notApplicableGuest.subtract(liveGuest)
// The snapshot rename is a full install's alone: it has already been
// done on any VM an environment update is allowed to run against, and
// this run creates no new snapshot to flip.
@@@ -1218,24 -1537,39 +1538,39 @@@
let identity = FirmwareGuestIdentityPatchSet.prebootDeviceTreeIdentity
var rewriteIdentity = false
if includeIdentity {
- if guestDevice.isPad {
+ if guestDevice.presentsBoard {
print(" [·] \(identity): skipped, the device tree already presents \(guestDevice.productType)")
} else {
- rewriteIdentity = on(identity)
+ rewriteIdentity = enabled(identity)
+ if !rewriteIdentity { print(" [·] \(identity): off in the current selection") }
}
+ } else if priorGuest.contains(identity) {
+ // An environment update does not touch the identity rewrite; if the
+ // last install wrote it, it is still live.
+ live.insert(identity)
}
- let spoofBuild = includeIdentity ? spoofBuild : nil
- var repairs: [(verb: String, arguments: [String])] = []
- if let boardDeviceTree, on(FirmwareGuestSystemPatchSet.prebootBoardAudio) {
- repairs.append(("patch-dt-board-audio", [boardDeviceTree.path]))
- }
- if on(FirmwareGuestSystemPatchSet.prebootHaptics) {
- repairs.append(("patch-dt-haptics", []))
+
+ // The repairs, which share the one devicetree.img4.
+ var repairGroup: [(id: String, verb: String, arguments: [String])] = []
+ if let boardDeviceTree {
+ repairGroup.append((FirmwareGuestSystemPatchSet.prebootBoardAudio, "patch-dt-board-audio", [boardDeviceTree.path]))
}
- if on(FirmwareGuestSystemPatchSet.prebootMicrophoneArray) {
- repairs.append(("patch-dt-microphone-array", []))
+ repairGroup.append((FirmwareGuestSystemPatchSet.prebootHaptics, "patch-dt-haptics", []))
+ repairGroup.append((FirmwareGuestSystemPatchSet.prebootMicrophoneArray, "patch-dt-microphone-array", []))
+ let repairsOn = repairGroup.filter { enabled($0.id) }
+ for off in repairGroup where !enabled(off.id) {
+ print(" [·] \(off.id): off in the current selection")
}
- guard rewriteIdentity || !repairs.isEmpty || !(spoofBuild ?? "").isEmpty else { return }
+
+ let buildID = "system-systemversion-cfw-build_version"
+
+ // Mount only when there is device-tree work to do, a repair to revert,
+ // or a build spoof to apply or revert.
+ let mayRevertRepair = repairGroup.contains { !enabled($0.id) && priorGuest.contains($0.id) }
+ let wantsBuild = (buildVersion.map { !$0.isEmpty } ?? false) && enabled(buildID)
+ let touchesBuild = wantsBuild || priorGuest.contains(buildID)
+ guard rewriteIdentity || !repairsOn.isEmpty || mayRevertRepair || touchesBuild else { return live }
+
guard
let preboot = volumes.first(where: { ($0["Roles"] as? [String])?.contains("Preboot") == true }),
let device = preboot["DeviceIdentifier"] as? String