diff --git a/OpenCore-Patcher.command b/OpenCore-Patcher.command index d5f3758d3..459eb4162 100755 --- a/OpenCore-Patcher.command +++ b/OpenCore-Patcher.command @@ -17,7 +17,7 @@ class OpenCoreLegacyPatcher: self.constants = constants.Constants() self.generate_base_data() if utilities.check_cli_args() is None: - self.main_menu(True) + self.main_menu(False) def generate_base_data(self): self.constants.detected_os = os_probe.detect_kernel_major() @@ -47,11 +47,9 @@ class OpenCoreLegacyPatcher: # 5. Install OpenCore to ESP # 6. flash macOS # 7. Prompt user to reboot + self.constants.walkthrough = True build.BuildOpenCore(self.constants.custom_model or self.constants.computer.real_model, self.constants).build_opencore() cli_menu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).download_macOS() - utilities.cls() - - sys.exit(0) def post_install(self): @@ -61,8 +59,9 @@ class OpenCoreLegacyPatcher: # 3. Install OpenCore to ESP # 4. Determine whether root patching needed # 5. Prompt user to reboot - print() - + build.BuildOpenCore(self.constants.custom_model or self.constants.computer.real_model, self.constants).build_opencore() + install.tui_disk_installation(self.constants).copy_efi() + cli_menu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).PatchVolume def main_menu(self, walkthrough): response = None diff --git a/data/mirror_data.py b/data/mirror_data.py new file mode 100644 index 000000000..063c50a5a --- /dev/null +++ b/data/mirror_data.py @@ -0,0 +1,11 @@ +# Mirrors of Apple's InstallAssistant.ppkg +# Currently only listing important Installers no longer on Apple's servers + +Install_macOS_Big_Sur_11_2_3 = { + "Version": "11.2.3", + "Build": "20D91", + "Link": "https://archive.org/download/install-assistant-20D91/InstallAssistant.pkg", + "Size": 11848909000, + "Source": "Archive.org", + "integirty": None, +} \ No newline at end of file diff --git a/resources/cli_menu.py b/resources/cli_menu.py index e7bbde607..407f363c5 100644 --- a/resources/cli_menu.py +++ b/resources/cli_menu.py @@ -4,7 +4,7 @@ from __future__ import print_function import sys from resources import constants, install, utilities, defaults, sys_patch, installer -from data import cpu_data, smbios_data, model_array, os_data +from data import cpu_data, smbios_data, model_array, os_data, mirror_data class MenuOptions: @@ -1073,8 +1073,10 @@ to your USB drive. menu = utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True) avalible_installers = installer.list_downloadable_macOS_installers(self.constants.payload_path, "DeveloperSeed") if avalible_installers: + # Add mirror of 11.2.3 for users who want it + options.append([f"macOS {mirror_data.Install_macOS_Big_Sur_11_2_3['Version']} ({mirror_data.Install_macOS_Big_Sur_11_2_3['Build']} - {utilities.human_fmt(mirror_data.Install_macOS_Big_Sur_11_2_3['Size'])} - {mirror_data.Install_macOS_Big_Sur_11_2_3['Source']})", lambda: self.download_install_assistant(mirror_data.Install_macOS_Big_Sur_11_2_3['Link'])]) for app in avalible_installers: - options.append([f"macOS {avalible_installers[app]['Version']} ({avalible_installers[app]['Build']} - {utilities.human_fmt(avalible_installers[app]['Size'])})", lambda x=app: self.download_install_assistant(avalible_installers[x]['Link'])]) + options.append([f"macOS {avalible_installers[app]['Version']} ({avalible_installers[app]['Build']} - {utilities.human_fmt(avalible_installers[app]['Size'])} - {avalible_installers[app]['Source']})", lambda x=app: self.download_install_assistant(avalible_installers[x]['Link'])]) for option in options: menu.add_menu_option(option[0], function=option[1]) response = menu.start() @@ -1107,7 +1109,8 @@ to your USB drive. utilities.header(["Create macOS installer"]) print("Installer created successfully.") input("Press enter to exit.") - self.closing_message() + if self.constants.walkthrough is True: + self.closing_message() else: utilities.cls() utilities.header(["Create macOS installer"]) @@ -1115,7 +1118,8 @@ to your USB drive. input("Press enter to return to the previous.") return else: - sys.exit() + if self.constants.walkthrough is True: + sys.exit() def closing_message(self): utilities.cls() diff --git a/resources/constants.py b/resources/constants.py index 5dbe2ad86..25cf4c608 100644 --- a/resources/constants.py +++ b/resources/constants.py @@ -160,7 +160,8 @@ class Constants: self.disable_msr_power_ctl = False # Disable MSR Power Control (missing battery throttling) self.software_demux = False # Enable Software Demux patch set self.force_vmm = False # Force VMM patch - self.custom_sip_value = None # Set custom SIP value + self.custom_sip_value = None # Set custom SIP value + self.walkthrough = False # Enable Walkthrough self.legacy_accel_support = [ os_data.os_data.mojave, diff --git a/resources/installer.py b/resources/installer.py index 8aceac19b..1b721d834 100644 --- a/resources/installer.py +++ b/resources/installer.py @@ -99,6 +99,7 @@ def list_downloadable_macOS_installers(download_path, catalog): "Link": download_link, "Size": size, "integirty": integirty, + "Source": "Apple Inc.", } }) except KeyError: diff --git a/resources/utilities.py b/resources/utilities.py index c2dfe01cc..9e49c0cd8 100644 --- a/resources/utilities.py +++ b/resources/utilities.py @@ -293,6 +293,11 @@ def get_rom(variable: str, *, decode: bool = False): def download_file(link, location): if Path(location).exists(): Path(location).unlink() + try: + # Handle cases where Content-Length has garbage or is missing + size_string = f" of {int(requests.head(link).headers['Content-Length']) / 1024 / 1024}MB" + except KeyError: + size_string = "" response = requests.get(link, stream=True) short_link = os.path.basename(link) # SU Catalog's link is quite long, strip to make it bearable @@ -300,17 +305,18 @@ def download_file(link, location): short_link = "sucatalog.gz" header = f"# Downloading: {short_link} #" box_length = len(header) + box_string = "#" * box_length with location.open("wb") as file: count = 0 for chunk in response.iter_content(1024 * 1024 * 4): file.write(chunk) count += len(chunk) cls() - print("#" * box_length) + print(box_string) print(header) - print("#" * box_length) + print(box_string) print("") - print(f"{count / 1024 / 1024}MB Downloaded") + print(f"{count / 1024 / 1024}MB Downloaded{size_string}") checksum = hashlib.sha256() with location.open("rb") as file: chunk = file.read(1024 * 1024 * 16)