mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-20 14:10:51 +10:00
kdk_handler.py: Support passive mode
This commit is contained in:
@@ -50,12 +50,14 @@ class KernelDebugKitObject:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, constants: Constants, host_build: str, host_version: str, ignore_installed: bool = False):
|
def __init__(self, constants: Constants, host_build: str, host_version: str, ignore_installed: bool = False, passive: bool = False):
|
||||||
self.constants: Constants = constants
|
self.constants: Constants = constants
|
||||||
|
|
||||||
self.host_build: str = host_build # ex. 20A5384c
|
self.host_build: str = host_build # ex. 20A5384c
|
||||||
self.host_version: str = host_version # ex. 11.0.1
|
self.host_version: str = host_version # ex. 11.0.1
|
||||||
|
|
||||||
|
self.passive: bool = passive # Don't perform actions requiring elevated privileges
|
||||||
|
|
||||||
self.ignore_installed: bool = ignore_installed # If True, will ignore any installed KDKs and download the latest
|
self.ignore_installed: bool = ignore_installed # If True, will ignore any installed KDKs and download the latest
|
||||||
self.kdk_already_installed: bool = False
|
self.kdk_already_installed: bool = False
|
||||||
|
|
||||||
@@ -365,10 +367,16 @@ class KernelDebugKitObject:
|
|||||||
if not kdk_pkg.name.endswith(f"{match}.pkg"):
|
if not kdk_pkg.name.endswith(f"{match}.pkg"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
logging.info(f"- Found KDK backup, restoring: {kdk_pkg.name}")
|
logging.info(f"- Found KDK backup: {kdk_pkg.name}")
|
||||||
if KernelDebugKitUtilities().install_kdk_pkg(kdk_pkg):
|
if self.passive is False:
|
||||||
logging.info("- Successfully restored KDK")
|
logging.info("- Attempting KDK restoration")
|
||||||
return self._local_kdk_installed(match=match, check_version=check_version)
|
if KernelDebugKitUtilities().install_kdk_pkg(kdk_pkg):
|
||||||
|
logging.info("- Successfully restored KDK")
|
||||||
|
return self._local_kdk_installed(match=match, check_version=check_version)
|
||||||
|
else:
|
||||||
|
# When in passive mode, we're just checking if a KDK could be restored
|
||||||
|
logging.info("- KDK restoration skipped, running in passive mode")
|
||||||
|
return kdk_pkg
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -381,6 +389,9 @@ class KernelDebugKitObject:
|
|||||||
kdk_path (str): Path to KDK
|
kdk_path (str): Path to KDK
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if self.passive is True:
|
||||||
|
return
|
||||||
|
|
||||||
if os.getuid() != 0:
|
if os.getuid() != 0:
|
||||||
logging.warning("- Cannot remove KDK, not running as root")
|
logging.warning("- Cannot remove KDK, not running as root")
|
||||||
return
|
return
|
||||||
@@ -402,6 +413,9 @@ class KernelDebugKitObject:
|
|||||||
If None, defaults to host and closest match builds.
|
If None, defaults to host and closest match builds.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if self.passive is True:
|
||||||
|
return
|
||||||
|
|
||||||
if exclude_builds is None:
|
if exclude_builds is None:
|
||||||
exclude_builds = [
|
exclude_builds = [
|
||||||
self.kdk_url_build,
|
self.kdk_url_build,
|
||||||
|
|||||||
Reference in New Issue
Block a user