Add upgraded GPU checks

This commit is contained in:
Mykola Grymalyuk
2021-03-01 20:08:40 -07:00
parent 9ce2e2add1
commit 83df3e3e12
5 changed files with 91 additions and 12 deletions
+8 -9
View File
@@ -12,7 +12,6 @@ PATCHER_VERSION = "0.0.11"
class OpenCoreLegacyPatcher():
def __init__(self):
self.constants = Constants.Constants()
self.custom_model: str = None
self.current_model: str = None
opencore_model: str = subprocess.run("nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:oem-product".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
if not opencore_model.startswith("nvram: Error getting variable"):
@@ -23,10 +22,10 @@ class OpenCoreLegacyPatcher():
self.current_model = [line.strip().split(": ", 1)[1] for line in self.current_model.stdout.decode().split("\n") if line.strip().startswith("Model Identifier")][0]
def build_opencore(self):
build.BuildOpenCore(self.custom_model or self.current_model, self.constants).build_opencore()
build.BuildOpenCore(self.constants.custom_model or self.current_model, self.constants).build_opencore()
def install_opencore(self):
build.BuildOpenCore(self.custom_model or self.current_model, self.constants).copy_efi()
build.BuildOpenCore(self.constants.custom_model or self.current_model, self.constants).copy_efi()
def change_model(self):
utilities.cls()
@@ -36,7 +35,7 @@ Tip: Run the following command on the target machine to find the model identifie
system_profiler SPHardwareDataType | grep 'Model Identifier'
""")
self.custom_model = input("Please enter the model identifier of the target machine: ").strip()
self.constants.custom_model = input("Please enter the model identifier of the target machine: ").strip()
def credits(self):
utilities.TUIOnlyPrint(["Credits"], "Press [Enter] to go back.\n",
@@ -53,23 +52,23 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
while not (response and response == -1):
title = [
f"OpenCore Legacy Patcher v{self.constants.patcher_version}",
f"Selected Model: {self.custom_model or self.current_model}"
f"Selected Model: {self.constants.custom_model or self.current_model}"
]
if (self.custom_model or self.current_model) not in ModelArray.SupportedSMBIOS:
if (self.constants.custom_model or self.current_model) not in ModelArray.SupportedSMBIOS:
in_between = [
'Your model is not supported by this patcher!',
'',
'If you plan to create the USB for another machine, please select the "Change Model" option in the menu.'
]
elif not self.custom_model and self.current_model in ("MacPro3,1", "iMac7,1") and \
elif not self.constants.custom_model and self.current_model in ("MacPro3,1", "iMac7,1") and \
"SSE4.1" not in subprocess.run("sysctl machdep.cpu.features".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode():
in_between = [
'Your model requires a CPU upgrade to a CPU supporting SSE4.1+ to be supported by this patcher!',
'',
f'If you plan to create the USB for another {self.current_model} with SSE4.1+, please select the "Change Model" option in the menu.'
]
elif self.custom_model in ("MacPro3,1", "iMac7,1"):
elif self.constants.custom_model in ("MacPro3,1", "iMac7,1"):
in_between = ["This model is supported",
"However please ensure the CPU has been upgraded to support SSE4.1+"
]
@@ -78,7 +77,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
menu = utilities.TUIMenu(title, "Please select an option: ", in_between=in_between, auto_number=True, top_level=True)
options = ([["Build OpenCore", self.build_opencore]] if ((self.custom_model or self.current_model) in ModelArray.SupportedSMBIOS) else []) + [
options = ([["Build OpenCore", self.build_opencore]] if ((self.constants.custom_model or self.current_model) in ModelArray.SupportedSMBIOS) else []) + [
["Install OpenCore to USB/internal drive", self.install_opencore],
["Change Model", self.change_model],
["Credits", self.credits]