mirror of
https://github.com/outbackdingo/OpCore-Simplify.git
synced 2026-08-25 14:53:06 +00:00
Refactor kext index retrieval
This commit is contained in:
+4
-6
@@ -172,7 +172,7 @@ class OCPE:
|
||||
if patch.checked:
|
||||
if patch.name == "BATP":
|
||||
patch.checked = getattr(self.ac, patch.function_name)()
|
||||
self.k.kexts[self.k.get_kext_index("ECEnabler")].checked = patch.checked
|
||||
self.k.kexts[self.k.kext_data.kext_index_by_name("ECEnabler")].checked = patch.checked
|
||||
continue
|
||||
|
||||
acpi_load = getattr(self.ac, patch.function_name)()
|
||||
@@ -251,14 +251,12 @@ class OCPE:
|
||||
print("OpenCore EFI build complete.")
|
||||
time.sleep(2)
|
||||
|
||||
def results(self, hardware_report, smbios_model, kexts):
|
||||
def results(self, hardware_report, smbios_model):
|
||||
self.u.head("Results")
|
||||
print("")
|
||||
print("Your OpenCore EFI for {} has been built at:".format(hardware_report.get("Motherboard").get("Name")))
|
||||
print("\t{}".format(self.result_dir))
|
||||
for kext in kexts:
|
||||
if kext.name == "USBInjectAll":
|
||||
if kext.checked:
|
||||
if self.k.kexts[self.k.kext_data.kext_index_by_name("USBInjectAll")].checked:
|
||||
print("\033[0;31mNote: USBInjectAll is not recommended. Please use USBMap.kext instead.\033[0m")
|
||||
print("")
|
||||
print("To use USBMap.kext:")
|
||||
@@ -363,7 +361,7 @@ class OCPE:
|
||||
continue
|
||||
|
||||
self.build_opencore_efi(customized_hardware, disabled_devices, smbios_model, macos_version, needs_oclp)
|
||||
self.results(customized_hardware, smbios_model, self.k.kexts)
|
||||
self.results(customized_hardware, smbios_model)
|
||||
|
||||
if __name__ == '__main__':
|
||||
update_flag = updater.Updater().run_update()
|
||||
|
||||
+10
-14
@@ -1,7 +1,7 @@
|
||||
from Scripts.datasets import chipset_data
|
||||
from Scripts.datasets import cpu_data
|
||||
from Scripts.datasets import mac_model_data
|
||||
from Scripts.datasets import os_data
|
||||
from Scripts.datasets import kext_data
|
||||
from Scripts.datasets import pci_data
|
||||
from Scripts.datasets import codec_layouts
|
||||
from Scripts import gathering_files
|
||||
@@ -404,9 +404,7 @@ class ConfigProdigy:
|
||||
def block_kext_bundle(self, kexts):
|
||||
kernel_block = []
|
||||
|
||||
for kext in kexts:
|
||||
if kext.checked:
|
||||
if kext.name == "IOSkywalkFamily":
|
||||
if kexts[kext_data.kext_index_by_name("IOSkywalkFamily")].checked:
|
||||
kernel_block.append({
|
||||
"Arch": "x86_64",
|
||||
"Comment": "Allow IOSkywalk Downgrade",
|
||||
@@ -455,14 +453,12 @@ class ConfigProdigy:
|
||||
if any(network_props.get("Device ID") in pci_data.AquantiaAqtionIDs for network_props in networks.values()):
|
||||
kernel_patch.extend(self.g.get_kernel_patches("Aquantia macOS Patches", self.g.aquantia_macos_patches_url))
|
||||
|
||||
for kext in kexts:
|
||||
if kext.checked:
|
||||
if kext.name == "CpuTopologyRebuild":
|
||||
if kexts[kext_data.kext_index_by_name("CpuTopologyRebuild")].checked:
|
||||
kernel_patch.extend(self.g.get_kernel_patches("Hyper Threading Patches", self.g.hyper_threading_patches_url))
|
||||
elif kext.name == "ForgedInvariant":
|
||||
elif kexts[kext_data.kext_index_by_name("ForgedInvariant")].checked:
|
||||
if not "AMD" in cpu_manufacturer:
|
||||
kernel_patch.extend(self.g.get_kernel_patches("AMD Vanilla Patches", self.g.amd_vanilla_patches_url)[-6:-4])
|
||||
elif kext.name == "CatalinaBCM5701Ethernet":
|
||||
elif kexts[kext_data.kext_index_by_name("CatalinaBCM5701Ethernet")].checked:
|
||||
kernel_patch.append({
|
||||
"Arch": "Any",
|
||||
"Base": "",
|
||||
@@ -691,14 +687,14 @@ class ConfigProdigy:
|
||||
config["UEFI"]["Quirks"]["UnblockFsConnect"] = "HP " in hardware_report.get("Motherboard").get("Name")
|
||||
config["UEFI"]["ReservedMemory"] = []
|
||||
|
||||
for kext in kexts:
|
||||
if kext.checked:
|
||||
if kext.name == "BlueToolFixup":
|
||||
if kexts[kext_data.kext_index_by_name("BlueToolFixup")].checked:
|
||||
config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["bluetoothExternalDongleFailed"] = self.utils.hex_to_bytes("00")
|
||||
config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["bluetoothInternalControllerInfo"] = self.utils.hex_to_bytes("0000000000000000000000000000")
|
||||
elif kext.name == "USBInjectAll":
|
||||
|
||||
if kexts[kext_data.kext_index_by_name("USBInjectAll")].checked:
|
||||
config["Kernel"]["Quirks"]["XhciPortLimit"] = True
|
||||
elif kext.name == "RestrictEvents":
|
||||
|
||||
if kexts[kext_data.kext_index_by_name("RestrictEvents")].checked:
|
||||
revpatch = []
|
||||
revblock = []
|
||||
if self.utils.parse_darwin_version(macos_version) > self.utils.parse_darwin_version("23.0.0") or \
|
||||
|
||||
@@ -887,3 +887,5 @@ kexts = [
|
||||
}
|
||||
)
|
||||
]
|
||||
|
||||
kext_index_by_name = {kext.name: index for index, kext in enumerate(kexts)}
|
||||
+8
-15
@@ -1,4 +1,3 @@
|
||||
|
||||
from Scripts.datasets import cpu_data
|
||||
from Scripts.datasets import kext_data
|
||||
from Scripts.datasets import os_data
|
||||
@@ -78,12 +77,6 @@ class KextMaestro:
|
||||
|
||||
return False
|
||||
|
||||
def get_kext_index(self, name):
|
||||
for index, kext in enumerate(self.kexts):
|
||||
if kext.name == name:
|
||||
return index
|
||||
return None
|
||||
|
||||
def check_kext(self, index, target_darwin_version, allow_unsupported_kexts=False):
|
||||
kext = self.kexts[index]
|
||||
|
||||
@@ -93,7 +86,7 @@ class KextMaestro:
|
||||
kext.checked = True
|
||||
|
||||
for requires_kext_name in kext.requires_kexts:
|
||||
requires_kext_index = self.get_kext_index(requires_kext_name)
|
||||
requires_kext_index = kext_data.kext_index_by_name(requires_kext_name)
|
||||
if requires_kext_index:
|
||||
self.check_kext(requires_kext_index, target_darwin_version, allow_unsupported_kexts)
|
||||
|
||||
@@ -277,7 +270,7 @@ class KextMaestro:
|
||||
selected_kexts.extend(("AppleIntelCPUPowerManagement", "AppleIntelCPUPowerManagementClient"))
|
||||
|
||||
for name in selected_kexts:
|
||||
self.check_kext(self.get_kext_index(name), macos_version, "Beta" in os_data.get_macos_name_by_darwin(macos_version))
|
||||
self.check_kext(kext_data.kext_index_by_name(name), macos_version, "Beta" in os_data.get_macos_name_by_darwin(macos_version))
|
||||
|
||||
def install_kexts_to_efi(self, macos_version, kexts_directory):
|
||||
for kext in self.kexts:
|
||||
@@ -302,7 +295,7 @@ class KextMaestro:
|
||||
break
|
||||
else:
|
||||
main_kext = kext_path.split("/")[0]
|
||||
main_kext_index = self.get_kext_index(main_kext)
|
||||
main_kext_index = kext_data.kext_index_by_name(main_kext)
|
||||
if not main_kext_index or self.kexts[main_kext_index].checked:
|
||||
if os.path.splitext(os.path.basename(kext_path))[0] in kext.name:
|
||||
source_kext_path = os.path.join(self.ock_files_dir, kext_path)
|
||||
@@ -372,15 +365,15 @@ class KextMaestro:
|
||||
kernel_add = []
|
||||
unload_kext = []
|
||||
|
||||
if self.kexts[self.get_kext_index("IO80211ElCap")].checked:
|
||||
if self.kexts[kext_data.kext_index_by_name("IO80211ElCap")].checked:
|
||||
unload_kext.extend((
|
||||
"AirPortBrcm4331",
|
||||
"AppleAirPortBrcm43224"
|
||||
))
|
||||
elif self.kexts[self.get_kext_index("VoodooSMBus")].checked:
|
||||
elif self.kexts[kext_data.kext_index_by_name("VoodooSMBus")].checked:
|
||||
unload_kext.append("VoodooPS2Mouse")
|
||||
elif self.kexts[self.get_kext_index("VoodooRMI")].checked:
|
||||
if not self.kexts[self.get_kext_index("VoodooI2C")].checked:
|
||||
elif self.kexts[kext_data.kext_index_by_name("VoodooRMI")].checked:
|
||||
if not self.kexts[kext_data.kext_index_by_name("VoodooI2C")].checked:
|
||||
unload_kext.append("RMII2C")
|
||||
else:
|
||||
unload_kext.extend((
|
||||
@@ -414,7 +407,7 @@ class KextMaestro:
|
||||
bundle["MaxKernel"] = os_data.get_latest_darwin_version()
|
||||
bundle["MinKernel"] = os_data.get_lowest_darwin_version()
|
||||
|
||||
kext_index = self.get_kext_index(os.path.splitext(os.path.basename(bundle.get("BundlePath")))[0])
|
||||
kext_index = kext_data.kext_index_by_name(os.path.splitext(os.path.basename(bundle.get("BundlePath")))[0])
|
||||
|
||||
if kext_index:
|
||||
bundle["MaxKernel"] = self.kexts[kext_index].max_darwin_version
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ class SMBIOS:
|
||||
selected_kexts.append("NoTouchID")
|
||||
|
||||
for name in selected_kexts:
|
||||
kext_maestro.check_kext(kext_maestro.get_kext_index(name), macos_version, "Beta" in os_data.get_macos_name_by_darwin(macos_version))
|
||||
kext_maestro.check_kext(kext_maestro.kext_data.kext_index_by_name(name), macos_version, "Beta" in os_data.get_macos_name_by_darwin(macos_version))
|
||||
|
||||
def select_smbios_model(self, hardware_report, macos_version):
|
||||
platform = "NUC" if "NUC" in hardware_report.get("Motherboard").get("Name") else hardware_report.get("Motherboard").get("Platform")
|
||||
|
||||
Reference in New Issue
Block a user