mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-17 04:40:01 +10:00
gui.py: Add validation checks and download view
This commit is contained in:
+12
-34
@@ -12,8 +12,8 @@ import zipfile
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
from resources import constants, device_probe, utilities, generate_smbios
|
||||
from data import sip_data, sys_patch_data, model_array, os_data, smbios_data, cpu_data, dylib_data
|
||||
from resources import constants, device_probe, utilities, generate_smbios, sys_patch_download
|
||||
from data import sip_data, sys_patch_data, model_array, os_data, smbios_data, cpu_data
|
||||
|
||||
|
||||
class PatchSysVolume:
|
||||
@@ -639,7 +639,7 @@ set million colour before rebooting"""
|
||||
|
||||
def check_files(self):
|
||||
if Path(self.constants.payload_apple_root_path).exists():
|
||||
print("- Found Apple Binaries")
|
||||
print("- Found local Apple Binaries")
|
||||
if self.constants.gui_mode is False:
|
||||
patch_input = input("Would you like to redownload?(y/n): ")
|
||||
if patch_input in {"y", "Y", "yes", "Yes"}:
|
||||
@@ -648,38 +648,14 @@ set million colour before rebooting"""
|
||||
else:
|
||||
self.download_files()
|
||||
else:
|
||||
print("- Apple binaries missing")
|
||||
self.download_files()
|
||||
|
||||
def download_files(self):
|
||||
if self.constants.detected_os == os_data.os_data.monterey:
|
||||
os_ver = "12-Monterey"
|
||||
elif self.constants.detected_os == os_data.os_data.big_sur:
|
||||
os_ver = "11-Big-Sur"
|
||||
elif self.constants.detected_os == os_data.os_data.catalina:
|
||||
os_ver = "10.15-Catalina"
|
||||
elif self.constants.detected_os == os_data.os_data.mojave:
|
||||
os_ver = "10.14-Mojave"
|
||||
if self.constants.gui_mode is False:
|
||||
download_result, os_ver, link = sys_patch_download.grab_patcher_support_pkg(self.constants).download_files()
|
||||
else:
|
||||
raise Exception(f"Unsupported OS: {self.constants.detected_os}")
|
||||
link = f"{self.constants.url_patcher_support_pkg}{self.constants.patcher_support_pkg_version}/{os_ver}.zip"
|
||||
|
||||
if Path(self.constants.payload_apple_root_path).exists():
|
||||
print("- Removing old Apple Binaries folder")
|
||||
Path(self.constants.payload_apple_root_path).unlink()
|
||||
if Path(self.constants.payload_apple_root_path_zip).exists():
|
||||
print("- Removing old Apple Binaries zip")
|
||||
Path(self.constants.payload_apple_root_path_zip).unlink()
|
||||
|
||||
download_result = None
|
||||
local_zip = Path(self.constants.payload_path) / f"{os_ver}.zip"
|
||||
if Path(local_zip).exists():
|
||||
print(f"- Found local {os_ver} zip, skipping download")
|
||||
print(f"- Duplicating into Apple.zip")
|
||||
shutil.copy(local_zip, self.constants.payload_apple_root_path_zip)
|
||||
download_result = True
|
||||
else:
|
||||
download_result = utilities.download_file(link, self.constants.payload_apple_root_path_zip)
|
||||
os_ver, link = sys_patch_download.grab_patcher_support_pkg(self.constants).generate_pkg_link()
|
||||
|
||||
if download_result and self.constants.payload_apple_root_path_zip.exists():
|
||||
print("- Download completed")
|
||||
@@ -691,15 +667,17 @@ set million colour before rebooting"""
|
||||
Path(self.constants.payload_apple_root_path_zip).unlink()
|
||||
print("- Binaries downloaded to:")
|
||||
print(self.constants.payload_path)
|
||||
# if self.constants.gui_mode is False:
|
||||
# input("Press [ENTER] to continue")
|
||||
return self.constants.payload_apple_root_path
|
||||
except zipfile.BadZipFile:
|
||||
print("- Couldn't unzip")
|
||||
return
|
||||
return None
|
||||
else:
|
||||
print("- Download failed, please verify the below link works:")
|
||||
print(link)
|
||||
input("Press [ENTER] to continue")
|
||||
if download_result is None and self.constants.gui_mode is False:
|
||||
print("\nIf you continue to have issues, try using the Offline builds")
|
||||
print("located on Github next to the other builds")
|
||||
input("Press enter to exit")
|
||||
|
||||
def detect_gpus(self):
|
||||
gpus = self.constants.computer.gpus
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from resources import constants, device_probe, utilities
|
||||
from data import model_array, os_data, smbios_data, cpu_data
|
||||
from resources import constants, device_probe, utilities, generate_smbios
|
||||
from data import model_array, os_data, smbios_data, cpu_data, sip_data
|
||||
|
||||
class detect_root_patch:
|
||||
def __init__(self, model, versions):
|
||||
@@ -28,6 +28,14 @@ class detect_root_patch:
|
||||
self.check_board_id= False
|
||||
self.supports_metal= False
|
||||
|
||||
# Validation Checks
|
||||
self.sip_enabled = False
|
||||
self.sbm_enabled = False
|
||||
self.amfi_enabled = False
|
||||
self.fv_enabled = False
|
||||
self.dosdude_patched = False
|
||||
self.bad_board_id = False
|
||||
|
||||
|
||||
def detect_gpus(self):
|
||||
gpus = self.constants.computer.gpus
|
||||
@@ -154,6 +162,7 @@ class detect_root_patch:
|
||||
"Graphics: Intel Ironlake": self.iron_gpu,
|
||||
"Graphics: Intel Sandy Bridge": self.sandy_gpu,
|
||||
"Graphics: Intel Ivy Bridge": self.ivy_gpu,
|
||||
# "Graphics: Intel Ivy Bridge": True,
|
||||
"Brightness: Legacy Backlight Control": self.brightness_legacy,
|
||||
"Audio: Legacy Realtek": self.legacy_audio,
|
||||
"Networking: Legacy Wireless": self.legacy_wifi,
|
||||
@@ -161,6 +170,27 @@ class detect_root_patch:
|
||||
"Miscellaneous: Legacy Keyboard Backlight": self.legacy_keyboard_backlight,
|
||||
"Settings: Requires AMFI exemption": self.amfi_must_disable,
|
||||
"Settings: Requires Board ID validation": self.check_board_id,
|
||||
"Validation: Patching Possible": self.verify_patch_allowed(),
|
||||
"Validation: SIP is enabled": self.sip_enabled,
|
||||
"Validation: SBM is enabled": self.sbm_enabled,
|
||||
"Validation: AMFI is enabled": self.amfi_enabled,
|
||||
"Validation: FileVault is enabled": self.fv_enabled,
|
||||
"Validation: System is dosdude1 patched": self.dosdude_patched,
|
||||
"Validation: Board ID is unsupported": self.bad_board_id,
|
||||
}
|
||||
|
||||
return self.root_patch_dict
|
||||
return self.root_patch_dict
|
||||
|
||||
def verify_patch_allowed(self):
|
||||
sip = sip_data.system_integrity_protection.root_patch_sip_big_sur if self.constants.detected_os > os_data.os_data.catalina else sip_data.system_integrity_protection.root_patch_sip_mojave
|
||||
self.sip_enabled, self.sbm_enabled, self.amfi_enabled, self.fv_enabled, self.dosdude_patched = utilities.patching_status(sip, self.constants.detected_os)
|
||||
|
||||
if self.check_board_id is True and (self.computer.reported_board_id not in self.constants.sandy_board_id and self.computer.reported_board_id not in self.constants.sandy_board_id_stock):
|
||||
self.bad_board_id = True
|
||||
|
||||
if any(
|
||||
[self.sip_enabled, self.sbm_enabled, self.fv_enabled, self.dosdude_patched, self.amfi_enabled if self.amfi_must_disable else False, self.bad_board_id if self.check_board_id else False]
|
||||
):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
@@ -0,0 +1,48 @@
|
||||
# Download PatcherSupportPkg for usage with Root Patching
|
||||
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk
|
||||
|
||||
from data import os_data
|
||||
from resources import utilities
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
|
||||
class grab_patcher_support_pkg:
|
||||
|
||||
def __init__(self, constants):
|
||||
self.constants = constants
|
||||
|
||||
def generate_pkg_link(self):
|
||||
if self.constants.detected_os == os_data.os_data.monterey:
|
||||
os_ver = "12-Monterey"
|
||||
elif self.constants.detected_os == os_data.os_data.big_sur:
|
||||
os_ver = "11-Big-Sur"
|
||||
elif self.constants.detected_os == os_data.os_data.catalina:
|
||||
os_ver = "10.15-Catalina"
|
||||
elif self.constants.detected_os == os_data.os_data.mojave:
|
||||
os_ver = "10.14-Mojave"
|
||||
else:
|
||||
raise Exception(f"Unsupported OS: {self.constants.detected_os}")
|
||||
link = f"{self.constants.url_patcher_support_pkg}{self.constants.patcher_support_pkg_version}/{os_ver}.zip"
|
||||
return os_ver, link
|
||||
|
||||
def download_files(self):
|
||||
os_ver, link = self.generate_pkg_link()
|
||||
if Path(self.constants.payload_apple_root_path).exists():
|
||||
print("- Removing old Apple Binaries folder")
|
||||
# Delete folder
|
||||
shutil.rmtree(self.constants.payload_apple_root_path)
|
||||
if Path(self.constants.payload_apple_root_path_zip).exists():
|
||||
print("- Removing old Apple Binaries zip")
|
||||
Path(self.constants.payload_apple_root_path_zip).unlink()
|
||||
|
||||
download_result = None
|
||||
local_zip = Path(self.constants.payload_path) / f"{os_ver}.zip"
|
||||
if Path(local_zip).exists():
|
||||
print(f"- Found local {os_ver} zip, skipping download")
|
||||
print(f"- Duplicating into Apple.zip")
|
||||
shutil.copy(local_zip, self.constants.payload_apple_root_path_zip)
|
||||
download_result = True
|
||||
else:
|
||||
download_result = utilities.download_file(link, self.constants.payload_apple_root_path_zip)
|
||||
|
||||
return download_result, os_ver, link
|
||||
@@ -61,20 +61,20 @@ class check_binary_updates:
|
||||
return False
|
||||
|
||||
def check_binary_updates(self):
|
||||
print("- Checking for updates...")
|
||||
# print("- Checking for updates...")
|
||||
if self.verify_network_connection(self.binary_url):
|
||||
print("- Network connection functional")
|
||||
# print("- Network connection functional")
|
||||
response = requests.get(self.binary_url)
|
||||
data_set = response.json()
|
||||
print("- Retrived latest version data")
|
||||
# print("- Retrived latest version data")
|
||||
self.remote_version = data_set["tag_name"]
|
||||
print(f"- Latest version: {self.remote_version}")
|
||||
# print(f"- Latest version: {self.remote_version}")
|
||||
self.remote_version_array = self.remote_version.split(".")
|
||||
self.remote_version_array = [
|
||||
int(x) for x in self.remote_version_array
|
||||
]
|
||||
if self.check_if_build_newer() is True:
|
||||
print("- Remote version is newer")
|
||||
# print("- Remote version is newer")
|
||||
for asset in data_set["assets"]:
|
||||
print(f"- Found asset: {asset['name']}")
|
||||
if self.determine_remote_type(
|
||||
@@ -82,7 +82,7 @@ class check_binary_updates:
|
||||
) and self.determine_remote_offline_type(
|
||||
asset["name"]
|
||||
) == self.determine_local_build_type_offline():
|
||||
print(f"- Found matching asset: {asset['name']}")
|
||||
# print(f"- Found matching asset: {asset['name']}")
|
||||
self.available_binaries.update({
|
||||
asset['name']: {
|
||||
"Name":
|
||||
@@ -104,8 +104,8 @@ class check_binary_updates:
|
||||
if self.available_binaries:
|
||||
return self.available_binaries
|
||||
else:
|
||||
print("- No matching binaries available")
|
||||
# print("- No matching binaries available")
|
||||
return None
|
||||
else:
|
||||
print("- Failed to connect to GitHub API")
|
||||
# else:
|
||||
# print("- Failed to connect to GitHub API")
|
||||
return None
|
||||
Reference in New Issue
Block a user