kdk_handler.py: Fix pkg detection

This commit is contained in:
Mykola Grymalyuk
2023-03-25 10:36:23 -06:00
parent 462fff9d66
commit 29d3e98b81

View File

@@ -448,14 +448,13 @@ class KernelDebugKitObject:
logging.warning(f"- KDK does not exist: {kdk_path}")
return
rm_args = ["rm", "-f", kdk_path]
if Path(kdk_path).is_dir():
rm_args = ["rm", "-rf", kdk_path]
rm_args = ["rm", "-rf" if Path(kdk_path).is_dir() else "-f", kdk_path]
result = utilities.elevated(rm_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if result.returncode != 0:
logging.warning(f"- Failed to remove KDK: {kdk_path}")
logging.warning(f"- {result.stdout.decode('utf-8')}")
return
logging.info(f"- Successfully removed KDK: {kdk_path}")
@@ -486,18 +485,17 @@ class KernelDebugKitObject:
logging.info("- Cleaning unused KDKs")
for kdk_folder in Path(KDK_INSTALL_PATH).iterdir():
if kdk_folder.is_dir():
if kdk_folder.name.endswith(".kdk") or kdk_folder.name.endswith(".pkg"):
should_remove = True
for build in exclude_builds:
if build != "":
continue
if kdk_folder.name.endswith(f"{build}.kdk") or kdk_folder.name.endswith(f"{build}.pkg"):
should_remove = False
break
if should_remove is False:
if kdk_folder.name.endswith(".kdk") or kdk_folder.name.endswith(".pkg"):
should_remove = True
for build in exclude_builds:
if build != "":
continue
self._remove_kdk(kdk_folder)
if kdk_folder.name.endswith(f"_{build}.kdk") or kdk_folder.name.endswith(f"_{build}.pkg"):
should_remove = False
break
if should_remove is False:
continue
self._remove_kdk(kdk_folder)
def validate_kdk_checksum(self, kdk_dmg_path: str = None) -> bool: