Adjust utilities to py scheme

This commit is contained in:
Mykola Grymalyuk
2021-10-03 14:12:11 -06:00
parent 8e1923ee21
commit 8a6faa0836
9 changed files with 153 additions and 153 deletions
+3 -3
View File
@@ -7,7 +7,7 @@ import subprocess
import sys import sys
from pathlib import Path from pathlib import Path
from resources import Build, cli_menu, constants, Utilities, device_probe, os_probe, defaults, arguments from resources import Build, cli_menu, constants, utilities, device_probe, os_probe, defaults, arguments
from data import model_array from data import model_array
class OpenCoreLegacyPatcher: class OpenCoreLegacyPatcher:
@@ -23,7 +23,7 @@ class OpenCoreLegacyPatcher:
self.constants.detected_os_minor = os_probe.detect_kernel_minor() self.constants.detected_os_minor = os_probe.detect_kernel_minor()
self.constants.detected_os_build = os_probe.detect_kernel_build() self.constants.detected_os_build = os_probe.detect_kernel_build()
self.constants.computer = device_probe.Computer.probe() self.constants.computer = device_probe.Computer.probe()
self.constants.recovery_status = Utilities.check_recovery() self.constants.recovery_status = utilities.check_recovery()
self.computer = self.constants.computer self.computer = self.constants.computer
defaults.generate_defaults.probe(self.computer.real_model, True, self.constants) defaults.generate_defaults.probe(self.computer.real_model, True, self.constants)
if arguments.arguments().check_cli() is True: if arguments.arguments().check_cli() is True:
@@ -64,7 +64,7 @@ class OpenCoreLegacyPatcher:
else: else:
in_between = ["This model is supported"] in_between = ["This model is supported"]
menu = Utilities.TUIMenu(title, "Please select an option: ", in_between=in_between, auto_number=True, top_level=True) menu = utilities.TUIMenu(title, "Please select an option: ", in_between=in_between, auto_number=True, top_level=True)
options = ( options = (
[["Build OpenCore", Build.BuildOpenCore(self.constants.custom_model or self.constants.computer.real_model, self.constants).build_opencore()]] [["Build OpenCore", Build.BuildOpenCore(self.constants.custom_model or self.constants.computer.real_model, self.constants).build_opencore()]]
+21 -21
View File
@@ -14,7 +14,7 @@ import ast
from pathlib import Path from pathlib import Path
from datetime import date from datetime import date
from resources import constants, Utilities, device_probe, generate_smbios from resources import constants, utilities, device_probe, generate_smbios
from data import smbios_data, bluetooth_data, cpu_data, os_data, model_array from data import smbios_data, bluetooth_data, cpu_data, os_data, model_array
@@ -55,7 +55,7 @@ class BuildOpenCore:
shutil.copy(self.constants.icon_path_internal, self.constants.opencore_release_folder) shutil.copy(self.constants.icon_path_internal, self.constants.opencore_release_folder)
def build_efi(self): def build_efi(self):
Utilities.cls() utilities.cls()
if not self.constants.custom_model: if not self.constants.custom_model:
print(f"Building Configuration on model: {self.model}") print(f"Building Configuration on model: {self.model}")
else: else:
@@ -174,8 +174,8 @@ class BuildOpenCore:
if not self.constants.custom_model: if not self.constants.custom_model:
nvme_devices = [i for i in self.computer.storage if isinstance(i, device_probe.NVMeController)] nvme_devices = [i for i in self.computer.storage if isinstance(i, device_probe.NVMeController)]
for i, controller in enumerate(nvme_devices): for i, controller in enumerate(nvme_devices):
print(f"- Found 3rd Party NVMe SSD ({i + 1}): {Utilities.friendly_hex(controller.vendor_id)}:{Utilities.friendly_hex(controller.device_id)}") print(f"- Found 3rd Party NVMe SSD ({i + 1}): {utilities.friendly_hex(controller.vendor_id)}:{utilities.friendly_hex(controller.device_id)}")
self.config["#Revision"][f"Hardware-NVMe-{i}"] = f"{Utilities.friendly_hex(controller.vendor_id)}:{Utilities.friendly_hex(controller.device_id)}" self.config["#Revision"][f"Hardware-NVMe-{i}"] = f"{utilities.friendly_hex(controller.vendor_id)}:{utilities.friendly_hex(controller.device_id)}"
# Disable Bit 0 (L0s), enable Bit 1 (L1) # Disable Bit 0 (L0s), enable Bit 1 (L1)
nvme_aspm = (controller.aspm & (~0b11)) | 0b10 nvme_aspm = (controller.aspm & (~0b11)) | 0b10
@@ -231,8 +231,8 @@ class BuildOpenCore:
# TODO: -a is not supported in Lion and older, need to add proper fix # TODO: -a is not supported in Lion and older, need to add proper fix
if self.constants.detected_os > self.constants.lion and not self.constants.custom_model: if self.constants.detected_os > self.constants.lion and not self.constants.custom_model:
if self.computer.wifi: if self.computer.wifi:
print(f"- Found Wireless Device {Utilities.friendly_hex(self.computer.wifi.vendor_id)}:{Utilities.friendly_hex(self.computer.wifi.device_id)}") print(f"- Found Wireless Device {utilities.friendly_hex(self.computer.wifi.vendor_id)}:{utilities.friendly_hex(self.computer.wifi.device_id)}")
self.config["#Revision"]["Hardware-Wifi"] = f"{Utilities.friendly_hex(self.computer.wifi.vendor_id)}:{Utilities.friendly_hex(self.computer.wifi.device_id)}" self.config["#Revision"]["Hardware-Wifi"] = f"{utilities.friendly_hex(self.computer.wifi.vendor_id)}:{utilities.friendly_hex(self.computer.wifi.device_id)}"
else: else:
print("- Unable to run Wireless hardware detection") print("- Unable to run Wireless hardware detection")
@@ -519,7 +519,7 @@ class BuildOpenCore:
else: else:
print("- Failed to find vendor") print("- Failed to find vendor")
elif not self.constants.custom_model and self.model in model_array.LegacyGPU and self.computer.dgpu: elif not self.constants.custom_model and self.model in model_array.LegacyGPU and self.computer.dgpu:
print(f"- Detected dGPU: {Utilities.friendly_hex(self.computer.dgpu.vendor_id)}:{Utilities.friendly_hex(self.computer.dgpu.device_id)}") print(f"- Detected dGPU: {utilities.friendly_hex(self.computer.dgpu.vendor_id)}:{utilities.friendly_hex(self.computer.dgpu.device_id)}")
if self.computer.dgpu.arch in [ if self.computer.dgpu.arch in [
device_probe.AMD.Archs.Legacy_GCN, device_probe.AMD.Archs.Legacy_GCN,
device_probe.AMD.Archs.Polaris, device_probe.AMD.Archs.Polaris,
@@ -534,8 +534,8 @@ class BuildOpenCore:
if self.model in model_array.MacPro: if self.model in model_array.MacPro:
if not self.constants.custom_model: if not self.constants.custom_model:
for i, device in enumerate(self.computer.gpus): for i, device in enumerate(self.computer.gpus):
print(f"- Found dGPU ({i + 1}): {Utilities.friendly_hex(device.vendor_id)}:{Utilities.friendly_hex(device.device_id)}") print(f"- Found dGPU ({i + 1}): {utilities.friendly_hex(device.vendor_id)}:{utilities.friendly_hex(device.device_id)}")
self.config["#Revision"][f"Hardware-MacPro-dGPU-{i + 1}"] = f"{Utilities.friendly_hex(device.vendor_id)}:{Utilities.friendly_hex(device.device_id)}" self.config["#Revision"][f"Hardware-MacPro-dGPU-{i + 1}"] = f"{utilities.friendly_hex(device.vendor_id)}:{utilities.friendly_hex(device.device_id)}"
if device.pci_path and device.acpi_path: if device.pci_path and device.acpi_path:
print(f"- Found dGPU ({i + 1}) at {device.pci_path}") print(f"- Found dGPU ({i + 1}) at {device.pci_path}")
@@ -734,7 +734,7 @@ class BuildOpenCore:
# fw_feature = self.patch_firmware_feature() # fw_feature = self.patch_firmware_feature()
fw_feature = hex(fw_feature).lstrip("0x").rstrip("L").strip() fw_feature = hex(fw_feature).lstrip("0x").rstrip("L").strip()
print(f"- Setting Firmware Feature: {fw_feature}") print(f"- Setting Firmware Feature: {fw_feature}")
fw_feature = Utilities.string_to_hex(fw_feature) fw_feature = utilities.string_to_hex(fw_feature)
# FirmwareFeatures # FirmwareFeatures
self.config["PlatformInfo"]["PlatformNVRAM"]["FirmwareFeatures"] = fw_feature self.config["PlatformInfo"]["PlatformNVRAM"]["FirmwareFeatures"] = fw_feature
@@ -973,11 +973,11 @@ class BuildOpenCore:
input("Press [Enter] to go back.\n") input("Press [Enter] to go back.\n")
def copy_efi(self): def copy_efi(self):
Utilities.cls() utilities.cls()
Utilities.header(["Installing OpenCore to Drive"]) utilities.header(["Installing OpenCore to Drive"])
if not self.constants.opencore_release_folder.exists(): if not self.constants.opencore_release_folder.exists():
Utilities.TUIOnlyPrint( utilities.TUIOnlyPrint(
["Installing OpenCore to Drive"], ["Installing OpenCore to Drive"],
"Press [Enter] to go back.\n", "Press [Enter] to go back.\n",
[ [
@@ -1013,7 +1013,7 @@ Please build OpenCore first!"""
# Avoid crashing with CDs installed # Avoid crashing with CDs installed
continue continue
# TODO: Advanced mode # TODO: Advanced mode
menu = Utilities.TUIMenu( menu = utilities.TUIMenu(
["Select Disk"], ["Select Disk"],
"Please select the disk you would like to install OpenCore to: ", "Please select the disk you would like to install OpenCore to: ",
in_between=["Missing disks? Ensure they have an EFI or FAT32 partition."], in_between=["Missing disks? Ensure they have an EFI or FAT32 partition."],
@@ -1023,7 +1023,7 @@ Please build OpenCore first!"""
for disk in all_disks: for disk in all_disks:
if not any(all_disks[disk]["partitions"][partition]["fs"] in ("msdos", "EFI") for partition in all_disks[disk]["partitions"]): if not any(all_disks[disk]["partitions"][partition]["fs"] in ("msdos", "EFI") for partition in all_disks[disk]["partitions"]):
continue continue
menu.add_menu_option(f"{disk}: {all_disks[disk]['name']} ({Utilities.human_fmt(all_disks[disk]['size'])})", key=disk[4:]) menu.add_menu_option(f"{disk}: {all_disks[disk]['name']} ({utilities.human_fmt(all_disks[disk]['size'])})", key=disk[4:])
response = menu.start() response = menu.start()
@@ -1033,7 +1033,7 @@ Please build OpenCore first!"""
disk_identifier = "disk" + response disk_identifier = "disk" + response
selected_disk = all_disks[disk_identifier] selected_disk = all_disks[disk_identifier]
menu = Utilities.TUIMenu( menu = utilities.TUIMenu(
["Select Partition"], ["Select Partition"],
"Please select the partition you would like to install OpenCore to: ", "Please select the partition you would like to install OpenCore to: ",
return_number_instead_of_direct_call=True, return_number_instead_of_direct_call=True,
@@ -1043,7 +1043,7 @@ Please build OpenCore first!"""
for partition in selected_disk["partitions"]: for partition in selected_disk["partitions"]:
if selected_disk["partitions"][partition]["fs"] not in ("msdos", "EFI"): if selected_disk["partitions"][partition]["fs"] not in ("msdos", "EFI"):
continue continue
text = f"{partition}: {selected_disk['partitions'][partition]['name']} ({Utilities.human_fmt(selected_disk['partitions'][partition]['size'])})" text = f"{partition}: {selected_disk['partitions'][partition]['name']} ({utilities.human_fmt(selected_disk['partitions'][partition]['size'])})"
if selected_disk["partitions"][partition]["type"] == "EFI" or ( if selected_disk["partitions"][partition]["type"] == "EFI" or (
selected_disk["partitions"][partition]["type"] == "Microsoft Basic Data" and selected_disk["partitions"][partition]["size"] < 1024 * 1024 * 512 selected_disk["partitions"][partition]["type"] == "Microsoft Basic Data" and selected_disk["partitions"][partition]["size"] < 1024 * 1024 * 512
): # 512 megabytes: ): # 512 megabytes:
@@ -1075,7 +1075,7 @@ Please build OpenCore first!"""
# cancelled prompt # cancelled prompt
return return
else: else:
Utilities.TUIOnlyPrint( utilities.TUIOnlyPrint(
["Copying OpenCore"], "Press [Enter] to go back.\n", ["An error occurred!"] + result.stderr.decode().split("\n") + ["", "Please report this to the devs at GitHub."] ["Copying OpenCore"], "Press [Enter] to go back.\n", ["An error occurred!"] + result.stderr.decode().split("\n") + ["", "Please report this to the devs at GitHub."]
).start() ).start()
return return
@@ -1090,8 +1090,8 @@ Please build OpenCore first!"""
ssd_type = False ssd_type = False
mount_path = Path(partition_info["MountPoint"]) mount_path = Path(partition_info["MountPoint"])
disk_type = partition_info["BusProtocol"] disk_type = partition_info["BusProtocol"]
Utilities.cls() utilities.cls()
Utilities.header(["Copying OpenCore"]) utilities.header(["Copying OpenCore"])
if mount_path.exists(): if mount_path.exists():
if (mount_path / Path("EFI/Microsoft")).exists(): if (mount_path / Path("EFI/Microsoft")).exists():
@@ -1148,4 +1148,4 @@ Please build OpenCore first!"""
print("\nPress [Enter] to continue.\n") print("\nPress [Enter] to continue.\n")
input() input()
else: else:
Utilities.TUIOnlyPrint(["Copying OpenCore"], "Press [Enter] to go back.\n", ["EFI failed to mount!", "Please report this to the devs at GitHub."]).start() utilities.TUIOnlyPrint(["Copying OpenCore"], "Press [Enter] to go back.\n", ["EFI failed to mount!", "Please report this to the devs at GitHub."]).start()
+70 -70
View File
@@ -3,7 +3,7 @@
from __future__ import print_function from __future__ import print_function
import subprocess import subprocess
from resources import constants, Utilities, defaults, sys_patch from resources import constants, utilities, defaults, sys_patch
from data import cpu_data, smbios_data, model_array from data import cpu_data, smbios_data, model_array
@@ -13,8 +13,8 @@ class MenuOptions:
self.constants: constants.Constants() = versions self.constants: constants.Constants() = versions
def change_verbose(self): def change_verbose(self):
Utilities.cls() utilities.cls()
Utilities.header(["Set Verbose mode"]) utilities.header(["Set Verbose mode"])
change_menu = input("Enable Verbose mode(y/n/q): ") change_menu = input("Enable Verbose mode(y/n/q): ")
if change_menu in {"y", "Y", "yes", "Yes"}: if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.verbose_debug = True self.constants.verbose_debug = True
@@ -26,8 +26,8 @@ class MenuOptions:
self.change_verbose() self.change_verbose()
def change_oc(self): def change_oc(self):
Utilities.cls() utilities.cls()
Utilities.header(["Set OpenCore DEBUG mode"]) utilities.header(["Set OpenCore DEBUG mode"])
change_menu = input("Enable OpenCore DEBUG mode(y/n/q): ") change_menu = input("Enable OpenCore DEBUG mode(y/n/q): ")
if change_menu in {"y", "Y", "yes", "Yes"}: if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.opencore_debug = True self.constants.opencore_debug = True
@@ -41,8 +41,8 @@ class MenuOptions:
self.change_oc() self.change_oc()
def change_kext(self): def change_kext(self):
Utilities.cls() utilities.cls()
Utilities.header(["Set Kext DEBUG mode"]) utilities.header(["Set Kext DEBUG mode"])
change_menu = input("Enable Kext DEBUG mode(y/n/q): ") change_menu = input("Enable Kext DEBUG mode(y/n/q): ")
if change_menu in {"y", "Y", "yes", "Yes"}: if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.kext_debug = True self.constants.kext_debug = True
@@ -54,8 +54,8 @@ class MenuOptions:
self.change_kext() self.change_kext()
def change_metal(self): def change_metal(self):
Utilities.cls() utilities.cls()
Utilities.header(["Assume Metal GPU Always in iMac"]) utilities.header(["Assume Metal GPU Always in iMac"])
print( print(
"""This is for iMacs that have upgraded Metal GPUs, otherwise """This is for iMacs that have upgraded Metal GPUs, otherwise
Patcher assumes based on stock configuration (ie. iMac10,x-12,x) Patcher assumes based on stock configuration (ie. iMac10,x-12,x)
@@ -87,8 +87,8 @@ option is for those patching on a different machine or OCLP cannot detect.
self.change_metal() self.change_metal()
def change_serial(self): def change_serial(self):
Utilities.cls() utilities.cls()
Utilities.header(["Set SMBIOS Spoof Level"]) utilities.header(["Set SMBIOS Spoof Level"])
print( print(
"""This section is for setting how OpenCore generates the SMBIOS """This section is for setting how OpenCore generates the SMBIOS
Recommended for adanced users who want control how serials are handled Recommended for adanced users who want control how serials are handled
@@ -116,8 +116,8 @@ Note: For new users we recommend leaving as default(1. Minimal)
self.change_serial() self.change_serial()
def change_showpicker(self): def change_showpicker(self):
Utilities.cls() utilities.cls()
Utilities.header(["Set OpenCore Picker mode"]) utilities.header(["Set OpenCore Picker mode"])
print( print(
"""By default, OpenCore will show its boot picker each time on boot up, """By default, OpenCore will show its boot picker each time on boot up,
however this can be disabled by default and be shown on command by repeatedly however this can be disabled by default and be shown on command by repeatedly
@@ -135,8 +135,8 @@ pressing the "Esc" key
self.change_showpicker() self.change_showpicker()
def change_vault(self): def change_vault(self):
Utilities.cls() utilities.cls()
Utilities.header(["Set OpenCore Vaulting"]) utilities.header(["Set OpenCore Vaulting"])
print( print(
"""By default, this patcher will sign all your files and ensure none of the """By default, this patcher will sign all your files and ensure none of the
contents can be tampered with. However for more advanced users, you may contents can be tampered with. However for more advanced users, you may
@@ -157,8 +157,8 @@ Note: For security reasons, OpenShell will be disabled when Vault is set.
self.change_vault() self.change_vault()
def change_sip(self): def change_sip(self):
Utilities.cls() utilities.cls()
Utilities.header(["Set System Integrity protection"]) utilities.header(["Set System Integrity protection"])
print( print(
"""SIP is used to ensure proper secuirty measures are set, """SIP is used to ensure proper secuirty measures are set,
however to patch the root volume this must be disabled. however to patch the root volume this must be disabled.
@@ -183,8 +183,8 @@ Q. Return to previous menu
self.change_sip() self.change_sip()
def change_sbm(self): def change_sbm(self):
Utilities.cls() utilities.cls()
Utilities.header(["Set SecureBootModel"]) utilities.header(["Set SecureBootModel"])
print( print(
"""SecureBootModel is used to ensure best firmware security, """SecureBootModel is used to ensure best firmware security,
however to patch the root volume this must be disabled. however to patch the root volume this must be disabled.
@@ -209,8 +209,8 @@ Q. Return to previous menu
self.change_sbm() self.change_sbm()
def set_amfi(self): def set_amfi(self):
Utilities.cls() utilities.cls()
Utilities.header(["Set AMFI"]) utilities.header(["Set AMFI"])
print( print(
"""Required for Root Patching non-Metal GPUs """Required for Root Patching non-Metal GPUs
in macOS Big Sur. Without this, will receive kernel panic once in macOS Big Sur. Without this, will receive kernel panic once
@@ -228,8 +228,8 @@ Patcher finishes installing legacy acceleration patches.
self.set_amfi() self.set_amfi()
def bootstrap_setting(self): def bootstrap_setting(self):
Utilities.cls() utilities.cls()
Utilities.header(["Set Bootstrap method"]) utilities.header(["Set Bootstrap method"])
print( print(
"""Sets OpenCore's bootstrap method, currently the patcher supports the """Sets OpenCore's bootstrap method, currently the patcher supports the
following options. following options.
@@ -259,8 +259,8 @@ see the EFI Boot entry in the boot picker.
self.bootstrap_setting() self.bootstrap_setting()
def drm_setting(self): def drm_setting(self):
Utilities.cls() utilities.cls()
Utilities.header(["Set DRM preferences"]) utilities.header(["Set DRM preferences"])
print( print(
"""Sets OpenCore's DRM preferences for iMac13,x and iMac14,x. """Sets OpenCore's DRM preferences for iMac13,x and iMac14,x.
In Big Sur, some DRM based content may be broken by In Big Sur, some DRM based content may be broken by
@@ -285,8 +285,8 @@ Recommend only disabling if absolutely required.
self.drm_setting() self.drm_setting()
def allow_native_models(self): def allow_native_models(self):
Utilities.cls() utilities.cls()
Utilities.header(["Allow OpenCore on native Models"]) utilities.header(["Allow OpenCore on native Models"])
print( print(
"""Allows natively supported Macs to use OpenCore. Recommended """Allows natively supported Macs to use OpenCore. Recommended
for users with 3rd Party NVMe SSDs to achieve improved overall for users with 3rd Party NVMe SSDs to achieve improved overall
@@ -307,8 +307,8 @@ power usage.
self.allow_native_models() self.allow_native_models()
def custom_cpu(self): def custom_cpu(self):
Utilities.cls() utilities.cls()
Utilities.header(["Set custom CPU Model Name"]) utilities.header(["Set custom CPU Model Name"])
print( print(
"""Change reported CPU Model name in About This Mac """Change reported CPU Model name in About This Mac
Custom names will report as follows: Custom names will report as follows:
@@ -342,8 +342,8 @@ Q. Return to previous menu
self.custom_cpu() self.custom_cpu()
def disable_cpufriend(self): def disable_cpufriend(self):
Utilities.cls() utilities.cls()
Utilities.header(["Disable CPU Friend?"]) utilities.header(["Disable CPU Friend?"])
print( print(
"""Only recommended for advanced users """Only recommended for advanced users
Disabling CPUFriend forces macOS into using a different Disabling CPUFriend forces macOS into using a different
@@ -362,8 +362,8 @@ hardware
self.disable_cpufriend() self.disable_cpufriend()
def set_smbios(self): def set_smbios(self):
Utilities.cls() utilities.cls()
Utilities.header(["Set SMBIOS Spoof Model"]) utilities.header(["Set SMBIOS Spoof Model"])
print( print(
"""Change model OpenCore spoofs Mac too """Change model OpenCore spoofs Mac too
@@ -396,8 +396,8 @@ Q. Return to previous menu
self.set_smbios() self.set_smbios()
def allow_firewire(self): def allow_firewire(self):
Utilities.cls() utilities.cls()
Utilities.header(["Allow FireWire Boot Support"]) utilities.header(["Allow FireWire Boot Support"])
print( print(
""" """
In macOS Catalina and newer, Apple restricted In macOS Catalina and newer, Apple restricted
@@ -423,8 +423,8 @@ Note: MacBook5,x-7,1 don't support FireWire boot
self.allow_firewire() self.allow_firewire()
def allow_nvme(self): def allow_nvme(self):
Utilities.cls() utilities.cls()
Utilities.header(["Allow NVMe UEFI Support"]) utilities.header(["Allow NVMe UEFI Support"])
print( print(
""" """
For machines not natively supporting NVMe, For machines not natively supporting NVMe,
@@ -450,8 +450,8 @@ OpenCore will enable NVMe support in it's picker
self.allow_nvme() self.allow_nvme()
def allow_wowl(self): def allow_wowl(self):
Utilities.cls() utilities.cls()
Utilities.header(["Allow Wake on WLAN"]) utilities.header(["Allow Wake on WLAN"])
print( print(
""" """
Due to an unfortunate bug in macOS Big Sur+, Wake on WLAN is Due to an unfortunate bug in macOS Big Sur+, Wake on WLAN is
@@ -474,8 +474,8 @@ be prepared if enabling.
self.allow_wowl() self.allow_wowl()
def allow_ivy(self): def allow_ivy(self):
Utilities.cls() utilities.cls()
Utilities.header(["Allow Ivy iMac iGPU"]) utilities.header(["Allow Ivy iMac iGPU"])
print( print(
""" """
For iMac13,x systems with a Nvidia dGPU, the iGPU is disabled by default to For iMac13,x systems with a Nvidia dGPU, the iGPU is disabled by default to
@@ -502,8 +502,8 @@ Note 2: This setting only affects iMac13,x with dGPUs
self.allow_ivy() self.allow_ivy()
def latebloom_settings(self): def latebloom_settings(self):
Utilities.cls() utilities.cls()
Utilities.header(["Set latebloom properties"]) utilities.header(["Set latebloom properties"])
print( print(
f""" f"""
Set latebloom properties, useful for debugging boot stalls on Set latebloom properties, useful for debugging boot stalls on
@@ -548,8 +548,8 @@ Q. Return to previous menu
self.latebloom_settings() self.latebloom_settings()
def allow_moj_cat_patch(self): def allow_moj_cat_patch(self):
Utilities.cls() utilities.cls()
Utilities.header(["Allow Root Patching on Mojave/Catalina"]) utilities.header(["Allow Root Patching on Mojave/Catalina"])
print( print(
""" """
This is an experimental option that allows the usage of legacy acceleration This is an experimental option that allows the usage of legacy acceleration
@@ -576,8 +576,8 @@ Note: for the average user, we recommend using dosdude1's legacy patcher:
self.allow_moj_cat_patch() self.allow_moj_cat_patch()
def disable_tb(self): def disable_tb(self):
Utilities.cls() utilities.cls()
Utilities.header(["Disable Thunderbolt on 2013-14 MacBook Pros"]) utilities.header(["Disable Thunderbolt on 2013-14 MacBook Pros"])
print( print(
""" """
Some 2013-14 MacBook Pro's have issues with the built-in thunderbolt, Some 2013-14 MacBook Pro's have issues with the built-in thunderbolt,
@@ -602,8 +602,8 @@ other devices that benefit from this fix.
self.disable_tb() self.disable_tb()
def terascale_2_accel(self): def terascale_2_accel(self):
Utilities.cls() utilities.cls()
Utilities.header(["Set TeraScale 2 Acceleration"]) utilities.header(["Set TeraScale 2 Acceleration"])
print( print(
""" """
By default this patcher will install TeraScale 2 acceleration, however By default this patcher will install TeraScale 2 acceleration, however
@@ -627,15 +627,15 @@ handle acceleration tasks.
self.terascale_2_accel() self.terascale_2_accel()
def dump_hardware(self): def dump_hardware(self):
Utilities.cls() utilities.cls()
Utilities.header(["Dumping detected hardware"]) utilities.header(["Dumping detected hardware"])
print("") print("")
print(self.constants.computer) print(self.constants.computer)
input("\nPress [ENTER] to exit: ") input("\nPress [ENTER] to exit: ")
def applealc_support(self): def applealc_support(self):
Utilities.cls() utilities.cls()
Utilities.header(["Set AppleALC usage"]) utilities.header(["Set AppleALC usage"])
print( print(
""" """
By default this patcher will install audio patches in-memory via By default this patcher will install audio patches in-memory via
@@ -658,8 +658,8 @@ If AppleALC is detected, the Patcher will not install AppleHDA.
self.applealc_support() self.applealc_support()
def dGPU_switch_support(self): def dGPU_switch_support(self):
Utilities.cls() utilities.cls()
Utilities.header(["Set Windows GMUX support"]) utilities.header(["Set Windows GMUX support"])
print( print(
""" """
With OCLP, we're able to restore iGPU funbctionality on iGPU+dGPU With OCLP, we're able to restore iGPU funbctionality on iGPU+dGPU
@@ -679,8 +679,8 @@ for Windows may prefer to only work with the dGPU and eGPU active.
self.dGPU_switch_support() self.dGPU_switch_support()
def set_surplus(self): def set_surplus(self):
Utilities.cls() utilities.cls()
Utilities.header(["Override SurPlus MaxKernel"]) utilities.header(["Override SurPlus MaxKernel"])
print( print(
""" """
By default OCLP will only allow SurPlus to be used on kernels 21.1.0 By default OCLP will only allow SurPlus to be used on kernels 21.1.0
@@ -705,7 +705,7 @@ the event there's issues.
self.set_surplus() self.set_surplus()
def credits(self): def credits(self):
Utilities.TUIOnlyPrint( utilities.TUIOnlyPrint(
["Credits"], ["Credits"],
"Press [Enter] to go back.\n", "Press [Enter] to go back.\n",
[ [
@@ -722,8 +722,8 @@ the event there's issues.
).start() ).start()
def change_model(self): def change_model(self):
Utilities.cls() utilities.cls()
Utilities.header(["Select Different Model"]) utilities.header(["Select Different Model"])
print( print(
""" """
Tip: Run the following command on the target machine to find the model identifier: Tip: Run the following command on the target machine to find the model identifier:
@@ -746,8 +746,8 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
defaults.generate_defaults.probe(self.constants.custom_model, False, self.constants) defaults.generate_defaults.probe(self.constants.custom_model, False, self.constants)
def PatchVolume(self): def PatchVolume(self):
Utilities.cls() utilities.cls()
Utilities.header(["Patching System Volume"]) utilities.header(["Patching System Volume"])
no_patch = False no_patch = False
if self.constants.detected_os == self.constants.monterey: if self.constants.detected_os == self.constants.monterey:
@@ -771,7 +771,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
response = None response = None
while not (response and response == -1): while not (response and response == -1):
title = ["Adjust Advanced Patcher Settings, for developers ONLY"] title = ["Adjust Advanced Patcher Settings, for developers ONLY"]
menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True) menu = utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [ options = [
[f"Set Metal GPU Status:\t\tCurrently {self.constants.imac_vendor}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_metal], [f"Set Metal GPU Status:\t\tCurrently {self.constants.imac_vendor}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_metal],
[f"Set DRM Preferences:\t\tCurrently {self.constants.drm_support}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).drm_setting], [f"Set DRM Preferences:\t\tCurrently {self.constants.drm_support}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).drm_setting],
@@ -792,7 +792,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
response = None response = None
while not (response and response == -1): while not (response and response == -1):
title = ["Adjust Patcher Settings"] title = ["Adjust Patcher Settings"]
menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True) menu = utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [ options = [
["Debug Settings", self.patcher_setting_debug], ["Debug Settings", self.patcher_setting_debug],
["Security Settings", self.patcher_settings_security], ["Security Settings", self.patcher_settings_security],
@@ -820,7 +820,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
response = None response = None
while not (response and response == -1): while not (response and response == -1):
title = ["Adjust Debug Settings"] title = ["Adjust Debug Settings"]
menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True) menu = utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [ options = [
[f"Enable Verbose Mode:\tCurrently {self.constants.verbose_debug}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_verbose], [f"Enable Verbose Mode:\tCurrently {self.constants.verbose_debug}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_verbose],
[f"Enable OpenCore DEBUG:\tCurrently {self.constants.opencore_debug}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_oc], [f"Enable OpenCore DEBUG:\tCurrently {self.constants.opencore_debug}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_oc],
@@ -842,7 +842,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
response = None response = None
while not (response and response == -1): while not (response and response == -1):
title = ["Adjust Security Settings"] title = ["Adjust Security Settings"]
menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True) menu = utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [ options = [
# [ # [
# f"Set Apple Mobile File Integrity (AMFI):\tCurrently {self.constants.amfi_status}", # f"Set Apple Mobile File Integrity (AMFI):\tCurrently {self.constants.amfi_status}",
@@ -868,7 +868,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
response = None response = None
while not (response and response == -1): while not (response and response == -1):
title = ["Adjust SMBIOS Settings"] title = ["Adjust SMBIOS Settings"]
menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True) menu = utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [ options = [
[f"Set SMBIOS Spoof Level:\tCurrently {self.constants.serial_settings}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_serial], [f"Set SMBIOS Spoof Level:\tCurrently {self.constants.serial_settings}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_serial],
[f"Set SMBIOS Spoof Model:\tCurrently {self.constants.override_smbios}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).set_smbios], [f"Set SMBIOS Spoof Model:\tCurrently {self.constants.override_smbios}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).set_smbios],
@@ -884,7 +884,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
response = None response = None
while not (response and response == -1): while not (response and response == -1):
title = ["Adjust Bootable Volume Settings"] title = ["Adjust Bootable Volume Settings"]
menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True) menu = utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [ options = [
[f"Set FireWire Boot:\tCurrently {self.constants.firewire_boot}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).allow_firewire], [f"Set FireWire Boot:\tCurrently {self.constants.firewire_boot}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).allow_firewire],
[f"Set NVMe Boot:\tCurrently {self.constants.nvme_boot}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).allow_nvme], [f"Set NVMe Boot:\tCurrently {self.constants.nvme_boot}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).allow_nvme],
@@ -899,7 +899,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
response = None response = None
while not (response and response == -1): while not (response and response == -1):
title = ["Adjust Miscellaneous Settings"] title = ["Adjust Miscellaneous Settings"]
menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True) menu = utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [ options = [
[f"Set ShowPicker Mode:\tCurrently {self.constants.showpicker}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_showpicker], [f"Set ShowPicker Mode:\tCurrently {self.constants.showpicker}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_showpicker],
[f"Set Wake on WLAN:\t\tCurrently {self.constants.enable_wake_on_wlan}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).allow_wowl], [f"Set Wake on WLAN:\t\tCurrently {self.constants.enable_wake_on_wlan}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).allow_wowl],
@@ -922,7 +922,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
response = None response = None
while not (response and response == -1): while not (response and response == -1):
title = ["Adjust Advanced Patcher Settings, for developers ONLY"] title = ["Adjust Advanced Patcher Settings, for developers ONLY"]
menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True) menu = utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [ options = [
[f"Set Metal GPU Status:\t\tCurrently {self.constants.imac_vendor}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_metal], [f"Set Metal GPU Status:\t\tCurrently {self.constants.imac_vendor}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_metal],
[f"Set DRM Preferences:\t\tCurrently {self.constants.drm_support}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).drm_setting], [f"Set DRM Preferences:\t\tCurrently {self.constants.drm_support}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).drm_setting],
+8 -8
View File
@@ -1,5 +1,5 @@
# Generate Default Data # Generate Default Data
from resources import Utilities, device_probe from resources import utilities, device_probe
from data import model_array from data import model_array
class generate_defaults(): class generate_defaults():
@@ -11,7 +11,7 @@ class generate_defaults():
settings.amfi_status = True settings.amfi_status = True
if host_is_target: if host_is_target:
if Utilities.check_metal_support(device_probe, settings.computer) is False: if utilities.check_metal_support(device_probe, settings.computer) is False:
settings.disable_cs_lv = True settings.disable_cs_lv = True
if settings.computer.dgpu and settings.computer.dgpu.arch == device_probe.NVIDIA.Archs.Kepler: if settings.computer.dgpu and settings.computer.dgpu.arch == device_probe.NVIDIA.Archs.Kepler:
settings.sip_status = False settings.sip_status = False
@@ -27,7 +27,7 @@ class generate_defaults():
settings.disable_cs_lv = True settings.disable_cs_lv = True
if model in model_array.LegacyGPU: if model in model_array.LegacyGPU:
if host_is_target and Utilities.check_metal_support(device_probe, settings.computer) is True: if host_is_target and utilities.check_metal_support(device_probe, settings.computer) is True:
# Building on device and we have a native, supported GPU # Building on device and we have a native, supported GPU
if settings.computer.dgpu and settings.computer.dgpu.arch == device_probe.NVIDIA.Archs.Kepler: if settings.computer.dgpu and settings.computer.dgpu.arch == device_probe.NVIDIA.Archs.Kepler:
settings.sip_status = False settings.sip_status = False
@@ -54,22 +54,22 @@ class generate_defaults():
# MacBook8,1 has an odd bug where it cannot install Monterey with Minimal spoofing # MacBook8,1 has an odd bug where it cannot install Monterey with Minimal spoofing
settings.serial_settings = "Moderate" settings.serial_settings = "Moderate"
custom_cpu_model_value = Utilities.get_nvram("revcpuname", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) custom_cpu_model_value = utilities.get_nvram("revcpuname", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True)
if custom_cpu_model_value is not None: if custom_cpu_model_value is not None:
# TODO: Fix to not use two separate variables # TODO: Fix to not use two separate variables
settings.custom_cpu_model = 1 settings.custom_cpu_model = 1
settings.custom_cpu_model_value = custom_cpu_model_value.split("%00")[0] settings.custom_cpu_model_value = custom_cpu_model_value.split("%00")[0]
if "-v" in (Utilities.get_nvram("boot-args") or ""): if "-v" in (utilities.get_nvram("boot-args") or ""):
settings.verbose_debug = True settings.verbose_debug = True
if Utilities.amfi_status() is False: if utilities.amfi_status() is False:
settings.amfi_status = False settings.amfi_status = False
if Utilities.get_nvram("gpu-power-prefs", "FA4CE28D-B62F-4C99-9CC3-6815686E30F9"): if utilities.get_nvram("gpu-power-prefs", "FA4CE28D-B62F-4C99-9CC3-6815686E30F9"):
# Users disabling TS2 most likely have a faulty dGPU # Users disabling TS2 most likely have a faulty dGPU
# users can override this in settings # users can override this in settings
settings.allow_ts2_accel = False settings.allow_ts2_accel = False
# Check if running in RecoveryOS # Check if running in RecoveryOS
settings.recovery_status = Utilities.check_recovery() settings.recovery_status = utilities.check_recovery()
+7 -7
View File
@@ -10,7 +10,7 @@ import subprocess
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import Any, ClassVar, Optional, Type, Union from typing import Any, ClassVar, Optional, Type, Union
from resources import Utilities, ioreg from resources import utilities, ioreg
from data import pci_data from data import pci_data
@@ -373,7 +373,7 @@ class Computer:
devices = ioreg.ioiterator_to_list( devices = ioreg.ioiterator_to_list(
ioreg.IOServiceGetMatchingServices( ioreg.IOServiceGetMatchingServices(
ioreg.kIOMasterPortDefault, ioreg.kIOMasterPortDefault,
{"IOProviderClass": "IOPCIDevice", "IOPropertyMatch": {"class-code": binascii.a2b_hex(Utilities.hexswap(hex(WirelessCard.CLASS_CODE)[2:].zfill(8)))}}, {"IOProviderClass": "IOPCIDevice", "IOPropertyMatch": {"class-code": binascii.a2b_hex(utilities.hexswap(hex(WirelessCard.CLASS_CODE)[2:].zfill(8)))}},
None, None,
)[1] )[1]
) )
@@ -389,7 +389,7 @@ class Computer:
sata_controllers = ioreg.ioiterator_to_list( sata_controllers = ioreg.ioiterator_to_list(
ioreg.IOServiceGetMatchingServices( ioreg.IOServiceGetMatchingServices(
ioreg.kIOMasterPortDefault, ioreg.kIOMasterPortDefault,
{"IOProviderClass": "IOPCIDevice", "IOPropertyMatch": [{"class-code": binascii.a2b_hex(Utilities.hexswap(hex(SATAController.CLASS_CODE)[2:].zfill(8)))}]}, {"IOProviderClass": "IOPCIDevice", "IOPropertyMatch": [{"class-code": binascii.a2b_hex(utilities.hexswap(hex(SATAController.CLASS_CODE)[2:].zfill(8)))}]},
None, None,
)[1] )[1]
) )
@@ -431,12 +431,12 @@ class Computer:
# Real model # Real model
# TODO: We previously had logic for OC users using iMacPro1,1 with incorrect ExposeSensitiveData. Add logic? # TODO: We previously had logic for OC users using iMacPro1,1 with incorrect ExposeSensitiveData. Add logic?
self.real_model = Utilities.get_nvram("oem-product", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) or self.reported_model self.real_model = utilities.get_nvram("oem-product", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) or self.reported_model
self.real_board_id = Utilities.get_nvram("oem-board", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) or self.reported_board_id self.real_board_id = utilities.get_nvram("oem-board", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) or self.reported_board_id
# OCLP version # OCLP version
self.oclp_version = Utilities.get_nvram("OCLP-Version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) self.oclp_version = utilities.get_nvram("OCLP-Version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True)
self.opencore_version = Utilities.get_nvram("opencore-version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) self.opencore_version = utilities.get_nvram("opencore-version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True)
def cpu_probe(self): def cpu_probe(self):
self.cpu = CPU( self.cpu = CPU(
+2 -2
View File
@@ -1,5 +1,5 @@
from data import smbios_data, os_data from data import smbios_data, os_data
from resources import Utilities from resources import utilities
def set_smbios_model_spoof(model): def set_smbios_model_spoof(model):
try: try:
@@ -65,7 +65,7 @@ def update_firmware_features(firmwarefeature):
def generate_fw_features(model, custom): def generate_fw_features(model, custom):
if not custom: if not custom:
firmwarefeature = Utilities.get_rom("firmware-features") firmwarefeature = utilities.get_rom("firmware-features")
if not firmwarefeature: if not firmwarefeature:
print("- Failed to find FirmwareFeatures, falling back on defaults") print("- Failed to find FirmwareFeatures, falling back on defaults")
firmwarefeature = int(smbios_data.smbios_dictionary[model]["FirmwareFeatures"], 16) firmwarefeature = int(smbios_data.smbios_dictionary[model]["FirmwareFeatures"], 16)
+1 -1
View File
@@ -1,6 +1,6 @@
# Logic for mounting root volume # Logic for mounting root volume
from data import os_data from data import os_data
from resources import Utilities from resources import utilities
import plistlib import plistlib
import subprocess import subprocess
+41 -41
View File
@@ -11,7 +11,7 @@ import subprocess
import zipfile import zipfile
from pathlib import Path from pathlib import Path
from resources import constants, device_probe, Utilities from resources import constants, device_probe, utilities
from data import sip_data, sys_patch_data, model_array from data import sip_data, sys_patch_data, model_array
@@ -68,7 +68,7 @@ class PatchSysVolume:
return subprocess.run(["sudo"] + [args[0][0]] + args[0][1:], **kwargs) return subprocess.run(["sudo"] + [args[0][0]] + args[0][1:], **kwargs)
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 and self.validate is False: if self.constants.detected_os == self.constants.catalina and self.validate is False:
print("- Mounting Catalina Root Volume as writable") print("- Mounting Catalina Root Volume as writable")
@@ -77,7 +77,7 @@ class PatchSysVolume:
if Path(self.mount_extensions).exists(): if Path(self.mount_extensions).exists():
print("- Root Volume is already mounted") print("- Root Volume is already mounted")
if patch is True: if patch is True:
if self.constants.detected_os < self.constants.big_sur or (self.constants.detected_os == self.constants.big_sur and Utilities.check_seal() is True): if self.constants.detected_os < self.constants.big_sur or (self.constants.detected_os == self.constants.big_sur and utilities.check_seal() is True):
self.backup_volume() self.backup_volume()
self.patch_root_vol() self.patch_root_vol()
return True return True
@@ -91,7 +91,7 @@ class PatchSysVolume:
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:
if self.constants.detected_os < self.constants.big_sur or (self.constants.detected_os == self.constants.big_sur and Utilities.check_seal() is True): if self.constants.detected_os < self.constants.big_sur or (self.constants.detected_os == self.constants.big_sur and utilities.check_seal() is True):
self.backup_volume() self.backup_volume()
self.patch_root_vol() self.patch_root_vol()
return True return True
@@ -110,7 +110,7 @@ class PatchSysVolume:
def backup_volume(self): def backup_volume(self):
for location in sys_patch_data.BackupLocations: for location in sys_patch_data.BackupLocations:
Utilities.cls() utilities.cls()
print("Backing up root volume before patching (This may take some time)") print("Backing up root volume before patching (This may take some time)")
print(f"- Attempting to backup {location}") print(f"- Attempting to backup {location}")
location_zip = f"{location}-Backup.zip" location_zip = f"{location}-Backup.zip"
@@ -125,7 +125,7 @@ class PatchSysVolume:
# rm -r ./Extensions-Backup # rm -r ./Extensions-Backup
print("- Creating Backup folder") print("- Creating Backup folder")
Utilities.process_status( utilities.process_status(
self.elevated( self.elevated(
["cp", "-r", f"{self.mount_location}/{location}", f"{self.mount_location}/{location}-Backup"], ["cp", "-r", f"{self.mount_location}/{location}", f"{self.mount_location}/{location}-Backup"],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
@@ -133,7 +133,7 @@ class PatchSysVolume:
) )
) )
print("- Zipping Backup folder") print("- Zipping Backup folder")
Utilities.process_status( utilities.process_status(
self.elevated( self.elevated(
["ditto", "-c", "-k", "--sequesterRsrc", "--keepParent", f"{self.mount_location}/{location}-Backup", f"{self.mount_location}/{location_zip}"], ["ditto", "-c", "-k", "--sequesterRsrc", "--keepParent", f"{self.mount_location}/{location}-Backup", f"{self.mount_location}/{location_zip}"],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
@@ -142,7 +142,7 @@ class PatchSysVolume:
) )
print("- Removing Backup folder") print("- Removing Backup folder")
Utilities.process_status( utilities.process_status(
self.elevated( self.elevated(
["rm", "-r", f"{self.mount_location}/{location}-Backup"], ["rm", "-r", f"{self.mount_location}/{location}-Backup"],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
@@ -156,7 +156,7 @@ class PatchSysVolume:
print("- Verified manual unpatching is available") print("- Verified manual unpatching is available")
for location in sys_patch_data.BackupLocations: for location in sys_patch_data.BackupLocations:
Utilities.cls() utilities.cls()
print("Reverting root volume patches (This may take some time)") print("Reverting root volume patches (This may take some time)")
print(f"- Attempting to unpatch {location}") print(f"- Attempting to unpatch {location}")
@@ -175,21 +175,21 @@ class PatchSysVolume:
print(f"- Found {location_zip}") print(f"- Found {location_zip}")
print(f"- Unzipping {location_zip}") print(f"- Unzipping {location_zip}")
Utilities.process_status(self.elevated(["unzip", location_zip_path, "-d", copy_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["unzip", location_zip_path, "-d", copy_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
if location_old_path.exists(): if location_old_path.exists():
print(f"- Renaming {location}") print(f"- Renaming {location}")
Utilities.process_status(self.elevated(["mv", location_old_path, f"{location_old_path}-Patched"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["mv", location_old_path, f"{location_old_path}-Patched"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
print(f"- Renaming {location}-Backup") print(f"- Renaming {location}-Backup")
Utilities.process_status(self.elevated(["mv", f"{location_old_path}-Backup", location_old_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["mv", f"{location_old_path}-Backup", location_old_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
print(f"- Removing {location_old_path}-Patched") print(f"- Removing {location_old_path}-Patched")
Utilities.process_status(self.elevated(["rm", "-r", f"{location_old_path}-Patched"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["rm", "-r", f"{location_old_path}-Patched"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
# ditto will create a '__MACOSX' folder # ditto will create a '__MACOSX' folder
# print("- Removing __MACOSX folder") # print("- Removing __MACOSX folder")
# Utilities.process_status(self.elevated(["rm", "-r", f"{copy_path}/__MACOSX"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) # utilities.process_status(self.elevated(["rm", "-r", f"{copy_path}/__MACOSX"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
else: else:
print(f"- Failed to find {location_zip}, unable to unpatch") print(f"- Failed to find {location_zip}, unable to unpatch")
@@ -250,9 +250,9 @@ class PatchSysVolume:
else: else:
if self.constants.detected_os == self.constants.catalina: if self.constants.detected_os == self.constants.catalina:
print("- Merging kernel cache") print("- Merging kernel cache")
Utilities.process_status(self.elevated(["kcditto"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["kcditto"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
print("- Merging dyld cache") print("- Merging dyld cache")
Utilities.process_status(self.elevated(["update_dyld_shared_cache", "-root", f"{self.mount_location}/"])) utilities.process_status(self.elevated(["update_dyld_shared_cache", "-root", f"{self.mount_location}/"]))
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 and self.constants.allow_ts2_accel is True: if self.amd_ts2 is True and self.constants.allow_ts2_accel is True:
@@ -274,7 +274,7 @@ set million colour before rebooting"""
delete_path = Path(self.mount_extensions) / Path(delete_current_kext) delete_path = Path(self.mount_extensions) / Path(delete_current_kext)
if Path(delete_path).exists(): if Path(delete_path).exists():
print(f"- Deleting {delete_current_kext}") print(f"- Deleting {delete_current_kext}")
Utilities.process_status(self.elevated(["rm", "-R", delete_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["rm", "-R", delete_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
else: else:
print(f"- Couldn't find {delete_current_kext}, skipping") print(f"- Couldn't find {delete_current_kext}, skipping")
@@ -283,18 +283,18 @@ set million colour before rebooting"""
existing_path = Path(self.mount_extensions) / Path(add_current_kext) existing_path = Path(self.mount_extensions) / Path(add_current_kext)
if Path(existing_path).exists(): if Path(existing_path).exists():
print(f"- Found conflicting kext, Deleting Root Volume's {add_current_kext}") print(f"- Found conflicting kext, Deleting Root Volume's {add_current_kext}")
Utilities.process_status(self.elevated(["rm", "-R", existing_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["rm", "-R", existing_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
print(f"- Adding {add_current_kext}") print(f"- Adding {add_current_kext}")
Utilities.process_status(self.elevated(["cp", "-R", f"{vendor_location}/{add_current_kext}", self.mount_extensions], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["cp", "-R", f"{vendor_location}/{add_current_kext}", self.mount_extensions], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
Utilities.process_status(self.elevated(["chmod", "-Rf", "755", f"{self.mount_extensions}/{add_current_kext}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["chmod", "-Rf", "755", f"{self.mount_extensions}/{add_current_kext}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
Utilities.process_status(self.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_extensions}/{add_current_kext}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_extensions}/{add_current_kext}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
def add_brightness_patch(self): def add_brightness_patch(self):
self.delete_old_binaries(sys_patch_data.DeleteBrightness) self.delete_old_binaries(sys_patch_data.DeleteBrightness)
self.add_new_binaries(sys_patch_data.AddBrightness, self.constants.legacy_brightness) self.add_new_binaries(sys_patch_data.AddBrightness, self.constants.legacy_brightness)
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_private_frameworks_path_brightness}/", self.mount_private_frameworks], stdout=subprocess.PIPE) self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_private_frameworks_path_brightness}/", self.mount_private_frameworks], stdout=subprocess.PIPE)
Utilities.process_status(self.elevated(["chmod", "-Rf", "755", f"{self.mount_private_frameworks}/DisplayServices.framework"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["chmod", "-Rf", "755", f"{self.mount_private_frameworks}/DisplayServices.framework"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
Utilities.process_status(self.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_private_frameworks}/DisplayServices.framework"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_private_frameworks}/DisplayServices.framework"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
def add_audio_patch(self): def add_audio_patch(self):
if self.model in ["iMac7,1", "iMac8,1"]: if self.model in ["iMac7,1", "iMac8,1"]:
@@ -306,17 +306,17 @@ set million colour before rebooting"""
def add_wifi_patch(self): def add_wifi_patch(self):
print("- Merging Wireless CoreSerices patches") print("- Merging Wireless CoreSerices patches")
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.legacy_wifi_coreservices}/", self.mount_coreservices], stdout=subprocess.PIPE) self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.legacy_wifi_coreservices}/", self.mount_coreservices], stdout=subprocess.PIPE)
Utilities.process_status(self.elevated(["chmod", "-Rf", "755", f"{self.mount_coreservices}/WiFiAgent.app"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["chmod", "-Rf", "755", f"{self.mount_coreservices}/WiFiAgent.app"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
Utilities.process_status(self.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_coreservices}/WiFiAgent.app"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_coreservices}/WiFiAgent.app"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
print("- Merging Wireless usr/libexec patches") print("- Merging Wireless usr/libexec patches")
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.legacy_wifi_libexec}/", self.mount_libexec], stdout=subprocess.PIPE) self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.legacy_wifi_libexec}/", self.mount_libexec], stdout=subprocess.PIPE)
Utilities.process_status(self.elevated(["chmod", "755", f"{self.mount_libexec}/airportd"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["chmod", "755", f"{self.mount_libexec}/airportd"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
Utilities.process_status(self.elevated(["chown", "root:wheel", f"{self.mount_libexec}/airportd"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["chown", "root:wheel", f"{self.mount_libexec}/airportd"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
def add_legacy_mux_patch(self): def add_legacy_mux_patch(self):
self.delete_old_binaries(sys_patch_data.DeleteDemux) self.delete_old_binaries(sys_patch_data.DeleteDemux)
print("- Merging Legacy Mux Kext patches") print("- Merging Legacy Mux Kext patches")
Utilities.process_status(self.elevated(["cp", "-R", f"{self.constants.legacy_mux_path}/AppleMuxControl.kext", self.mount_extensions_mux], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["cp", "-R", f"{self.constants.legacy_mux_path}/AppleMuxControl.kext", self.mount_extensions_mux], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
def gpu_accel_legacy(self): def gpu_accel_legacy(self):
if self.constants.detected_os == self.constants.mojave: if self.constants.detected_os == self.constants.mojave:
@@ -413,7 +413,7 @@ set million colour before rebooting"""
self.add_new_binaries(sys_patch_data.AddIntelGen3Accel, self.constants.legacy_intel_gen3_path) self.add_new_binaries(sys_patch_data.AddIntelGen3Accel, self.constants.legacy_intel_gen3_path)
if self.validate is False: if self.validate is False:
print("- Fixing Acceleration in CoreMedia") print("- Fixing Acceleration in CoreMedia")
Utilities.process_status(subprocess.run(["defaults", "write", "com.apple.coremedia", "hardwareVideoDecoder", "-string", "enable"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(subprocess.run(["defaults", "write", "com.apple.coremedia", "hardwareVideoDecoder", "-string", "enable"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
print("- Merging Ivy Bridge Frameworks") print("- Merging Ivy Bridge Frameworks")
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_frameworks_path_accel_ivy}/", self.mount_frameworks], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_frameworks_path_accel_ivy}/", self.mount_frameworks], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print("- Merging Ivy Bridge PrivateFrameworks") print("- Merging Ivy Bridge PrivateFrameworks")
@@ -441,14 +441,14 @@ set million colour before rebooting"""
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_private_frameworks_path_accel}/", self.mount_private_frameworks], stdout=subprocess.PIPE) self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_private_frameworks_path_accel}/", self.mount_private_frameworks], stdout=subprocess.PIPE)
if self.constants.detected_os > self.constants.catalina: if self.constants.detected_os > self.constants.catalina:
print("- Adding IOHID-Fixup.plist") print("- Adding IOHID-Fixup.plist")
Utilities.process_status( utilities.process_status(
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_lauchd_path_accel}/", self.mount_lauchd], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_lauchd_path_accel}/", self.mount_lauchd], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
) )
Utilities.process_status(self.elevated(["chmod", "755", f"{self.mount_lauchd}/IOHID-Fixup.plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["chmod", "755", f"{self.mount_lauchd}/IOHID-Fixup.plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
Utilities.process_status(self.elevated(["chown", "root:wheel", f"{self.mount_lauchd}/IOHID-Fixup.plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(self.elevated(["chown", "root:wheel", f"{self.mount_lauchd}/IOHID-Fixup.plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
else: else:
print("- Disabling Library Validation") print("- Disabling Library Validation")
Utilities.process_status( utilities.process_status(
self.elevated( self.elevated(
["defaults", "write", "/Library/Preferences/com.apple.security.libraryvalidation.plist", "DisableLibraryValidation", "-bool", "true"], ["defaults", "write", "/Library/Preferences/com.apple.security.libraryvalidation.plist", "DisableLibraryValidation", "-bool", "true"],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
@@ -464,7 +464,7 @@ set million colour before rebooting"""
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_private_frameworks_path_accel_ts2}/", self.mount_private_frameworks], stdout=subprocess.PIPE) self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_private_frameworks_path_accel_ts2}/", self.mount_private_frameworks], stdout=subprocess.PIPE)
if self.validate is False: if self.validate is False:
print("- Fixing Acceleration in CMIO") print("- Fixing Acceleration in CMIO")
Utilities.process_status(subprocess.run(["defaults", "write", "com.apple.cmio", "CMIO_Unit_Input_ASC.DoNotUseOpenCL", "-bool", "true"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(subprocess.run(["defaults", "write", "com.apple.cmio", "CMIO_Unit_Input_ASC.DoNotUseOpenCL", "-bool", "true"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
def patch_root_vol(self): def patch_root_vol(self):
print(f"- Running patches for {self.model}") print(f"- Running patches for {self.model}")
@@ -599,13 +599,13 @@ set million colour before rebooting"""
print(f"- Duplicating into Apple.zip") print(f"- Duplicating into Apple.zip")
shutil.copy(local_zip, self.constants.payload_apple_root_path_zip) shutil.copy(local_zip, self.constants.payload_apple_root_path_zip)
else: else:
Utilities.download_file(link, self.constants.payload_apple_root_path_zip) utilities.download_file(link, self.constants.payload_apple_root_path_zip)
if self.constants.payload_apple_root_path_zip.exists(): if self.constants.payload_apple_root_path_zip.exists():
print("- Download completed") print("- Download completed")
print("- Unzipping download...") print("- Unzipping download...")
try: try:
Utilities.process_status(subprocess.run(["unzip", self.constants.payload_apple_root_path_zip], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=self.constants.payload_path)) utilities.process_status(subprocess.run(["unzip", self.constants.payload_apple_root_path_zip], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=self.constants.payload_path))
print("- Renaming folder") print("- Renaming folder")
os.rename(self.constants.payload_path / Path(os_ver), self.constants.payload_apple_root_path) os.rename(self.constants.payload_path / Path(os_ver), self.constants.payload_apple_root_path)
Path(self.constants.payload_apple_root_path_zip).unlink() Path(self.constants.payload_apple_root_path_zip).unlink()
@@ -630,7 +630,7 @@ set million colour before rebooting"""
i = 0 i = 0
for gpu in gpus: for gpu in gpus:
if gpu.class_code and gpu.class_code != 0xFFFFFFFF: if gpu.class_code and gpu.class_code != 0xFFFFFFFF:
print(f"- Found GPU ({i}): {Utilities.friendly_hex(gpu.vendor_id)}:{Utilities.friendly_hex(gpu.device_id)}") print(f"- Found GPU ({i}): {utilities.friendly_hex(gpu.vendor_id)}:{utilities.friendly_hex(gpu.device_id)}")
if gpu.arch in [device_probe.NVIDIA.Archs.Tesla, device_probe.NVIDIA.Archs.Fermi]: if gpu.arch in [device_probe.NVIDIA.Archs.Tesla, device_probe.NVIDIA.Archs.Fermi]:
if self.constants.detected_os > non_metal_os: if self.constants.detected_os > non_metal_os:
self.nvidia_legacy = True self.nvidia_legacy = True
@@ -679,7 +679,7 @@ set million colour before rebooting"""
def detect_demux(self): def detect_demux(self):
# If GFX0 is missing, assume machine was demuxed # If GFX0 is missing, assume machine was demuxed
# -wegnoegpu would also trigger this, so ensure arg is not present # -wegnoegpu would also trigger this, so ensure arg is not present
if not "-wegnoegpu" in (Utilities.get_nvram("boot-args") or ""): if not "-wegnoegpu" in (utilities.get_nvram("boot-args") or ""):
igpu = self.constants.computer.igpu igpu = self.constants.computer.igpu
dgpu = self.constants.computer.dgpu dgpu = self.constants.computer.dgpu
if igpu and not dgpu: if igpu and not dgpu:
@@ -693,7 +693,7 @@ set million colour before rebooting"""
if self.constants.detected_os > self.constants.catalina: if self.constants.detected_os > self.constants.catalina:
self.brightness_legacy = True self.brightness_legacy = True
if self.model in ["iMac7,1", "iMac8,1"] or (self.model in model_array.LegacyAudio and Utilities.check_kext_loaded("AppleALC", self.constants.detected_os) is False): if self.model in ["iMac7,1", "iMac8,1"] or (self.model in model_array.LegacyAudio and utilities.check_kext_loaded("AppleALC", self.constants.detected_os) is False):
# Special hack for systems with botched GOPs # Special hack for systems with botched GOPs
# TL;DR: No Boot Screen breaks Lilu, therefore breaking audio # TL;DR: No Boot Screen breaks Lilu, therefore breaking audio
if self.constants.detected_os > self.constants.catalina: if self.constants.detected_os > self.constants.catalina:
@@ -717,7 +717,7 @@ set million colour before rebooting"""
else: else:
self.legacy_gmux = True self.legacy_gmux = True
Utilities.cls() utilities.cls()
print("The following patches will be applied:") print("The following patches will be applied:")
if self.nvidia_legacy is True: if self.nvidia_legacy is True:
print("- Add Legacy Nvidia Tesla Graphics Patch") print("- Add Legacy Nvidia Tesla Graphics Patch")
@@ -766,7 +766,7 @@ set million colour before rebooting"""
sip_value = ( sip_value = (
"For Hackintoshes, please set csr-active-config to '030E0000' (0xE03)\nFor non-OpenCore Macs, please run 'csrutil disable' and \n'csrutil authenticated-root disable' in RecoveryOS" "For Hackintoshes, please set csr-active-config to '030E0000' (0xE03)\nFor non-OpenCore Macs, please run 'csrutil disable' and \n'csrutil authenticated-root disable' in RecoveryOS"
) )
self.sip_enabled, self.sbm_enabled, self.amfi_enabled, self.fv_enabled, self.dosdude_patched = Utilities.patching_status(sip, self.constants.detected_os) self.sip_enabled, self.sbm_enabled, self.amfi_enabled, self.fv_enabled, self.dosdude_patched = utilities.patching_status(sip, self.constants.detected_os)
if self.sip_enabled is True: if self.sip_enabled is True:
print("\nCannot patch! Please disable System Integrity Protection (SIP).") print("\nCannot patch! Please disable System Integrity Protection (SIP).")
print("Disable SIP in Patcher Settings and Rebuild OpenCore\n") print("Disable SIP in Patcher Settings and Rebuild OpenCore\n")