mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-20 22:20:53 +10:00
Fix formatting
This commit is contained in:
@@ -10,6 +10,7 @@ from pathlib import Path
|
|||||||
from resources import build, cli_menu, constants, utilities, device_probe, os_probe, defaults, arguments
|
from resources import build, cli_menu, constants, utilities, device_probe, os_probe, defaults, arguments
|
||||||
from data import model_array
|
from data import model_array
|
||||||
|
|
||||||
|
|
||||||
class OpenCoreLegacyPatcher:
|
class OpenCoreLegacyPatcher:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
print("- Loading...")
|
print("- Loading...")
|
||||||
@@ -28,7 +29,7 @@ class OpenCoreLegacyPatcher:
|
|||||||
defaults.generate_defaults.probe(self.computer.real_model, True, self.constants)
|
defaults.generate_defaults.probe(self.computer.real_model, True, self.constants)
|
||||||
if utilities.check_cli_args() is not None:
|
if utilities.check_cli_args() is not None:
|
||||||
print("- Detected arguments, switching to CLI mode")
|
print("- Detected arguments, switching to CLI mode")
|
||||||
self.constants.gui_mode = True # Assumes no user interaction is required
|
self.constants.gui_mode = True # Assumes no user interaction is required
|
||||||
self.constants.current_path = Path.cwd()
|
self.constants.current_path = Path.cwd()
|
||||||
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
|
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
|
||||||
print("- Rerouting payloads location")
|
print("- Rerouting payloads location")
|
||||||
|
|||||||
+10
-9
@@ -1,14 +1,15 @@
|
|||||||
import enum
|
import enum
|
||||||
|
|
||||||
|
|
||||||
class bluetooth_data(enum.IntEnum):
|
class bluetooth_data(enum.IntEnum):
|
||||||
# Bluetooth Chipsets
|
# Bluetooth Chipsets
|
||||||
NonApplicable = 0
|
NonApplicable = 0
|
||||||
BRCM2045 = 1 # TODO: Rename chipset, currently guessing MacPro1,1-3,1 name
|
BRCM2045 = 1 # TODO: Rename chipset, currently guessing MacPro1,1-3,1 name
|
||||||
BRCM2046 = 2 # BT 2.1
|
BRCM2046 = 2 # BT 2.1
|
||||||
BRCM2070 = 3 # BT 2.1
|
BRCM2070 = 3 # BT 2.1
|
||||||
BRCM20702_v1 = 4 # BT 4.0 - 2012
|
BRCM20702_v1 = 4 # BT 4.0 - 2012
|
||||||
BRCM20702_v2 = 5 # BT 4.0 - 2013+
|
BRCM20702_v2 = 5 # BT 4.0 - 2013+
|
||||||
BRCM20703 = 6 # BT 4.2
|
BRCM20703 = 6 # BT 4.2
|
||||||
BRCM20703_UART = 9 # BRCM20703 over UART, BT 4.2
|
BRCM20703_UART = 9 # BRCM20703 over UART, BT 4.2
|
||||||
UART = 10 # T2
|
UART = 10 # T2
|
||||||
PCIe = 20 # Apple Silicon
|
PCIe = 20 # Apple Silicon
|
||||||
|
|||||||
+9
-9
@@ -1,22 +1,22 @@
|
|||||||
import enum
|
import enum
|
||||||
|
|
||||||
|
|
||||||
class cpu_data(enum.IntEnum):
|
class cpu_data(enum.IntEnum):
|
||||||
pentium_4 = 0
|
pentium_4 = 0
|
||||||
yonah = 1
|
yonah = 1
|
||||||
conroe = 2
|
conroe = 2
|
||||||
penryn = 3
|
penryn = 3
|
||||||
nehalem = 4 # (Westmere included)
|
nehalem = 4 # (Westmere included)
|
||||||
sandy_bridge = 5 # 2000
|
sandy_bridge = 5 # 2000
|
||||||
ivy_bridge = 6 # 3000
|
ivy_bridge = 6 # 3000
|
||||||
haswell = 7 # 4000
|
haswell = 7 # 4000
|
||||||
broadwell = 8 # 5000
|
broadwell = 8 # 5000
|
||||||
skylake = 9 # 6000
|
skylake = 9 # 6000
|
||||||
kaby_lake = 10 # 7000
|
kaby_lake = 10 # 7000
|
||||||
coffee_lake = 11 # 8000
|
coffee_lake = 11 # 8000
|
||||||
comet_lake = 12 # 9000
|
comet_lake = 12 # 9000
|
||||||
ice_lake = 13 # 10000
|
ice_lake = 13 # 10000
|
||||||
|
|
||||||
|
apple_dtk = 112 # A12
|
||||||
apple_dtk = 112 # A12
|
apple_m1 = 114 # A14
|
||||||
apple_m1 = 114 # A14
|
apple_m2 = 115 # A15
|
||||||
apple_m2 = 115 # A15
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import enum
|
import enum
|
||||||
|
|
||||||
|
|
||||||
class os_data(enum.IntEnum):
|
class os_data(enum.IntEnum):
|
||||||
# OS Versions, Based off Major Kernel Version
|
# OS Versions, Based off Major Kernel Version
|
||||||
tiger = 8
|
tiger = 8
|
||||||
|
|||||||
+307
-187
File diff suppressed because it is too large
Load Diff
@@ -169,7 +169,7 @@ AddIntelGen2AccelStock = [
|
|||||||
|
|
||||||
AddIntelGen2AccelPatched = [
|
AddIntelGen2AccelPatched = [
|
||||||
"AppleIntelSNBGraphicsFB.kext",
|
"AppleIntelSNBGraphicsFB.kext",
|
||||||
],
|
]
|
||||||
|
|
||||||
AddIntelGen3Accel = [
|
AddIntelGen3Accel = [
|
||||||
"AppleIntelFramebufferCapri.kext",
|
"AppleIntelFramebufferCapri.kext",
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ If you plan to create the USB for another machine, please select the "Change Mod
|
|||||||
print("- Set verbose configuration")
|
print("- Set verbose configuration")
|
||||||
settings.verbose_debug = True
|
settings.verbose_debug = True
|
||||||
else:
|
else:
|
||||||
settings.verbose_debug = False # Override Defaults detected
|
settings.verbose_debug = False # Override Defaults detected
|
||||||
if self.args.debug_oc:
|
if self.args.debug_oc:
|
||||||
print("- Set OpenCore DEBUG configuration")
|
print("- Set OpenCore DEBUG configuration")
|
||||||
settings.opencore_debug = True
|
settings.opencore_debug = True
|
||||||
@@ -48,12 +48,12 @@ If you plan to create the USB for another machine, please select the "Change Mod
|
|||||||
print("- Set Disable SIP configuration")
|
print("- Set Disable SIP configuration")
|
||||||
settings.sip_status = False
|
settings.sip_status = False
|
||||||
else:
|
else:
|
||||||
settings.sip_status = True # Override Defaults detected
|
settings.sip_status = True # Override Defaults detected
|
||||||
if self.args.disable_smb:
|
if self.args.disable_smb:
|
||||||
print("- Set Disable SecureBootModel configuration")
|
print("- Set Disable SecureBootModel configuration")
|
||||||
settings.secure_status = False
|
settings.secure_status = False
|
||||||
else:
|
else:
|
||||||
settings.secure_status = True # Override Defaults detected
|
settings.secure_status = True # Override Defaults detected
|
||||||
if self.args.vault:
|
if self.args.vault:
|
||||||
print("- Set Vault configuration")
|
print("- Set Vault configuration")
|
||||||
settings.vault = True
|
settings.vault = True
|
||||||
|
|||||||
+18
-4
@@ -106,7 +106,12 @@ class BuildOpenCore:
|
|||||||
# CPU patches
|
# CPU patches
|
||||||
("AppleMCEReporterDisabler.kext", self.constants.mce_version, self.constants.mce_path, lambda: self.model.startswith("MacPro") or self.model.startswith("Xserve")),
|
("AppleMCEReporterDisabler.kext", self.constants.mce_version, self.constants.mce_path, lambda: self.model.startswith("MacPro") or self.model.startswith("Xserve")),
|
||||||
("AAAMouSSE.kext", self.constants.mousse_version, self.constants.mousse_path, lambda: smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.penryn.value),
|
("AAAMouSSE.kext", self.constants.mousse_version, self.constants.mousse_path, lambda: smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.penryn.value),
|
||||||
("telemetrap.kext", self.constants.telemetrap_version, self.constants.telemetrap_path, lambda: smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.penryn.value),
|
(
|
||||||
|
"telemetrap.kext",
|
||||||
|
self.constants.telemetrap_version,
|
||||||
|
self.constants.telemetrap_path,
|
||||||
|
lambda: smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.penryn.value,
|
||||||
|
),
|
||||||
(
|
(
|
||||||
"CPUFriend.kext",
|
"CPUFriend.kext",
|
||||||
self.constants.cpufriend_version,
|
self.constants.cpufriend_version,
|
||||||
@@ -117,11 +122,21 @@ class BuildOpenCore:
|
|||||||
("nForceEthernet.kext", self.constants.nforce_version, self.constants.nforce_path, lambda: smbios_data.smbios_dictionary[self.model]["Ethernet Chipset"] == "Nvidia"),
|
("nForceEthernet.kext", self.constants.nforce_version, self.constants.nforce_path, lambda: smbios_data.smbios_dictionary[self.model]["Ethernet Chipset"] == "Nvidia"),
|
||||||
("MarvelYukonEthernet.kext", self.constants.marvel_version, self.constants.marvel_path, lambda: smbios_data.smbios_dictionary[self.model]["Ethernet Chipset"] == "Marvell"),
|
("MarvelYukonEthernet.kext", self.constants.marvel_version, self.constants.marvel_path, lambda: smbios_data.smbios_dictionary[self.model]["Ethernet Chipset"] == "Marvell"),
|
||||||
# Legacy audio
|
# Legacy audio
|
||||||
("AppleALC.kext", self.constants.applealc_version, self.constants.applealc_path, lambda: (self.model in model_array.LegacyAudio or self.model in model_array.MacPro) and self.constants.set_alc_usage is True),
|
(
|
||||||
|
"AppleALC.kext",
|
||||||
|
self.constants.applealc_version,
|
||||||
|
self.constants.applealc_path,
|
||||||
|
lambda: (self.model in model_array.LegacyAudio or self.model in model_array.MacPro) and self.constants.set_alc_usage is True,
|
||||||
|
),
|
||||||
# IDE patch
|
# IDE patch
|
||||||
("AppleIntelPIIXATA.kext", self.constants.piixata_version, self.constants.piixata_path, lambda: self.model in model_array.IDEPatch),
|
("AppleIntelPIIXATA.kext", self.constants.piixata_version, self.constants.piixata_path, lambda: self.model in model_array.IDEPatch),
|
||||||
# Misc
|
# Misc
|
||||||
("FeatureUnlock.kext", self.constants.featureunlock_version, self.constants.featureunlock_path, lambda: smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.kaby_lake.value),
|
(
|
||||||
|
"FeatureUnlock.kext",
|
||||||
|
self.constants.featureunlock_version,
|
||||||
|
self.constants.featureunlock_path,
|
||||||
|
lambda: smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.kaby_lake.value,
|
||||||
|
),
|
||||||
("DebugEnhancer.kext", self.constants.debugenhancer_version, self.constants.debugenhancer_path, lambda: self.constants.kext_debug is True),
|
("DebugEnhancer.kext", self.constants.debugenhancer_version, self.constants.debugenhancer_path, lambda: self.constants.kext_debug is True),
|
||||||
("AppleUSBTrackpad.kext", self.constants.apple_trackpad, self.constants.apple_trackpad_path, lambda: self.model in ["MacBook4,1", "MacBook5,2"]),
|
("AppleUSBTrackpad.kext", self.constants.apple_trackpad, self.constants.apple_trackpad_path, lambda: self.model in ["MacBook4,1", "MacBook5,2"]),
|
||||||
]:
|
]:
|
||||||
@@ -415,7 +430,6 @@ class BuildOpenCore:
|
|||||||
# Used to enable Audio support for non-standard dGPUs
|
# Used to enable Audio support for non-standard dGPUs
|
||||||
self.enable_kext("AppleALC.kext", self.constants.applealc_version, self.constants.applealc_path)
|
self.enable_kext("AppleALC.kext", self.constants.applealc_version, self.constants.applealc_path)
|
||||||
|
|
||||||
|
|
||||||
def check_firewire(model):
|
def check_firewire(model):
|
||||||
# MacBooks never supported FireWire
|
# MacBooks never supported FireWire
|
||||||
# Pre-Thunderbolt MacBook Airs as well
|
# Pre-Thunderbolt MacBook Airs as well
|
||||||
|
|||||||
@@ -792,7 +792,6 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
|
|||||||
|
|
||||||
response = menu.start()
|
response = menu.start()
|
||||||
|
|
||||||
|
|
||||||
def patcher_settings(self):
|
def patcher_settings(self):
|
||||||
response = None
|
response = None
|
||||||
while not (response and response == -1):
|
while not (response and response == -1):
|
||||||
@@ -831,9 +830,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
|
|||||||
[f"Enable OpenCore DEBUG:\tCurrently {self.constants.opencore_debug}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_oc],
|
[f"Enable OpenCore DEBUG:\tCurrently {self.constants.opencore_debug}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_oc],
|
||||||
[f"Enable Kext DEBUG:\t\tCurrently {self.constants.kext_debug}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_kext],
|
[f"Enable Kext DEBUG:\t\tCurrently {self.constants.kext_debug}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_kext],
|
||||||
] + (
|
] + (
|
||||||
[
|
[[f"Set SurPlus Settings:\tCurrently {self.constants.force_surplus}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).set_surplus]]
|
||||||
[f"Set SurPlus Settings:\tCurrently {self.constants.force_surplus}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).set_surplus]
|
|
||||||
]
|
|
||||||
if (smbios_data.smbios_dictionary[self.constants.custom_model or self.constants.computer.real_model]["CPU Generation"] <= cpu_data.cpu_data.sandy_bridge)
|
if (smbios_data.smbios_dictionary[self.constants.custom_model or self.constants.computer.real_model]["CPU Generation"] <= cpu_data.cpu_data.sandy_bridge)
|
||||||
else []
|
else []
|
||||||
)
|
)
|
||||||
@@ -909,13 +906,19 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
|
|||||||
[f"Set ShowPicker Mode:\tCurrently {self.constants.showpicker}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_showpicker],
|
[f"Set ShowPicker Mode:\tCurrently {self.constants.showpicker}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_showpicker],
|
||||||
[f"Set Wake on WLAN:\t\tCurrently {self.constants.enable_wake_on_wlan}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).allow_wowl],
|
[f"Set Wake on WLAN:\t\tCurrently {self.constants.enable_wake_on_wlan}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).allow_wowl],
|
||||||
[f"Set Ivy iMac iGPU:\t\tCurrently {self.constants.allow_ivy_igpu}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).allow_ivy],
|
[f"Set Ivy iMac iGPU:\t\tCurrently {self.constants.allow_ivy_igpu}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).allow_ivy],
|
||||||
[f"Set TeraScale 2 Accel:\tCurrently {self.constants.allow_ts2_accel}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).terascale_2_accel],
|
[
|
||||||
|
f"Set TeraScale 2 Accel:\tCurrently {self.constants.allow_ts2_accel}",
|
||||||
|
MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).terascale_2_accel,
|
||||||
|
],
|
||||||
[
|
[
|
||||||
f"Disable Thunderbolt:\tCurrently {self.constants.disable_tb}",
|
f"Disable Thunderbolt:\tCurrently {self.constants.disable_tb}",
|
||||||
MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).disable_tb,
|
MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).disable_tb,
|
||||||
],
|
],
|
||||||
[f"Set AppleALC Usage:\t\tCurrently {self.constants.set_alc_usage}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).applealc_support],
|
[f"Set AppleALC Usage:\t\tCurrently {self.constants.set_alc_usage}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).applealc_support],
|
||||||
[f"Set Windows GMUX support:\tCurrently {self.constants.dGPU_switch}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).dGPU_switch_support],
|
[
|
||||||
|
f"Set Windows GMUX support:\tCurrently {self.constants.dGPU_switch}",
|
||||||
|
MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).dGPU_switch_support,
|
||||||
|
],
|
||||||
]
|
]
|
||||||
|
|
||||||
for option in options:
|
for option in options:
|
||||||
@@ -943,9 +946,6 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
|
|||||||
|
|
||||||
response = menu.start()
|
response = menu.start()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
big_sur = """Patches Root volume to fix misc issues such as:
|
big_sur = """Patches Root volume to fix misc issues such as:
|
||||||
|
|
||||||
- Non-Metal Graphics Acceleration
|
- Non-Metal Graphics Acceleration
|
||||||
|
|||||||
+1
-28
@@ -13,7 +13,7 @@ from resources import device_probe
|
|||||||
class Constants:
|
class Constants:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Patcher Versioning
|
# Patcher Versioning
|
||||||
self.patcher_version = "0.3.0" # OpenCore-Legacy-Patcher
|
self.patcher_version = "0.3.0" # OpenCore-Legacy-Patcher
|
||||||
self.patcher_support_pkg_version = "0.1.6" # PatcherSupportPkg
|
self.patcher_support_pkg_version = "0.1.6" # PatcherSupportPkg
|
||||||
self.url_patcher_support_pkg = "https://github.com/dortania/PatcherSupportPkg/releases/download/"
|
self.url_patcher_support_pkg = "https://github.com/dortania/PatcherSupportPkg/releases/download/"
|
||||||
self.nightly_url_patcher_support_pkg = "https://nightly.link/dortania/PatcherSupportPkg/workflows/build/master/"
|
self.nightly_url_patcher_support_pkg = "https://nightly.link/dortania/PatcherSupportPkg/workflows/build/master/"
|
||||||
@@ -165,33 +165,6 @@ class Constants:
|
|||||||
self.big_sur = 20
|
self.big_sur = 20
|
||||||
self.monterey = 21
|
self.monterey = 21
|
||||||
|
|
||||||
# Vendor IDs
|
|
||||||
self.pci_nvidia = "10DE"
|
|
||||||
self.pci_amd_ati = "1002"
|
|
||||||
self.pci_intel = "8086"
|
|
||||||
self.pci_broadcom = "14E4"
|
|
||||||
self.pci_atheros = "168C"
|
|
||||||
self.pci_apple = "106B"
|
|
||||||
self.pci_aquantia = "1D6A"
|
|
||||||
self.pci_marvell = "11AB"
|
|
||||||
self.pci_syskonnect = "1148"
|
|
||||||
|
|
||||||
# Class Codes
|
|
||||||
## https://pci-ids.ucw.cz/read/PD
|
|
||||||
self.classcode_sata = "01060100"
|
|
||||||
self.classcode_nvme = "02080100"
|
|
||||||
self.classcode_nvme_generic = "02800100"
|
|
||||||
self.classcode_wifi = "00800200"
|
|
||||||
self.classcode_gpu = "00000300"
|
|
||||||
self.classcode_gpu_variant = "00800300"
|
|
||||||
self.classcode_xhci = "30030C00"
|
|
||||||
self.classcode_ethernet = "00000200"
|
|
||||||
|
|
||||||
# Nvidia GPU Architecture
|
|
||||||
self.arch_tesla = "NV50"
|
|
||||||
self.arch_fermi = "GF100"
|
|
||||||
self.arch_kepler = "GK100"
|
|
||||||
|
|
||||||
self.legacy_accel_support = [
|
self.legacy_accel_support = [
|
||||||
self.mojave,
|
self.mojave,
|
||||||
self.catalina,
|
self.catalina,
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
from resources import utilities, device_probe
|
from resources import utilities, device_probe
|
||||||
from data import model_array
|
from data import model_array
|
||||||
|
|
||||||
class generate_defaults():
|
|
||||||
|
class generate_defaults:
|
||||||
def probe(model, host_is_target, settings):
|
def probe(model, host_is_target, settings):
|
||||||
# Generate Default Data
|
# Generate Default Data
|
||||||
# Takes in Settings data set, and returns updated Settings
|
# Takes in Settings data set, and returns updated Settings
|
||||||
@@ -49,7 +50,6 @@ class generate_defaults():
|
|||||||
settings.allow_fv_root = True # Allow FileVault on broken seal
|
settings.allow_fv_root = True # Allow FileVault on broken seal
|
||||||
# settings.amfi_status = True # Signed bundles, Don't need to explicitly set currently
|
# settings.amfi_status = True # Signed bundles, Don't need to explicitly set currently
|
||||||
|
|
||||||
|
|
||||||
if model == "MacBook8,1":
|
if model == "MacBook8,1":
|
||||||
# MacBook8,1 has an odd bug where it cannot install Monterey with Minimal spoofing
|
# MacBook8,1 has an odd bug where it cannot install Monterey with Minimal spoofing
|
||||||
settings.serial_settings = "Moderate"
|
settings.serial_settings = "Moderate"
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class PCIDevice:
|
|||||||
|
|
||||||
vendor_id: int # The vendor ID of this PCI device
|
vendor_id: int # The vendor ID of this PCI device
|
||||||
device_id: int # The device ID of this PCI device
|
device_id: int # The device ID of this PCI device
|
||||||
class_code: int # The class code of this PCI device
|
class_code: int # The class code of this PCI device - https://pci-ids.ucw.cz/read/PD
|
||||||
|
|
||||||
# ioregistryentry: Optional[ioreg.IORegistryEntry] = None
|
# ioregistryentry: Optional[ioreg.IORegistryEntry] = None
|
||||||
name: Optional[str] = None # Name of IORegistryEntry
|
name: Optional[str] = None # Name of IORegistryEntry
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from data import smbios_data, os_data
|
from data import smbios_data, os_data
|
||||||
from resources import utilities
|
from resources import utilities
|
||||||
|
|
||||||
|
|
||||||
def set_smbios_model_spoof(model):
|
def set_smbios_model_spoof(model):
|
||||||
try:
|
try:
|
||||||
smbios_data.smbios_dictionary[model]["Screen Size"]
|
smbios_data.smbios_dictionary[model]["Screen Size"]
|
||||||
@@ -53,6 +54,7 @@ def set_smbios_model_spoof(model):
|
|||||||
# Unknown Model
|
# Unknown Model
|
||||||
raise Exception(f"Unknown SMBIOS for spoofing: {model}")
|
raise Exception(f"Unknown SMBIOS for spoofing: {model}")
|
||||||
|
|
||||||
|
|
||||||
def update_firmware_features(firmwarefeature):
|
def update_firmware_features(firmwarefeature):
|
||||||
# Adjust FirmwareFeature to support everything macOS requires
|
# Adjust FirmwareFeature to support everything macOS requires
|
||||||
# APFS Bit (19/20): 10.13+ (OSInstall)
|
# APFS Bit (19/20): 10.13+ (OSInstall)
|
||||||
@@ -63,6 +65,7 @@ def update_firmware_features(firmwarefeature):
|
|||||||
firmwarefeature |= 2 ** 35 # FW_FEATURE_SUPPORTS_LARGE_BASESYSTEM
|
firmwarefeature |= 2 ** 35 # FW_FEATURE_SUPPORTS_LARGE_BASESYSTEM
|
||||||
return firmwarefeature
|
return firmwarefeature
|
||||||
|
|
||||||
|
|
||||||
def generate_fw_features(model, custom):
|
def generate_fw_features(model, custom):
|
||||||
if not custom:
|
if not custom:
|
||||||
firmwarefeature = utilities.get_rom("firmware-features")
|
firmwarefeature = utilities.get_rom("firmware-features")
|
||||||
@@ -73,3 +76,25 @@ def generate_fw_features(model, custom):
|
|||||||
firmwarefeature = int(smbios_data.smbios_dictionary[model]["FirmwareFeatures"], 16)
|
firmwarefeature = int(smbios_data.smbios_dictionary[model]["FirmwareFeatures"], 16)
|
||||||
firmwarefeature = update_firmware_features(firmwarefeature)
|
firmwarefeature = update_firmware_features(firmwarefeature)
|
||||||
return firmwarefeature
|
return firmwarefeature
|
||||||
|
|
||||||
|
|
||||||
|
def find_model_off_board(board):
|
||||||
|
# Find model based off Board ID provided
|
||||||
|
# Return none if unknown
|
||||||
|
|
||||||
|
# Strip extra data from Target Types (ap, uppercase)
|
||||||
|
if not (board.startswith("Mac-") or board.startswith("VMM-")):
|
||||||
|
if board.lower().endswith("ap"):
|
||||||
|
board = board[:-2]
|
||||||
|
board = board.lower()
|
||||||
|
|
||||||
|
for key in smbios_data.smbios_dictionary:
|
||||||
|
if board in [smbios_data.smbios_dictionary[key]["Board ID"], smbios_data.smbios_dictionary[key]["SecureBootModel"]]:
|
||||||
|
if key.endswith("_v2") or key.endswith("_v3") or key.endswith("_v4"):
|
||||||
|
# smbios_data has duplicate SMBIOS to handle multiple board IDs
|
||||||
|
key = key[:-3]
|
||||||
|
if key == "MacPro4,1":
|
||||||
|
# 4,1 and 5,1 have the same board ID, best to return the newer ID
|
||||||
|
key = "MacPro5,1"
|
||||||
|
return key
|
||||||
|
return None
|
||||||
|
|||||||
+6
-6
@@ -7,13 +7,13 @@ from typing import NewType, Union
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import objc
|
import objc
|
||||||
except ImportError:
|
except ImportError:
|
||||||
subprocess.run(["pip3", "install", "pyobjc"], stdout=subprocess.PIPE)
|
subprocess.run(["pip3", "install", "pyobjc"], stdout=subprocess.PIPE)
|
||||||
try:
|
try:
|
||||||
import objc
|
import objc
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise Exception("Missing PyObjc library!\nPlease run the following before starting OCLP:\npip3 install pyobjc")
|
raise Exception("Missing PyObjc library!\nPlease run the following before starting OCLP:\npip3 install pyobjc")
|
||||||
|
|
||||||
from CoreFoundation import CFRelease, kCFAllocatorDefault # type: ignore # pylint: disable=no-name-in-module
|
from CoreFoundation import CFRelease, kCFAllocatorDefault # type: ignore # pylint: disable=no-name-in-module
|
||||||
from Foundation import NSBundle # type: ignore # pylint: disable=no-name-in-module
|
from Foundation import NSBundle # type: ignore # pylint: disable=no-name-in-module
|
||||||
|
|||||||
@@ -3,16 +3,19 @@
|
|||||||
import platform
|
import platform
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
def detect_kernel_major():
|
def detect_kernel_major():
|
||||||
# Return Major Kernel Version
|
# Return Major Kernel Version
|
||||||
# Example Output: 21 (integer)
|
# Example Output: 21 (integer)
|
||||||
return int(platform.uname().release.partition(".")[0])
|
return int(platform.uname().release.partition(".")[0])
|
||||||
|
|
||||||
|
|
||||||
def detect_kernel_minor():
|
def detect_kernel_minor():
|
||||||
# Return Minor Kernel Version
|
# Return Minor Kernel Version
|
||||||
# Example Output: 1 (integer)
|
# Example Output: 1 (integer)
|
||||||
return int(platform.uname().release.partition(".")[2].partition(".")[0])
|
return int(platform.uname().release.partition(".")[2].partition(".")[0])
|
||||||
|
|
||||||
|
|
||||||
def detect_kernel_build():
|
def detect_kernel_build():
|
||||||
# Return OS build
|
# Return OS build
|
||||||
# Example Output: 21A5522h (string)
|
# Example Output: 21A5522h (string)
|
||||||
|
|||||||
+13
-10
@@ -237,7 +237,9 @@ class PatchSysVolume:
|
|||||||
input("Press [ENTER] to continue with kernel and dyld cache merging")
|
input("Press [ENTER] to continue with kernel and dyld cache merging")
|
||||||
if self.constants.detected_os > self.constants.catalina:
|
if self.constants.detected_os > self.constants.catalina:
|
||||||
print("- Creating new APFS snapshot")
|
print("- Creating new APFS snapshot")
|
||||||
bless = utilities.elevated(["bless", "--folder", f"{self.mount_location}/System/Library/CoreServices", "--bootefi", "--create-snapshot"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
bless = utilities.elevated(
|
||||||
|
["bless", "--folder", f"{self.mount_location}/System/Library/CoreServices", "--bootefi", "--create-snapshot"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
||||||
|
)
|
||||||
if bless.returncode != 0:
|
if bless.returncode != 0:
|
||||||
print("- Unable to create new snapshot")
|
print("- Unable to create new snapshot")
|
||||||
print("Reason for snapshot failure:")
|
print("Reason for snapshot failure:")
|
||||||
@@ -289,7 +291,6 @@ set million colour before rebooting"""
|
|||||||
utilities.process_status(utilities.elevated(["chmod", "-Rf", "755", f"{self.mount_extensions}/{add_current_kext}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["chmod", "-Rf", "755", f"{self.mount_extensions}/{add_current_kext}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
utilities.process_status(utilities.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_extensions}/{add_current_kext}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_extensions}/{add_current_kext}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
|
|
||||||
|
|
||||||
def add_brightness_patch(self):
|
def add_brightness_patch(self):
|
||||||
self.delete_old_binaries(sys_patch_data.DeleteBrightness)
|
self.delete_old_binaries(sys_patch_data.DeleteBrightness)
|
||||||
self.add_new_binaries(sys_patch_data.AddBrightness, self.constants.legacy_brightness)
|
self.add_new_binaries(sys_patch_data.AddBrightness, self.constants.legacy_brightness)
|
||||||
@@ -317,7 +318,9 @@ set million colour before rebooting"""
|
|||||||
def add_legacy_mux_patch(self):
|
def add_legacy_mux_patch(self):
|
||||||
self.delete_old_binaries(sys_patch_data.DeleteDemux)
|
self.delete_old_binaries(sys_patch_data.DeleteDemux)
|
||||||
print("- Merging Legacy Mux Kext patches")
|
print("- Merging Legacy Mux Kext patches")
|
||||||
utilities.process_status(utilities.elevated(["cp", "-R", f"{self.constants.legacy_mux_path}/AppleMuxControl.kext", self.mount_extensions_mux], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(
|
||||||
|
utilities.elevated(["cp", "-R", f"{self.constants.legacy_mux_path}/AppleMuxControl.kext", self.mount_extensions_mux], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
)
|
||||||
|
|
||||||
def gpu_accel_legacy(self):
|
def gpu_accel_legacy(self):
|
||||||
if self.constants.detected_os == self.constants.mojave:
|
if self.constants.detected_os == self.constants.mojave:
|
||||||
@@ -423,9 +426,13 @@ set million colour before rebooting"""
|
|||||||
utilities.elevated(["rm", "-r", f"{self.mount_extensions}/AppleIntelSNBGraphicsFB.kext"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
utilities.elevated(["rm", "-r", f"{self.mount_extensions}/AppleIntelSNBGraphicsFB.kext"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
# Add kext
|
# Add kext
|
||||||
print("- Adding AppleIntelSNBGraphicsFB.kext")
|
print("- Adding AppleIntelSNBGraphicsFB.kext")
|
||||||
utilities.elevated(["cp", "-r", f"{self.constants.legacy_intel_gen2_path}/AppleIntelSNBGraphicsFB-Clean.kext", f"{self.mount_extensions}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
utilities.elevated(
|
||||||
|
["cp", "-r", f"{self.constants.legacy_intel_gen2_path}/AppleIntelSNBGraphicsFB-Clean.kext", f"{self.mount_extensions}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
||||||
|
)
|
||||||
# Rename kext
|
# Rename kext
|
||||||
utilities.elevated(["mv", f"{self.mount_extensions}/AppleIntelSNBGraphicsFB-Clean.kext", f"{self.mount_extensions}/AppleIntelSNBGraphicsFB.kext"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
utilities.elevated(
|
||||||
|
["mv", f"{self.mount_extensions}/AppleIntelSNBGraphicsFB-Clean.kext", f"{self.mount_extensions}/AppleIntelSNBGraphicsFB.kext"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
||||||
|
)
|
||||||
# Fix permissions
|
# Fix permissions
|
||||||
utilities.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_extensions}/AppleIntelSNBGraphicsFB.kext"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
utilities.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_extensions}/AppleIntelSNBGraphicsFB.kext"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
utilities.elevated(["chmod", "-Rf", "755", f"{self.mount_extensions}/AppleIntelSNBGraphicsFB.kext"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
utilities.elevated(["chmod", "-Rf", "755", f"{self.mount_extensions}/AppleIntelSNBGraphicsFB.kext"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
@@ -725,7 +732,6 @@ set million colour before rebooting"""
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def detect_patch_set(self):
|
def detect_patch_set(self):
|
||||||
self.detect_gpus()
|
self.detect_gpus()
|
||||||
if self.model in model_array.LegacyBrightness:
|
if self.model in model_array.LegacyBrightness:
|
||||||
@@ -827,10 +833,7 @@ set million colour before rebooting"""
|
|||||||
print("\nCannot patch! Please disable AMFI.")
|
print("\nCannot patch! Please disable AMFI.")
|
||||||
print("For Hackintoshes, please add amfi_get_out_of_my_way=1 to boot-args")
|
print("For Hackintoshes, please add amfi_get_out_of_my_way=1 to boot-args")
|
||||||
|
|
||||||
if self.check_board_id is True and (
|
if self.check_board_id is True and (self.computer.reported_board_id not in self.constants.sandy_board_id and self.computer.reported_board_id not in self.constants.sandy_board_id_stock):
|
||||||
self.computer.reported_board_id not in self.constants.sandy_board_id and
|
|
||||||
self.computer.reported_board_id not in self.constants.sandy_board_id_stock
|
|
||||||
):
|
|
||||||
print("\nCannot patch! Board ID not supported by AppleIntelSNBGraphicsFB")
|
print("\nCannot patch! Board ID not supported by AppleIntelSNBGraphicsFB")
|
||||||
print(f"Detected Board ID: {self.computer.reported_board_id}")
|
print(f"Detected Board ID: {self.computer.reported_board_id}")
|
||||||
print("Please ensure your Board ID is listed below:")
|
print("Please ensure your Board ID is listed below:")
|
||||||
|
|||||||
+11
-7
@@ -129,6 +129,7 @@ def amfi_status():
|
|||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def check_kext_loaded(kext_name, os_version):
|
def check_kext_loaded(kext_name, os_version):
|
||||||
if os_version > constants.Constants().catalina:
|
if os_version > constants.Constants().catalina:
|
||||||
kext_loaded = subprocess.run(["kmutil", "showloaded", "--list-only", "--variant-suffix", "release"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
kext_loaded = subprocess.run(["kmutil", "showloaded", "--list-only", "--variant-suffix", "release"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
@@ -139,6 +140,7 @@ def check_kext_loaded(kext_name, os_version):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def check_oclp_boot():
|
def check_oclp_boot():
|
||||||
if get_nvram("OCLP-Version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True):
|
if get_nvram("OCLP-Version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True):
|
||||||
return True
|
return True
|
||||||
@@ -194,7 +196,10 @@ def patching_status(os_sip, os):
|
|||||||
# Catalina and older supports individually disabling Library Validation
|
# Catalina and older supports individually disabling Library Validation
|
||||||
amfi_enabled = False
|
amfi_enabled = False
|
||||||
|
|
||||||
if get_nvram("HardwareModel", "94B73556-2197-4702-82A8-3E1337DAFBFB", decode=False) not in constants.Constants.sbm_values:
|
if (
|
||||||
|
get_nvram("HardwareModel", "94B73556-2197-4702-82A8-3E1337DAFBFB", decode=False)
|
||||||
|
and get_nvram("HardwareModel", "94B73556-2197-4702-82A8-3E1337DAFBFB", decode=False) not in constants.Constants().sbm_values
|
||||||
|
):
|
||||||
sbm_enabled = False
|
sbm_enabled = False
|
||||||
|
|
||||||
if get_nvram("csr-active-config", decode=False) and csr_decode(get_nvram("csr-active-config", decode=False), os_sip) is False:
|
if get_nvram("csr-active-config", decode=False) and csr_decode(get_nvram("csr-active-config", decode=False), os_sip) is False:
|
||||||
@@ -233,6 +238,7 @@ def cls():
|
|||||||
else:
|
else:
|
||||||
print("\u001Bc")
|
print("\u001Bc")
|
||||||
|
|
||||||
|
|
||||||
def get_nvram(variable: str, uuid: str = None, *, decode: bool = False):
|
def get_nvram(variable: str, uuid: str = None, *, decode: bool = False):
|
||||||
# TODO: Properly fix for El Capitan, which does not print the XML representation even though we say to
|
# TODO: Properly fix for El Capitan, which does not print the XML representation even though we say to
|
||||||
|
|
||||||
@@ -299,6 +305,7 @@ def download_file(link, location):
|
|||||||
chunk = file.read(1024 * 1024 * 16)
|
chunk = file.read(1024 * 1024 * 16)
|
||||||
return checksum
|
return checksum
|
||||||
|
|
||||||
|
|
||||||
def elevated(*args, **kwargs) -> subprocess.CompletedProcess:
|
def elevated(*args, **kwargs) -> subprocess.CompletedProcess:
|
||||||
# When runnign through our GUI, we run as root, however we do not get uid 0
|
# When runnign through our GUI, we run as root, however we do not get uid 0
|
||||||
# Best to assume CLI is running as root
|
# Best to assume CLI is running as root
|
||||||
@@ -307,6 +314,7 @@ def elevated(*args, **kwargs) -> subprocess.CompletedProcess:
|
|||||||
else:
|
else:
|
||||||
return subprocess.run(["sudo"] + [args[0][0]] + args[0][1:], **kwargs)
|
return subprocess.run(["sudo"] + [args[0][0]] + args[0][1:], **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def check_cli_args():
|
def check_cli_args():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("--build", help="Build OpenCore", action="store_true", required=False)
|
parser.add_argument("--build", help="Build OpenCore", action="store_true", required=False)
|
||||||
@@ -339,16 +347,12 @@ def check_cli_args():
|
|||||||
# validation args
|
# validation args
|
||||||
parser.add_argument("--validate", help="Runs Validation Tests for CI", action="store_true", required=False)
|
parser.add_argument("--validate", help="Runs Validation Tests for CI", action="store_true", required=False)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if not(
|
if not (args.build or args.patch_sys_vol or args.unpatch_sys_vol or args.validate):
|
||||||
args.build or
|
|
||||||
args.patch_sys_vol or
|
|
||||||
args.unpatch_sys_vol or
|
|
||||||
args.validate
|
|
||||||
):
|
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
# def menu(title, prompt, menu_options, add_quit=True, auto_number=False, in_between=[], top_level=False):
|
# def menu(title, prompt, menu_options, add_quit=True, auto_number=False, in_between=[], top_level=False):
|
||||||
# return_option = ["Q", "Quit", None] if top_level else ["B", "Back", None]
|
# return_option = ["Q", "Quit", None] if top_level else ["B", "Back", None]
|
||||||
# if add_quit: menu_options.append(return_option)
|
# if add_quit: menu_options.append(return_option)
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
from resources import build
|
from resources import build
|
||||||
from data import example_data, model_array
|
from data import example_data, model_array
|
||||||
@@ -24,6 +23,7 @@ def validate(settings):
|
|||||||
]
|
]
|
||||||
|
|
||||||
settings.validate = True
|
settings.validate = True
|
||||||
|
|
||||||
def build_prebuilt():
|
def build_prebuilt():
|
||||||
for model in model_array.SupportedSMBIOS:
|
for model in model_array.SupportedSMBIOS:
|
||||||
print(f"Validating predefined model: {model}")
|
print(f"Validating predefined model: {model}")
|
||||||
|
|||||||
Reference in New Issue
Block a user