Skip to content

Commit

Permalink
kdk_handler.py: Fix pkg detection
Browse files Browse the repository at this point in the history
  • Loading branch information
khronokernel committed Mar 25, 2023
1 parent 462fff9 commit 29d3e98
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions resources/kdk_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,14 +448,13 @@ def _remove_kdk(self, kdk_path: str) -> None:
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}")

Expand Down Expand Up @@ -486,18 +485,17 @@ def _remove_unused_kdks(self, exclude_builds: list = None) -> None:

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:
Expand Down

0 comments on commit 29d3e98

Please sign in to comment.