Opt for kernel detection

This commit is contained in:
Mykola Grymalyuk
2021-03-23 19:33:17 -06:00
parent ebc39a58eb
commit ed14fbfff0
35 changed files with 28 additions and 17 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
- Fix CPU Speed reporting
- Increment binaries
- OpenCore c92bcb7 (0.6.8 rolling - 2021-03-20)
- Add El Capitan and newer .app support
- Add Mavericks and newer .app support
- Refactor USB map building, fixes USB 3.0 displaying as USB 2.0
## 0.0.18
+1 -2
View File
@@ -19,8 +19,7 @@ class OpenCoreLegacyPatcher():
else:
self.current_model = subprocess.run("system_profiler SPHardwareDataType".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
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]
self.constants.detected_os, _, _ = platform.mac_ver()
self.constants.detected_os = float('.'.join(self.constants.detected_os.split('.')[:2]))
self.constants.detected_os = int(platform.uname().release.partition(".")[0])
if self.current_model in ModelArray.NoAPFSsupport:
self.constants.serial_settings = "Moderate"
+2 -2
View File
@@ -2,9 +2,9 @@
<img src="images/OC-Patcher.png" width="256">
A python program for building and booting [OpenCore](https://github.com/acidanthera/OpenCorePkg) on legacy Macs, see [Supported SMBIOS](https://dortania.github.io/OpenCore-Legacy-Patcher/MODELS.html) on whether your model is supported. Designed around Big Sur support.
A python program for building and booting [OpenCore](https://github.com/acidanthera/OpenCorePkg) on legacy Macs, see [Supported SMBIOS](https://dortania.github.io/OpenCore-Legacy-Patcher/MODELS.html) on whether your model is supported. Designed around Big Sur support, however can be used on older OSes.
* Application supports running on macOS El Capitan and newer
* Application supports running on macOS Mavericks (10.9) and newer
Supported features:
+1 -1
View File
@@ -57,7 +57,7 @@ class Constants:
self.vault = False
self.sip_status = True
self.secure_status = True
self.detected_os = 0.0
self.detected_os = 0
# Payload Location
# OpenCore
+4 -4
View File
@@ -233,8 +233,8 @@ class PatchSysVolume:
print("Root Patching not required for this machine!")
elif self.model not in ModelArray.SupportedSMBIOS:
print("Cannot run on this machine, model is unsupported!")
elif self.constants.detected_os < 10.16:
print(f"Cannot run on this OS: {self.constants.detected_os}")
elif self.constants.detected_os < 20:
print(f"Cannot run on this OS! Kernel detected: {self.constants.detected_os}")
else:
self.check_status()
utilities.cls()
@@ -262,8 +262,8 @@ class PatchSysVolume:
def start_unpatch(self):
if self.constants.custom_model is not None:
print("Unpatching must be done on target machine!")
elif self.constants.detected_os < 10.16:
print(f"Cannot run on this OS: {self.constants.detected_os}")
elif self.constants.detected_os < 20:
print(f"Cannot run on this OS! Kernel detected: {self.constants.detected_os}")
else:
self.check_status()
utilities.cls()
+19 -7
View File
@@ -96,8 +96,12 @@ class BuildOpenCore:
# WiFi patches
# TODO: -a is not supported in Lion and older, need to add proper fix
wifi_devices = plistlib.loads(subprocess.run("ioreg -c IOPCIDevice -r -d2 -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
wifi_devices = [i for i in wifi_devices if i["vendor-id"] == binascii.unhexlify("E4140000") and i["class-code"] == binascii.unhexlify("00800200")]
try:
wifi_devices = plistlib.loads(subprocess.run("ioreg -c IOPCIDevice -r -d2 -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
wifi_devices = [i for i in wifi_devices if i["vendor-id"] == binascii.unhexlify("E4140000") and i["class-code"] == binascii.unhexlify("00800200")]
except ValueError:
wifi_devices = ""
print("- Couldn't run Wifi hardware detection")
if self.constants.wifi_build is True:
print("- Skipping Wifi patches on request")
elif not self.constants.custom_model and wifi_devices and self.hexswap(binascii.hexlify(wifi_devices[0]["device-id"]).decode()[:4]) in ModelArray.nativeWifi:
@@ -132,7 +136,7 @@ class BuildOpenCore:
self.get_kext_by_bundle_path("IO80211Mojave.kext/Contents/PlugIns/AirPortBrcm4331.kext")["Enabled"] = True
# CPUFriend
pp_map_path = Path(self.constants.current_path) / Path(f"payloads/Kexts/PlatformPlugin/{self.model}/Info.plist")
pp_map_path = Path(self.constants.current_path) / Path(f"payloads/Kexts/Plists/PlatformPlugin/{self.model}/Info.plist")
if self.model in ModelArray.X86PP:
Path(self.constants.pp_kext_folder).mkdir()
Path(self.constants.pp_contents_folder).mkdir()
@@ -150,7 +154,7 @@ class BuildOpenCore:
self.get_item_by_kv(self.config["ACPI"]["Add"], "Path", "SSDT-CPBG.aml")["Enabled"] = True
# USB Map
usb_map_path = Path(self.constants.current_path) / Path(f"payloads/Kexts/Maps/Universal/Info.plist")
usb_map_path = Path(self.constants.current_path) / Path(f"payloads/Kexts/Plists/AppleUSBMaps/Info.plist")
if usb_map_path.exists():
print(f"- Adding USB-Map.kext")
Path(self.constants.map_kext_folder).mkdir()
@@ -163,6 +167,10 @@ class BuildOpenCore:
print("- Adding dual GPU patch")
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " agdpmod=pikera"
if self.model == "MacBookPro9,1":
print("- Adding dual GPU patch for MacBookPro9,1")
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " agdpmod=vit9696"
# HiDPI OpenCanopy and FileVault
if self.model in ModelArray.HiDPIpicker:
print("- Setting HiDPI picker")
@@ -337,7 +345,7 @@ class BuildOpenCore:
self.config["PlatformInfo"]["UpdateDataHub"] = True
self.config["PlatformInfo"]["UpdateNVRAM"] = True
self.config["UEFI"]["ProtocolOverrides"]["DataHub"] = True
self.config["PlatformInfo"]["Generic"]["ROM"] = binascii.unhexlify("112233445566")
self.config["PlatformInfo"]["Generic"]["ROM"] = binascii.unhexlify("0016CB445566")
self.config["PlatformInfo"]["Generic"]["SystemProductName"] = self.spoofed_model
self.config["PlatformInfo"]["Generic"]["SystemSerialNumber"] = macserial_output[0]
self.config["PlatformInfo"]["Generic"]["MLB"] = macserial_output[1]
@@ -455,7 +463,7 @@ Please build OpenCore first!"""
print("\nDisk picker is loading...")
all_disks = {}
# TODO: AllDisksAndPartitions is not supported in Yosemite(?) and older
# TODO: AllDisksAndPartitions is not supported in Mountain Lion(?) and older
try:
# High Sierra and newer
disks = plistlib.loads(subprocess.run("diskutil list -plist physical".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
@@ -516,6 +524,7 @@ Please build OpenCore first!"""
if response == -1:
return
# TODO: Apple Script fails in Yosemite(?) and older
args = [
"osascript",
"-e",
@@ -525,7 +534,10 @@ Please build OpenCore first!"""
" without altering line endings",
]
result = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if self.constants.detected_os > 14: # Yosemite's kernel
result = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
result = subprocess.run(f"diskutil mount {disk_identifier}s{response}".split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode != 0:
if "execution error" in result.stderr.decode() and result.stderr.decode().strip()[-5:-1] == "-128":