From 6fca3339fce2997ae9df2dbb48275d89ca88eb07 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Fri, 28 Apr 2023 14:50:59 -0600 Subject: [PATCH] macos_installer_handler.py: Add min OS check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ventura’s installer requires an El Cap host to run --- CHANGELOG.md | 2 ++ docs/MODELS.md | 6 ++--- resources/gui/gui_main.py | 15 +++++++++++- resources/macos_installer_handler.py | 36 +++++++++++++++++----------- 4 files changed, 41 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1813b8b43..3fc21bff3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ - thanks [@jazzzny](https://github.com/Jazzzny) - Resolve UI unable to download macOS installers on unknown models - ex. M2 Macs and Hackintoshes +- Implement minimum OS check for installer creation + - Prevents vague errors when creating Ventura installers on Yosemite - Increment Binaries: - PatcherSupportPkg 0.9.6 - release - Build Server Changes: diff --git a/docs/MODELS.md b/docs/MODELS.md index 3e83a18e9..4e78001c9 100644 --- a/docs/MODELS.md +++ b/docs/MODELS.md @@ -18,13 +18,13 @@ The below table will list all supported and unsupported functions of the patcher Regarding OS support, see below: -* Machines listing `YES - Ventura and older` means they cannot run macOS Ventura at this time. Machines with only `YES` can run all of the supported macOS versions offered by OpenCore Legacy Patcher. - | Support Entry | Supported OSes | Description | Comment | | :--- | :--- | :--- | :--- | -| HostOS | macOS 10.9 - macOS 13 | Refers to OSes where running OpenCore-Patcher.app are supported | Supports 10.7+ if [Python 3.9 or higher](https://www.python.org/downloads/) is manually installed, simply run the `OpenCore-Patcher-GUI.command` located in the repo | +| HostOS | macOS 10.10 - macOS 13 | Refers to OSes where running OpenCore-Patcher.app are supported | Supports 10.7+ if [Python 3.9 or higher](https://www.python.org/downloads/) is manually installed, simply run the `OpenCore-Patcher-GUI.command` located in the repo | | TargetOS | macOS 11 - macOS 13 | Refers to OSes that can be patched to run with OpenCore | May support 10.4 and newer (in a potentially broken state). No support provided. | +* macOS Ventura installer creation requires 10.11 or later + ### MacBook | SMBIOS | Year | Supported | Comment | diff --git a/resources/gui/gui_main.py b/resources/gui/gui_main.py index b7ddc657e..aee182e58 100644 --- a/resources/gui/gui_main.py +++ b/resources/gui/gui_main.py @@ -2060,7 +2060,17 @@ class wx_python_gui: logging.info("Installer(s) found:") for app in available_installers: logging.info(f"- {available_installers[app]['Short Name']}: {available_installers[app]['Version']} ({available_installers[app]['Build']})") - self.install_selection = wx.Button(self.frame, label=f"{available_installers[app]['Short Name']}: {available_installers[app]['Version']} ({available_installers[app]['Build']})", size=(320, 30)) + + app_str = f"{available_installers[app]['Short Name']}" + unsupported: bool = available_installers[app]['Minimum Host OS'] > self.constants.detected_os + + if unsupported: + min_str = os_data.os_conversion.convert_kernel_to_marketing_name(available_installers[app]['Minimum Host OS']) + app_str += f" (Requires {min_str})" + else: + app_str += f": {available_installers[app]['Version']} ({available_installers[app]['Build']})" + + self.install_selection = wx.Button(self.frame, label=app_str, size=(320, 30)) i = i + 25 self.install_selection.SetPosition( wx.Point( @@ -2070,6 +2080,9 @@ class wx_python_gui: ) self.install_selection.Bind(wx.EVT_BUTTON, lambda event, temp=app: self.format_usb_menu(available_installers[temp]['Short Name'], available_installers[temp]['Path'])) self.install_selection.Centre(wx.HORIZONTAL) + + if unsupported: + self.install_selection.Disable() else: logging.info("No installers found") # Label: No Installers Found diff --git a/resources/macos_installer_handler.py b/resources/macos_installer_handler.py index 368b798ef..d118e5559 100644 --- a/resources/macos_installer_handler.py +++ b/resources/macos_installer_handler.py @@ -518,28 +518,35 @@ class LocalInstallerCatalog: if "CFBundleDisplayName" not in application_info_plist: continue - app_version = application_info_plist["DTPlatformVersion"] - clean_name = application_info_plist["CFBundleDisplayName"] + app_version: str = application_info_plist["DTPlatformVersion"] + clean_name: str = application_info_plist["CFBundleDisplayName"] + app_sdk: str = application_info_plist["DTSDKBuild"] if "DTSDKBuild" in application_info_plist else "Unknown" + min_required: str = application_info_plist["LSMinimumSystemVersion"] if "LSMinimumSystemVersion" in application_info_plist else "Unknown" - if "DTSDKBuild" in application_info_plist: - app_sdk = application_info_plist["DTSDKBuild"] - else: - app_sdk = "Unknown" + kernel: int = 0 + try: + kernel = int(app_sdk[:2]) + except ValueError: + pass + + min_required = os_data.os_conversion.os_to_kernel(min_required) if min_required != "Unknown" else "Unknown" + + if isinstance(min_required, int): + if min_required == os_data.os_data.sierra and kernel == os_data.os_data.ventura: + # Ventura's installer requires El Capitan minimum + # Ref: https://github.com/dortania/OpenCore-Legacy-Patcher/discussions/1038 + min_required = os_data.os_data.el_capitan # app_version can sometimes report GM instead of the actual version # This is a workaround to get the actual version if app_version.startswith("GM"): - try: - app_version = int(app_sdk[:2]) - if app_version < 20: - app_version = f"10.{app_version - 4}" - else: - app_version = f"{app_version - 9}.0" - except ValueError: + if kernel == 0: app_version = "Unknown" + else: + app_version = os_data.os_conversion.kernel_to_os(kernel) # Check if App Version is High Sierra or newer - if os_data.os_conversion.os_to_kernel(app_version) < os_data.os_data.high_sierra: + if kernel < os_data.os_data.high_sierra: continue results = self._parse_sharedsupport_version(Path(APPLICATION_SEARCH_PATH) / Path(application)/ Path("Contents/SharedSupport/SharedSupport.dmg")) @@ -554,6 +561,7 @@ class LocalInstallerCatalog: "Version": app_version, "Build": app_sdk, "Path": application, + "Minimum Host OS": min_required, } })