Skip to content

Commit 1abd9a7

Browse files
committed
main: Filter IPSWs to those supported by OS
Signed-off-by: Hector Martin <[email protected]>
1 parent 5d6418f commit 1abd9a7

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

src/main.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def action_install_into_container(self, avail_parts):
105105
idx = self.choice("Target container", containers)
106106
self.part = self.parts[int(idx)]
107107

108-
ipsw = self.choose_ipsw()
108+
ipsw = self.choose_ipsw(template.get("supported_fw", None))
109109
self.ins = stub.StubInstaller(self.sysinfo, self.dutil, self.osinfo, ipsw)
110110
self.osins = osinstall.OSInstaller(self.dutil, self.data, template)
111111
self.osins.load_package()
@@ -131,7 +131,7 @@ def action_install_into_free(self, avail_free):
131131
self.osins.name = label
132132
print()
133133

134-
ipsw = self.choose_ipsw()
134+
ipsw = self.choose_ipsw(template.get("supported_fw", None))
135135
self.ins = stub.StubInstaller(self.sysinfo, self.dutil, self.osinfo, ipsw)
136136

137137
print(f"Creating new stub macOS named {label}")
@@ -159,27 +159,32 @@ def do_install(self):
159159

160160
self.step2()
161161

162-
def choose_ipsw(self):
162+
def choose_ipsw(self, supported_fw=None):
163163
sys_iboot = split_ver(self.sysinfo.sys_firmware)
164164
sys_macos = split_ver(self.sysinfo.macos_ver)
165165
chip_min = split_ver(CHIP_MIN_VER.get(self.sysinfo.chip_id, "0"))
166166
device_min = split_ver(DEVICE_MIN_VER.get(self.sysinfo.device_class, "0"))
167-
avail = [ipsw for ipsw in IPSW_VERSIONS
167+
minver = [ipsw for ipsw in IPSW_VERSIONS
168+
if split_ver(ipsw.version) >= max(chip_min, device_min)
169+
and (supported_fw is None or ipsw.version in supported_fw)]
170+
avail = [ipsw for ipsw in minver
168171
if split_ver(ipsw.min_iboot) <= sys_iboot
169-
and split_ver(ipsw.min_macos) <= sys_macos
170-
and split_ver(ipsw.version) >= max(chip_min, device_min)]
172+
and split_ver(ipsw.min_macos) <= sys_macos]
171173

172174
if not avail:
173-
print("Your OS is too old.")
174-
print(f"You need to be running at least {IPSW_VERSIONS[0].version}.")
175+
print("Your system firmware is too old.")
176+
print(f"Please upgrade to macOS {minver[0].version} or newer.")
175177
sys.exit(1)
176178

177-
print("Choose the macOS version to use for boot firmware:")
178-
print("(If unsure, just press enter)")
179-
idx = self.choice("Version", [i.version for i in avail], len(avail)-1)
179+
if len(avail) > 1:
180+
print("Choose the macOS version to use for boot firmware:")
181+
print("(If unsure, just press enter)")
182+
idx = self.choice("Version", [i.version for i in avail], len(avail)-1)
183+
else:
184+
idx = 0
180185

181186
self.ipsw = ipsw = avail[idx]
182-
print(f"Using macOS {ipsw.version}")
187+
print(f"Using macOS {ipsw.version} for OS firmware")
183188
print()
184189

185190
return ipsw

0 commit comments

Comments
 (0)