mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-23 19:40:15 +10:00
patchsets: Implement new patch detection architecture
Greatly streamlines future patch set development
This commit is contained in:
@@ -19,9 +19,13 @@ from ..support import subprocess_wrapper
|
||||
from ..datasets import (
|
||||
example_data,
|
||||
model_array,
|
||||
sys_patch_dict,
|
||||
os_data
|
||||
)
|
||||
from ..sys_patch.patchsets import (
|
||||
HardwarePatchsetDetection,
|
||||
PatchType,
|
||||
DynamicPatchset
|
||||
)
|
||||
|
||||
|
||||
class PatcherValidation:
|
||||
@@ -120,29 +124,29 @@ class PatcherValidation:
|
||||
minor_kernel (int): Minor kernel version
|
||||
"""
|
||||
|
||||
patchset = sys_patch_dict.SystemPatchDictionary(major_kernel, minor_kernel, self.constants.legacy_accel_support, self.constants.detected_os_version).patchset_dict
|
||||
host_os_float = float(f"{major_kernel}.{minor_kernel}")
|
||||
patchset = HardwarePatchsetDetection(self.constants, xnu_major=major_kernel, xnu_minor=minor_kernel, validation=True).patches
|
||||
|
||||
for patch_subject in patchset:
|
||||
for patch_core in patchset[patch_subject]:
|
||||
patch_os_min_float = float(f'{patchset[patch_subject][patch_core]["OS Support"]["Minimum OS Support"]["OS Major"]}.{patchset[patch_subject][patch_core]["OS Support"]["Minimum OS Support"]["OS Minor"]}')
|
||||
patch_os_max_float = float(f'{patchset[patch_subject][patch_core]["OS Support"]["Maximum OS Support"]["OS Major"]}.{patchset[patch_subject][patch_core]["OS Support"]["Maximum OS Support"]["OS Minor"]}')
|
||||
if (host_os_float < patch_os_min_float or host_os_float > patch_os_max_float):
|
||||
continue
|
||||
for install_type in ["Install", "Install Non-Root"]:
|
||||
if install_type in patchset[patch_subject][patch_core]:
|
||||
for install_directory in patchset[patch_subject][patch_core][install_type]:
|
||||
for install_file in patchset[patch_subject][patch_core][install_type][install_directory]:
|
||||
try:
|
||||
if patchset[patch_subject][patch_core][install_type][install_directory][install_file] in sys_patch_dict.DynamicPatchset:
|
||||
continue
|
||||
except TypeError:
|
||||
pass
|
||||
source_file = str(self.constants.payload_local_binaries_root_path) + "/" + patchset[patch_subject][patch_core][install_type][install_directory][install_file] + install_directory + "/" + install_file
|
||||
if not Path(source_file).exists():
|
||||
logging.info(f"File not found: {source_file}")
|
||||
raise Exception(f"Failed to find {source_file}")
|
||||
if self.verify_unused_files is True:
|
||||
for patch_core in patchset:
|
||||
# Check if any unknown PathType is present
|
||||
for install_type in patchset[patch_core]:
|
||||
if install_type not in PatchType:
|
||||
raise Exception(f"Unknown PatchType: {install_type}")
|
||||
|
||||
for install_type in [PatchType.INSTALL_SYSTEM_VOLUME, PatchType.INSTALL_DATA_VOLUME]:
|
||||
if install_type in patchset[patch_core]:
|
||||
for install_directory in patchset[patch_core][install_type]:
|
||||
for install_file in patchset[patch_core][install_type][install_directory]:
|
||||
try:
|
||||
if patchset[patch_core][install_type][install_directory][install_file] in DynamicPatchset:
|
||||
continue
|
||||
except TypeError:
|
||||
pass
|
||||
source_file = str(self.constants.payload_local_binaries_root_path) + "/" + patchset[patch_core][install_type][install_directory][install_file] + install_directory + "/" + install_file
|
||||
if not Path(source_file).exists():
|
||||
logging.info(f"File not found: {source_file}")
|
||||
raise Exception(f"Failed to find {source_file}")
|
||||
if self.verify_unused_files is True:
|
||||
if source_file not in self.active_patchset_files:
|
||||
self.active_patchset_files.append(source_file)
|
||||
|
||||
logging.info(f"Validating against Darwin {major_kernel}.{minor_kernel}")
|
||||
@@ -214,10 +218,10 @@ class PatcherValidation:
|
||||
raise Exception("Failed to mount Universal-Binaries.dmg")
|
||||
|
||||
logging.info("Mounted Universal-Binaries.dmg")
|
||||
|
||||
|
||||
atexit.register(self._unmount_dmg)
|
||||
|
||||
for supported_os in [os_data.os_data.big_sur, os_data.os_data.monterey, os_data.os_data.ventura, os_data.os_data.sonoma]:
|
||||
for supported_os in [os_data.os_data.big_sur, os_data.os_data.monterey, os_data.os_data.ventura, os_data.os_data.sonoma, os_data.os_data.sequoia]:
|
||||
for i in range(0, 10):
|
||||
self._validate_root_patch_files(supported_os, i)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user