mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-20 14:10:51 +10:00
Streamline diags.efi injection, add GUI support
This commit is contained in:
+18
-4
@@ -53,6 +53,16 @@ class BuildOpenCore:
|
|||||||
else:
|
else:
|
||||||
print("- Adding Internal Drive icon")
|
print("- Adding Internal Drive icon")
|
||||||
shutil.copy(self.constants.icon_path_internal, self.constants.opencore_release_folder)
|
shutil.copy(self.constants.icon_path_internal, self.constants.opencore_release_folder)
|
||||||
|
|
||||||
|
def chainload_diags(self):
|
||||||
|
Path(self.constants.opencore_release_folder / Path("System/Library/CoreServices/.diagnostics/Drivers/HardwareDrivers")).mkdir(parents=True, exist_ok=True)
|
||||||
|
if self.constants.boot_efi is True:
|
||||||
|
path_oc_loader = self.constants.opencore_release_folder / Path("EFI/BOOT/BOOTx64.efi")
|
||||||
|
else:
|
||||||
|
path_oc_loader = self.constants.opencore_release_folder / Path("System/Library/CoreServices/boot.efi")
|
||||||
|
shutil.move(path_oc_loader, self.constants.opencore_release_folder / Path("System/Library/CoreServices/.diagnostics/Drivers/HardwareDrivers/Product.efi"))
|
||||||
|
shutil.copy(self.constants.diags_launcher_path, self.constants.opencore_release_folder)
|
||||||
|
shutil.move(self.constants.opencore_release_folder / Path("diags.efi"), self.constants.opencore_release_folder / Path("boot.efi"))
|
||||||
|
|
||||||
def build_efi(self):
|
def build_efi(self):
|
||||||
utilities.cls()
|
utilities.cls()
|
||||||
@@ -735,14 +745,18 @@ class BuildOpenCore:
|
|||||||
|
|
||||||
# To work around this issue, we trick the firmware into loading OpenCore through Apple's Hardware Diagnostic Tests
|
# To work around this issue, we trick the firmware into loading OpenCore through Apple's Hardware Diagnostic Tests
|
||||||
# Specifically hiding as Product.efi under '/System/Library/CoreServices/.diagnostics/Drivers/HardwareDrivers/Product.efi'
|
# Specifically hiding as Product.efi under '/System/Library/CoreServices/.diagnostics/Drivers/HardwareDrivers/Product.efi'
|
||||||
|
# The reason chainloading via ./Drivers/HardwareDrivers is possible is thanks to it being loaded via an encrypted file buffer
|
||||||
|
# whereas other drivers like ./qa_logger.efi is invoked via Device Path.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
smbios_data.smbios_dictionary[self.model]["5K Display"]
|
smbios_data.smbios_dictionary[self.model]["5K Display"]
|
||||||
print("- Adding 5K Display Patch")
|
print("- Adding 5K Display Patch")
|
||||||
# Set LauncherPath to '/System/Library/CoreServices/boot.efi'
|
# Set LauncherPath to '/boot.efi'
|
||||||
self.config["Misc"]["Boot"]["LauncherPath"] = "\\System\\Library\\CoreServices\\boot.efi"
|
# This is to ensure that only the Mac's firmware presents the boot option, but not OpenCore
|
||||||
# Set Diagnostics Flag
|
# https://github.com/acidanthera/OpenCorePkg/blob/0.7.6/Library/OcAppleBootPolicyLib/OcAppleBootPolicyLib.c#L50-L73
|
||||||
self.constants.force_diagnostics = True
|
self.config["Misc"]["Boot"]["LauncherPath"] = "\\boot.efi"
|
||||||
|
# Setup diags.efi chainloading
|
||||||
|
self.chainload_diags()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,6 @@ class Constants:
|
|||||||
self.secure_status = False # Secure Boot Model
|
self.secure_status = False # Secure Boot Model
|
||||||
self.vault = False # EFI Vault
|
self.vault = False # EFI Vault
|
||||||
self.disable_cs_lv = False # Disable Library validation
|
self.disable_cs_lv = False # Disable Library validation
|
||||||
self.force_diagnostics = False # Force diags.efi chainloading for 5k iMacs and iMac Pro
|
|
||||||
|
|
||||||
## OS Settings
|
## OS Settings
|
||||||
self.os_support = 12.0
|
self.os_support = 12.0
|
||||||
|
|||||||
@@ -191,19 +191,6 @@ Please build OpenCore first!"""
|
|||||||
print("- Adding Internal Drive icon")
|
print("- Adding Internal Drive icon")
|
||||||
shutil.copy(self.constants.icon_path_internal, mount_path)
|
shutil.copy(self.constants.icon_path_internal, mount_path)
|
||||||
|
|
||||||
if self.constants.force_diagnostics is True:
|
|
||||||
# Chainload Diagnostics
|
|
||||||
# Required for 5k iMacs
|
|
||||||
print("- Adding 5K Display Patch")
|
|
||||||
Path(mount_path / Path("System/Library/CoreServices/.diagnostics/Drivers/HardwareDrivers")).mkdir(parents=True, exist_ok=True)
|
|
||||||
if self.constants.boot_efi is True:
|
|
||||||
path_boot_efi = mount_path / Path("EFI/BOOT/BOOTx64.efi")
|
|
||||||
else:
|
|
||||||
path_boot_efi = mount_path / Path("System/Library/CoreServices/boot.efi")
|
|
||||||
shutil.move(path_boot_efi, mount_path / Path("System/Library/CoreServices/.diagnostics/Drivers/HardwareDrivers/Product.efi"))
|
|
||||||
shutil.copy(self.constants.diags_launcher_path, mount_path / Path("System/Library/CoreServices"))
|
|
||||||
shutil.move(mount_path / Path("System/Library/CoreServices/diags.efi"), mount_path / Path("System/Library/CoreServices/boot.efi"))
|
|
||||||
|
|
||||||
print("- Cleaning install location")
|
print("- Cleaning install location")
|
||||||
if not self.constants.recovery_status:
|
if not self.constants.recovery_status:
|
||||||
print("- Unmounting EFI partition")
|
print("- Unmounting EFI partition")
|
||||||
|
|||||||
Reference in New Issue
Block a user