From c1b7e62a023bf9d93a46a827764b473b362d92dc Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk <48863253+khronokernel@users.noreply.github.com> Date: Tue, 23 Mar 2021 22:28:32 -0600 Subject: [PATCH] Fix variable naming for kernel versions --- README.md | 1 + Resources/Constants.py | 15 +++++++++++++++ Resources/SysPatch.py | 8 ++++---- Resources/build.py | 10 +++++----- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 06eb5589a..76a7facbc 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ 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 Mavericks (10.9) and newer + * Supports macOS Lion (10.7) and newer if [python 3.6 or higher](https://www.python.org/downloads/) is manually installed, simply run the `OpenCore-Patcher.command` located in the repo Supported features: diff --git a/Resources/Constants.py b/Resources/Constants.py index dc3f0ce0f..eabf1c3a7 100644 --- a/Resources/Constants.py +++ b/Resources/Constants.py @@ -59,6 +59,21 @@ class Constants: self.secure_status = True self.detected_os = 0 + # OS Versions + self.tiger = 8 + self.leopard = 9 + self.snow_leopard = 10 + self.lion = 11 + self.mountain_lion = 12 + self.mavericks = 13 + self.yosemite = 14 + self.el_capitan = 15 + self.sierra = 16 + self.high_sierra = 17 + self.mojave = 18 + self.catalina = 19 + self.big_sur = 20 + # Payload Location # OpenCore @property diff --git a/Resources/SysPatch.py b/Resources/SysPatch.py index d120fc090..718130917 100644 --- a/Resources/SysPatch.py +++ b/Resources/SysPatch.py @@ -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 < 20: - print(f"Cannot run on this OS! Kernel detected: {self.constants.detected_os}") + elif self.constants.detected_os < self.constants.big_sur: + print(f"Cannot run on this OS, requires macOS 11!") 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 < 20: - print(f"Cannot run on this OS! Kernel detected: {self.constants.detected_os}") + elif self.constants.detected_os < self.constants.big_sur: + print(f"Cannot run on this OS, requires macOS 11!") else: self.check_status() utilities.cls() diff --git a/Resources/build.py b/Resources/build.py index d0dfd4bef..20d8c9279 100644 --- a/Resources/build.py +++ b/Resources/build.py @@ -96,12 +96,12 @@ class BuildOpenCore: # WiFi patches # TODO: -a is not supported in Lion and older, need to add proper fix - try: + if self.constants.detected_os > self.constants.lion: 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: + else: wifi_devices = "" - print("- Couldn't run Wifi hardware detection") + print("- Can't run Wifi hardware detection on Snow Leopard and older") 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: @@ -497,7 +497,7 @@ Please build OpenCore first!""" print("\nDisk picker is loading...") all_disks = {} - # TODO: AllDisksAndPartitions is not supported in Mountain Lion(?) and older + # TODO: AllDisksAndPartitions is not supported in Snow Leopard and older try: # High Sierra and newer disks = plistlib.loads(subprocess.run("diskutil list -plist physical".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) @@ -568,7 +568,7 @@ Please build OpenCore first!""" " without altering line endings", ] - if self.constants.detected_os > 14: # Yosemite's kernel + if self.constants.detected_os > self.constants.yosemite: 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)