Fix formatting

This commit is contained in:
Mykola Grymalyuk
2021-10-09 11:19:39 -06:00
parent 12998bc7e1
commit 06e0e9a2c0
21 changed files with 469 additions and 324 deletions

View File

@@ -10,6 +10,7 @@ from pathlib import Path
from resources import build, cli_menu, constants, utilities, device_probe, os_probe, defaults, arguments
from data import model_array
class OpenCoreLegacyPatcher:
def __init__(self):
print("- Loading...")
@@ -17,7 +18,7 @@ class OpenCoreLegacyPatcher:
self.generate_base_data()
if utilities.check_cli_args() is None:
self.main_menu()
def generate_base_data(self):
self.constants.detected_os = os_probe.detect_kernel_major()
self.constants.detected_os_minor = os_probe.detect_kernel_minor()
@@ -28,7 +29,7 @@ class OpenCoreLegacyPatcher:
defaults.generate_defaults.probe(self.computer.real_model, True, self.constants)
if utilities.check_cli_args() is not None:
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()
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
print("- Rerouting payloads location")

View File

@@ -1,14 +1,15 @@
import enum
class bluetooth_data(enum.IntEnum):
# Bluetooth Chipsets
NonApplicable = 0
BRCM2045 = 1 # TODO: Rename chipset, currently guessing MacPro1,1-3,1 name
BRCM2046 = 2 # BT 2.1
BRCM2070 = 3 # BT 2.1
BRCM20702_v1 = 4 # BT 4.0 - 2012
BRCM20702_v2 = 5 # BT 4.0 - 2013+
BRCM20703 = 6 # BT 4.2
BRCM20703_UART = 9 # BRCM20703 over UART, BT 4.2
UART = 10 # T2
PCIe = 20 # Apple Silicon
BRCM2045 = 1 # TODO: Rename chipset, currently guessing MacPro1,1-3,1 name
BRCM2046 = 2 # BT 2.1
BRCM2070 = 3 # BT 2.1
BRCM20702_v1 = 4 # BT 4.0 - 2012
BRCM20702_v2 = 5 # BT 4.0 - 2013+
BRCM20703 = 6 # BT 4.2
BRCM20703_UART = 9 # BRCM20703 over UART, BT 4.2
UART = 10 # T2
PCIe = 20 # Apple Silicon

View File

@@ -1,22 +1,22 @@
import enum
class cpu_data(enum.IntEnum):
pentium_4 = 0
yonah = 1
conroe = 2
penryn = 3
nehalem = 4 # (Westmere included)
nehalem = 4 # (Westmere included)
sandy_bridge = 5 # 2000
ivy_bridge = 6 # 3000
haswell = 7 # 4000
broadwell = 8 # 5000
skylake = 9 # 6000
haswell = 7 # 4000
broadwell = 8 # 5000
skylake = 9 # 6000
kaby_lake = 10 # 7000
coffee_lake = 11 # 8000
comet_lake = 12 # 9000
comet_lake = 12 # 9000
ice_lake = 13 # 10000
apple_dtk = 112 # A12
apple_m1 = 114 # A14
apple_m2 = 115 # A15
apple_dtk = 112 # A12
apple_m1 = 114 # A14
apple_m2 = 115 # A15

View File

@@ -392,4 +392,4 @@ Missing_USB_Map = [
"MacPro4,1",
"Xserve2,1",
"Xserve3,1",
]
]

View File

@@ -1,5 +1,6 @@
import enum
class os_data(enum.IntEnum):
# OS Versions, Based off Major Kernel Version
tiger = 8
@@ -16,4 +17,4 @@ class os_data(enum.IntEnum):
catalina = 19
big_sur = 20
monterey = 21
max_os = 99
max_os = 99

View File

@@ -699,8 +699,8 @@ class amd_ids:
0x6898, # HD 5870
0x6899, # HD 5850
0x68B8, # HD 5770
0x68B0, # Unknown
0x68B1, # Unknown
0x68B0, # Unknown
0x68B1, # Unknown
0x68A0, # HD 5870 (mobile)
0x68A1, # HD 5850 (mobile)
0x6840, # HD 7500M/7600M
@@ -714,7 +714,7 @@ class amd_ids:
0x6759, # HD 6570/7570/8550
0x6740, # HD 6730M/6770M/7690M XT
0x6741, # HD 6630M/6650M/6750M/7670M/7690M
0x6745, # Unknown
0x6745, # Unknown
]

View File

@@ -32,4 +32,4 @@ class system_integrity_protection:
"CSR_ALLOW_UNAPPROVED_KEXTS", # 0x200
"CSR_ALLOW_EXECUTABLE_POLICY_OVERRIDE", # 0x400
"CSR_ALLOW_UNAUTHENTICATED_ROOT", # 0x800
]
]

File diff suppressed because it is too large Load Diff

View File

@@ -169,7 +169,7 @@ AddIntelGen2AccelStock = [
AddIntelGen2AccelPatched = [
"AppleIntelSNBGraphicsFB.kext",
],
]
AddIntelGen3Accel = [
"AppleIntelFramebufferCapri.kext",

View File

@@ -6,7 +6,7 @@ from data import model_array
class arguments:
def __init__(self):
self.args = utilities.check_cli_args()
def parse_arguments(self, settings):
if self.args.model:
if self.args.model:
@@ -33,7 +33,7 @@ If you plan to create the USB for another machine, please select the "Change Mod
print("- Set verbose configuration")
settings.verbose_debug = True
else:
settings.verbose_debug = False # Override Defaults detected
settings.verbose_debug = False # Override Defaults detected
if self.args.debug_oc:
print("- Set OpenCore DEBUG configuration")
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")
settings.sip_status = False
else:
settings.sip_status = True # Override Defaults detected
settings.sip_status = True # Override Defaults detected
if self.args.disable_smb:
print("- Set Disable SecureBootModel configuration")
settings.secure_status = False
else:
settings.secure_status = True # Override Defaults detected
settings.secure_status = True # Override Defaults detected
if self.args.vault:
print("- Set Vault configuration")
settings.vault = True
@@ -104,4 +104,4 @@ If you plan to create the USB for another machine, please select the "Change Mod
sys_patch.PatchSysVolume(settings.custom_model or settings.computer.real_model, settings).start_patch()
elif self.args.unpatch_sys_vol:
print("- Set System Volume unpatching")
sys_patch.PatchSysVolume(settings.custom_model or settings.computer.real_model, settings).start_unpatch()
sys_patch.PatchSysVolume(settings.custom_model or settings.computer.real_model, settings).start_unpatch()

View File

@@ -106,7 +106,12 @@ class BuildOpenCore:
# CPU patches
("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),
("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",
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"),
("MarvelYukonEthernet.kext", self.constants.marvel_version, self.constants.marvel_path, lambda: smbios_data.smbios_dictionary[self.model]["Ethernet Chipset"] == "Marvell"),
# 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
("AppleIntelPIIXATA.kext", self.constants.piixata_version, self.constants.piixata_path, lambda: self.model in model_array.IDEPatch),
# 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),
("AppleUSBTrackpad.kext", self.constants.apple_trackpad, self.constants.apple_trackpad_path, lambda: self.model in ["MacBook4,1", "MacBook5,2"]),
]:
@@ -136,7 +151,7 @@ class BuildOpenCore:
# Required due to Big Sur's BCM5701 requiring VT-x support
# Applicable for pre-Ivy Bridge models
self.enable_kext("CatalinaBCM5701Ethernet.kext", self.constants.bcm570_version, self.constants.bcm570_path)
if self.constants.allow_oc_everywhere is False:
if (smbios_data.smbios_dictionary[generate_smbios.set_smbios_model_spoof(self.model) or self.constants.override_smbios]["SecureBootModel"]) != None:
# Monterey T2 SMBIOS don't get OS updates without a T2 SBM
@@ -415,7 +430,6 @@ class BuildOpenCore:
# Used to enable Audio support for non-standard dGPUs
self.enable_kext("AppleALC.kext", self.constants.applealc_version, self.constants.applealc_path)
def check_firewire(model):
# MacBooks never supported FireWire
# Pre-Thunderbolt MacBook Airs as well
@@ -745,12 +759,12 @@ class BuildOpenCore:
self.config["PlatformInfo"]["PlatformNVRAM"]["FirmwareFeaturesMask"] = fw_feature
self.config["PlatformInfo"]["SMBIOS"]["FirmwareFeatures"] = fw_feature
self.config["PlatformInfo"]["SMBIOS"]["FirmwareFeaturesMask"] = fw_feature
# Board ID
self.config["PlatformInfo"]["DataHub"]["BoardProduct"] = self.spoofed_board
self.config["PlatformInfo"]["PlatformNVRAM"]["BID"] = self.spoofed_board
self.config["PlatformInfo"]["SMBIOS"]["BoardProduct"] = self.spoofed_board
# Model (ensures tables are not mismatched, even if we're not spoofing)
self.config["PlatformInfo"]["DataHub"]["SystemProductName"] = self.model
self.config["PlatformInfo"]["SMBIOS"]["SystemProductName"] = self.model
@@ -866,7 +880,7 @@ class BuildOpenCore:
for gpu in ["Vendor10deDevice0a34", "Vendor10deDevice0a29"]:
agpm_config["IOKitPersonalities"]["AGPM"]["Machines"][self.spoofed_board][gpu]["BoostPState"] = [2, 2, 2, 2]
agpm_config["IOKitPersonalities"]["AGPM"]["Machines"][self.spoofed_board][gpu]["BoostTime"] = [2, 2, 2, 2]
for entry in list(agpm_config["IOKitPersonalities"]["AGPM"]["Machines"]):
if not entry.startswith(self.spoofed_board):
agpm_config["IOKitPersonalities"]["AGPM"]["Machines"].pop(entry)

View File

@@ -632,7 +632,7 @@ handle acceleration tasks.
print("")
print(self.constants.computer)
input("\nPress [ENTER] to exit: ")
def applealc_support(self):
utilities.cls()
utilities.header(["Set AppleALC usage"])
@@ -656,7 +656,7 @@ If AppleALC is detected, the Patcher will not install AppleHDA.
print("Returning to previous menu")
else:
self.applealc_support()
def dGPU_switch_support(self):
utilities.cls()
utilities.header(["Set Windows GMUX support"])
@@ -677,7 +677,7 @@ for Windows may prefer to only work with the dGPU and eGPU active.
print("Returning to previous menu")
else:
self.dGPU_switch_support()
def set_surplus(self):
utilities.cls()
utilities.header(["Override SurPlus MaxKernel"])
@@ -703,7 +703,7 @@ the event there's issues.
print("Returning to previous menu")
else:
self.set_surplus()
def credits(self):
utilities.TUIOnlyPrint(
["Credits"],
@@ -749,7 +749,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
input("\nPress [ENTER] to continue")
else:
defaults.generate_defaults.probe(self.constants.custom_model, False, self.constants)
def PatchVolume(self):
utilities.cls()
utilities.header(["Patching System Volume"])
@@ -771,7 +771,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
sys_patch.PatchSysVolume(self.constants.custom_model or self.constants.computer.real_model, self.constants).start_unpatch()
else:
print("Returning to main menu")
def advanced_patcher_settings(self):
response = None
while not (response and response == -1):
@@ -791,7 +791,6 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
menu.add_menu_option(option[0], function=option[1])
response = menu.start()
def patcher_settings(self):
response = None
@@ -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 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)
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 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 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}",
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 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:
@@ -943,9 +946,6 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
response = menu.start()
big_sur = """Patches Root volume to fix misc issues such as:
- Non-Metal Graphics Acceleration
@@ -1012,4 +1012,4 @@ install that requires root patches such as macOS Big Sur or Monterey
Supported Options:
B. Exit
"""
"""

View File

@@ -13,7 +13,7 @@ from resources import device_probe
class Constants:
def __init__(self):
# 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.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/"
@@ -165,33 +165,6 @@ class Constants:
self.big_sur = 20
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.mojave,
self.catalina,
@@ -256,7 +229,7 @@ class Constants:
@property
def restrictevents_path(self):
return self.payload_kexts_path / Path(f"Acidanthera/RestrictEvents-v{self.restrictevents_version}.zip")
@property
def efi_disabler_path(self):
return self.payload_kexts_path / Path(f"Acidanthera/EFICheckDisabler-v{self.restrictevents_version}.zip")
@@ -569,7 +542,7 @@ class Constants:
@property
def payload_apple_private_frameworks_path_brightness(self):
return self.payload_apple_private_frameworks_path / Path("Brightness-Control")
@property
def payload_apple_private_frameworks_path_legacy_drm(self):
return self.payload_apple_private_frameworks_path / Path("Legacy-GVA")
@@ -626,7 +599,7 @@ class Constants:
@property
def legacy_brightness(self):
return self.payload_apple_kexts_path / Path("Brightness-Control")
@property
def legacy_mux_path(self):
return self.payload_apple_kexts_path / Path("Legacy-Mux")
@@ -674,8 +647,8 @@ class Constants:
"Mac-942459F5819B171B", # MacBookPro8,3
"Mac-C08A6BB70A942AC2", # MacBookAir4,1
"Mac-742912EFDBEE19B3", # MacBookAir4,2
"Mac-8ED6AF5B48C039E1", # Macmini5,1
"Mac-7BA5B2794B2CDB12", # Macmini5,3
"Mac-942B5BF58194151B", # iMac12,1
"Mac-942B59F58194171B", # iMac12,2
]
"Mac-8ED6AF5B48C039E1", # Macmini5,1
"Mac-7BA5B2794B2CDB12", # Macmini5,3
"Mac-942B5BF58194151B", # iMac12,1
"Mac-942B59F58194171B", # iMac12,2
]

View File

@@ -2,7 +2,8 @@
from resources import utilities, device_probe
from data import model_array
class generate_defaults():
class generate_defaults:
def probe(model, host_is_target, settings):
# Generate Default Data
# Takes in Settings data set, and returns updated Settings
@@ -48,7 +49,6 @@ class generate_defaults():
settings.secure_status = False # Modified root volume
settings.allow_fv_root = True # Allow FileVault on broken seal
# settings.amfi_status = True # Signed bundles, Don't need to explicitly set currently
if model == "MacBook8,1":
# MacBook8,1 has an odd bug where it cannot install Monterey with Minimal spoofing
@@ -72,4 +72,4 @@ class generate_defaults():
settings.allow_ts2_accel = False
# Check if running in RecoveryOS
settings.recovery_status = utilities.check_recovery()
settings.recovery_status = utilities.check_recovery()

View File

@@ -26,7 +26,7 @@ class PCIDevice:
vendor_id: int # The vendor 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
name: Optional[str] = None # Name of IORegistryEntry

View File

@@ -1,6 +1,7 @@
from data import smbios_data, os_data
from resources import utilities
def set_smbios_model_spoof(model):
try:
smbios_data.smbios_dictionary[model]["Screen Size"]
@@ -53,6 +54,7 @@ def set_smbios_model_spoof(model):
# Unknown Model
raise Exception(f"Unknown SMBIOS for spoofing: {model}")
def update_firmware_features(firmwarefeature):
# Adjust FirmwareFeature to support everything macOS requires
# APFS Bit (19/20): 10.13+ (OSInstall)
@@ -62,7 +64,8 @@ def update_firmware_features(firmwarefeature):
firmwarefeature |= 2 ** 20 # FW_FEATURE_SUPPORTS_APFS_EXTRA
firmwarefeature |= 2 ** 35 # FW_FEATURE_SUPPORTS_LARGE_BASESYSTEM
return firmwarefeature
def generate_fw_features(model, custom):
if not custom:
firmwarefeature = utilities.get_rom("firmware-features")
@@ -72,4 +75,26 @@ def generate_fw_features(model, custom):
else:
firmwarefeature = int(smbios_data.smbios_dictionary[model]["FirmwareFeatures"], 16)
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

View File

@@ -7,13 +7,13 @@ from typing import NewType, Union
import subprocess
try:
import objc
import objc
except ImportError:
subprocess.run(["pip3", "install", "pyobjc"], stdout=subprocess.PIPE)
try:
import objc
except ImportError:
raise Exception("Missing PyObjc library!\nPlease run the following before starting OCLP:\npip3 install pyobjc")
subprocess.run(["pip3", "install", "pyobjc"], stdout=subprocess.PIPE)
try:
import objc
except ImportError:
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 Foundation import NSBundle # type: ignore # pylint: disable=no-name-in-module

View File

@@ -3,17 +3,20 @@
import platform
import subprocess
def detect_kernel_major():
# Return Major Kernel Version
# Example Output: 21 (integer)
return int(platform.uname().release.partition(".")[0])
def detect_kernel_minor():
# Return Minor Kernel Version
# Example Output: 1 (integer)
return int(platform.uname().release.partition(".")[2].partition(".")[0])
def detect_kernel_build():
# Return OS build
# Example Output: 21A5522h (string)
return subprocess.run("sw_vers -buildVersion".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
return subprocess.run("sw_vers -buildVersion".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()

View File

@@ -237,7 +237,9 @@ class PatchSysVolume:
input("Press [ENTER] to continue with kernel and dyld cache merging")
if self.constants.detected_os > self.constants.catalina:
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:
print("- Unable to create new snapshot")
print("Reason for snapshot failure:")
@@ -268,7 +270,7 @@ set million colour before rebooting"""
def unmount_drive(self):
print("- Unmounting Root Volume (Don't worry if this fails)")
utilities.elevated(["diskutil", "unmount", self.root_mount_path], stdout=subprocess.PIPE).stdout.decode().strip().encode()
def delete_old_binaries(self, vendor_patch):
for delete_current_kext in vendor_patch:
delete_path = Path(self.mount_extensions) / Path(delete_current_kext)
@@ -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(["chown", "-Rf", "root:wheel", f"{self.mount_extensions}/{add_current_kext}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
def add_brightness_patch(self):
self.delete_old_binaries(sys_patch_data.DeleteBrightness)
self.add_new_binaries(sys_patch_data.AddBrightness, self.constants.legacy_brightness)
@@ -313,11 +314,13 @@ set million colour before rebooting"""
utilities.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.legacy_wifi_libexec}/", self.mount_libexec], stdout=subprocess.PIPE)
utilities.process_status(utilities.elevated(["chmod", "755", f"{self.mount_libexec}/airportd"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(utilities.elevated(["chown", "root:wheel", f"{self.mount_libexec}/airportd"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
def add_legacy_mux_patch(self):
self.delete_old_binaries(sys_patch_data.DeleteDemux)
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):
if self.constants.detected_os == self.constants.mojave:
@@ -411,7 +414,7 @@ set million colour before rebooting"""
print("- Installing basic Sandy Bridge Framebuffer Kext patches for generic OS")
self.add_new_binaries(sys_patch_data.AddIntelGen2Accel, self.constants.legacy_intel_gen2_path)
self.gpu_accel_legacy_sandybridge_board_id()
def gpu_accel_legacy_sandybridge_board_id(self):
if self.constants.computer.reported_board_id in self.constants.sandy_board_id_stock:
print("- Using stock AppleIntelSNBGraphicsFB")
@@ -423,13 +426,17 @@ set million colour before rebooting"""
utilities.elevated(["rm", "-r", f"{self.mount_extensions}/AppleIntelSNBGraphicsFB.kext"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
# Add 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
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
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)
else:
# Adjust board ID for spoofs
print("- Using Board ID patched AppleIntelSNBGraphicsFB")
@@ -441,7 +448,7 @@ set million colour before rebooting"""
# Fix permissions
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)
def gpu_framebuffer_ivybridge_master(self):
if self.constants.detected_os == self.constants.monterey:
print("- Installing IvyBridge Acceleration Kext patches for Monterey")
@@ -464,7 +471,7 @@ set million colour before rebooting"""
else:
print("- Installing Kepler Kext patches for generic OS")
self.add_new_binaries(sys_patch_data.AddNvidiaKeplerAccel11, self.constants.legacy_nvidia_kepler_path)
def gpu_accel_legacy_gva(self):
print("- Merging AppleGVA Hardware Accel patches for non-Metal")
utilities.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_private_frameworks_path_legacy_drm}/", self.mount_private_frameworks], stdout=subprocess.PIPE)
@@ -590,7 +597,7 @@ set million colour before rebooting"""
if self.legacy_wifi is True:
print("- Installing legacy Wireless support")
self.add_wifi_patch()
if self.legacy_gmux is True:
print("- Installing Legacy Mux Brightness support")
self.add_legacy_mux_patch()
@@ -714,7 +721,7 @@ set million colour before rebooting"""
self.amd_ts2 = False
self.iron_gpu = False
self.sandy_gpu = False
def detect_demux(self):
# If GFX0 is missing, assume machine was demuxed
# -wegnoegpu would also trigger this, so ensure arg is not present
@@ -724,7 +731,6 @@ set million colour before rebooting"""
if igpu and not dgpu:
return True
return False
def detect_patch_set(self):
self.detect_gpus()
@@ -744,7 +750,7 @@ set million colour before rebooting"""
) or (isinstance(self.constants.computer.wifi, device_probe.Atheros) and self.constants.computer.wifi.chipset == device_probe.Atheros.Chipsets.AirPortAtheros40):
if self.constants.detected_os > self.constants.big_sur:
self.legacy_wifi = True
if self.model in ["MacBookPro5,1", "MacBookPro5,2", "MacBookPro5,3", "MacBookPro8,2", "MacBookPro8,3"]:
# Sierra uses a legacy GMUX control method needed for dGPU switching on MacBookPro5,x
# Same method is also used for demuxed machines
@@ -827,10 +833,7 @@ set million colour before rebooting"""
print("\nCannot patch! Please disable AMFI.")
print("For Hackintoshes, please add amfi_get_out_of_my_way=1 to boot-args")
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
):
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):
print("\nCannot patch! Board ID not supported by AppleIntelSNBGraphicsFB")
print(f"Detected Board ID: {self.computer.reported_board_id}")
print("Please ensure your Board ID is listed below:")

View File

@@ -129,6 +129,7 @@ def amfi_status():
else:
return True
def check_kext_loaded(kext_name, os_version):
if os_version > constants.Constants().catalina:
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:
return False
def check_oclp_boot():
if get_nvram("OCLP-Version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True):
return True
@@ -194,7 +196,10 @@ def patching_status(os_sip, os):
# Catalina and older supports individually disabling Library Validation
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
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:
print("\u001Bc")
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
@@ -299,6 +305,7 @@ def download_file(link, location):
chunk = file.read(1024 * 1024 * 16)
return checksum
def elevated(*args, **kwargs) -> subprocess.CompletedProcess:
# When runnign through our GUI, we run as root, however we do not get uid 0
# Best to assume CLI is running as root
@@ -307,6 +314,7 @@ def elevated(*args, **kwargs) -> subprocess.CompletedProcess:
else:
return subprocess.run(["sudo"] + [args[0][0]] + args[0][1:], **kwargs)
def check_cli_args():
parser = argparse.ArgumentParser()
parser.add_argument("--build", help="Build OpenCore", action="store_true", required=False)
@@ -339,16 +347,12 @@ def check_cli_args():
# validation args
parser.add_argument("--validate", help="Runs Validation Tests for CI", action="store_true", required=False)
args = parser.parse_args()
if not(
args.build or
args.patch_sys_vol or
args.unpatch_sys_vol or
args.validate
):
if not (args.build or args.patch_sys_vol or args.unpatch_sys_vol or args.validate):
return None
else:
return args
# 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]
# if add_quit: menu_options.append(return_option)

View File

@@ -1,4 +1,3 @@
import subprocess
from resources import build
from data import example_data, model_array
@@ -22,8 +21,9 @@ def validate(settings):
example_data.MacPro.MacPro41_Modern_AMD,
example_data.MacPro.MacPro41_51__Flashed_Modern_AMD,
]
settings.validate = True
def build_prebuilt():
for model in model_array.SupportedSMBIOS:
print(f"Validating predefined model: {model}")
@@ -36,7 +36,7 @@ def validate(settings):
raise Exception(f"Validation failed for predefined model: {model}")
else:
print(f"Validation succeeded for predefined model: {model}")
def build_dumps():
for model in valid_dumps:
settings.computer = model
@@ -50,7 +50,7 @@ def validate(settings):
raise Exception(f"Validation failed for predefined model: {settings.computer.real_model}")
else:
print(f"Validation succeeded for predefined model: {settings.computer.real_model}")
# First run is with default settings
build_prebuilt()
build_dumps()
@@ -68,4 +68,4 @@ def validate(settings):
settings.disable_tb = True
settings.force_surplus = True
build_prebuilt()
build_dumps()
build_dumps()