device_probe.py: Add non-Mac detection

Applicable for Virtual Machines and Hackintoshes
This commit is contained in:
Mykola Grymalyuk
2022-05-29 21:49:57 -06:00
parent d289dbbffa
commit d84fbb6cb0
5 changed files with 49 additions and 7 deletions

View File

@@ -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,

View File

@@ -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(),

View File

@@ -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:

View File

@@ -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: