mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-20 22:20:53 +10:00
macos_installer_handler.py: Add support for Privileged Helper
This commit is contained in:
@@ -15,7 +15,8 @@ from ..datasets import os_data
|
|||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
network_handler,
|
network_handler,
|
||||||
utilities
|
utilities,
|
||||||
|
subprocess_wrapper
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -63,17 +64,24 @@ class InstallerCreation():
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
logging.info("Extracting macOS installer from InstallAssistant.pkg")
|
logging.info("Extracting macOS installer from InstallAssistant.pkg")
|
||||||
try:
|
if subprocess_wrapper.supports_privileged_helper() is False:
|
||||||
applescript.AppleScript(
|
try:
|
||||||
f'''do shell script "installer -pkg {Path(download_path)}/InstallAssistant.pkg -target /"'''
|
applescript.AppleScript(
|
||||||
' with prompt "OpenCore Legacy Patcher needs administrator privileges to extract the installer."'
|
f'''do shell script "installer -pkg {Path(download_path)}/InstallAssistant.pkg -target /"'''
|
||||||
" with administrator privileges"
|
' with prompt "OpenCore Legacy Patcher needs administrator privileges to extract the installer."'
|
||||||
" without altering line endings",
|
" with administrator privileges"
|
||||||
).run()
|
" without altering line endings",
|
||||||
except Exception as e:
|
).run()
|
||||||
logging.info("Failed to install InstallAssistant")
|
except Exception as e:
|
||||||
logging.info(f" Error Code: {e}")
|
logging.info("Failed to install InstallAssistant")
|
||||||
return False
|
logging.info(f" Error Code: {e}")
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
result = subprocess_wrapper.run_as_root(["/usr/sbin/installer", "-pkg", f"{Path(download_path)}/InstallAssistant.pkg", "-target", "/"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
if result.returncode != 0:
|
||||||
|
logging.info("Failed to install InstallAssistant")
|
||||||
|
subprocess_wrapper.log(result)
|
||||||
|
return False
|
||||||
|
|
||||||
logging.info("InstallAssistant installed")
|
logging.info("InstallAssistant installed")
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user