Skip to content

Commit 8e04434

Browse files
authored
Enhance KDK matching logic for version compatibility
Refactor logic to find closest KDK version, including checks for beta versions and build compatibility.
1 parent 2a25921 commit 8e04434

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

oclp_r/support/kdk_handler.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,17 @@ def _get_latest_kdk(self, host_build: str = None, host_version: str = None) -> N
226226
count_kdks.sort(key=lambda x: x["build"], reverse=True)
227227
closest = None
228228
for kdk in count_kdks:
229-
if kdk["build"][-1]>="a" and kdk["build"][-1]<="z":
230-
logging.info(self.trans["This is macOS beta's KDK"])
231-
if kdk["build"][2] <= host_build[2]:
232-
closest = kdk
229+
# Need same version (example: 26.3==26.3 -> 26D==26D)
230+
if kdk["build"][0:3] == host_build[0:3]:
231+
# We need to check beta versions
232+
if kdk["build"][-1]>="a" and kdk["build"][-1]<="z":
233+
# example: 25D5087f -> macOS 26.3 Beta
234+
# earlier than 25D125
235+
logging.info(self.trans["This is macOS beta's KDK"])
236+
closest=kdk
237+
break
238+
elif kdk["build"][0:2] == host_build[0:2] and ord(kdk["build"][2])-1==ord(host_build[2]):
239+
closest=kdk
233240
break
234241
if closest is None:
235242
closest = count_kdks[-1]
@@ -702,4 +709,4 @@ def _create_backup(self, kdk_path: Path, kdk_info_plist: Path) -> None:
702709
result = subprocess_wrapper.run_as_root(generate_copy_arguments(kdk_path, kdk_dst_path), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
703710
if result.returncode != 0:
704711
logging.info(self.trans["Failed to create KDK backup:"])
705-
subprocess_wrapper.log(result)
712+
subprocess_wrapper.log(result)

0 commit comments

Comments
 (0)