mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-13 20:28:21 +10:00
Refactor CLI Menu
This commit is contained in:
@@ -4,7 +4,7 @@ from __future__ import print_function
|
||||
|
||||
import subprocess, sys, time, platform
|
||||
|
||||
from Resources import build, ModelArray, Constants, SysPatch, utilities
|
||||
from Resources import build, ModelArray, Constants, SysPatch, utilities, CliMenu
|
||||
|
||||
|
||||
class OpenCoreLegacyPatcher():
|
||||
@@ -49,207 +49,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
|
||||
if self.constants.custom_model in ModelArray.NoAPFSsupport:
|
||||
self.constants.serial_settings = "Moderate"
|
||||
|
||||
def change_os(self):
|
||||
utilities.cls()
|
||||
utilities.header(["Select Patcher's Target OS"])
|
||||
print(f"""
|
||||
Minimum Target:\t{self.constants.min_os_support}
|
||||
Maximum Target:\t{self.constants.max_os_support}
|
||||
Current target:\t{self.constants.os_support}
|
||||
""")
|
||||
temp_os_support = float(input("Please enter OS target: "))
|
||||
if (self.constants.max_os_support < temp_os_support) or (temp_os_support < self.constants.min_os_support):
|
||||
print("Unsupported entry")
|
||||
else:
|
||||
self.constants.os_support = temp_os_support
|
||||
if temp_os_support == 11.0:
|
||||
ModelArray.SupportedSMBIOS = ModelArray.SupportedSMBIOS11
|
||||
elif temp_os_support == 12.0:
|
||||
ModelArray.SupportedSMBIOS = ModelArray.SupportedSMBIOS12
|
||||
|
||||
def change_verbose(self):
|
||||
utilities.cls()
|
||||
utilities.header(["Set Verbose mode"])
|
||||
verbose_menu = input("Enable Verbose mode(y/n): ")
|
||||
if verbose_menu in {"y", "Y", "yes", "Yes"}:
|
||||
self.constants.verbose_debug = True
|
||||
elif verbose_menu in {"n", "N", "no", "No"}:
|
||||
self.constants.verbose_debug = False
|
||||
else:
|
||||
print("Invalid option")
|
||||
|
||||
def change_oc(self):
|
||||
utilities.cls()
|
||||
utilities.header(["Set OpenCore DEBUG mode"])
|
||||
change_oc_menu = input("Enable OpenCore DEBUG mode(y/n): ")
|
||||
if change_oc_menu in {"y", "Y", "yes", "Yes"}:
|
||||
self.constants.opencore_debug = True
|
||||
self.constants.opencore_build = "DEBUG"
|
||||
elif change_oc_menu in {"n", "N", "no", "No"}:
|
||||
self.constants.opencore_debug = False
|
||||
self.constants.opencore_build = "RELEASE"
|
||||
else:
|
||||
print("Invalid option")
|
||||
def change_kext(self):
|
||||
utilities.cls()
|
||||
utilities.header(["Set Kext DEBUG mode"])
|
||||
change_kext_menu = input("Enable Kext DEBUG mode(y/n): ")
|
||||
if change_kext_menu in {"y", "Y", "yes", "Yes"}:
|
||||
self.constants.kext_debug = True
|
||||
elif change_kext_menu in {"n", "N", "no", "No"}:
|
||||
self.constants.kext_debug = False
|
||||
else:
|
||||
print("Invalid option")
|
||||
|
||||
def change_metal(self):
|
||||
utilities.cls()
|
||||
utilities.header(["Assume Metal GPU Always in iMac"])
|
||||
print("""This is for iMacs that have upgraded Metal GPUs, otherwise
|
||||
Patcher assumes based on stock configuration (ie. iMac10,x-12,x)
|
||||
|
||||
Valid Options:
|
||||
|
||||
1. None(stock GPU)
|
||||
2. Nvidia GPU
|
||||
3. AMD GPU
|
||||
|
||||
Note: Patcher will detect whether hardware has been upgraded regardless, this
|
||||
option is for those patching on a different machine or OCLP cannot detect.
|
||||
""")
|
||||
change_kext_menu = input("Set GPU Patch type(ie. 1): ")
|
||||
if change_kext_menu == "1":
|
||||
self.constants.metal_build = False
|
||||
self.constants.imac_vendor = "None"
|
||||
elif change_kext_menu == "2":
|
||||
self.constants.metal_build = True
|
||||
self.constants.imac_vendor = "Nvidia"
|
||||
elif change_kext_menu == "3":
|
||||
self.constants.metal_build = True
|
||||
self.constants.imac_vendor = "AMD"
|
||||
else:
|
||||
print("Invalid option")
|
||||
|
||||
def change_wifi(self):
|
||||
utilities.cls()
|
||||
utilities.header(["Assume Upgraded Wifi Always"])
|
||||
print("""This is for Macs with upgraded wifi cards(ie. BCM94360/2)
|
||||
|
||||
Note: Patcher will detect whether hardware has been upgraded regardless, this
|
||||
option is for those patching on a different machine or cannot detect.
|
||||
""")
|
||||
change_kext_menu = input("Enable Upgraded Wifi build algorithm?(y/n): ")
|
||||
if change_kext_menu in {"y", "Y", "yes", "Yes"}:
|
||||
self.constants.wifi_build = True
|
||||
elif change_kext_menu in {"n", "N", "no", "No"}:
|
||||
self.constants.wifi_build = False
|
||||
else:
|
||||
print("Invalid option")
|
||||
|
||||
def change_serial(self):
|
||||
utilities.cls()
|
||||
utilities.header(["Set SMBIOS Mode"])
|
||||
print("""This section is for setting how OpenCore generates the SMBIOS
|
||||
Recommended for adanced users who want control how serials are handled
|
||||
|
||||
Valid options:
|
||||
|
||||
1. Minimal:\tUse original serials and minimally update SMBIOS
|
||||
2. Moderate:\tReplace entire SMBIOS but keep original serials
|
||||
3. Advanced:\tReplace entire SMBIOS and generate new serials
|
||||
|
||||
Note: For new users we recommend leaving as default(1. Minimal)
|
||||
""")
|
||||
change_serial_menu = input("Set SMBIOS Mode(ie. 1): ")
|
||||
if change_serial_menu == "1":
|
||||
self.constants.serial_settings = "Minimal"
|
||||
elif change_serial_menu == "2":
|
||||
self.constants.serial_settings = "Moderate"
|
||||
elif change_serial_menu == "3":
|
||||
self.constants.serial_settings = "Advanced"
|
||||
else:
|
||||
print("Invalid option")
|
||||
def change_showpicker(self):
|
||||
utilities.cls()
|
||||
utilities.header(["Set OpenCore Picker mode"])
|
||||
print("""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
|
||||
pressing the "Esc" key
|
||||
""")
|
||||
change_kext_menu = input("Show OpenCore Picker by default(y/n): ")
|
||||
if change_kext_menu in {"y", "Y", "yes", "Yes"}:
|
||||
self.constants.showpicker = True
|
||||
elif change_kext_menu in {"n", "N", "no", "No"}:
|
||||
self.constants.showpicker = False
|
||||
else:
|
||||
print("Invalid option")
|
||||
|
||||
def change_vault(self):
|
||||
utilities.cls()
|
||||
utilities.header(["Set OpenCore Vaulting"])
|
||||
print("""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
|
||||
want to be able to freely edit the config.plist and files.
|
||||
|
||||
Note: For secuirty reasons, OpenShell will be disabled when Vault is set.
|
||||
|
||||
""")
|
||||
change_kext_menu = input("Enable Vault(y/n): ")
|
||||
if change_kext_menu in {"y", "Y", "yes", "Yes"}:
|
||||
self.constants.vault = True
|
||||
elif change_kext_menu in {"n", "N", "no", "No"}:
|
||||
self.constants.vault = False
|
||||
else:
|
||||
print("Invalid option")
|
||||
|
||||
def change_sip(self):
|
||||
utilities.cls()
|
||||
utilities.header(["Set SIP and SecureBootModel"])
|
||||
print("""SIP and SecureBootModel are used to ensure proper OTA functionality,
|
||||
however to patch the root volume both of these must be disabled.
|
||||
Only disable is absolutely necessary. SIP value = 0xFEF
|
||||
|
||||
Note: for minor changes, SIP can be adjusted in recovery like normal.
|
||||
Additionally, when disabling SIP via the patcher amfi_get_out_of_my_way=1
|
||||
will be added to boot-args.
|
||||
|
||||
Valid options:
|
||||
|
||||
1. Enable Both
|
||||
2. Disable SIP only
|
||||
3. Disable SecureBootModel Only
|
||||
4. Disable Both
|
||||
|
||||
""")
|
||||
change_kext_menu = input("Set SIP and SecureBootModel(ie. 1): ")
|
||||
if change_kext_menu == "1":
|
||||
self.constants.sip_status = True
|
||||
self.constants.secure_status = True
|
||||
elif change_kext_menu == "2":
|
||||
self.constants.sip_status = False
|
||||
self.constants.secure_status = True
|
||||
elif change_kext_menu == "3":
|
||||
self.constants.sip_status = True
|
||||
self.constants.secure_status = False
|
||||
elif change_kext_menu == "4":
|
||||
self.constants.sip_status = False
|
||||
self.constants.secure_status = False
|
||||
else:
|
||||
print("Invalid option")
|
||||
|
||||
def change_imac_nvidia(self):
|
||||
utilities.cls()
|
||||
utilities.header(["Force iMac Nvidia Patches"])
|
||||
print("""Specifically for iMac10,x-12,x with Metal Nvidia GPU upgrades
|
||||
By default the patcher will try to detect what hardware is
|
||||
running, however this will enforce iMac Nvidia Build Patches.
|
||||
""")
|
||||
change_kext_menu = input("Assume iMac Nvidia patches(y/n): ")
|
||||
if change_kext_menu in {"y", "Y", "yes", "Yes"}:
|
||||
self.constants.imac_nvidia_build = True
|
||||
elif change_kext_menu in {"n", "N", "no", "No"}:
|
||||
self.constants.imac_nvidia_build = False
|
||||
else:
|
||||
print("Invalid option")
|
||||
|
||||
def patcher_settings(self):
|
||||
response = None
|
||||
@@ -261,15 +61,15 @@ running, however this will enforce iMac Nvidia Build Patches.
|
||||
options = [
|
||||
# TODO: Enable setting OS target when more OSes become supported by the patcher
|
||||
#[f"Change OS version:\t\t\tCurrently macOS {self.constants.os_support}", self.change_os],
|
||||
[f"Enable Verbose Mode:\t\tCurrently {self.constants.verbose_debug}", self.change_verbose],
|
||||
[f"Enable OpenCore DEBUG:\t\tCurrently {self.constants.opencore_debug}", self.change_oc],
|
||||
[f"Enable Kext DEBUG:\t\t\tCurrently {self.constants.kext_debug}", self.change_kext],
|
||||
[f"Force iMac Metal Patch:\t\tCurrently {self.constants.imac_vendor}", self.change_metal],
|
||||
[f"Assume Upgraded Wifi Always:\tCurrently {self.constants.wifi_build}", self.change_wifi],
|
||||
[f"Set ShowPicker Mode:\t\tCurrently {self.constants.showpicker}", self.change_showpicker],
|
||||
[f"Set Vault Mode:\t\t\tCurrently {self.constants.vault}", self.change_vault],
|
||||
[f"Set SIP and SecureBootModel:\tSIP: {self.constants.sip_status} SBM: {self.constants.secure_status}", self.change_sip],
|
||||
[f"Set SMBIOS Mode:\t\t\tCurrently {self.constants.serial_settings}", self.change_serial],
|
||||
[f"Enable Verbose Mode:\t\tCurrently {self.constants.verbose_debug}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_verbose],
|
||||
[f"Enable OpenCore DEBUG:\t\tCurrently {self.constants.opencore_debug}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_oc],
|
||||
[f"Enable Kext DEBUG:\t\t\tCurrently {self.constants.kext_debug}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_kext],
|
||||
[f"Force iMac Metal Patch:\t\tCurrently {self.constants.imac_vendor}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_metal],
|
||||
[f"Assume Upgraded Wifi Always:\tCurrently {self.constants.wifi_build}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_wifi],
|
||||
[f"Set ShowPicker Mode:\t\tCurrently {self.constants.showpicker}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_showpicker],
|
||||
[f"Set Vault Mode:\t\t\tCurrently {self.constants.vault}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_vault],
|
||||
[f"Set SIP and SecureBootModel:\tSIP: {self.constants.sip_status} SBM: {self.constants.secure_status}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_sip],
|
||||
[f"Set SMBIOS Mode:\t\t\tCurrently {self.constants.serial_settings}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_serial],
|
||||
]
|
||||
|
||||
for option in options:
|
||||
@@ -303,8 +103,8 @@ desired.
|
||||
Root Volume patches can be reverted by booting Recovery and selecting
|
||||
older OS snapshots under Time Machine System Restore.
|
||||
""")
|
||||
change_kext_menu = input("Patch System Volume?(y/n): ")
|
||||
if change_kext_menu in {"y", "Y", "yes", "Yes"}:
|
||||
change_menu = input("Patch System Volume?(y/n): ")
|
||||
if change_menu in {"y", "Y", "yes", "Yes"}:
|
||||
SysPatch.PatchSysVolume(self.constants.custom_model or self.current_model, self.constants).start_patch()
|
||||
else:
|
||||
print("Returning to main menu")
|
||||
|
||||
Reference in New Issue
Block a user