mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-13 20:28:21 +10:00
Add User prompt for mismatched config
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
- Add Serial Number Spoofing
|
||||
- For recycled machines where MDM was mistakenly left on
|
||||
- Add sys_patch file validation during CI
|
||||
- Add GUI Prompt for booting mismatched OpenCore configs
|
||||
- ex. Booting MacBookPro8,1 config on MacBookPro11,1
|
||||
|
||||
## 0.4.4
|
||||
- Lower SIP requirement for Root Patching
|
||||
|
||||
@@ -66,8 +66,6 @@ class wx_python_gui:
|
||||
if current_uid == 0:
|
||||
self.file_menu.Enable(wx.ID_REDO, False)
|
||||
|
||||
# Spawn thread to check for updates
|
||||
threading.Thread(target=self.check_for_updates).start()
|
||||
self.main_menu(None)
|
||||
|
||||
wx.CallAfter(self.frame.Close)
|
||||
@@ -78,11 +76,11 @@ class wx_python_gui:
|
||||
self.app.ExitMainLoop()
|
||||
sys.exit()
|
||||
|
||||
def reboot_system(self, event=None):
|
||||
def reboot_system(self, event=None, message=""):
|
||||
self.popup = wx.MessageDialog(
|
||||
self.frame,
|
||||
"Root Patcher finished successfully\nWould you like to reboot now?",
|
||||
"Reboot to apply patches?",
|
||||
message,
|
||||
"Reboot to apply?",
|
||||
wx.YES_NO | wx.ICON_INFORMATION
|
||||
)
|
||||
self.popup.SetYesNoLabels("Reboot", "Ignore")
|
||||
@@ -97,6 +95,24 @@ class wx_python_gui:
|
||||
self.frame.SetSize(self.WINDOW_WIDTH_MAIN, self.WINDOW_HEIGHT_MAIN)
|
||||
sys.stdout = self.stock_stdout
|
||||
sys.stderr = self.stock_stderr
|
||||
|
||||
def preflight_check(self):
|
||||
if (
|
||||
self.constants.computer.build_model != None and
|
||||
self.constants.computer.build_model != self.constants.computer.real_model
|
||||
):
|
||||
# Notify user they're booting an unsupported configuration
|
||||
self.constants.start_build_install = True
|
||||
self.popup = wx.MessageDialog(
|
||||
self.frame,
|
||||
f"We found you are currently booting OpenCore built for a different unit: {self.constants.computer.build_model}\n\nWe builds configs to match individual units and cannot be mixed or reused with different Macs.\n\nPlease Build and Install a new OpenCore config, and reboot your Mac.",
|
||||
"Unsupported Configuration Detected!",
|
||||
style = wx.OK | wx.ICON_EXCLAMATION
|
||||
)
|
||||
self.popup.ShowModal()
|
||||
else:
|
||||
# Spawn thread to check for updates
|
||||
threading.Thread(target=self.check_for_updates).start()
|
||||
|
||||
def check_for_updates(self, event=None):
|
||||
ignore_updates = subprocess.run(["defaults", "read", "com.dortania.opencore-legacy-patcher-wxpython", "IgnoreAppUpdates"], capture_output=True).stdout.decode("utf-8").strip()
|
||||
@@ -361,16 +377,16 @@ class wx_python_gui:
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
self.preflight_check()
|
||||
if self.finished_auto_patch is False:
|
||||
if "--gui_patch" in sys.argv:
|
||||
if self.constants.start_build_install is True:
|
||||
self.build_install_menu()
|
||||
elif "--gui_patch" in sys.argv:
|
||||
self.patches = sys_patch_detect.detect_root_patch(self.computer.real_model, self.constants).detect_patch_set()
|
||||
self.root_patch_start()
|
||||
elif "--gui_unpatch" in sys.argv:
|
||||
self.patches = sys_patch_detect.detect_root_patch(self.computer.real_model, self.constants).detect_patch_set()
|
||||
self.root_patch_revert()
|
||||
elif self.constants.start_build_install is True:
|
||||
self.build_install_menu()
|
||||
self.finished_auto_patch = True
|
||||
self.constants.start_build_install = False
|
||||
|
||||
@@ -709,15 +725,17 @@ class wx_python_gui:
|
||||
# Centre the text box to top of window
|
||||
self.stdout_text.Centre(wx.HORIZONTAL)
|
||||
self.stdout_text.SetValue("")
|
||||
sys.stdout=menu_redirect.RedirectText(self.stdout_text, False)
|
||||
sys.stderr=menu_redirect.RedirectText(self.stdout_text, False)
|
||||
|
||||
# Update frame height to right below
|
||||
self.frame.SetSize(self.WINDOW_WIDTH_BUILD, self.stdout_text.GetPosition().y + self.stdout_text.GetSize().height + 40)
|
||||
|
||||
self.frame.Show()
|
||||
|
||||
install.tui_disk_installation(self.constants).install_opencore(partition)
|
||||
sys.stdout=menu_redirect.RedirectText(self.stdout_text, False)
|
||||
sys.stderr=menu_redirect.RedirectText(self.stdout_text, False)
|
||||
result = install.tui_disk_installation(self.constants).install_opencore(partition)
|
||||
sys.stdout=sys.__stdout__
|
||||
sys.stderr=sys.__stderr__
|
||||
|
||||
self.return_to_main_menu = wx.Button(self.frame, label="Return to Main Menu")
|
||||
self.return_to_main_menu.SetPosition(
|
||||
@@ -732,6 +750,9 @@ class wx_python_gui:
|
||||
|
||||
self.frame.SetSize(self.WINDOW_WIDTH_BUILD, self.return_to_main_menu.GetPosition().y + self.return_to_main_menu.GetSize().height + 40)
|
||||
|
||||
if result is True:
|
||||
self.reboot_system(message="OpenCore has finished installing to disk.\n\nYou will need to reboot and hold the Option key and select OpenCore/Boot EFI's option.\n\nWould you like to reboot?")
|
||||
|
||||
def root_patch_menu(self, event=None):
|
||||
# Define Menu
|
||||
# Header: Post-Install Menu
|
||||
@@ -966,7 +987,7 @@ class wx_python_gui:
|
||||
sys.stderr = self.stock_stderr
|
||||
if self.constants.root_patcher_succeded is True:
|
||||
print("- Root Patcher finished successfully")
|
||||
self.reboot_system()
|
||||
self.reboot_system(message="Root Patcher finished successfully\nWould you like to reboot now?")
|
||||
self.return_to_main_menu.Enable()
|
||||
|
||||
wx.GetApp().Yield()
|
||||
@@ -1048,7 +1069,7 @@ class wx_python_gui:
|
||||
sys.stderr = self.stock_stderr
|
||||
if self.constants.root_patcher_succeded is True:
|
||||
print("- Root Patcher finished successfully")
|
||||
self.reboot_system()
|
||||
self.reboot_system(message="Root Patcher finished successfully\nWould you like to reboot now?")
|
||||
self.return_to_main_menu.Enable()
|
||||
|
||||
wx.GetApp().Yield()
|
||||
|
||||
@@ -1771,11 +1771,12 @@
|
||||
<key>4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102</key>
|
||||
<array>
|
||||
<string>OCLP-Version</string>
|
||||
<string>OCLP-Model</string>
|
||||
<string>OCLP-Settings</string>
|
||||
<string>revcpu</string>
|
||||
<string>revcpuname</string>
|
||||
<string>OCLP-Spoofed-SN</string>
|
||||
<string>OCLP-Spoofed-MLB</string>
|
||||
<string>revcpu</string>
|
||||
<string>revcpuname</string>
|
||||
</array>
|
||||
<key>7C436110-AB2A-4BBB-A880-FE41995C9F82</key>
|
||||
<array>
|
||||
|
||||
@@ -104,6 +104,7 @@ class BuildOpenCore:
|
||||
self.config["#Revision"]["OpenCore-Version"] = f"{self.constants.opencore_version} - {self.constants.opencore_build} - {self.constants.opencore_commit}"
|
||||
self.config["#Revision"]["Original-Model"] = self.model
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Version"] = f"{self.constants.patcher_version}"
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Model"] = self.model
|
||||
|
||||
for name, version, path, check in [
|
||||
# Essential kexts
|
||||
|
||||
@@ -457,6 +457,7 @@ class Computer:
|
||||
real_board_id: Optional[str] = None
|
||||
reported_model: Optional[str] = None
|
||||
reported_board_id: Optional[str] = None
|
||||
build_model: Optional[str] = None
|
||||
gpus: list[GPU] = field(default_factory=list)
|
||||
igpu: Optional[GPU] = None # Shortcut for IGPU
|
||||
dgpu: Optional[GPU] = None # Shortcut for GFX0
|
||||
@@ -683,6 +684,7 @@ class Computer:
|
||||
# Real 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.build_model = utilities.get_nvram("OCLP-Model", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True)
|
||||
|
||||
# OCLP version
|
||||
self.oclp_version = utilities.get_nvram("OCLP-Version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True)
|
||||
|
||||
@@ -207,7 +207,7 @@ Please build OpenCore first!"""
|
||||
choice = input("\nWould you like to still install OpenCore to this drive?(y/n): ")
|
||||
if not choice in ["y", "Y", "Yes", "yes"]:
|
||||
subprocess.run(["diskutil", "umount", mount_path], stdout=subprocess.PIPE).stdout.decode().strip().encode()
|
||||
return
|
||||
return False
|
||||
if (mount_path / Path("EFI/OC")).exists():
|
||||
print("- Removing preexisting EFI/OC folder")
|
||||
shutil.rmtree(mount_path / Path("EFI/OC"), onerror=rmtree_handler)
|
||||
@@ -255,6 +255,8 @@ Please build OpenCore first!"""
|
||||
tui_helpers.TUIOnlyPrint(["Copying OpenCore"], "Press [Enter] to go back.\n", ["EFI failed to mount!"]).start()
|
||||
else:
|
||||
print("EFI failed to mount!")
|
||||
return False
|
||||
return True
|
||||
|
||||
def rmtree_handler(func, path, exc_info):
|
||||
if exc_info[0] == FileNotFoundError:
|
||||
|
||||
Reference in New Issue
Block a user