From d57a758c73a42b49af8c30c28a812a8a7095353f Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Thu, 26 Oct 2023 10:02:19 -0600 Subject: [PATCH] kdk_handler.py: Add support for optional backup without installation --- resources/kdk_handler.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/resources/kdk_handler.py b/resources/kdk_handler.py index fd31b27e2..7891b827a 100644 --- a/resources/kdk_handler.py +++ b/resources/kdk_handler.py @@ -587,7 +587,7 @@ class KernelDebugKitUtilities: return True - def install_kdk_dmg(self, kdk_path: Path) -> bool: + def install_kdk_dmg(self, kdk_path: Path, only_install_backup: bool = False) -> bool: """ Installs provided KDK disk image @@ -617,9 +617,11 @@ class KernelDebugKitUtilities: self._unmount_disk_image(mount_point) return False - if self.install_kdk_pkg(kdk_pkg_path) is False: - self._unmount_disk_image(mount_point) - return False + + if only_install_backup is False: + if self.install_kdk_pkg(kdk_pkg_path) is False: + self._unmount_disk_image(mount_point) + return False self._create_backup(kdk_pkg_path, Path(f"{kdk_path.parent}/{KDK_INFO_PLIST}")) self._unmount_disk_image(mount_point) @@ -663,6 +665,9 @@ class KernelDebugKitUtilities: logging.warning("Cannot create KDK backup, not running as root") return + if not Path(KDK_INSTALL_PATH).exists(): + subprocess.run(["mkdir", "-p", KDK_INSTALL_PATH], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + kdk_dst_name = f"KDK_{kdk_info_dict['version']}_{kdk_info_dict['build']}.pkg" kdk_dst_path = Path(f"{KDK_INSTALL_PATH}/{kdk_dst_name}")