From 22822be94414219f36750cd4e6a1059e1206c16c Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk <48863253+khronokernel@users.noreply.github.com> Date: Sun, 20 Jun 2021 00:23:55 -0600 Subject: [PATCH] Remove curl usage for downloading --- .gitignore | 1 + Resources/SysPatch.py | 36 ++++++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index f1a6c269d..b4d483c42 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .DS_Store OCLP-GUI.command /payloads/Apple +/payloads/Apple.zip /payloads/__MACOSX /App /Build-Folder diff --git a/Resources/SysPatch.py b/Resources/SysPatch.py index 7f188b3d5..f7b7146cf 100644 --- a/Resources/SysPatch.py +++ b/Resources/SysPatch.py @@ -5,7 +5,9 @@ # - Temporary Work-around: sudo bless --mount /System/Volumes/Update/mnt1 --bootefi --last-sealed-snapshot # - Work-around battery throttling on laptops with no battery (IOPlatformPluginFamily.kext/Contents/PlugIns/ACPI_SMC_PlatformPlugin.kext/Contents/Resources/) +import hashlib import os +import requests import shutil import subprocess import zipfile @@ -328,18 +330,27 @@ class PatchSysVolume: elif self.constants.detected_os == self.constants.mojave: os_ver = "10.14-Mojave" link = f"{self.constants.url_patcher_support_pkg}{self.constants.patcher_support_pkg_version}/{os_ver}.zip" - Utilities.cls() - print("- Downloading Apple binaries") - popen_oclp = subprocess.Popen( - ["curl", "-S", "-L", link, "--output", self.constants.payload_apple_root_path_zip], - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - universal_newlines=True, - ) - for stdout_line in iter(popen_oclp.stdout.readline, ""): - print(stdout_line, end="") - popen_oclp.stdout.close() + + if Path(self.constants.payload_apple_root_path).exists(): + print("- Removing old Apple Binaries") + Path(self.constants.payload_apple_root_path).unlink() + + response = requests.get(link, stream=True) + with self.constants.payload_apple_root_path_zip.open("wb") as file: + count = 0 + for chunk in response.iter_content(1024 * 1024 * 4): + file.write(chunk) + count += len(chunk) + Utilities.cls() + print("- Downloading Apple binaries (Big Sur) from PatcherSupportPkg") + print(f"- {count / 1024 / 1024}MB Downloaded") + checksum = hashlib.sha256() + with self.constants.payload_apple_root_path_zip.open("rb") as file: + chunk = file.read(1024 * 1024 * 16) + while chunk: + checksum.update(chunk) + chunk = file.read(1024 * 1024 * 16) + print(f"- Checksum: {checksum.hexdigest()}") if self.constants.payload_apple_root_path_zip.exists(): print("- Download completed") print("- Unzipping download...") @@ -470,6 +481,7 @@ class PatchSysVolume: print("- Starting Patch Process") print(f"- Determinging Required Patch set for Darwin {self.constants.detected_os}") self.detect_patch_set() + self.check_files() if self.no_patch is False and self.constants.gui_mode is False: change_menu = input("Would you like to continue with Root Volume Patching?(y/n): ") else: