From a8f56c1ec8fd01905a299e4c8d4fb948d82a3445 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Tue, 21 Dec 2021 12:33:10 -0700 Subject: [PATCH] installer.py: resolve IA install error --- resources/cli_menu.py | 2 ++ resources/installer.py | 24 ++++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/resources/cli_menu.py b/resources/cli_menu.py index c3989e6b1..47f3e3a21 100644 --- a/resources/cli_menu.py +++ b/resources/cli_menu.py @@ -1107,6 +1107,8 @@ B. Exit def download_install_assistant(self, link): installer.download_install_assistant(self.constants.payload_path, link) + installer.install_macOS_installer(self.constants.payload_path) + input("Press any key to continue...") # To avoid selecting the wrong installer by mistake, let user select the correct one self.find_local_installer() diff --git a/resources/installer.py b/resources/installer.py index 18b47e7f6..3428c5202 100644 --- a/resources/installer.py +++ b/resources/installer.py @@ -53,11 +53,27 @@ def create_installer(installer_path, volume_name): return False def download_install_assistant(download_path, ia_link): - # Downloads and unpackages InstallAssistant.pkg into /Applications + # Downloads InstallAssistant.pkg utilities.download_file(ia_link, (Path(download_path) / Path("InstallAssistant.pkg"))) - print("- Installing InstallAssistant.pkg to /Applications/") - utilities.elevated(["installer", "-pkg", (Path(download_path) / Path("InstallAssistant.pkg")), "-target", "/Applications"]) - input("- Press ENTER to continue: ") + +def install_macOS_installer(download_path): + args = [ + "osascript", + "-e", + f'''do shell script "installer -pkg {Path(download_path)}/InstallAssistant.pkg -target /"''' + ' with prompt "OpenCore Legacy Patcher needs administrator privileges to add InstallAssistant."' + " with administrator privileges" + " without altering line endings", + ] + + result = subprocess.run(args,stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if result.returncode == 0: + print("- InstallAssistant installed") + return True + else: + print("- Failed to install InstallAssistant") + print(f" Error Code: {result.returncode}") + return False def list_downloadable_macOS_installers(download_path, catalog): avalible_apps = {}