sys_patch.py: Save MetallibSupportPkg path to patchset file

This commit is contained in:
Mykola Grymalyuk
2024-08-28 17:48:38 -06:00
parent 9a3181d465
commit 669cc0ac5f
3 changed files with 19 additions and 6 deletions

View File

@@ -85,6 +85,7 @@ class PatchSysVolume:
self.patch_set_dictionary = {}
self.needs_kmutil_exemptions = False # For '/Library/Extensions' rebuilds
self.kdk_path = None
self.metallib_path = None
# GUI will detect hardware patches before starting PatchSysVolume()
# However the TUI will not, so allow for data to be passed in manually avoiding multiple calls
@@ -320,7 +321,7 @@ class PatchSysVolume:
destination_path = f"{self.mount_location}/System/Library/CoreServices"
file_name = "OpenCore-Legacy-Patcher.plist"
destination_path_file = f"{destination_path}/{file_name}"
if sys_patch_helpers.SysPatchHelpers(self.constants).generate_patchset_plist(patchset, file_name, self.kdk_path):
if sys_patch_helpers.SysPatchHelpers(self.constants).generate_patchset_plist(patchset, file_name, self.kdk_path, self.metallib_path):
logging.info("- Writing patchset information to Root Volume")
if Path(destination_path_file).exists():
subprocess_wrapper.run_as_root_and_verify(["/bin/rm", destination_path_file], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
@@ -447,6 +448,7 @@ class PatchSysVolume:
if not metallib_download_obj:
# Already downloaded, return path
logging.info(f"Using MetalLibSupportPkg: {metallib_obj.metallib_installed_path}")
self.metallib_path = metallib_obj.metallib_installed_path
return str(metallib_obj.metallib_installed_path)
metallib_download_obj.download(spawn_thread=False)
@@ -495,8 +497,11 @@ class PatchSysVolume:
continue
for install_patch_directory in required_patches[patch][method_type]:
for install_file in required_patches[patch][method_type][install_patch_directory]:
if required_patches[patch][method_type][install_patch_directory][install_file] in sys_patch_dict.DynamicPatchset:
required_patches[patch][method_type][install_patch_directory][install_file] = self._resolve_dynamic_patchset(required_patches[patch][method_type][install_patch_directory][install_file])
try:
if required_patches[patch][method_type][install_patch_directory][install_file] in sys_patch_dict.DynamicPatchset:
required_patches[patch][method_type][install_patch_directory][install_file] = self._resolve_dynamic_patchset(required_patches[patch][method_type][install_patch_directory][install_file])
except TypeError:
pass
source_file = required_patches[patch][method_type][install_patch_directory][install_file] + install_patch_directory + "/" + install_file

View File

@@ -77,7 +77,7 @@ class SysPatchHelpers:
f.write(data)
def generate_patchset_plist(self, patchset: dict, file_name: str, kdk_used: Path):
def generate_patchset_plist(self, patchset: dict, file_name: str, kdk_used: Path, metallib_used: Path):
"""
Generate patchset file for user reference
@@ -98,12 +98,17 @@ class SysPatchHelpers:
if kdk_used:
kdk_string = kdk_used
metallib_used_string = "Not applicable"
if metallib_used:
metallib_used_string = metallib_used
data = {
"OpenCore Legacy Patcher": f"v{self.constants.patcher_version}",
"PatcherSupportPkg": f"v{self.constants.patcher_support_pkg_version}",
"Time Patched": f"{datetime.now().strftime('%B %d, %Y @ %H:%M:%S')}",
"Commit URL": f"{self.constants.commit_info[2]}",
"Kernel Debug Kit Used": f"{kdk_string}",
"Metal Library Used": f"{metallib_used_string}",
"OS Version": f"{self.constants.detected_os}.{self.constants.detected_os_minor} ({self.constants.detected_os_build})",
"Custom Signature": bool(Path(self.constants.payload_local_binaries_root_path / ".signed").exists()),
}