mirror of
https://github.com/outbackdingo/OpCore-Simplify.git
synced 2026-01-27 10:19:49 +00:00
Add customizable SMBIOS model selection for user configuration
This commit is contained in:
@@ -3,6 +3,7 @@ from Scripts import aida64
|
||||
from Scripts import compatibility_checker
|
||||
from Scripts import efi_builder
|
||||
from Scripts import gathering_files
|
||||
from Scripts import smbios
|
||||
from Scripts import utils
|
||||
import updater
|
||||
import os
|
||||
@@ -16,6 +17,7 @@ class OCPE:
|
||||
self.a = aida64.AIDA64()
|
||||
self.c = compatibility_checker.CompatibilityChecker()
|
||||
self.b = efi_builder.builder()
|
||||
self.s = smbios.SMBIOS()
|
||||
self.u = utils.Utils()
|
||||
self.result_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "Results")
|
||||
|
||||
@@ -165,16 +167,19 @@ class OCPE:
|
||||
def main(self):
|
||||
hardware_report_path = None
|
||||
macos_version = None
|
||||
smbios_model = None
|
||||
|
||||
while True:
|
||||
self.u.head()
|
||||
print("")
|
||||
print("Hardware Report: {}".format("No report selected" if not hardware_report_path else hardware_report_path))
|
||||
print("macOS Version: {}{}".format("Unknown" if not macos_version else os_data.get_macos_name_by_darwin(macos_version), "" if not macos_version else " ({})".format(macos_version)))
|
||||
print("SMBIOS: {}".format("Unknown" if not smbios_model else smbios_model))
|
||||
print("")
|
||||
print("1. Select Hardware Report")
|
||||
print("2. Select macOS Version")
|
||||
print("3. Build OpenCore EFI")
|
||||
print("3. Customize SMBIOS Model")
|
||||
print("4. Build OpenCore EFI")
|
||||
print("")
|
||||
print("Q. Quit")
|
||||
print("")
|
||||
@@ -188,18 +193,21 @@ class OCPE:
|
||||
macos_version = supported_macos_version[-1]
|
||||
if int(macos_version[:2]) == os_data.macos_versions[-1].darwin_version and os_data.macos_versions[-1].release_status == "beta":
|
||||
macos_version = str(int(macos_version[:2]) - 1) + macos_version[2:]
|
||||
elif option == "2":
|
||||
try:
|
||||
smbios_model = self.s.select_smbios_model(hardware_report, macos_version)
|
||||
try:
|
||||
hardware_report
|
||||
|
||||
if option == "2":
|
||||
macos_version = self.select_macos_version(supported_macos_version)
|
||||
except:
|
||||
self.u.request_input("\nPlease select a hardware report to proceed")
|
||||
elif option == "3":
|
||||
try:
|
||||
smbios_model = self.s.select_smbios_model(hardware_report, macos_version)
|
||||
elif option == "3":
|
||||
smbios_model = self.s.customize_smbios_model(hardware_report, smbios_model, macos_version)
|
||||
if option == "4":
|
||||
self.gathering_files()
|
||||
self.b.build_efi(hardware_report, unsupported_devices, macos_version)
|
||||
self.b.build_efi(hardware_report, unsupported_devices, smbios_model, macos_version)
|
||||
self.show_result(hardware_report)
|
||||
except:
|
||||
self.u.request_input("\nPlease select a hardware report to proceed")
|
||||
except:
|
||||
self.u.request_input("\nPlease select a hardware report to proceed")
|
||||
|
||||
if __name__ == '__main__':
|
||||
o = OCPE()
|
||||
|
||||
@@ -330,7 +330,7 @@ class ConfigProdigy:
|
||||
config["NVRAM"]["Delete"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"].extend(["revcpu", "revcpuname"])
|
||||
config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"].append("csr-active-config")
|
||||
|
||||
config["PlatformInfo"]["Generic"].update(self.smbios.generate(efi_option.get("SMBIOS")))
|
||||
config["PlatformInfo"]["Generic"].update(self.smbios.generate_smbios(efi_option.get("SMBIOS")))
|
||||
if efi_option.get("Custom CPU Name"):
|
||||
config["PlatformInfo"]["Generic"]["ProcessorType"] = 1537 if int(hardware["CPU Cores"]) < 8 else 3841
|
||||
config["PlatformInfo"]["Generic"]["ROM"] = self.utils.hex_to_bytes(config["PlatformInfo"]["Generic"]["ROM"])
|
||||
|
||||
@@ -257,85 +257,6 @@ class builder:
|
||||
igpu_properties["framebuffer-patch-enable"] = "01000000"
|
||||
return igpu_properties
|
||||
|
||||
def system_product_info(self, platform, cpu_manufacturer, processor_name, cpu_codename, cpu_cores, discrete_gpu, igpu_props, macos_version):
|
||||
product_name = "iMacPro1,1" if self.utils.parse_darwin_version(macos_version) < self.utils.parse_darwin_version("20.0.0") or self.utils.contains_any(cpu_data.IntelCPUGenerations, cpu_codename, start=12) else "MacPro7,1"
|
||||
|
||||
if "AMD" in cpu_manufacturer and not discrete_gpu:
|
||||
product_name = "MacBookPro16,3" if "Laptop" in platform else "iMacPro1,1"
|
||||
|
||||
if igpu_props:
|
||||
if "Kaby Lake-R".lower() in cpu_codename.lower() and self.utils.parse_darwin_version(macos_version) >= self.utils.parse_darwin_version("23.0.0"):
|
||||
cpu_codename = "Coffee Lake"
|
||||
|
||||
if "Sandy Bridge" in cpu_codename:
|
||||
if "Desktop" in platform:
|
||||
if self.utils.parse_darwin_version(macos_version) < self.utils.parse_darwin_version("18.0.0"):
|
||||
product_name = "iMac12,2"
|
||||
else:
|
||||
product_name = "MacPro6,1"
|
||||
elif "NUC" in platform:
|
||||
product_name = "Macmini5,1" if int(cpu_cores) < 4 else "Macmini5,3"
|
||||
else:
|
||||
product_name = "MacBookPro8,1" if int(cpu_cores) < 4 else "MacBookPro8,2"
|
||||
elif "Ivy Bridge" in cpu_codename:
|
||||
if self.utils.parse_darwin_version(macos_version) < self.utils.parse_darwin_version("21.0.0"):
|
||||
if "Desktop" in platform:
|
||||
product_name = "iMac14,4" if not discrete_gpu else "iMac15,1"
|
||||
elif "NUC" in platform:
|
||||
product_name = "Macmini7,1"
|
||||
else:
|
||||
product_name = "MacBookPro11,1" if int(cpu_cores) < 4 else "MacBookPro11,5"
|
||||
elif self.utils.parse_darwin_version(macos_version) < self.utils.parse_darwin_version("20.0.0"):
|
||||
if "Desktop" in platform:
|
||||
product_name = "iMac13,1" if not discrete_gpu else "iMac13,2"
|
||||
elif "NUC" in platform:
|
||||
product_name = "Macmini6,1" if int(cpu_cores) < 4 else "Macmini6,2"
|
||||
else:
|
||||
product_name = "MacBookPro10,2" if int(cpu_cores) < 4 else "MacBookPro10,1"
|
||||
else:
|
||||
product_name = "MacPro6,1"
|
||||
elif "Haswell" in cpu_codename:
|
||||
if "Desktop" in platform:
|
||||
product_name = "iMac14,4" if not discrete_gpu else "iMac15,1"
|
||||
if self.utils.parse_darwin_version(macos_version) < self.utils.parse_darwin_version("22.0.0"):
|
||||
product_name = "iMac16,2" if not discrete_gpu else "iMac17,1"
|
||||
elif "NUC" in platform:
|
||||
product_name = "Macmini7,1"
|
||||
else:
|
||||
product_name = "MacBookPro11,1" if self.utils.parse_darwin_version(macos_version) < self.utils.parse_darwin_version("21.0.0") and int(cpu_cores) < 4 else "MacBookPro11,5"
|
||||
elif "Broadwell" in cpu_codename:
|
||||
if "Desktop" in platform:
|
||||
product_name = "iMac16,2" if not discrete_gpu else "iMac17,1"
|
||||
elif "NUC" in platform:
|
||||
product_name = "iMac16,1"
|
||||
else:
|
||||
product_name = "MacBookPro12,1" if int(cpu_cores) < 4 else "MacBookPro11,5"
|
||||
elif "Skylake" in cpu_codename:
|
||||
product_name = "iMac17,1"
|
||||
if "Laptop" in platform:
|
||||
product_name = "MacBookPro13,1" if int(cpu_cores) < 4 else "MacBookPro13,3"
|
||||
elif self.utils.contains_any(cpu_data.IntelCPUGenerations, cpu_codename, start=8, end=11):
|
||||
product_name = "Macmini8,1"
|
||||
if "Desktop" in platform:
|
||||
product_name = "iMac18,3" if self.utils.parse_darwin_version(macos_version) < self.utils.parse_darwin_version("18.0.0") else "iMac19,1"
|
||||
if "Comet Lake" in cpu_codename:
|
||||
product_name = "iMac20,1" if int(cpu_cores) < 10 else "iMac20,2"
|
||||
elif "Laptop" in platform:
|
||||
if "-8" in processor_name:
|
||||
product_name = "MacBookPro15,2" if int(cpu_cores) < 6 else "MacBookPro15,3"
|
||||
else:
|
||||
product_name = "MacBookPro16,3" if int(cpu_cores) < 6 else "MacBookPro16,1"
|
||||
elif "Kaby Lake" in cpu_codename:
|
||||
product_name = "iMac18,1" if not discrete_gpu else "iMac18,3"
|
||||
if "Laptop" in platform:
|
||||
product_name = "MacBookPro14,1" if int(cpu_cores) < 4 else "MacBookPro14,3"
|
||||
elif "Amber Lake" in cpu_codename:
|
||||
product_name = "MacBookAir8,1"
|
||||
elif "Ice Lake" in cpu_codename:
|
||||
product_name = "MacBookAir9,1" if int(cpu_cores) < 4 else "MacBookPro16,2"
|
||||
|
||||
return product_name
|
||||
|
||||
def clean_up(self, config, efi_directory):
|
||||
files_to_remove = []
|
||||
|
||||
@@ -376,7 +297,7 @@ class builder:
|
||||
print("")
|
||||
self.utils.request_input()
|
||||
|
||||
def build_efi(self, hardware, unsupported_devices, macos_version):
|
||||
def build_efi(self, hardware, unsupported_devices, smbios_model, macos_version):
|
||||
efi_directory = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "Results")
|
||||
|
||||
self.utils.create_folder(efi_directory, remove_content=True)
|
||||
@@ -427,15 +348,7 @@ class builder:
|
||||
hardware_shorc["Integrated GPU"].get("Manufacturer", ""),
|
||||
hardware_shorc["Integrated GPU Name"],
|
||||
efi_option.get("macOS Version"))
|
||||
efi_option["SMBIOS"] = self.system_product_info(
|
||||
hardware_shorc["Platform"],
|
||||
hardware_shorc["CPU Manufacturer"],
|
||||
hardware_shorc.get("Processor Name"),
|
||||
hardware_shorc["CPU Codename"],
|
||||
hardware_shorc["CPU Cores"],
|
||||
hardware_shorc["Discrete GPU"],
|
||||
efi_option["iGPU Properties"],
|
||||
efi_option.get("macOS Version"))
|
||||
efi_option["SMBIOS"] = smbios_model
|
||||
|
||||
input_devices = ", ".join(list(hardware_shorc.get("Input", {}).keys()))
|
||||
hardware_shorc["Touchpad Communication"] = "None" if not "Laptop" in hardware_shorc.get("Platform") else "I2C" if "I2C" in input_devices else "PS2" if "PS2" in input_devices else "None"
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from Scripts.datasets import cpu_data
|
||||
from Scripts.datasets.mac_model_data import mac_devices
|
||||
from Scripts import gathering_files
|
||||
from Scripts import run
|
||||
from Scripts import utils
|
||||
import os
|
||||
import subprocess
|
||||
import uuid
|
||||
import random
|
||||
|
||||
@@ -35,13 +36,13 @@ class SMBIOS:
|
||||
random_mac = ''.join([format(random.randint(0, 255), '02X') for _ in range(6)])
|
||||
return random_mac
|
||||
|
||||
def generate(self, product_name):
|
||||
def generate_smbios(self, smbios_model):
|
||||
macserial = self.check_macserial()
|
||||
|
||||
random_mac_address = self.generate_random_mac()
|
||||
|
||||
output = self.run({
|
||||
"args":[macserial, "-g", "--model", product_name]
|
||||
"args":[macserial, "-g", "--model", smbios_model]
|
||||
})
|
||||
|
||||
if output[-1] != 0 or not " | " in output[0]:
|
||||
@@ -52,7 +53,150 @@ class SMBIOS:
|
||||
return {
|
||||
"MLB": "A" + "0"*15 + "Z" if not serial else serial[-1],
|
||||
"ROM": random_mac_address,
|
||||
"SystemProductName": product_name,
|
||||
"SystemProductName": smbios_model,
|
||||
"SystemSerialNumber": "A" + "0"*10 + "9" if not serial else serial[0],
|
||||
"SystemUUID": str(uuid.uuid4()).upper(),
|
||||
}
|
||||
}
|
||||
|
||||
def select_smbios_model(self, hardware_report, macos_version):
|
||||
if self.utils.parse_darwin_version(macos_version) < self.utils.parse_darwin_version("20.0.0") or \
|
||||
self.utils.contains_any(cpu_data.IntelCPUGenerations, hardware_report.get("CPU").get("CPU Codename"), start=12):
|
||||
smbios_model = "iMacPro1,1"
|
||||
else:
|
||||
smbios_model = "MacPro7,1"
|
||||
|
||||
if "AMD" in hardware_report.get("CPU").get("CPU Manufacturer") and \
|
||||
"Integrated GPU" in list(hardware_report.get("GPU").items())[-1][-1].get("Device Type"):
|
||||
smbios_model = "MacBookPro16,3" if "Laptop" in hardware_report.get("Motherboard").get("Platform") else "iMacPro1,1"
|
||||
|
||||
if "Intel" in list(hardware_report.get("GPU").items())[0][-1].get("Manufacturer") and \
|
||||
"Integrated GPU" in list(hardware_report.get("GPU").items())[0][-1].get("Device Type"):
|
||||
if "Kaby Lake-R".lower() in hardware_report.get("CPU").get("CPU Codename").lower() and self.utils.parse_darwin_version(macos_version) >= self.utils.parse_darwin_version("23.0.0"):
|
||||
hardware_report["CPU"]["CPU Codename"] = "Coffee Lake"
|
||||
|
||||
if "Sandy Bridge" in hardware_report.get("CPU").get("CPU Codename"):
|
||||
if "Desktop" in hardware_report.get("Motherboard").get("Platform"):
|
||||
if self.utils.parse_darwin_version(macos_version) < self.utils.parse_darwin_version("18.0.0"):
|
||||
smbios_model = "iMac12,2"
|
||||
else:
|
||||
smbios_model = "MacPro6,1"
|
||||
elif "NUC" in hardware_report.get("Motherboard").get("Platform"):
|
||||
smbios_model = "Macmini5,1" if int(hardware_report.get("CPU").get("CPU Cores")) < 4 else "Macmini5,3"
|
||||
else:
|
||||
smbios_model = "MacBookPro8,1" if int(hardware_report.get("CPU").get("CPU Cores")) < 4 else "MacBookPro8,2"
|
||||
elif "Ivy Bridge" in hardware_report.get("CPU").get("CPU Codename"):
|
||||
if self.utils.parse_darwin_version(macos_version) < self.utils.parse_darwin_version("21.0.0"):
|
||||
if "Desktop" in hardware_report.get("Motherboard").get("Platform"):
|
||||
smbios_model = "iMac14,4" if "Integrated GPU" in list(hardware_report.get("GPU").items())[-1][-1].get("Device Type") else "iMac15,1"
|
||||
elif "NUC" in hardware_report.get("Motherboard").get("Platform"):
|
||||
smbios_model = "Macmini7,1"
|
||||
else:
|
||||
smbios_model = "MacBookPro11,1" if int(hardware_report.get("CPU").get("CPU Cores")) < 4 else "MacBookPro11,5"
|
||||
elif self.utils.parse_darwin_version(macos_version) < self.utils.parse_darwin_version("20.0.0"):
|
||||
if "Desktop" in hardware_report.get("Motherboard").get("Platform"):
|
||||
smbios_model = "iMac13,1" if "Integrated GPU" in list(hardware_report.get("GPU").items())[-1][-1].get("Device Type") else "iMac13,2"
|
||||
elif "NUC" in hardware_report.get("Motherboard").get("Platform"):
|
||||
smbios_model = "Macmini6,1" if int(hardware_report.get("CPU").get("CPU Cores")) < 4 else "Macmini6,2"
|
||||
else:
|
||||
smbios_model = "MacBookPro10,2" if int(hardware_report.get("CPU").get("CPU Cores")) < 4 else "MacBookPro10,1"
|
||||
else:
|
||||
smbios_model = "MacPro6,1"
|
||||
elif "Haswell" in hardware_report.get("CPU").get("CPU Codename"):
|
||||
if "Desktop" in hardware_report.get("Motherboard").get("Platform"):
|
||||
smbios_model = "iMac14,4" if "Integrated GPU" in list(hardware_report.get("GPU").items())[-1][-1].get("Device Type") else "iMac15,1"
|
||||
if self.utils.parse_darwin_version(macos_version) < self.utils.parse_darwin_version("22.0.0"):
|
||||
smbios_model = "iMac16,2" if "Integrated GPU" in list(hardware_report.get("GPU").items())[-1][-1].get("Device Type") else "iMac17,1"
|
||||
elif "NUC" in hardware_report.get("Motherboard").get("Platform"):
|
||||
smbios_model = "Macmini7,1"
|
||||
else:
|
||||
smbios_model = "MacBookPro11,1" if self.utils.parse_darwin_version(macos_version) < self.utils.parse_darwin_version("21.0.0") and int(hardware_report.get("CPU").get("CPU Cores")) < 4 else "MacBookPro11,5"
|
||||
elif "Broadwell" in hardware_report.get("CPU").get("CPU Codename"):
|
||||
if "Desktop" in hardware_report.get("Motherboard").get("Platform"):
|
||||
smbios_model = "iMac16,2" if "Integrated GPU" in list(hardware_report.get("GPU").items())[-1][-1].get("Device Type") else "iMac17,1"
|
||||
elif "NUC" in hardware_report.get("Motherboard").get("Platform"):
|
||||
smbios_model = "iMac16,1"
|
||||
else:
|
||||
smbios_model = "MacBookPro12,1" if int(hardware_report.get("CPU").get("CPU Cores")) < 4 else "MacBookPro11,5"
|
||||
elif "Skylake" in hardware_report.get("CPU").get("CPU Codename"):
|
||||
smbios_model = "iMac17,1"
|
||||
if "Laptop" in hardware_report.get("Motherboard").get("Platform"):
|
||||
smbios_model = "MacBookPro13,1" if int(hardware_report.get("CPU").get("CPU Cores")) < 4 else "MacBookPro13,3"
|
||||
elif self.utils.contains_any(cpu_data.IntelCPUGenerations, hardware_report.get("CPU").get("CPU Codename"), start=8, end=11):
|
||||
smbios_model = "Macmini8,1"
|
||||
if "Desktop" in hardware_report.get("Motherboard").get("Platform"):
|
||||
smbios_model = "iMac18,3" if self.utils.parse_darwin_version(macos_version) < self.utils.parse_darwin_version("18.0.0") else "iMac19,1"
|
||||
if "Comet Lake" in hardware_report.get("CPU").get("CPU Codename"):
|
||||
smbios_model = "iMac20,1" if int(hardware_report.get("CPU").get("CPU Cores")) < 10 else "iMac20,2"
|
||||
elif "Laptop" in hardware_report.get("Motherboard").get("Platform"):
|
||||
if "-8" in hardware_report.get("CPU").get("Processor Name"):
|
||||
smbios_model = "MacBookPro15,2" if int(hardware_report.get("CPU").get("CPU Cores")) < 6 else "MacBookPro15,3"
|
||||
else:
|
||||
smbios_model = "MacBookPro16,3" if int(hardware_report.get("CPU").get("CPU Cores")) < 6 else "MacBookPro16,1"
|
||||
elif "Kaby Lake" in hardware_report.get("CPU").get("CPU Codename"):
|
||||
smbios_model = "iMac18,1" if "Integrated GPU" in list(hardware_report.get("GPU").items())[-1][-1].get("Device Type") else "iMac18,3"
|
||||
if "Laptop" in hardware_report.get("Motherboard").get("Platform"):
|
||||
smbios_model = "MacBookPro14,1" if int(hardware_report.get("CPU").get("CPU Cores")) < 4 else "MacBookPro14,3"
|
||||
elif "Amber Lake" in hardware_report.get("CPU").get("CPU Codename"):
|
||||
smbios_model = "MacBookAir8,1"
|
||||
elif "Ice Lake" in hardware_report.get("CPU").get("CPU Codename"):
|
||||
smbios_model = "MacBookAir9,1" if int(hardware_report.get("CPU").get("CPU Cores")) < 4 else "MacBookPro16,2"
|
||||
|
||||
return smbios_model
|
||||
|
||||
def customize_smbios_model(self, hardware_report, selected_smbios_model, macos_version):
|
||||
current_category = None
|
||||
default_smbios_model = self.select_smbios_model(hardware_report, macos_version)
|
||||
|
||||
while True:
|
||||
contents = []
|
||||
contents.append("")
|
||||
contents.append("List of available SMBIOS:")
|
||||
for index, device in enumerate(mac_devices, start=1):
|
||||
category = ""
|
||||
for char in device.name:
|
||||
if char.isdigit():
|
||||
break
|
||||
category += char
|
||||
if category != current_category:
|
||||
current_category = category
|
||||
category_header = f"Category: {current_category if current_category else "Uncategorized"}"
|
||||
contents.append(f"\n{category_header}\n" + "=" * len(category_header))
|
||||
|
||||
line = "{:2}. {:15} - {:10} {:20}{}".format(index, device.name, device.cpu, "({})".format(device.cpu_generation), "" if not device.discrete_gpu else " - {}".format(device.discrete_gpu))
|
||||
if not self.utils.parse_darwin_version(device.initial_support) <= self.utils.parse_darwin_version(macos_version) <= self.utils.parse_darwin_version(device.last_supported_version):
|
||||
line = "\033[90m{}\033[0m".format(line)
|
||||
contents.append(line)
|
||||
contents.append("")
|
||||
contents.append("Current SMBIOS: {}".format(selected_smbios_model))
|
||||
contents.append("\033[1;36m")
|
||||
contents.append("Note:")
|
||||
contents.append("- Lines in gray indicate mac models that are not supported by the current macOS version ({}).".format(macos_version))
|
||||
contents.append("- You can select mac model by entering their index or name.")
|
||||
contents.append("\033[0m")
|
||||
if selected_smbios_model != default_smbios_model:
|
||||
contents.append("R. Restore default SMBIOS model ({})".format(default_smbios_model))
|
||||
contents.append("")
|
||||
contents.append("B. Back")
|
||||
contents.append("Q. Quit")
|
||||
contents.append("")
|
||||
content = "\n".join(contents)
|
||||
|
||||
self.utils.adjust_window_size(content)
|
||||
self.utils.head("Customize SMBIOS Model", resize=False)
|
||||
print(content)
|
||||
option = self.utils.request_input("Select your option: ")
|
||||
if option.lower() == "q":
|
||||
self.utils.exit_program()
|
||||
if option.lower() == "b":
|
||||
return selected_smbios_model
|
||||
if option.lower() == "r" and selected_smbios_model != default_smbios_model:
|
||||
return default_smbios_model
|
||||
|
||||
if option.strip().isdigit():
|
||||
index = int(option) - 1
|
||||
if index >= 0 and index < len(mac_devices):
|
||||
return mac_devices[index].name
|
||||
else:
|
||||
for device in mac_devices:
|
||||
if option.lower() == device.name.lower():
|
||||
return device.name
|
||||
Reference in New Issue
Block a user