diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ca0a4f38..05a3152d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - Update non-Metal Binaries: - Improve experimental Menubar implementation stability - Implement reduce transparency Menubar +- Resolve app not updating in `/Applications` after an update + - Work-around users manually copying app to `/Applications` instead of allowing Root Volume Patcher to create a proper alias - Increment Binaries: - PatcherSupportPkg 1.1.3 - release diff --git a/resources/wx_gui/gui_main_menu.py b/resources/wx_gui/gui_main_menu.py index 91b5502d7..07a5234ad 100644 --- a/resources/wx_gui/gui_main_menu.py +++ b/resources/wx_gui/gui_main_menu.py @@ -4,6 +4,9 @@ import sys import logging import threading import webbrowser +import subprocess + +from pathlib import Path from resources.wx_gui import ( gui_build, @@ -11,7 +14,6 @@ from resources.wx_gui import ( gui_support, gui_help, gui_settings, - gui_sys_patch_start, gui_sys_patch_display, gui_update, ) @@ -204,6 +206,8 @@ class MainFrame(wx.Frame): self.on_build_and_install() return + self._fix_local_install() + 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 @@ -235,6 +239,34 @@ class MainFrame(wx.Frame): threading.Thread(target=self._check_for_updates).start() + def _fix_local_install(self) -> None: + """ + Work-around users manually copying the app to /Applications + We'll delete the app, and create a proper symlink + Note: This *shouldn't* be needed with installs after 0.6.7, but it's a good catch-all + """ + + if "--update_installed" not in sys.argv: + return + if self.constants.has_checked_updates is True: + return + + # Check if app exists in /Applications, and is not a symlink + if Path("/Applications/OpenCore-Patcher.app").exists() and Path("/Applications/OpenCore-Patcher.app").is_symlink() is False: + logging.info("Found user-installed app in /Applications, replacing with symlink") + # Delete app + result = subprocess.run(["rm", "-rf", "/Applications/OpenCore-Patcher.app"], capture_output=True) + if result.returncode != 0: + print("Failed to delete app from /Applications") + return + + # Create symlink + result = subprocess.run(["ln", "-s", "/Library/Application Support/Dortania/OpenCore-Patcher.app", "/Applications/OpenCore-Patcher.app"], capture_output=True) + if result.returncode != 0: + print("Failed to create symlink to /Applications") + return + + def _check_for_updates(self): if self.constants.has_checked_updates is True: return diff --git a/resources/wx_gui/gui_update.py b/resources/wx_gui/gui_update.py index 8f095d9ef..f8d8b2b32 100644 --- a/resources/wx_gui/gui_update.py +++ b/resources/wx_gui/gui_update.py @@ -226,18 +226,20 @@ if [ ! -d "/Library/Application Support/Dortania" ]; then mkdir -p "/Library/Application Support/Dortania" fi -# Check if '/Library/Application Support/Dortania/OpenCore-Patcher.app' exists +# Check if 'OpenCore-Patcher.app' exists if [ -d "/Library/Application Support/Dortania/OpenCore-Patcher.app" ]; then rm -rf "/Library/Application Support/Dortania/OpenCore-Patcher.app" fi +if [ -d "/Applications/OpenCore-Patcher.app" ]; then + rm -rf "/Applications/OpenCore-Patcher.app" +fi + # Move '/tmp/OpenCore-Patcher.app' to '/Library/Application Support/Dortania' mv "{str(self.application_path)}" "/Library/Application Support/Dortania/OpenCore-Patcher.app" # Check if '/Applications/OpenCore-Patcher.app' exists -if [ ! -d "/Applications/OpenCore-Patcher.app" ]; then - ln -s "/Library/Application Support/Dortania/OpenCore-Patcher.app" "/Applications/OpenCore-Patcher.app" -fi +ln -s "/Library/Application Support/Dortania/OpenCore-Patcher.app" "/Applications/OpenCore-Patcher.app" # Create update.plist with info about update cat << EOF > "/Library/Application Support/Dortania/update.plist"