Skip to content

Commit 178c604

Browse files
committed
Clean Detection Code
1 parent 88b660e commit 178c604

File tree

7 files changed

+262
-356
lines changed

7 files changed

+262
-356
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# OpenCore Legacy Patcher changelog
22

3+
## 0.1.8
4+
- Fix Kernel Panic in Big Sur and Monterey
5+
- Increment binaries:
6+
- Lilu (1.5.4 rolling - 06-15-2021)
7+
38
## 0.1.7
49
- Add FireWire Boot Support for Catalina and newer
510
- Add NVMe firmware support for older models (ie. MacPro3,1)

OpenCore-Patcher.command

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,52 +17,47 @@ class OpenCoreLegacyPatcher():
1717
self.current_model: str = None
1818
self.current_model = DeviceProbe.smbios_probe().model_detect(False)
1919
self.constants.detected_os = int(platform.uname().release.partition(".")[0])
20-
if self.current_model in ModelArray.LegacyGPU:
21-
dgpu_vendor,dgpu_device,dgpu_acpi = DeviceProbe.pci_probe().gpu_probe("GFX0")
22-
23-
if (dgpu_vendor == self.constants.pci_amd_ati and (dgpu_device in PCIIDArray.amd_ids().polaris_ids or dgpu_device in PCIIDArray.amd_ids().vega_ids or dgpu_device in PCIIDArray.amd_ids().navi_ids or dgpu_device in PCIIDArray.amd_ids().legacy_gcn_ids)) or (dgpu_vendor == self.constants.pci_nvidia and dgpu_device in PCIIDArray.nvidia_ids().kepler_ids):
24-
self.constants.sip_status = True
25-
self.constants.secure_status = False
26-
self.constants.disable_amfi = False
27-
else:
28-
self.constants.sip_status = False
29-
self.constants.secure_status = False
30-
self.constants.disable_amfi = True
31-
if self.current_model in ModelArray.ModernGPU:
32-
if self.current_model in ["iMac13,1", "iMac13,3"]:
33-
dgpu_vendor,dgpu_device,dgpu_acpi = DeviceProbe.pci_probe().gpu_probe("GFX0")
34-
if not dgpu_vendor:
35-
self.constants.sip_status = False
36-
self.constants.secure_status = False
37-
else:
38-
self.constants.sip_status = False
39-
self.constants.secure_status = False
40-
41-
# Logic for when user runs custom OpenCore build and do not expose it
42-
# Note: This logic currently only applies for iMacPro1,1 users, see below threads on the culprits:
43-
# - https://forums.macrumors.com/threads/2011-imac-graphics-card-upgrade.1596614/post-17425857
44-
# - https://forums.macrumors.com/threads/opencore-on-the-mac-pro.2207814/
45-
# PLEASE FOR THE LOVE OF GOD JUST SET ExposeSensitiveData CORRECTLY!!!
46-
if self.current_model == "iMacPro1,1":
47-
serial: str = subprocess.run("system_profiler SPHardwareDataType | grep Serial".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
48-
serial = [line.strip().split("Number (system): ", 1)[1] for line in serial.split("\n") if line.strip().startswith("Serial")][0]
49-
true_model = subprocess.run([str(self.constants.macserial_path), "--info", str(serial)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
50-
true_model = [i.partition(" - ")[2] for i in true_model.stdout.decode().split("\n") if "Model: " in i][0]
51-
print(f"True Model: {true_model}")
52-
if not true_model.startswith("Unknown"):
53-
self.current_model = true_model
20+
self.check_default_settings(self.current_model, False)
5421

5522
custom_cpu_model_value: str = subprocess.run("nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:revcpuname".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
56-
5723
if not custom_cpu_model_value.startswith("nvram: Error getting variable"):
5824
custom_cpu_model_value = [line.strip().split(":revcpuname ", 1)[1] for line in custom_cpu_model_value.split("\n") if line.strip().startswith("4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:")][0]
5925
if custom_cpu_model_value.split("%00")[0] != "":
6026
self.constants.custom_cpu_model = 1
6127
self.constants.custom_cpu_model_value = custom_cpu_model_value.split("%00")[0]
6228

29+
if "-v" in Utilities.get_nvram("boot-args", decode=False):
30+
self.constants.verbose_debug = True
31+
6332
# Check if running in RecoveryOS
6433
self.check_recovery()
6534

35+
def check_default_settings(self, model, custom):
36+
self.constants.sip_status = True
37+
self.constants.disable_amfi = False
38+
if model in ModelArray.LegacyGPU:
39+
if custom is False:
40+
dgpu_vendor,dgpu_device,dgpu_acpi = DeviceProbe.pci_probe().gpu_probe("GFX0")
41+
if (dgpu_vendor == self.constants.pci_amd_ati and (dgpu_device in PCIIDArray.amd_ids().polaris_ids or dgpu_device in PCIIDArray.amd_ids().vega_ids or dgpu_device in PCIIDArray.amd_ids().navi_ids or dgpu_device in PCIIDArray.amd_ids().legacy_gcn_ids)) or (dgpu_vendor == self.constants.pci_nvidia and dgpu_device in PCIIDArray.nvidia_ids().kepler_ids):
42+
self.constants.sip_status = True
43+
self.constants.secure_status = False
44+
self.constants.disable_amfi = False
45+
else:
46+
self.constants.sip_status = False
47+
self.constants.secure_status = False
48+
self.constants.disable_amfi = True
49+
if model in ModelArray.ModernGPU:
50+
if model in ["iMac13,1", "iMac13,3"]:
51+
52+
if custom is False:
53+
dgpu_vendor,dgpu_device,dgpu_acpi = DeviceProbe.pci_probe().gpu_probe("GFX0")
54+
if not dgpu_vendor:
55+
self.constants.sip_status = False
56+
self.constants.secure_status = False
57+
else:
58+
self.constants.sip_status = False
59+
self.constants.secure_status = False
60+
6661
def check_recovery(self):
6762
root_partition_info = plistlib.loads(subprocess.run("diskutil info -plist /".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
6863
if root_partition_info["VolumeName"] == "macOS Base System" and \
@@ -95,6 +90,8 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
9590
if print_models in {"y", "Y", "yes", "Yes"}:
9691
print("\n".join(ModelArray.SupportedSMBIOS))
9792
input("\nPress [ENTER] to continue")
93+
else:
94+
self.check_default_settings(self.constants.custom_model, True)
9895

9996
def patcher_settings(self):
10097
response = None
@@ -230,7 +227,6 @@ B. Exit
230227

231228
def main_menu(self):
232229
response = None
233-
ModelArray.SupportedSMBIOS = ModelArray.SupportedSMBIOS12
234230
while not (response and response == -1):
235231
title = [
236232
f"OpenCore Legacy Patcher v{self.constants.patcher_version}",

Resources/CliMenu.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,6 @@ def __init__(self, model, versions):
1111
self.model = model
1212
self.constants: Constants.Constants = versions
1313

14-
def change_os(self):
15-
Utilities.cls()
16-
Utilities.header(["Select Patcher's Target OS"])
17-
print(f"""
18-
Minimum Target:\t{self.constants.min_os_support}
19-
Maximum Target:\t{self.constants.max_os_support}
20-
Current target:\t{self.constants.os_support}
21-
""")
22-
temp_os_support = float(input("Please enter OS target: "))
23-
if (self.constants.max_os_support < temp_os_support) or (temp_os_support < self.constants.min_os_support):
24-
print("Unsupported entry")
25-
else:
26-
self.constants.os_support = temp_os_support
27-
if temp_os_support == 11.0:
28-
ModelArray.SupportedSMBIOS = ModelArray.SupportedSMBIOS11
29-
elif temp_os_support == 12.0:
30-
ModelArray.SupportedSMBIOS = ModelArray.SupportedSMBIOS12
31-
3214
def change_verbose(self):
3315
Utilities.cls()
3416
Utilities.header(["Set Verbose mode"])

Resources/Constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class Constants:
1111
def __init__(self):
12-
self.patcher_version = "0.1.7"
12+
self.patcher_version = "0.1.8"
1313
self.opencore_commit = "4e0ff2d - 05-23-2021"
1414
self.opencore_version = "0.7.0"
1515
self.lilu_version = "1.5.4"

0 commit comments

Comments
 (0)