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