mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-19 22:00:00 +10:00
kdk_handler.py: Clear out backup KDKs when unused
This commit is contained in:
@@ -10,6 +10,8 @@
|
|||||||
- Implement Kernel Debug Kit installation during OS installs
|
- Implement Kernel Debug Kit installation during OS installs
|
||||||
- Avoids network requirement for first time installs
|
- Avoids network requirement for first time installs
|
||||||
- Paired along side AutoPkgInstaller
|
- Paired along side AutoPkgInstaller
|
||||||
|
- Implement Kernel Debug Kit backup system
|
||||||
|
- Allows for easy restoration of KDKs if OS updates corrupted installed KDKs
|
||||||
- Backend Changes:
|
- Backend Changes:
|
||||||
- Refactored kdk_handler.py
|
- Refactored kdk_handler.py
|
||||||
- Prioritizes KdkSupportPkg repository for downloads
|
- Prioritizes KdkSupportPkg repository for downloads
|
||||||
|
|||||||
@@ -399,7 +399,15 @@ class KernelDebugKitObject:
|
|||||||
logging.warning("- Cannot remove KDK, not running as root")
|
logging.warning("- Cannot remove KDK, not running as root")
|
||||||
return
|
return
|
||||||
|
|
||||||
result = utilities.elevated(["rm", "-rf", kdk_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
if not Path(kdk_path).exists():
|
||||||
|
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]
|
||||||
|
|
||||||
|
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')}")
|
||||||
@@ -434,10 +442,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.is_dir():
|
||||||
if kdk_folder.name.endswith(".kdk"):
|
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 != "" and kdk_folder.name.endswith(f"{build}.kdk"):
|
if build != "":
|
||||||
|
continue
|
||||||
|
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:
|
||||||
|
|||||||
Reference in New Issue
Block a user