mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-14 04:38:20 +10:00
device_probe.py: Add non-Mac detection
Applicable for Virtual Machines and Hackintoshes
This commit is contained in:
@@ -164,7 +164,8 @@ class wx_python_gui:
|
||||
def preflight_check(self):
|
||||
if (
|
||||
self.constants.computer.build_model != None and
|
||||
self.constants.computer.build_model != self.constants.computer.real_model
|
||||
self.constants.computer.build_model != self.constants.computer.real_model and
|
||||
self.constants.host_is_hackintosh is False
|
||||
):
|
||||
# Notify user they're booting an unsupported configuration
|
||||
self.constants.start_build_install = True
|
||||
@@ -366,9 +367,16 @@ class wx_python_gui:
|
||||
self.build_install.Centre(wx.HORIZONTAL)
|
||||
|
||||
# Disable button if real_model not in model_array.SupportedSMBIOS
|
||||
if self.constants.allow_oc_everywhere is False and \
|
||||
self.constants.custom_model is None and \
|
||||
self.computer.real_model not in model_array.SupportedSMBIOS:
|
||||
if (
|
||||
(
|
||||
self.constants.allow_oc_everywhere is False and \
|
||||
self.constants.custom_model is None and \
|
||||
self.computer.real_model not in model_array.SupportedSMBIOS
|
||||
) or (
|
||||
self.constants.custom_model is None and \
|
||||
self.constants.host_is_hackintosh is True
|
||||
)
|
||||
):
|
||||
self.build_install.Disable()
|
||||
self.build_install.SetToolTip(wx.ToolTip("""If building for a native Mac model, \nselect 'Allow Native Models' in Settings.\nIf building for another Mac, change model in Settings"""))
|
||||
|
||||
@@ -1877,9 +1885,16 @@ class wx_python_gui:
|
||||
self.finished_cim_process = False
|
||||
# Only prompt user with option to install OC to disk if
|
||||
# the model is supported.
|
||||
if self.constants.allow_oc_everywhere is False and \
|
||||
self.constants.custom_model is None and \
|
||||
self.computer.real_model not in model_array.SupportedSMBIOS:
|
||||
if (
|
||||
(
|
||||
self.constants.allow_oc_everywhere is False and \
|
||||
self.constants.custom_model is None and \
|
||||
self.computer.real_model not in model_array.SupportedSMBIOS
|
||||
) or (
|
||||
self.constants.custom_model is None and \
|
||||
self.constants.host_is_hackintosh is True
|
||||
)
|
||||
):
|
||||
popup_message = wx.MessageDialog(self.frame, "Sucessfully created a macOS installer!", "Success", wx.OK)
|
||||
popup_message.ShowModal()
|
||||
else:
|
||||
|
||||
@@ -192,6 +192,7 @@ class Constants:
|
||||
self.start_build_install = False # Determine if build install should be started
|
||||
self.host_is_non_metal = False # Determine if host is non-metal (ie. enable UI hacks)
|
||||
self.needs_to_open_preferences = False # Determine if preferences need to be opened
|
||||
self.host_is_hackintosh = False # Determine if host is Hackintosh
|
||||
|
||||
self.legacy_accel_support = [
|
||||
os_data.os_data.big_sur,
|
||||
|
||||
@@ -484,6 +484,7 @@ class Computer:
|
||||
secure_boot_policy: Optional[int] = None
|
||||
oclp_sys_version: Optional[str] = None
|
||||
oclp_sys_date: Optional[str] = None
|
||||
firmware_vendor: Optional[str] = None
|
||||
|
||||
@staticmethod
|
||||
def probe():
|
||||
@@ -704,6 +705,13 @@ class Computer:
|
||||
# SecureBoot Variables
|
||||
self.secure_boot_model = utilities.check_secure_boot_model()
|
||||
self.secure_boot_policy = utilities.check_ap_security_policy()
|
||||
|
||||
# Firmware Vendor
|
||||
firmware_vendor = utilities.get_firmware_vendor(decode=False)
|
||||
if isinstance(firmware_vendor, bytes):
|
||||
firmware_vendor = str(firmware_vendor.replace(b"\x00", b"").decode("utf-8"))
|
||||
self.firmware_vendor = firmware_vendor
|
||||
|
||||
def cpu_probe(self):
|
||||
self.cpu = CPU(
|
||||
subprocess.run("sysctl machdep.cpu.brand_string".split(), stdout=subprocess.PIPE).stdout.decode().partition(": ")[2].strip(),
|
||||
|
||||
@@ -33,6 +33,9 @@ class OpenCoreLegacyPatcher:
|
||||
self.constants.recovery_status = utilities.check_recovery()
|
||||
self.computer = self.constants.computer
|
||||
self.constants.booted_oc_disk = utilities.find_disk_off_uuid(utilities.clean_device_path(self.computer.opencore_path))
|
||||
if self.constants.computer.firmware_vendor:
|
||||
if self.constants.computer.firmware_vendor != "Apple":
|
||||
self.constants.host_is_hackintosh = True
|
||||
launcher_script = None
|
||||
launcher_binary = sys.executable
|
||||
if "python" in launcher_binary:
|
||||
|
||||
@@ -371,6 +371,21 @@ def get_rom(variable: str, *, decode: bool = False):
|
||||
value = value.strip(b"\0").decode()
|
||||
return value
|
||||
|
||||
def get_firmware_vendor(*, decode: bool = False):
|
||||
efi = ioreg.IORegistryEntryFromPath(ioreg.kIOMasterPortDefault, "IODeviceTree:/efi".encode())
|
||||
value = ioreg.IORegistryEntryCreateCFProperty(efi, "firmware-vendor", ioreg.kCFAllocatorDefault, ioreg.kNilOptions)
|
||||
ioreg.IOObjectRelease(efi)
|
||||
|
||||
if not value:
|
||||
return None
|
||||
|
||||
value = ioreg.corefoundation_to_native(value)
|
||||
if decode:
|
||||
if isinstance(value, bytes):
|
||||
value = value.strip(b"\0").decode()
|
||||
elif isinstance(value, str):
|
||||
value = value.strip("\0")
|
||||
return value
|
||||
|
||||
def verify_network_connection(url):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user