mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-22 11:00:16 +10:00
GUI: Implement update flow
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
<key>CFBundleInfoDictionaryVersion</key>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
<string>6.0</string>
|
<string>6.0</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>OpenCore-Patcher</string>
|
<string>OpenCore-Patcher-Helper</string>
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ class Constants:
|
|||||||
self.launcher_script: str = None # Determine launch file path (None if PyInstaller)
|
self.launcher_script: str = None # Determine launch file path (None if PyInstaller)
|
||||||
self.booted_oc_disk: str = None # Determine current disk OCLP booted from
|
self.booted_oc_disk: str = None # Determine current disk OCLP booted from
|
||||||
self.unpack_thread = None # Determine if unpack thread finished (threading.Thread)
|
self.unpack_thread = None # Determine if unpack thread finished (threading.Thread)
|
||||||
|
self.update_stage: int = 0 # Determine update stage (see gui_support.py)
|
||||||
|
|
||||||
self.commit_info: tuple = (None, None, None) # Commit info (Branch, Commit Date, Commit URL)
|
self.commit_info: tuple = (None, None, None) # Commit info (Branch, Commit Date, Commit URL)
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import logging
|
|||||||
import threading
|
import threading
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from resources.gui import gui_main
|
|
||||||
from resources.wx_gui import gui_entry
|
from resources.wx_gui import gui_entry
|
||||||
from resources import (
|
from resources import (
|
||||||
constants,
|
constants,
|
||||||
@@ -39,7 +38,6 @@ class OpenCoreLegacyPatcher:
|
|||||||
self._generate_base_data()
|
self._generate_base_data()
|
||||||
|
|
||||||
if utilities.check_cli_args() is None:
|
if utilities.check_cli_args() is None:
|
||||||
# gui_main.wx_python_gui(self.constants).main_menu(None)
|
|
||||||
gui_entry.EntryPoint(self.constants).start()
|
gui_entry.EntryPoint(self.constants).start()
|
||||||
|
|
||||||
|
|
||||||
@@ -101,7 +99,7 @@ class OpenCoreLegacyPatcher:
|
|||||||
logging.info("- Detected arguments, switching to CLI mode")
|
logging.info("- Detected arguments, switching to CLI mode")
|
||||||
self.constants.gui_mode = True # Assumes no user interaction is required
|
self.constants.gui_mode = True # Assumes no user interaction is required
|
||||||
|
|
||||||
ignore_args = ["--auto_patch", "--gui_patch", "--gui_unpatch"]
|
ignore_args = ["--auto_patch", "--gui_patch", "--gui_unpatch", "--update_installed"]
|
||||||
if not any(x in sys.argv for x in ignore_args):
|
if not any(x in sys.argv for x in ignore_args):
|
||||||
self.constants.current_path = Path.cwd()
|
self.constants.current_path = Path.cwd()
|
||||||
self.constants.cli_mode = True
|
self.constants.cli_mode = True
|
||||||
|
|||||||
@@ -572,6 +572,7 @@ def check_cli_args():
|
|||||||
parser.add_argument("--gui_patch", help="Starts GUI in Root Patcher", action="store_true", required=False)
|
parser.add_argument("--gui_patch", help="Starts GUI in Root Patcher", action="store_true", required=False)
|
||||||
parser.add_argument("--gui_unpatch", help="Starts GUI in Root Unpatcher", action="store_true", required=False)
|
parser.add_argument("--gui_unpatch", help="Starts GUI in Root Unpatcher", action="store_true", required=False)
|
||||||
parser.add_argument("--auto_patch", help="Check if patches are needed and prompt user", action="store_true", required=False)
|
parser.add_argument("--auto_patch", help="Check if patches are needed and prompt user", action="store_true", required=False)
|
||||||
|
parser.add_argument("--update_installed", help="Prompt user to finish updating via GUI", action="store_true", required=False)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if not (args.build or args.patch_sys_vol or args.unpatch_sys_vol or args.validate or args.auto_patch):
|
if not (args.build or args.patch_sys_vol or args.unpatch_sys_vol or args.validate or args.auto_patch):
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ class BuildFrame(wx.Frame):
|
|||||||
|
|
||||||
self._generate_elements(self.frame_modal)
|
self._generate_elements(self.frame_modal)
|
||||||
|
|
||||||
|
if self.constants.update_stage != gui_support.AutoUpdateStages.INACTIVE:
|
||||||
|
self.constants.update_stage = gui_support.AutoUpdateStages.BUILDING
|
||||||
|
|
||||||
self.SetPosition(screen_location) if screen_location else self.Centre()
|
self.SetPosition(screen_location) if screen_location else self.Centre()
|
||||||
self.frame_modal.ShowWindowModal()
|
self.frame_modal.ShowWindowModal()
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import threading
|
|||||||
import logging
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from resources.wx_gui import gui_main_menu, gui_support
|
from resources.wx_gui import gui_main_menu, gui_support, gui_sys_patch
|
||||||
from resources import constants, install
|
from resources import constants, install
|
||||||
|
|
||||||
|
|
||||||
@@ -27,6 +27,9 @@ class InstallOCFrame(wx.Frame):
|
|||||||
|
|
||||||
self._generate_elements()
|
self._generate_elements()
|
||||||
|
|
||||||
|
if self.constants.update_stage != gui_support.AutoUpdateStages.INACTIVE:
|
||||||
|
self.constants.update_stage = gui_support.AutoUpdateStages.INSTALLING
|
||||||
|
|
||||||
self.SetPosition(screen_location) if screen_location else self.Centre()
|
self.SetPosition(screen_location) if screen_location else self.Centre()
|
||||||
self.Show()
|
self.Show()
|
||||||
|
|
||||||
@@ -262,7 +265,25 @@ class InstallOCFrame(wx.Frame):
|
|||||||
wx.GetApp().Yield()
|
wx.GetApp().Yield()
|
||||||
|
|
||||||
if self.result is True:
|
if self.result is True:
|
||||||
if not self.constants.custom_model:
|
if self.constants.update_stage != gui_support.AutoUpdateStages.INACTIVE:
|
||||||
|
self.constants.update_stage = gui_support.AutoUpdateStages.ROOT_PATCHING
|
||||||
|
popup_message = wx.MessageDialog(
|
||||||
|
self,
|
||||||
|
f"OpenCore has finished installing to disk.\n\nWould you like to update your root patches next?", "Success",
|
||||||
|
wx.YES_NO | wx.YES_DEFAULT
|
||||||
|
)
|
||||||
|
popup_message.ShowModal()
|
||||||
|
if popup_message.GetReturnCode() == wx.ID_YES:
|
||||||
|
gui_sys_patch.SysPatchFrame(
|
||||||
|
parent=None,
|
||||||
|
title=self.title,
|
||||||
|
global_constants=self.constants,
|
||||||
|
screen_location=self.GetPosition()
|
||||||
|
)
|
||||||
|
self.Destroy()
|
||||||
|
return
|
||||||
|
|
||||||
|
elif not self.constants.custom_model:
|
||||||
gui_support.RestartHost(self).restart(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?")
|
gui_support.RestartHost(self).restart(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?")
|
||||||
else:
|
else:
|
||||||
popup_message = wx.MessageDialog(
|
popup_message = wx.MessageDialog(
|
||||||
@@ -271,6 +292,9 @@ class InstallOCFrame(wx.Frame):
|
|||||||
wx.OK
|
wx.OK
|
||||||
)
|
)
|
||||||
popup_message.ShowModal()
|
popup_message.ShowModal()
|
||||||
|
else:
|
||||||
|
if self.constants.update_stage != gui_support.AutoUpdateStages.INACTIVE:
|
||||||
|
self.constants.update_stage = gui_support.AutoUpdateStages.FINISHED
|
||||||
|
|
||||||
|
|
||||||
def _install_oc(self, partition: dict) -> None:
|
def _install_oc(self, partition: dict) -> None:
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
|
# Generate GUI for main menu
|
||||||
import wx
|
import wx
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
@@ -113,6 +116,34 @@ class MainFrame(wx.Frame):
|
|||||||
self.on_build_and_install()
|
self.on_build_and_install()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if "--update_installed" in sys.argv and self.constants.has_checked_updates is False and gui_support.CheckProperties(self.constants).host_can_build():
|
||||||
|
# Notify user that the update has been installed
|
||||||
|
self.constants.has_checked_updates = True
|
||||||
|
pop_up = wx.MessageDialog(
|
||||||
|
self,
|
||||||
|
f"OpenCore Legacy Patcher has been updated to the latest version: {self.constants.patcher_version}\n\nWould you like to update OpenCore and your root volume patches?",
|
||||||
|
"Update successful!",
|
||||||
|
style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_INFORMATION
|
||||||
|
)
|
||||||
|
pop_up.ShowModal()
|
||||||
|
|
||||||
|
if pop_up.GetReturnCode() != wx.ID_YES:
|
||||||
|
print("- Skipping OpenCore and root volume patch update...")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
print("- Updating OpenCore and root volume patches...")
|
||||||
|
self.constants.update_stage = gui_support.AutoUpdateStages.CHECKING
|
||||||
|
self.Hide()
|
||||||
|
pos = self.GetPosition()
|
||||||
|
gui_build.BuildFrame(
|
||||||
|
parent=None,
|
||||||
|
title=self.title,
|
||||||
|
global_constants=self.constants,
|
||||||
|
screen_location=pos
|
||||||
|
)
|
||||||
|
self.Close()
|
||||||
|
|
||||||
threading.Thread(target=self._check_for_updates).start()
|
threading.Thread(target=self._check_for_updates).start()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,15 @@ from resources import constants
|
|||||||
from data import model_array, os_data
|
from data import model_array, os_data
|
||||||
|
|
||||||
|
|
||||||
|
class AutoUpdateStages:
|
||||||
|
INACTIVE = 0
|
||||||
|
CHECKING = 1
|
||||||
|
BUILDING = 2
|
||||||
|
INSTALLING = 3
|
||||||
|
ROOT_PATCHING = 4
|
||||||
|
FINISHED = 5
|
||||||
|
|
||||||
|
|
||||||
class GenerateMenubar:
|
class GenerateMenubar:
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class SysPatchFrame(wx.Frame):
|
|||||||
self.constants: constants.Constants = global_constants
|
self.constants: constants.Constants = global_constants
|
||||||
self.frame_modal: wx.Dialog = None
|
self.frame_modal: wx.Dialog = None
|
||||||
self.return_button: wx.Button = None
|
self.return_button: wx.Button = None
|
||||||
|
self.available_patches: bool = False
|
||||||
|
|
||||||
self.frame_modal = wx.Dialog(self, title=title, size=(360, 200))
|
self.frame_modal = wx.Dialog(self, title=title, size=(360, 200))
|
||||||
self.SetPosition(screen_location) if screen_location else self.Centre()
|
self.SetPosition(screen_location) if screen_location else self.Centre()
|
||||||
@@ -49,6 +50,10 @@ class SysPatchFrame(wx.Frame):
|
|||||||
self._generate_elements_display_patches(self.frame_modal, patches)
|
self._generate_elements_display_patches(self.frame_modal, patches)
|
||||||
self.frame_modal.ShowWindowModal()
|
self.frame_modal.ShowWindowModal()
|
||||||
|
|
||||||
|
if self.constants.update_stage != gui_support.AutoUpdateStages.INACTIVE:
|
||||||
|
if self.available_patches is False:
|
||||||
|
gui_support.RestartHost(self).restart(message="No root patch updates needed!\n\nWould you like to reboot to apply the new OpenCore build?")
|
||||||
|
|
||||||
|
|
||||||
def _kdk_download(self, frame: wx.Frame = None) -> bool:
|
def _kdk_download(self, frame: wx.Frame = None) -> bool:
|
||||||
frame = self if not frame else frame
|
frame = self if not frame else frame
|
||||||
@@ -239,12 +244,14 @@ class SysPatchFrame(wx.Frame):
|
|||||||
if not patches:
|
if not patches:
|
||||||
start_button.Disable()
|
start_button.Disable()
|
||||||
else:
|
else:
|
||||||
|
self.available_patches = True
|
||||||
if patches["Validation: Patching Possible"] is False:
|
if patches["Validation: Patching Possible"] is False:
|
||||||
start_button.Disable()
|
start_button.Disable()
|
||||||
|
elif no_new_patches is False:
|
||||||
|
start_button.SetDefault()
|
||||||
if can_unpatch is False:
|
if can_unpatch is False:
|
||||||
revert_button.Disable()
|
revert_button.Disable()
|
||||||
|
|
||||||
|
|
||||||
# Relaunch as root if not root
|
# Relaunch as root if not root
|
||||||
uid = os.geteuid()
|
uid = os.geteuid()
|
||||||
if uid != 0:
|
if uid != 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user