Merge branch 'main' into sonoma-development

This commit is contained in:
Mykola Grymalyuk
2023-07-26 10:58:30 -06:00
committed by GitHub
20 changed files with 288 additions and 147 deletions
+1 -2
View File
@@ -68,7 +68,6 @@ class PatchSysVolume:
self.skip_root_kmutil_requirement = self.hardware_details["Settings: Supports Auxiliary Cache"]
def _init_pathing(self, custom_root_mount_path: Path = None, custom_data_mount_path: Path = None) -> None:
"""
Initializes the pathing for root volume patching
@@ -494,7 +493,7 @@ class PatchSysVolume:
oclp_plist_data = plistlib.load(Path(oclp_path).open("rb"))
for key in oclp_plist_data:
if isinstance(oclp_plist_data[key], (bool, int)):
continue
continue
if "Install" not in oclp_plist_data[key]:
continue
for location in oclp_plist_data[key]["Install"]:
+10 -7
View File
@@ -47,8 +47,7 @@ class AutomaticSysPatch:
dict = updates.CheckBinaryUpdates(self.constants).check_binary_updates()
if dict:
for key in dict:
version = dict[key]["Version"]
version = dict["Version"]
logging.info(f"- Found new version: {version}")
app = wx.App()
@@ -64,7 +63,7 @@ class AutomaticSysPatch:
if response == wx.ID_YES:
gui_entry.EntryPoint(self.constants).start(entry=gui_entry.SupportedEntryPoints.UPDATE_APP)
elif response == wx.ID_NO:
webbrowser.open(dict[key]["Github Link"])
webbrowser.open(dict["Github Link"])
return
if utilities.check_seal() is True:
@@ -148,17 +147,21 @@ class AutomaticSysPatch:
logging.info("- Versions match")
return True
if self.constants.special_build is True:
# Version doesn't match and we're on a special build
# Special builds don't have good ways to compare versions
logging.info("- Special build detected, assuming installed is older")
return False
# Check if installed version is newer than booted version
if updates.CheckBinaryUpdates(self.constants)._check_if_build_newer(
self.constants.computer.oclp_version.split("."), self.constants.patcher_version.split(".")
) is True:
if updates.CheckBinaryUpdates(self.constants).check_if_newer(self.constants.computer.oclp_version):
logging.info("- Installed version is newer than booted version")
return True
args = [
"osascript",
"-e",
f"""display dialog "OpenCore Legacy Patcher has detected that you are booting an outdated OpenCore build\n- Booted: {self.constants.computer.oclp_version}\n- Installed: {self.constants.patcher_version}\n\nWould you like to update the OpenCore bootloader?" """
f"""display dialog "OpenCore Legacy Patcher has detected that you are booting {'a different' if self.constants.special_build else 'an outdated'} OpenCore build\n- Booted: {self.constants.computer.oclp_version}\n- Installed: {self.constants.patcher_version}\n\nWould you like to update the OpenCore bootloader?" """
f'with icon POSIX file "{self.constants.app_icon_path}"',
]
output = subprocess.run(
+35 -20
View File
@@ -3,26 +3,16 @@
# Used when supplying data to sys_patch.py
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk
import plistlib
import logging
import py_sip_xnu
import plistlib
from pathlib import Path
from resources import (
constants,
device_probe,
utilities,
amfi_detect,
network_handler,
kdk_handler
)
from data import (
model_array,
os_data,
sip_data,
smbios_data,
cpu_data
)
import packaging.version
import py_sip_xnu
from data import cpu_data, model_array, os_data, sip_data, smbios_data
from resources import (amfi_detect, constants, device_probe, kdk_handler,
network_handler, utilities)
class DetectRootPatch:
@@ -78,6 +68,7 @@ class DetectRootPatch:
self.dosdude_patched = False
self.missing_kdk = False
self.has_network = False
self.unsupported_os = False
self.missing_whatever_green = False
self.missing_nv_web_nvram = False
@@ -441,7 +432,18 @@ class DetectRootPatch:
bool: True if loaded, False otherwise
"""
return utilities.check_kext_loaded("WhateverGreen", self.constants.detected_os)
return utilities.check_kext_loaded("as.vit9696.WhateverGreen")
def _check_os_compat(self) -> bool:
"""
Base check to ensure patcher is compatible with host OS
"""
min_os = os_data.os_data.big_sur
max_os = os_data.os_data.ventura
if self.constants.detected_os < min_os or self.constants.detected_os > max_os:
return False
return True
def _check_kdk(self):
@@ -546,7 +548,7 @@ class DetectRootPatch:
if self.constants.detected_os > os_data.os_data.catalina:
self.brightness_legacy = True
if self.model in ["iMac7,1", "iMac8,1"] or (self.model in model_array.LegacyAudio and utilities.check_kext_loaded("AppleALC", self.constants.detected_os) is False):
if self.model in ["iMac7,1", "iMac8,1"] or (self.model in model_array.LegacyAudio and utilities.check_kext_loaded("as.vit9696.AppleALC") is False):
# Special hack for systems with botched GOPs
# TL;DR: No Boot Screen breaks Lilu, therefore breaking audio
if self.constants.detected_os > os_data.os_data.catalina:
@@ -618,6 +620,7 @@ class DetectRootPatch:
"Settings: Kernel Debug Kit missing": self.missing_kdk if self.constants.detected_os >= os_data.os_data.ventura.value else False,
"Validation: Patching Possible": self.verify_patch_allowed(),
"Validation: Unpatching Possible": self._verify_unpatch_allowed(),
f"Validation: Unsupported Host OS": self.unsupported_os,
f"Validation: SIP is enabled (Required: {self._check_sip()[2]} or higher)": self.sip_enabled,
f"Validation: Currently Booted SIP: ({hex(py_sip_xnu.SipXnu().get_sip_status().value)})": self.sip_enabled,
"Validation: SecureBootModel is enabled": self.sbm_enabled,
@@ -648,6 +651,12 @@ class DetectRootPatch:
if self.constants.detected_os < os_data.os_data.big_sur:
return amfi_detect.AmfiConfigDetectLevel.NO_CHECK
amfipass_version = utilities.check_kext_loaded("com.dhinakg.AMFIPass")
if amfipass_version:
if packaging.version.parse(amfipass_version) >= packaging.version.parse(self.constants.amfipass_compatibility_version):
# If AMFIPass is loaded, our binaries will work
return amfi_detect.AmfiConfigDetectLevel.NO_CHECK
if self.constants.detected_os >= os_data.os_data.ventura:
if self.amfi_shim_bins is True:
# Currently we require AMFI outright disabled
@@ -675,6 +684,8 @@ class DetectRootPatch:
self.sip_enabled, self.sbm_enabled, self.fv_enabled, self.dosdude_patched = utilities.patching_status(sip, self.constants.detected_os)
self.amfi_enabled = not amfi_detect.AmfiConfigurationDetection().check_config(self._get_amfi_level_needed())
self.unsupported_os = not self._check_os_compat()
if self.nvidia_web is True:
self.missing_nv_web_nvram = not self._check_nv_web_nvram()
self.missing_nv_web_opengl = not self._check_nv_web_opengl()
@@ -728,10 +739,14 @@ class DetectRootPatch:
logging.info("\nCannot patch! Network Connection Required")
logging.info("Please ensure you have an active internet connection")
if self.unsupported_os is True:
logging.info("\nCannot patch! Unsupported Host OS")
logging.info("Please ensure you are running a patcher-supported OS")
if any(
[
# General patch checks
self.sip_enabled, self.sbm_enabled, self.fv_enabled, self.dosdude_patched,
self.sip_enabled, self.sbm_enabled, self.fv_enabled, self.dosdude_patched, self.unsupported_os,
# non-Metal specific
self.amfi_enabled if self.amfi_must_disable is True else False,
+4 -2
View File
@@ -81,7 +81,7 @@ class GenerateRootPatchSets:
required_patches.update({"Sonoma Legacy Metal Extended": all_hardware_patchset["Graphics"]["Sonoma Legacy Metal Extended"]})
if self.hardware_details["Graphics: Intel Skylake"] is True:
required_patches.update({"Monterey GVA": all_hardware_patchset["Graphics"]["Monterey GVA"]})
required_patches.update({"Revert GVA Downgrade": all_hardware_patchset["Graphics"]["Revert GVA Downgrade"]})
required_patches.update({"Monterey OpenCL": all_hardware_patchset["Graphics"]["Monterey OpenCL"]})
required_patches.update({"Intel Skylake": all_hardware_patchset["Graphics"]["Intel Skylake"]})
required_patches.update({"Sonoma Legacy Metal Extended": all_hardware_patchset["Graphics"]["Sonoma Legacy Metal Extended"]})
@@ -133,7 +133,9 @@ class GenerateRootPatchSets:
del(required_patches["AMD TeraScale 2"]["Install"]["/System/Library/Extensions"]["AMDRadeonX3000.kext"])
if self.hardware_details["Graphics: AMD Legacy GCN"] is True or self.hardware_details["Graphics: AMD Legacy Polaris"] is True:
required_patches.update({"Monterey GVA": all_hardware_patchset["Graphics"]["Monterey GVA"]})
if self.hardware_details["Graphics: Intel Skylake"] is False:
# GVA downgrade not required if Skylake is present
required_patches.update({"Monterey GVA": all_hardware_patchset["Graphics"]["Monterey GVA"]})
required_patches.update({"Monterey OpenCL": all_hardware_patchset["Graphics"]["Monterey OpenCL"]})
if self.hardware_details["Graphics: AMD Legacy GCN"] is True:
required_patches.update({"AMD Legacy GCN": all_hardware_patchset["Graphics"]["AMD Legacy GCN"]})