Use device_probe

This commit is contained in:
Dhinak G
2021-06-17 13:18:31 -04:00
parent 7b758fcf15
commit 94af2350f4
12 changed files with 973 additions and 914 deletions
+94 -67
View File
@@ -3,7 +3,7 @@
from __future__ import print_function
import subprocess
from Resources import ModelArray, Constants, Utilities
from Resources import Constants, Utilities
class MenuOptions:
@@ -49,7 +49,8 @@ class MenuOptions:
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
print(
"""This is for iMacs that have upgraded Metal GPUs, otherwise
Patcher assumes based on stock configuration (ie. iMac10,x-12,x)
Valid Options:
@@ -60,7 +61,8 @@ Valid Options:
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_menu = input("Set GPU Patch type(ie. 1): ")
if change_menu == "1":
self.constants.metal_build = False
@@ -77,11 +79,13 @@ option is for those patching on a different machine or OCLP cannot detect.
def change_wifi(self):
Utilities.cls()
Utilities.header(["Assume Upgraded Wifi Always"])
print("""This is for Macs with upgraded wifi cards(ie. BCM94360/2)
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_menu = input("Enable Upgraded Wifi build algorithm?(y/n): ")
if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.wifi_build = True
@@ -93,7 +97,8 @@ option is for those patching on a different machine or cannot detect.
def change_serial(self):
Utilities.cls()
Utilities.header(["Set SMBIOS Mode"])
print("""This section is for setting how OpenCore generates the SMBIOS
print(
"""This section is for setting how OpenCore generates the SMBIOS
Recommended for adanced users who want control how serials are handled
Valid options:
@@ -103,7 +108,8 @@ Valid options:
3. Advanced:\tReplace entire SMBIOS and generate new serials
Note: For new users we recommend leaving as default(1. Minimal)
""")
"""
)
change_menu = input("Set SMBIOS Mode(ie. 1): ")
if change_menu == "1":
self.constants.serial_settings = "Minimal"
@@ -117,10 +123,12 @@ Note: For new users we recommend leaving as default(1. Minimal)
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,
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_menu = input("Show OpenCore Picker by default(y/n): ")
if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.showpicker = True
@@ -132,13 +140,15 @@ pressing the "Esc" key
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
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 security reasons, OpenShell will be disabled when Vault is set.
""")
"""
)
change_menu = input("Enable Vault(y/n): ")
if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.vault = True
@@ -150,7 +160,8 @@ Note: For security reasons, OpenShell will be disabled when Vault is set.
def change_sip(self):
Utilities.cls()
Utilities.header(["Set SIP and SecureBootModel"])
print("""SIP and SecureBootModel are used to ensure proper OTA functionality,
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
@@ -161,7 +172,8 @@ Valid options:
3. Disable SecureBootModel Only
4. Disable Both
""")
"""
)
change_menu = input("Set SIP and SecureBootModel(ie. 1): ")
if change_menu == "1":
self.constants.sip_status = True
@@ -181,10 +193,12 @@ Valid options:
def set_amfi(self):
Utilities.cls()
Utilities.header(["Disable AMFI"])
print("""Required for Root Patching non-Metal GPUs
print(
"""Required for Root Patching non-Metal GPUs
in macOS Big Sur. Without this, will receive kernel panic once
Patcher finishes installing legacy acceleration patches.
""")
"""
)
change_menu = input("Disable AMFI(y/n): ")
if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.disable_amfi = True
@@ -193,25 +207,11 @@ Patcher finishes installing legacy acceleration patches.
else:
print("Invalid option")
def change_imac_nvidia(self):
Utilities.cls()
Utilities.header(["Assume Metal GPU Always"])
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_menu = input("Assume iMac Nvidia patches(y/n): ")
if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.imac_nvidia_build = True
elif change_menu in {"n", "N", "no", "No"}:
self.constants.imac_nvidia_build = False
else:
print("Invalid option")
def bootstrap_setting(self):
Utilities.cls()
Utilities.header(["Set Bootstrap method"])
print("""Sets OpenCore's bootstrap method, currently the patcher supports the
print(
"""Sets OpenCore's bootstrap method, currently the patcher supports the
following options.
Valid options:
@@ -226,7 +226,8 @@ and not to macOS itself.
Recommended to set to BOOTx64.efi in situations where your Mac cannot
see the EFI Boot entry in the boot picker.
""")
"""
)
change_menu = input("Set Bootstrap method: ")
if change_menu == "1":
self.constants.boot_efi = False
@@ -235,11 +236,11 @@ see the EFI Boot entry in the boot picker.
else:
print("Invalid option")
def drm_setting(self):
Utilities.cls()
Utilities.header(["Set DRM preferences"])
print("""Sets OpenCore's DRM preferences for iMac13,x and iMac14,x.
print(
"""Sets OpenCore's DRM preferences for iMac13,x and iMac14,x.
In Big Sur, some DRM based content may be broken by
default in AppleTV, Photobooth, etc.
@@ -249,7 +250,8 @@ greatly hampers Video rendering performance in Final Cut Pro and
other programs relying on such features.
Recommend only disabling if absolutely required.
""")
"""
)
change_menu = input("Enable Nvidia's Software DRM rendering(y/n): ")
if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.drm_support = True
@@ -261,11 +263,13 @@ Recommend only disabling if absolutely required.
def force_accel_setting(self):
Utilities.cls()
Utilities.header(["Assume Legacy GPU"])
print("""Allows any model to force install Legacy Acceleration
print(
"""Allows any model to force install Legacy Acceleration
patches. Only required for Mac Pro and Xserve users.
DO NOT RUN IF METAL GPU IS INSTALLED
""")
"""
)
change_menu = input("Enable Beta Acceleration Patches(y/n): ")
if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.assume_legacy = True
@@ -277,11 +281,13 @@ DO NOT RUN IF METAL GPU IS INSTALLED
def allow_native_models(self):
Utilities.cls()
Utilities.header(["Allow OpenCore on native Models"])
print("""Allows natively supported Macs to use OpenCore. Recommended
print(
"""Allows natively supported Macs to use OpenCore. Recommended
for users with 3rd Party NVMe SSDs to achieve improved overall
power usage.
""")
"""
)
change_menu = input("Allow OpenCore on all Models(y/n): ")
if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.allow_oc_everywhere = True
@@ -295,13 +301,15 @@ power usage.
def custom_cpu(self):
Utilities.cls()
Utilities.header(["Set custom CPU Model Name"])
print("""Change reported CPU Model name in About This Mac
print(
"""Change reported CPU Model name in About This Mac
Custom names will report as follows:
1: Original Name: 2.5 Ghz Dual-Core Intel Core i5
2. CPU name: Intel(R) Core(TM) i5-3210M CPU @ 2.50Ghz
3. Custom Name: 2.5Ghz Cotton Candy (example)
""")
"""
)
if self.constants.custom_cpu_model_value == "":
if self.constants.custom_cpu_model == 0:
print("Currently using original name")
@@ -325,19 +333,21 @@ Custom names will report as follows:
def custom_color_thing(self):
Utilities.cls()
Utilities.header(["Set custom CPU Model Name"])
print("""Change reported CPU Model name in About This Mac
print(
"""Change reported CPU Model name in About This Mac
Custom names will report as follows:
1: Custom Color
2. Reset
""")
"""
)
change_menu = input("Set custom CPU Name(1,2,3): ")
if change_menu == "1":
print("")
#temp_tk_root = tk.Tk()
#temp_tk_root.wm_withdraw()
#self.constants.custom_color = colorchooser.askcolor(title="Choose color")
#temp_tk_root.destroy()
# temp_tk_root = tk.Tk()
# temp_tk_root.wm_withdraw()
# self.constants.custom_color = colorchooser.askcolor(title="Choose color")
# temp_tk_root.destroy()
elif change_menu == "2":
self.constants.custom_color = ""
else:
@@ -346,9 +356,11 @@ Custom names will report as follows:
def download_more_ram_dot_com(self):
Utilities.cls()
Utilities.header(["Download more RAM"])
print("""Downloads more RAM to your Mac!
print(
"""Downloads more RAM to your Mac!
Currently only offers 1.5TB bundles
""")
"""
)
change_menu = input("Download more RAM?(y/n): ")
if change_menu == "y":
self.constants.download_ram = True
@@ -360,11 +372,13 @@ Currently only offers 1.5TB bundles
def disable_cpufriend(self):
Utilities.cls()
Utilities.header(["Disable CPU Friend?"])
print("""Only recommended for advanced users
print(
"""Only recommended for advanced users
Disabling CPUFriend forces macOS into using a different
Mac's power profile for CPUs and GPUs, which can harm the
hardware
""")
"""
)
change_menu = input("Disable CPU Friend?(y/n): ")
if change_menu == "y":
self.constants.disallow_cpufriend = True
@@ -376,24 +390,30 @@ hardware
def set_seedutil(self):
Utilities.cls()
Utilities.header(["Set SeedUtil Status"])
print("""Used for setting OS Update Preferences
print(
"""Used for setting OS Update Preferences
Valid options:
1. Public Release Seed (Default)
2. Public Beta Seed
3. Developer Beta Seed
4. Check SeedUtil's current status
""")
"""
)
change_menu = input("Set update status(Press [ENTER] to exit): ")
if change_menu == "1":
subprocess.run(["sudo", "/System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil", "unenroll"], stdout=subprocess.PIPE).stdout.decode().strip().encode()
elif change_menu == "2":
subprocess.run(["sudo", "/System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil", "unenroll"], stdout=subprocess.PIPE).stdout.decode().strip().encode()
subprocess.run(["sudo", "/System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil", "enroll", "PublicSeed"], stdout=subprocess.PIPE).stdout.decode().strip().encode()
subprocess.run(
["sudo", "/System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil", "enroll", "PublicSeed"], stdout=subprocess.PIPE
).stdout.decode().strip().encode()
elif change_menu == "3":
subprocess.run(["sudo", "/System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil", "unenroll"], stdout=subprocess.PIPE).stdout.decode().strip().encode()
subprocess.run(["sudo", "/System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil", "enroll", "DeveloperSeed"], stdout=subprocess.PIPE).stdout.decode().strip().encode()
subprocess.run(
["sudo", "/System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil", "enroll", "DeveloperSeed"], stdout=subprocess.PIPE
).stdout.decode().strip().encode()
elif change_menu == "4":
result = subprocess.run(["sudo", "/System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil", "current"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
result = [i.partition(":")[2] for i in result.stdout.decode().split("\n") if "Currently enrolled in" in i][0]
@@ -406,13 +426,15 @@ Valid options:
def set_smbios(self):
Utilities.cls()
Utilities.header(["Override SMBIOS Spoof"])
print("""Change model OpenCore spoofs Mac too
print(
"""Change model OpenCore spoofs Mac too
Valid options:
1. Default set by OpenCore (Default)
2. User Override
3. Disable all spoofing (unsupported configuration)
""")
"""
)
change_menu = input("Set SMBIOS status: ")
if change_menu == "1":
@@ -435,7 +457,8 @@ Valid options:
def allow_firewire(self):
Utilities.cls()
Utilities.header(["Allow FireWire Boot Support"])
print("""
print(
"""
In macOS Catalina and newer, Apple restricted
usage of FireWire devices to boot macOS for
security concerns relating to DMA access.
@@ -445,7 +468,8 @@ you can re-enable FireWire support for Catalina
and newer.
Note: MacBook5,x-7,1 don't support FireWire boot
""")
"""
)
change_menu = input("Enable FireWire Boot support?(y/n): ")
if change_menu == "y":
@@ -458,7 +482,8 @@ Note: MacBook5,x-7,1 don't support FireWire boot
def allow_nvme(self):
Utilities.cls()
Utilities.header(["Allow NVMe UEFI Support"])
print("""
print(
"""
For machines not natively supporting NVMe,
this option allows you to see and boot NVMe
drive in OpenCore's picker
@@ -468,7 +493,8 @@ Not required if your machine natively supports NVMe
Note: You must have OpenCore on a bootable volume
first, ie. USB or SATA drive. Once loaded,
OpenCore will enable NVMe support in it's picker
""")
"""
)
change_menu = input("Enable NVMe Boot support?(y/n): ")
if change_menu == "y":
@@ -478,11 +504,11 @@ OpenCore will enable NVMe support in it's picker
else:
print("Invalid option")
def enable_terascale(self):
Utilities.cls()
Utilities.header(["Enable TeraScale 2 Acceleration"])
print("""
print(
"""
Currently TeraScale 2 graphics acceleration is in beta with
some unfortunate bugs on login including strobing colours
until the user forces Million Colours on the Display with
@@ -493,12 +519,13 @@ patches or ask someone to handle inital setup to ensure
no issues
Note: Acceleration only applies to macOS Big Sur
""")
"""
)
change_menu = input("Enable TS2 Acceleration?(y/n): ")
if change_menu == "y":
self.constants.terscale_2_patch = True
self.constants.terascale_2_patch = True
elif change_menu == "n":
self.constants.terscale_2_patch = False
self.constants.terascale_2_patch = False
else:
print("Invalid option")
print("Invalid option")