diff --git a/.gitignore b/.gitignore index aa815028e..11b228a9e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ .DS_Store OCLP-GUI.command -/payloads/Apple/Frameworks -/payloads/Apple/LaunchDaemons -/payloads/Apple/PrivateFrameworks +/payloads/Apple-Binaries-OCLP-main +/payloads/__MACOSX /App /Build-Folder /build diff --git a/OpenCore-Patcher.command b/OpenCore-Patcher.command index b6c91b811..dfd8ce921 100755 --- a/OpenCore-Patcher.command +++ b/OpenCore-Patcher.command @@ -73,6 +73,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier' [f"Set Vault Mode:\t\t\tCurrently {self.constants.vault}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_vault], [f"Set SIP and SecureBootModel:\tSIP: {self.constants.sip_status} SBM: {self.constants.secure_status}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_sip], [f"Set SMBIOS Mode:\t\t\tCurrently {self.constants.serial_settings}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_serial], + [f"Set Custom Patch Repo", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).custom_repo], ] for option in options: diff --git a/Resources/CliMenu.py b/Resources/CliMenu.py index 581b84298..e6e6fbe9f 100644 --- a/Resources/CliMenu.py +++ b/Resources/CliMenu.py @@ -210,5 +210,30 @@ running, however this will enforce iMac Nvidia Build Patches. self.constants.imac_nvidia_build = True elif change_menu in {"n", "N", "no", "No"}: self.constants.imac_nvidia_build = False + else: + print("Invalid option") + + def custom_repo(self): + utilities.cls() + utilities.header(["Swet custom patch repo"]) + print(f"""For users participating in OpenCore Patcher betas, this is +where you can add custom repos such as Google Drive links. + +Valid options: + +1. Set custom location +2. Reset repo location +3. Exit + +Current repo: +{self.constants.url_apple_binaries} + """) + change_menu = input("Set custom location?: ") + if change_menu == "1": + self.constants.url_backup = self.constants.url_apple_binaries + self.constants.url_apple_binaries = input("Enter new URL: ") + elif change_menu == "2": + if self.constants.url_backup != "": + self.constants.url_apple_binaries = self.constants.url_backup else: print("Invalid option") \ No newline at end of file diff --git a/Resources/Constants.py b/Resources/Constants.py index 2e7a77ce1..df0d6a84b 100644 --- a/Resources/Constants.py +++ b/Resources/Constants.py @@ -74,6 +74,10 @@ class Constants: self.catalina = 19 self.big_sur = 20 + # External Files + self.url_backup = "" + self.url_apple_binaries = "https://github.com/dortania/Apple-Binaries-OCLP/archive/refs/heads/main.zip" + # Payload Location # OpenCore @property @@ -192,7 +196,9 @@ class Constants: # Apple Paylods Paths @property - def payload_apple_root_path(self): return self.payload_path / Path("Apple") + def payload_apple_root_path(self): return self.payload_path / Path("Apple-Binaries-OCLP-main") + @property + def payload_apple_root_path_zip(self): return self.payload_path / Path("Apple.zip") @property def payload_apple_kexts_path(self): return self.payload_apple_root_path / Path("Extensions") @property @@ -204,22 +210,20 @@ class Constants: # Apple Extensions @property - def applebcm_path(self): return self.payload_apple_kexts_path / Path("misc-kexts/AppleBCM5701Ethernet.kext") - @property - def applehda_path(self): return self.payload_apple_kexts_path / Path("misc-kexts/AppleHDA.kext") - @property - def iosurface_path(self): return self.payload_apple_kexts_path / Path("misc-kexts/IOSurface.kext") + def applehda_path(self): return self.payload_apple_kexts_path / Path("Audio/AppleHDA.kext") # GPU Kexts and Bundles @property - def legacy_nvidia_path(self): return self.payload_apple_kexts_path / Path("legacy-nvidia") + def legacy_graphics(self): return self.payload_apple_kexts_path / Path("Graphics-Acceleration") @property - def legacy_amd_path(self): return self.payload_apple_kexts_path / Path("legacy-amd") + def legacy_nvidia_path(self): return self.legacy_graphics / Path("Nvidia-Tesla-Fermi") @property - def legacy_intel_gen1_path(self): return self.payload_apple_kexts_path / Path("intel-gen1") + def legacy_amd_path(self): return self.legacy_graphics / Path("AMD-ATI") @property - def legacy_intel_gen2_path(self): return self.payload_apple_kexts_path / Path("intel-gen2") + def legacy_intel_gen1_path(self): return self.legacy_graphics / Path("Intel-Gen5-Iconlake") + @property + def legacy_intel_gen2_path(self): return self.legacy_graphics / Path("Intel-Gen6-SandyBridge") # Apple Frameworks @property diff --git a/Resources/SysPatch.py b/Resources/SysPatch.py index dbe5e8f8e..5ca83da24 100644 --- a/Resources/SysPatch.py +++ b/Resources/SysPatch.py @@ -13,6 +13,8 @@ import shutil import subprocess import uuid import zipfile +import os +import urllib.request from pathlib import Path from datetime import date @@ -219,6 +221,35 @@ class PatchSysVolume: self.sip_patch_status = True self.csr_decode(self.sip_status, False) + def check_files(self): + if Path(self.constants.payload_apple_root_path).exists(): + print("- Found Apple Binaries") + patch_input = input("Would you like to redownload?(y/n): ") + if patch_input in {"y", "Y", "yes", "Yes"}: + shutil.rmtree(Path(self.constants.payload_apple_root_path)) + self.download_files() + else: + print("- Apple binaries missing") + self.download_files() + + def download_files(self): + print("- Downloading Apple binaries") + try: + urllib.request.urlretrieve(self.constants.url_apple_binaries, self.constants.payload_apple_root_path_zip) + except urllib.error.HTTPError: + print("- Link invalid") + if self.constants.payload_apple_root_path_zip.exists(): + print("- Download completed") + print("- Unzipping download...") + try: + zipfile.ZipFile(self.constants.payload_apple_root_path_zip).extractall(self.constants.payload_path) + except zipfile.BadZipFile: + print("- Couldn't unzip") + os.remove(self.constants.payload_apple_root_path_zip) + else: + print("- Download failed, please verify the below link works:") + print(self.constants.url_apple_binaries) + def start_patch(self): # Check SIP if self.constants.custom_model is not None: @@ -235,10 +266,12 @@ class PatchSysVolume: if (self.sip_patch_status is False) and (self.smb_status is False): print("- Detected SIP and SecureBootModel are disabled, continuing") input("\nPress [ENTER] to continue") - self.find_mount_root_vol(True) - self.unmount_drive() - print("- Patching complete") - print("\nPlease reboot the machine for patches to take effect") + self.check_files() + if self.constants.payload_apple_root_path.exists(): + self.find_mount_root_vol(True) + self.unmount_drive() + print("- Patching complete") + print("\nPlease reboot the machine for patches to take effect") if self.sip_patch_status is True: print("SIP set incorrectly, cannot patch on this machine!") print("Please disable SIP and SecureBootModel in Patcher Settings")