Add better Mojave/Catalina error handling

This commit is contained in:
Mykola Grymalyuk
2021-07-08 15:43:59 -06:00
parent 20b40f33ce
commit 637981b405
+21 -14
View File
@@ -58,6 +58,9 @@ class PatchSysVolume:
def find_mount_root_vol(self, patch): def find_mount_root_vol(self, patch):
self.root_mount_path = Utilities.get_disk_path() self.root_mount_path = Utilities.get_disk_path()
if self.root_mount_path.startswith("disk"): if self.root_mount_path.startswith("disk"):
if self.constants.detected_os == self.constants.catalina:
print("- Mounting Catalina Root Volume as writable")
self.elevated(["mount", "-uw", "/"], stdout=subprocess.PIPE).stdout.decode().strip().encode()
print(f"- Found Root Volume at: {self.root_mount_path}") print(f"- Found Root Volume at: {self.root_mount_path}")
if Path(self.mount_extensions).exists(): if Path(self.mount_extensions).exists():
print("- Root Volume is already mounted") print("- Root Volume is already mounted")
@@ -71,9 +74,6 @@ class PatchSysVolume:
if self.constants.detected_os > self.constants.catalina: if self.constants.detected_os > self.constants.catalina:
print("- Mounting APFS Snapshot as writable") print("- Mounting APFS Snapshot as writable")
self.elevated(["mount", "-o", "nobrowse", "-t", "apfs", f"/dev/{self.root_mount_path}", self.mount_location], stdout=subprocess.PIPE).stdout.decode().strip().encode() self.elevated(["mount", "-o", "nobrowse", "-t", "apfs", f"/dev/{self.root_mount_path}", self.mount_location], stdout=subprocess.PIPE).stdout.decode().strip().encode()
elif self.constants.detected_os == self.constants.catalina:
print("- Mounting Root Volume as writable")
self.elevated(["mount", "-uw", "/"], stdout=subprocess.PIPE).stdout.decode().strip().encode()
if Path(self.mount_extensions).exists(): if Path(self.mount_extensions).exists():
print("- Successfully mounted the Root Volume") print("- Successfully mounted the Root Volume")
if patch is True: if patch is True:
@@ -105,7 +105,7 @@ class PatchSysVolume:
else: else:
result = self.elevated(["kextcache", "-i", "/"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) result = self.elevated(["kextcache", "-i", "/"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if result.returncode != 0: if result.returncode != 0 or (self.constants.detected_os in [self.constants.mojave, self.constants.catalina] and "KernelCache ID" not in result):
self.success_status = False self.success_status = False
print("- Unable to build new kernel cache") print("- Unable to build new kernel cache")
print("\nPlease report this to Github") print("\nPlease report this to Github")
@@ -124,12 +124,16 @@ class PatchSysVolume:
print("- Creating new APFS snapshot") print("- Creating new APFS snapshot")
self.elevated(["bless", "--folder", f"{self.mount_location}/System/Library/CoreServices", "--bootefi", "--create-snapshot"], stdout=subprocess.PIPE).stdout.decode().strip().encode() self.elevated(["bless", "--folder", f"{self.mount_location}/System/Library/CoreServices", "--bootefi", "--create-snapshot"], stdout=subprocess.PIPE).stdout.decode().strip().encode()
self.unmount_drive() self.unmount_drive()
else:
print("Copying over KC")
self.elevated(["kcditto"], stdout=subprocess.PIPE).stdout.decode().strip().encode()
print("- Patching complete") print("- Patching complete")
print("\nPlease reboot the machine for patches to take effect") print("\nPlease reboot the machine for patches to take effect")
if self.amd_ts2 is True: if self.amd_ts2 is True:
print("\nPlease note that with ATI TeraScale 2 GPUs, you may experience colour strobing on reboot") print("""\nPlease note that with ATI TeraScale 2 GPUs, you may experience colour strobing
print("Please use SwitchResX or ResXtreme to force 1 million colours on your monitor to fix this") on reboot. Please use SwitchResX or ResXtreme to force 1 million colours on your
print("If you are epileptic, please ask for someone to aid you or set million colour before rebooting") monitor to fix this. If you are epileptic, please ask for someone to aid you or
set million colour before rebooting""")
if self.constants.gui_mode is False: if self.constants.gui_mode is False:
input("Press [ENTER] to continue") input("Press [ENTER] to continue")
@@ -369,29 +373,32 @@ class PatchSysVolume:
def detect_gpus(self): def detect_gpus(self):
dgpu = self.constants.computer.dgpu dgpu = self.constants.computer.dgpu
igpu = self.constants.computer.igpu igpu = self.constants.computer.igpu
if self.constants.moj_cat_accel is True:
non_metal_os = self.constants.high_sierra
else:
non_metal_os = self.constants.catalina
if dgpu: if dgpu:
print(f"- Found GFX0: {Utilities.friendly_hex(dgpu.vendor_id)}:{Utilities.friendly_hex(dgpu.device_id)}") print(f"- Found GFX0: {Utilities.friendly_hex(dgpu.vendor_id)}:{Utilities.friendly_hex(dgpu.device_id)}")
if dgpu.arch in [device_probe.NVIDIA.Archs.Tesla, device_probe.NVIDIA.Archs.Fermi]: if dgpu.arch in [device_probe.NVIDIA.Archs.Tesla, device_probe.NVIDIA.Archs.Fermi]:
if self.constants.detected_os > self.constants.catalina: if self.constants.detected_os > non_metal_os:
self.nvidia_legacy = True self.nvidia_legacy = True
self.amfi_must_disable = True self.amfi_must_disable = True
elif dgpu.arch == device_probe.AMD.Archs.TeraScale_1: elif dgpu.arch == device_probe.AMD.Archs.TeraScale_1:
if self.constants.detected_os > self.constants.catalina: if self.constants.detected_os > non_metal_os:
self.amd_ts1 = True self.amd_ts1 = True
self.amfi_must_disable = True self.amfi_must_disable = True
elif dgpu.arch == device_probe.AMD.Archs.TeraScale_2: elif dgpu.arch == device_probe.AMD.Archs.TeraScale_2:
# Requires manual permission from user to avoid medical issues if self.constants.detected_os > non_metal_os:
if self.constants.detected_os > self.constants.catalina:
self.amd_ts2 = True self.amd_ts2 = True
self.amfi_must_disable = True self.amfi_must_disable = True
if igpu and igpu.class_code != 0xFFFFFF: if igpu and igpu.class_code != 0xFFFFFF:
print(f"- Found IGPU: {Utilities.friendly_hex(igpu.vendor_id)}:{Utilities.friendly_hex(igpu.device_id)}") print(f"- Found IGPU: {Utilities.friendly_hex(igpu.vendor_id)}:{Utilities.friendly_hex(igpu.device_id)}")
if igpu.arch == device_probe.Intel.Archs.Iron_Lake: if igpu.arch == device_probe.Intel.Archs.Iron_Lake:
if self.constants.detected_os > self.constants.catalina: if self.constants.detected_os > non_metal_os:
self.iron_gpu = True self.iron_gpu = True
self.amfi_must_disable = True self.amfi_must_disable = True
elif igpu.arch == device_probe.Intel.Archs.Sandy_Bridge: elif igpu.arch == device_probe.Intel.Archs.Sandy_Bridge:
if self.constants.detected_os > self.constants.catalina: if self.constants.detected_os > non_metal_os:
self.sandy_gpu = True self.sandy_gpu = True
self.amfi_must_disable = True self.amfi_must_disable = True
self.check_board_id = True self.check_board_id = True
@@ -399,7 +406,7 @@ class PatchSysVolume:
if self.constants.detected_os > self.constants.big_sur: if self.constants.detected_os > self.constants.big_sur:
self.ivy_gpu = True self.ivy_gpu = True
elif isinstance(igpu, device_probe.NVIDIA): elif isinstance(igpu, device_probe.NVIDIA):
if self.constants.detected_os > self.constants.catalina: if self.constants.detected_os > non_metal_os:
self.nvidia_legacy = True self.nvidia_legacy = True
self.amfi_must_disable = True self.amfi_must_disable = True