mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-13 20:28:21 +10:00
Merge branch 'main' into logging
# Conflicts: # resources/kdk_handler.py # resources/utilities.py
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
- Ensure `Moraea_BlurBeta` is set on non-Metal systems
|
||||
- Implement proper Root Unpatching verification in GUI
|
||||
- Removes arbitrary patch requirements used against unpatching (ex. network connection)
|
||||
- Prioritize KdkSupportPkg repository for downloads
|
||||
- Skips calls to Apple's now defunct Developer Portal API
|
||||
- Increment Binaries:
|
||||
- PatcherSupportPkg 0.8.3 - release
|
||||
|
||||
|
||||
@@ -32,12 +32,12 @@ Regarding OS support, see below:
|
||||
| MacBook1,1 | Mid-2006 | <span style="color:red"> NO </span> | 32-Bit CPU limitation |
|
||||
| MacBook2,1 | Late 2006 | ^^ | 32-Bit Firmware limitation |
|
||||
| MacBook3,1 | Late 2007 | ^^ | ^^ |
|
||||
| MacBook4,1 | Early 2008 | <span style="color:#30BCD5"> YES - Monterey and older</span> | - No GPU Acceleration in Mavericks and newer<br/>- No Keyboard and Trackpad<br/>- No USB |
|
||||
| MacBook5,1 | Late 2008 | ^^ | - GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108))<br/> - Supports macOS Monterey and older ([Ventura support in development](./VENTURA-DROP.md))|
|
||||
| MacBook4,1 | Early 2008 | ^^ | - No GPU Acceleration in Mavericks and newer<br/>- No Keyboard and Trackpad<br/>- No USB |
|
||||
| MacBook5,1 | Late 2008 | <span style="color:#30BCD5"> YES </span> | - GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108))<br/> - UHCI/OHCI support in Public Beta, see current issues ([#1021](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/1021))|
|
||||
| MacBook5,2 | Early 2009 | ^^ | ^^ |
|
||||
| MacBook6,1 | Late 2009 | ^^ | ^^ |
|
||||
| MacBook7,1 | Mid-2010 | ^^ | ^^ |
|
||||
| MacBook8,1 | Mid-2015 | <span style="color:#30BCD5"> YES </span> | <span style="color:green"> Everything is supported</span> |
|
||||
| MacBook8,1 | Mid-2015 | ^^ | <span style="color:green"> Everything is supported</span> |
|
||||
| MacBook9,1 | Early 2016 | ^^ | ^^ |
|
||||
|
||||
### MacBook Air
|
||||
@@ -45,12 +45,12 @@ Regarding OS support, see below:
|
||||
| SMBIOS | Year | Supported | Comment |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| MacBookAir1,1 | Early 2008 | <span style="color:red"> NO </span> | Requires SSE4.1 CPU |
|
||||
| MacBookAir2,1 | Late 2008 | <span style="color:#30BCD5"> YES - Monterey and older</span> | - GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108))<br/> - Supports macOS Monterey and older ([Ventura support in development](./VENTURA-DROP.md))|
|
||||
| MacBookAir2,1 | Late 2008 | <span style="color:#30BCD5"> YES </span> | - GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108))<br/> - UHCI/OHCI support in Public Beta, see current issues ([#1021](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/1021))|
|
||||
| MacBookAir3,1 | Late 2010 | ^^ | ^^ |
|
||||
| MacBookAir3,2 | ^^ | ^^ | ^^ |
|
||||
| MacBookAir4,1 | Mid-2011 | ^^ | ^^ |
|
||||
| MacBookAir4,1 | Mid-2011 | ^^ | - GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108))|
|
||||
| MacBookAir4,2 | ^^ | ^^ | ^^ |
|
||||
| MacBookAir5,1 | Mid-2012 | <span style="color:#30BCD5"> YES </span> | <span style="color:green"> Everything is supported</span> |
|
||||
| MacBookAir5,1 | Mid-2012 | ^^ | <span style="color:green"> Everything is supported</span> |
|
||||
| MacBookAir5,2 | ^^ | ^^ | ^^ |
|
||||
| MacBookAir6,1 | Mid-2013, Early 2014 | ^^ | ^^ |
|
||||
| MacBookAir6,2 | ^^ | ^^ | ^^ |
|
||||
@@ -66,19 +66,19 @@ Regarding OS support, see below:
|
||||
| MacBookPro2,1 | Late 2006 | ^^ | 32-Bit Firmware limitation |
|
||||
| MacBookPro2,2 | Late 2006 | ^^ | ^^ |
|
||||
| MacBookPro3,1 | Mid-2007 | ^^ | Requires SSE4.1 CPU |
|
||||
| MacBookPro4,1 | Early 2008 | <span style="color:#30BCD5"> YES - Monterey and older</span> | - GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108))<br/> - Supports macOS Monterey and older ([Ventura support in development](./VENTURA-DROP.md))|
|
||||
| MacBookPro4,1 | Early 2008 | <span style="color:#30BCD5"> YES </span> | - GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108))<br/> - UHCI/OHCI support in Public Beta, see current issues ([#1021](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/1021))|
|
||||
| MacBookPro5,1 | Late 2008 | ^^ | ^^ |
|
||||
| MacBookPro5,2 | Early 2009 | ^^ | ^^ |
|
||||
| MacBookPro5,3 | Mid-2009 | ^^ | ^^ |
|
||||
| MacBookPro5,4 | ^^ | ^^ | ^^ |
|
||||
| MacBookPro5,5 | ^^ | ^^ | ^^ |
|
||||
| MacBookPro6,1 | Mid-2010 | ^^ | ^^ |
|
||||
| MacBookPro6,1 | Mid-2010 | ^^ | - GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108))|
|
||||
| MacBookPro6,2 | ^^ | ^^ | ^^ |
|
||||
| MacBookPro7,1 | ^^ | ^^ | ^^ |
|
||||
| MacBookPro8,1 | Early 2011 | ^^ | ^^ |
|
||||
| MacBookPro7,1 | ^^ | ^^ | - GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108))<br/> - UHCI/OHCI support in Public Beta, see current issues ([#1021](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/1021))|
|
||||
| MacBookPro8,1 | Early 2011 | ^^ | - GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108))|
|
||||
| MacBookPro8,2 | ^^ | ^^ | ^^ |
|
||||
| MacBookPro8,3 | ^^ | ^^ | ^^ |
|
||||
| MacBookPro9,1 | Mid-2012 | <span style="color:#30BCD5"> YES </span> | <span style="color:green"> Everything is supported</span> |
|
||||
| MacBookPro9,1 | Mid-2012 | ^^ | <span style="color:green"> Everything is supported</span> |
|
||||
| MacBookPro9,2 | ^^ | ^^ | ^^ |
|
||||
| MacBookPro10,1 | Mid-2012, Early 2013 | ^^ | ^^ |
|
||||
| MacBookPro10,2 | Late 2012, Early 2013 | ^^ | ^^ |
|
||||
@@ -98,12 +98,12 @@ Regarding OS support, see below:
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| Macmini1,1 | Early 2006 | <span style="color:red"> NO </span> | 32-Bit CPU limitation |
|
||||
| Macmini2,1 | Mid-2007 | ^^ | 32-Bit Firmware limitation |
|
||||
| Macmini3,1 | Early 2009 | <span style="color:#30BCD5"> YES - Monterey and older</span> | - GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108)) <br/> - Supports macOS Monterey and older ([Ventura support in development](./VENTURA-DROP.md)) |
|
||||
| Macmini3,1 | Early 2009 | <span style="color:#30BCD5"> YES </span> | - GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108))<br/> - UHCI/OHCI support in Public Beta, see current issues ([#1021](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/1021))|
|
||||
| Macmini4,1 | Mid-2010 | ^^ | ^^ |
|
||||
| Macmini5,1 | Mid-2011 | ^^ | ^^ |
|
||||
| Macmini5,1 | Mid-2011 | ^^ | - GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108))|
|
||||
| Macmini5,2 | ^^ | ^^ | ^^ |
|
||||
| Macmini5,3 | ^^ | ^^ | ^^ |
|
||||
| Macmini6,1 | Late 2012 | <span style="color:#30BCD5"> YES </span> | <span style="color:green"> Everything is supported</span> |
|
||||
| Macmini6,1 | Late 2012 | ^^ | <span style="color:green"> Everything is supported</span> |
|
||||
| Macmini6,2 | ^^ | ^^ | ^^ |
|
||||
| Macmini7,1 | Mid-2014 | ^^ | ^^ |
|
||||
|
||||
@@ -116,16 +116,16 @@ Regarding OS support, see below:
|
||||
| iMac5,1 | Late 2006 | ^^ | 32-Bit Firmware limitation |
|
||||
| iMac5,2 | ^^ | ^^ | ^^ |
|
||||
| iMac6,1 | ^^ | ^^ | ^^ |
|
||||
| iMac7,1 | Mid-2007 | <span style="color:#30BCD5"> YES - Monterey and older</span> | - Requires an [SSE4.1 CPU Upgrade](https://lowendmac.com/2018/penryn-t9300-9500-cpu-upgrades-for-the-2007-imac/)<br/>- GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108))<br/>- Stock Bluetooth 2.0 card non-functional<br/> - Supports macOS Monterey and older ([Ventura support in development](./VENTURA-DROP.md)) |
|
||||
| iMac8,1 | Early 2008 | ^^ | - GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108)))<br/> - Supports macOS Monterey and older ([Ventura support in development](./VENTURA-DROP.md))|
|
||||
| iMac7,1 | Mid-2007 | <span style="color:#30BCD5"> YES </span> | - Requires an [SSE4.1 CPU Upgrade](https://lowendmac.com/2018/penryn-t9300-9500-cpu-upgrades-for-the-2007-imac/)<br/>- GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108))<br/>- Stock Bluetooth 2.0 card non-functional<br/> - UHCI/OHCI support in Public Beta, see current issues ([#1021](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/1021))|
|
||||
| iMac8,1 | Early 2008 | ^^ | - GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108))<br/> - UHCI/OHCI support in Public Beta, see current issues ([#1021](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/1021))|
|
||||
| iMac9,1 | Early 2009 | ^^ | ^^ |
|
||||
| iMac10,1 | Late 2009 | ^^ | - GPU is socketed, [recommend upgrading to Metal GPU](https://forums.macrumors.com/threads/2011-imac-graphics-card-upgrade.1596614/?post=17425857#post-17425857) <br/>- GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108)) <br/> - Supports macOS Monterey and older ([Ventura support in development](./VENTURA-DROP.md))|
|
||||
| iMac11,1 | ^^ | ^^ | ^^ |
|
||||
| iMac10,1 | Late 2009 | ^^ | - GPU is socketed, [recommend upgrading to Metal GPU](https://forums.macrumors.com/threads/2011-imac-graphics-card-upgrade.1596614/?post=17425857#post-17425857) <br/>- GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108)) <br/> - UHCI/OHCI support in Public Beta, see current issues ([#1021](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/1021))|
|
||||
| iMac11,1 | ^^ | ^^ | - GPU Acceleration in Public Beta, see current issues ([#108](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108))|
|
||||
| iMac11,2 | Mid-2010 | ^^ | ^^ |
|
||||
| iMac11,3 | ^^ | ^^ | ^^ |
|
||||
| iMac12,1 | Mid-2011 | ^^ | ^^ |
|
||||
| iMac12,2 | ^^ | ^^ | ^^ |
|
||||
| iMac13,1 | Late 2012 | <span style="color:#30BCD5"> YES </span> | <span style="color:green"> Everything is supported</span> |
|
||||
| iMac13,1 | Late 2012 | ^^ | <span style="color:green"> Everything is supported</span> |
|
||||
| iMac13,2 | ^^ | ^^ | ^^ |
|
||||
| iMac13,3 | ^^ | ^^ | ^^ |
|
||||
| iMac14,1 | Late 2013 | ^^ | ^^ |
|
||||
@@ -145,8 +145,8 @@ Regarding OS support, see below:
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| MacPro1,1 | Mid-2006 | <span style="color:red"> NO </span> | 32-Bit Firmware limitation |
|
||||
| MacPro2,1 | Mid-2007 | ^^ | ^^ |
|
||||
| MacPro3,1 | Early 2008 | <span style="color:#30BCD5"> YES - Monterey and older</span> | - Potential boot issues with built-in USB 1.1 ports (recommend using a USB 2.0 hub or dedicated USB PCIe controller) <br/>- Potential boot issues with stock Bluetooth card, recommend removing to avoid kernel panics |
|
||||
| MacPro4,1 | Early 2009 | ^^ | - Everything is supported as long as GPU is Metal capable <br/> - Supports macOS Monterey and older ([Ventura support in development](./VENTURA-DROP.md)) |
|
||||
| MacPro3,1 | Early 2008 | <span style="color:#30BCD5"> YES </span> | - UHCI/OHCI support in Public Beta, see current issues ([#1021](https://github.com/dortania/OpenCore-Legacy-Patcher/issesues/1021)) <br/>- Potential boot issues with stock Bluetooth card, recommend removing to avoid kernel panics |
|
||||
| MacPro4,1 | Early 2009 | ^^ | - Everything is supported as long as GPU is Metal capable <br/> - UHCI/OHCI support in Public Beta, see current issues ([#1021](https://github.com/dortania/OpenCore-Legacy-Patcher/issesues/1021))|
|
||||
| MacPro5,1 | Mid-2010, Mid-2012 | ^^ | ^^ |
|
||||
| MacPro6,1 | Late 2013 | ^^ | - CPU Power Management currently unsupported<br/> - No DRM support |
|
||||
|
||||
@@ -155,7 +155,7 @@ Regarding OS support, see below:
|
||||
| SMBIOS | Year | Supported | Comment |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| Xserve1,1 | Mid-2006 | <span style="color:red"> NO </span> | 32-Bit Firmware limitation |
|
||||
| Xserve2,1 | Early 2008 | <span style="color:#30BCD5"> YES - Monterey and older</span> | - Everything is supported as long as GPU is Metal capable <br/> - Supports macOS Monterey and older ([Ventura support in development](./VENTURA-DROP.md))|
|
||||
| Xserve2,1 | Early 2008 | <span style="color:#30BCD5"> YES </span> | - UHCI/OHCI support in Public Beta, see current issues ([#1021](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/1021))|
|
||||
| Xserve3,1 | Early 2009 | ^^ | ^^ |
|
||||
|
||||
# Once you've verified your hardware is supported, head to [Download and build macOS Installers](./INSTALLER.md)
|
||||
|
||||
@@ -11,8 +11,6 @@ import requests
|
||||
|
||||
import subprocess
|
||||
|
||||
import logging
|
||||
|
||||
from resources import utilities
|
||||
from resources.constants import Constants
|
||||
|
||||
@@ -22,114 +20,27 @@ class kernel_debug_kit_handler:
|
||||
self.constants = constants
|
||||
|
||||
def get_available_kdks(self):
|
||||
KDK_API_LINK = "https://kdk-api.dhinak.net/v1"
|
||||
KDK_API_LINK = "https://raw.githubusercontent.com/dortania/KdkSupportPkg/gh-pages/manifest.json"
|
||||
|
||||
logging.info("- Fetching available KDKs")
|
||||
print("- Fetching available KDKs")
|
||||
|
||||
try:
|
||||
results = utilities.SESSION.get(KDK_API_LINK, headers={"User-Agent": f"OCLP/{self.constants.patcher_version}"}, timeout=10)
|
||||
except (requests.exceptions.Timeout, requests.exceptions.TooManyRedirects, requests.exceptions.ConnectionError):
|
||||
logging.info("- Could not contact KDK API")
|
||||
print("- Could not contact KDK API")
|
||||
return None
|
||||
|
||||
if results.status_code != 200:
|
||||
logging.info("- Could not fetch KDK list")
|
||||
print("- Could not fetch KDK list")
|
||||
return None
|
||||
|
||||
return sorted(results.json(), key=lambda x: (packaging.version.parse(x["version"]), datetime.datetime.fromisoformat(x["date"])), reverse=True)
|
||||
|
||||
def get_closest_match_legacy(self, host_version: str, host_build: str):
|
||||
# Get the closest match to the provided version
|
||||
# KDKs are generally a few days late, so we'll rely on N-1 matching
|
||||
|
||||
# Note: AppleDB is manually updated, so this is not a perfect solution
|
||||
|
||||
OS_DATABASE_LINK = "https://api.appledb.dev/main.json"
|
||||
VERSION_PATTERN = re.compile(r"\d+\.\d+(\.\d+)?")
|
||||
|
||||
parsed_host_version = cast(packaging.version.Version, packaging.version.parse(host_version))
|
||||
|
||||
logging.info(f"- Checking closest match for: {host_version} build {host_build}")
|
||||
|
||||
try:
|
||||
results = utilities.SESSION.get(OS_DATABASE_LINK)
|
||||
except (requests.exceptions.Timeout, requests.exceptions.TooManyRedirects, requests.exceptions.ConnectionError):
|
||||
logging.info("- Could not contact AppleDB")
|
||||
return None, "", ""
|
||||
|
||||
if results.status_code != 200:
|
||||
logging.info("- Could not fetch database")
|
||||
return None, "", ""
|
||||
|
||||
macos_builds = [i for i in results.json()["ios"] if i["osType"] == "macOS"]
|
||||
# If the version is borked, put it at the bottom of the list
|
||||
# Would omit it, but can't do that in this lambda
|
||||
macos_builds.sort(key=lambda x: (packaging.version.parse(VERSION_PATTERN.match(x["version"]).group() if VERSION_PATTERN.match(x["version"]) else "0.0.0"), datetime.datetime.fromisoformat(x["released"] if x["released"] != "" else "1984-01-01")), reverse=True) # type: ignore
|
||||
|
||||
# Iterate through, find build that is closest to the host version
|
||||
# Use date to determine which is closest
|
||||
for build_info in macos_builds:
|
||||
if build_info["osType"] == "macOS":
|
||||
raw_version = VERSION_PATTERN.match(build_info["version"])
|
||||
if not raw_version:
|
||||
# Skip if version is borked
|
||||
continue
|
||||
version = cast(packaging.version.Version, packaging.version.parse(raw_version.group()))
|
||||
build = build_info["build"]
|
||||
if build == host_build:
|
||||
# Skip, as we want the next closest match
|
||||
continue
|
||||
elif version <= parsed_host_version and version.major == parsed_host_version.major and version.minor == parsed_host_version.minor:
|
||||
# The KDK list is already sorted by date then version, so the first match is the closest
|
||||
logging.info(f"- Closest match: {version} build {build}")
|
||||
return self.generate_kdk_link(str(version), build), str(version), build
|
||||
|
||||
logging.info("- Could not find a match")
|
||||
return None, "", ""
|
||||
|
||||
def generate_kdk_link(self, version: str, build: str):
|
||||
return f"https://download.developer.apple.com/macOS/Kernel_Debug_Kit_{version}_build_{build}/Kernel_Debug_Kit_{version}_build_{build}.dmg"
|
||||
|
||||
def verify_apple_developer_portal(self, link):
|
||||
# Determine whether Apple Developer Portal is up
|
||||
# and if the requested file is available
|
||||
|
||||
# Returns following:
|
||||
# 0: Portal is up and file is available
|
||||
# 1: Portal is up but file is not available
|
||||
# 2: Portal is down
|
||||
# 3: Network error
|
||||
|
||||
if utilities.verify_network_connection("https://developerservices2.apple.com/services/download") is False:
|
||||
logging.info("- Could not connect to the network")
|
||||
return 3
|
||||
|
||||
TOKEN_URL_BASE = "https://developerservices2.apple.com/services/download"
|
||||
remote_path = urllib.parse.urlparse(link).path
|
||||
token_url = urllib.parse.urlunparse(urllib.parse.urlparse(TOKEN_URL_BASE)._replace(query=urllib.parse.urlencode({"path": remote_path})))
|
||||
|
||||
try:
|
||||
response = utilities.SESSION.get(token_url, timeout=5)
|
||||
except (requests.exceptions.Timeout, requests.exceptions.TooManyRedirects, requests.exceptions.ConnectionError):
|
||||
logging.info("- Could not contact Apple download servers")
|
||||
return 2
|
||||
|
||||
try:
|
||||
response.raise_for_status()
|
||||
except requests.exceptions.HTTPError:
|
||||
if response.status_code == 400 and "The path specified is invalid" in response.text:
|
||||
logging.info("- File does not exist on Apple download servers")
|
||||
return 1
|
||||
else:
|
||||
logging.info("- Could not request download authorization from Apple download servers")
|
||||
return 2
|
||||
return 0
|
||||
|
||||
def download_kdk(self, version: str, build: str):
|
||||
detected_build = build
|
||||
|
||||
if self.is_kdk_installed(detected_build) is True:
|
||||
logging.info("- KDK is already installed")
|
||||
print("- KDK is already installed")
|
||||
self.remove_unused_kdks(exclude_builds=[detected_build])
|
||||
return True, "", detected_build
|
||||
|
||||
@@ -147,84 +58,56 @@ class kernel_debug_kit_handler:
|
||||
kdk_version = cast(packaging.version.Version, packaging.version.parse(kdk["version"]))
|
||||
if kdk["build"] == build:
|
||||
download_link = kdk["url"]
|
||||
elif not closest_match_download_link and kdk_version <= parsed_version and kdk_version.major == parsed_version.major and (kdk_version.minor == parsed_version.minor or kdk_version.minor == parsed_version.minor - 1):
|
||||
# The KDK list is already sorted by date then version, so the first match is the closest
|
||||
elif not closest_match_download_link and kdk_version <= parsed_version and kdk_version.major == parsed_version.major and (kdk_version.minor in range(parsed_version.minor - 1, parsed_version.minor + 1)):
|
||||
# The KDK list is already sorted by version then date, so the first match is the closest
|
||||
closest_match_download_link = kdk["url"]
|
||||
closest_version = kdk["version"]
|
||||
closest_build = kdk["build"]
|
||||
else:
|
||||
logging.info("- Could not fetch KDK list, falling back to brute force")
|
||||
download_link = self.generate_kdk_link(version, build)
|
||||
closest_match_download_link, closest_version, closest_build = self.get_closest_match_legacy(version, build)
|
||||
msg = "Could not fetch KDK list"
|
||||
print(f"- {msg}")
|
||||
return False, msg, ""
|
||||
|
||||
logging.info(f"- Checking for KDK matching macOS {version} build {build}")
|
||||
print(f"- Checking for KDK matching macOS {version} build {build}")
|
||||
# download_link is None if no matching KDK is found, so we'll fall back to the closest match
|
||||
result = self.verify_apple_developer_portal(download_link) if download_link else 1
|
||||
if result == 0:
|
||||
logging.info("- Downloading KDK")
|
||||
elif result == 1:
|
||||
logging.info("- Could not find KDK, finding closest match")
|
||||
if not download_link:
|
||||
print("- Could not find KDK, finding closest match")
|
||||
|
||||
if self.is_kdk_installed(closest_build) is True:
|
||||
logging.info(f"- Closet Build ({closest_build}) already installed")
|
||||
print(f"- Closest build ({closest_build}) already installed")
|
||||
self.remove_unused_kdks(exclude_builds=[detected_build, closest_build])
|
||||
return True, "", closest_build
|
||||
|
||||
if closest_match_download_link is None:
|
||||
msg = "Could not find KDK for host, nor closest match"
|
||||
logging.info(f"- {msg}")
|
||||
print(f"- {msg}")
|
||||
return False, msg, ""
|
||||
|
||||
logging.info(f"- Closest match: {closest_version} build {closest_build}")
|
||||
result = self.verify_apple_developer_portal(closest_match_download_link)
|
||||
print(f"- Closest match: {closest_version} build {closest_build}")
|
||||
download_link = closest_match_download_link
|
||||
|
||||
if result == 0:
|
||||
logging.info("- Downloading KDK")
|
||||
download_link = closest_match_download_link
|
||||
elif result == 1:
|
||||
msg = "Could not find KDK for host on Apple's servers, nor closest match"
|
||||
logging.info(f"- {msg}")
|
||||
return False, msg, ""
|
||||
elif result == 2:
|
||||
msg = "Could not contact Apple download servers"
|
||||
download_link = self.kdk_backup_site(closest_build)
|
||||
if download_link is None:
|
||||
msg += " and could not find a backup copy online"
|
||||
logging.info(f"- {msg}")
|
||||
return False, msg, ""
|
||||
else:
|
||||
msg = "Unknown error"
|
||||
logging.info(f"- {msg}")
|
||||
return False, msg, ""
|
||||
elif result == 2:
|
||||
msg = "Could not contact Apple download servers"
|
||||
download_link = self.kdk_backup_site(build)
|
||||
if download_link is None:
|
||||
msg += " and could not find a backup copy online"
|
||||
logging.info(f"- {msg}")
|
||||
return False, msg, ""
|
||||
elif result == 3:
|
||||
msg = "Failed to connect to the internet"
|
||||
logging.info(f"- {msg}")
|
||||
if utilities.verify_network_connection(download_link):
|
||||
print("- Downloading KDK")
|
||||
else:
|
||||
msg = "Could not contact download site"
|
||||
print(f"- {msg}")
|
||||
return False, msg, ""
|
||||
|
||||
if "github" in download_link:
|
||||
result = utilities.download_file(download_link, self.constants.kdk_download_path)
|
||||
else:
|
||||
result = utilities.download_apple_developer_portal(download_link, self.constants.kdk_download_path)
|
||||
result = utilities.download_file(download_link, self.constants.kdk_download_path)
|
||||
|
||||
if result:
|
||||
# TODO: should we use the checksum from the API?
|
||||
result = subprocess.run(["hdiutil", "verify", self.constants.kdk_download_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
if result.returncode != 0:
|
||||
logging.info(f"Error: Kernel Debug Kit checksum verification failed!")
|
||||
logging.info(f"Output: {result.stderr}")
|
||||
print("Error: Kernel Debug Kit checksum verification failed!")
|
||||
print(f"Output: {result.stderr}")
|
||||
msg = "Kernel Debug Kit checksum verification failed, please try again.\n\nIf this continues to fail, ensure you're downloading on a stable network connection (ie. Ethernet)"
|
||||
logging.info(f"- {msg}")
|
||||
print(f"- {msg}")
|
||||
return False, msg, ""
|
||||
self.remove_unused_kdks(exclude_builds=[detected_build, closest_build])
|
||||
return True, "", detected_build
|
||||
msg = "Failed to download KDK"
|
||||
logging.info(f"- {msg}")
|
||||
print(f"- {msg}")
|
||||
return False, msg, ""
|
||||
|
||||
def is_kdk_installed(self, build):
|
||||
@@ -241,7 +124,7 @@ class kernel_debug_kit_handler:
|
||||
if file.name.endswith(f"{build}.kdk"):
|
||||
for kext in kexts_to_check:
|
||||
if not Path(f"{file}/System/Library/Extensions/{kext}").exists():
|
||||
logging.info(f"- Corrupted KDK found, removing due to missing: {file}/System/Library/Extensions/{kext}")
|
||||
print(f"- Corrupted KDK found, removing due to missing: {file}/System/Library/Extensions/{kext}")
|
||||
utilities.elevated(["rm", "-rf", file], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
return False
|
||||
return True
|
||||
@@ -257,7 +140,7 @@ class kernel_debug_kit_handler:
|
||||
if exclude_builds == []:
|
||||
return
|
||||
|
||||
logging.info("- Cleaning unused KDKs")
|
||||
print("- Cleaning unused KDKs")
|
||||
for kdk_folder in Path("/Library/Developer/KDKs").iterdir():
|
||||
if kdk_folder.is_dir():
|
||||
if kdk_folder.name.endswith(".kdk"):
|
||||
@@ -268,7 +151,7 @@ class kernel_debug_kit_handler:
|
||||
break
|
||||
if should_remove is False:
|
||||
continue
|
||||
logging.info(f" - Removing {kdk_folder.name}")
|
||||
print(f" - Removing {kdk_folder.name}")
|
||||
utilities.elevated(["rm", "-rf", kdk_folder], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
|
||||
|
||||
@@ -278,17 +161,17 @@ class kernel_debug_kit_handler:
|
||||
# Check if tag exists
|
||||
catalog = requests.get(KDK_MIRROR_REPOSITORY)
|
||||
if catalog.status_code != 200:
|
||||
logging.info(f"- Could not contact KDK mirror repository")
|
||||
print(f"- Could not contact KDK mirror repository")
|
||||
return None
|
||||
|
||||
catalog = catalog.json()
|
||||
|
||||
for release in catalog:
|
||||
if release["tag_name"] == build:
|
||||
logging.info(f"- Found KDK mirror for build: {build}")
|
||||
print(f"- Found KDK mirror for build: {build}")
|
||||
for asset in release["assets"]:
|
||||
if asset["name"].endswith(".dmg"):
|
||||
return asset["browser_download_url"]
|
||||
|
||||
logging.info(f"- Could not find KDK mirror for build {build}")
|
||||
print(f"- Could not find KDK mirror for build {build}")
|
||||
return None
|
||||
@@ -15,7 +15,6 @@ import requests
|
||||
import shutil
|
||||
import urllib.parse
|
||||
import py_sip_xnu
|
||||
import logging
|
||||
|
||||
from resources import constants, ioreg
|
||||
from data import sip_data, os_data
|
||||
@@ -40,8 +39,8 @@ def string_to_hex(input_string):
|
||||
|
||||
def process_status(process_result):
|
||||
if process_result.returncode != 0:
|
||||
logging.info(f"Process failed with exit code {process_result.returncode}")
|
||||
logging.info(f"Please report the issue on the Discord server")
|
||||
print(f"Process failed with exit code {process_result.returncode}")
|
||||
print(f"Please report the issue on the Discord server")
|
||||
raise Exception(f"Process result: \n{process_result.stdout.decode()}")
|
||||
|
||||
|
||||
@@ -56,11 +55,11 @@ def human_fmt(num):
|
||||
def header(lines):
|
||||
lines = [i for i in lines if i is not None]
|
||||
total_length = len(max(lines, key=len)) + 4
|
||||
logging.info("#" * (total_length))
|
||||
print("#" * (total_length))
|
||||
for line in lines:
|
||||
left_side = math.floor(((total_length - 2 - len(line.strip())) / 2))
|
||||
logging.info("#" + " " * left_side + line.strip() + " " * (total_length - len("#" + " " * left_side + line.strip()) - 1) + "#")
|
||||
logging.info("#" * total_length)
|
||||
print("#" + " " * left_side + line.strip() + " " * (total_length - len("#" + " " * left_side + line.strip()) - 1) + "#")
|
||||
print("#" * total_length)
|
||||
|
||||
|
||||
RECOVERY_STATUS = None
|
||||
@@ -125,7 +124,7 @@ sleep_process = None
|
||||
|
||||
def disable_sleep_while_running():
|
||||
global sleep_process
|
||||
logging.info("- Disabling Idle Sleep")
|
||||
print("- Disabling Idle Sleep")
|
||||
if sleep_process is None:
|
||||
# If sleep_process is active, we'll just keep it running
|
||||
sleep_process = subprocess.Popen(["caffeinate", "-d", "-i", "-s"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
@@ -135,7 +134,7 @@ def disable_sleep_while_running():
|
||||
def enable_sleep_after_running():
|
||||
global sleep_process
|
||||
if sleep_process:
|
||||
logging.info("- Re-enabling Idle Sleep")
|
||||
print("- Re-enabling Idle Sleep")
|
||||
sleep_process.kill()
|
||||
sleep_process = None
|
||||
|
||||
@@ -284,7 +283,7 @@ def cls():
|
||||
if not check_recovery():
|
||||
os.system("cls" if os.name == "nt" else "clear")
|
||||
else:
|
||||
logging.info("\u001Bc")
|
||||
print("\u001Bc")
|
||||
|
||||
def check_command_line_tools():
|
||||
# Determine whether Command Line Tools exist
|
||||
@@ -296,7 +295,7 @@ def check_command_line_tools():
|
||||
return False
|
||||
|
||||
def get_nvram(variable: str, uuid: str = None, *, decode: bool = False):
|
||||
# TODO: Properly fix for El Capitan, which does not logging.info the XML representation even though we say to
|
||||
# TODO: Properly fix for El Capitan, which does not print the XML representation even though we say to
|
||||
|
||||
if uuid is not None:
|
||||
uuid += ":"
|
||||
@@ -328,7 +327,7 @@ def get_nvram(variable: str, uuid: str = None, *, decode: bool = False):
|
||||
|
||||
|
||||
def get_rom(variable: str, *, decode: bool = False):
|
||||
# TODO: Properly fix for El Capitan, which does not logging.info the XML representation even though we say to
|
||||
# TODO: Properly fix for El Capitan, which does not print the XML representation even though we say to
|
||||
|
||||
rom = ioreg.IORegistryEntryFromPath(ioreg.kIOMasterPortDefault, "IODeviceTree:/rom".encode())
|
||||
|
||||
@@ -391,7 +390,7 @@ def download_file(link, location, is_gui=None, verify_checksum=False):
|
||||
|
||||
# Check if we have enough space
|
||||
if total_file_size > get_free_space():
|
||||
logging.info(f"Not enough space to download {base_name} ({file_size_rounded}MB)")
|
||||
print(f"Not enough space to download {base_name} ({file_size_rounded}MB)")
|
||||
return False
|
||||
else:
|
||||
file_size_string = ""
|
||||
@@ -408,78 +407,46 @@ def download_file(link, location, is_gui=None, verify_checksum=False):
|
||||
dl = 0
|
||||
total_downloaded_string = ""
|
||||
global clear
|
||||
checksum = hashlib.sha256() if verify_checksum else None
|
||||
with location.open("wb") as file:
|
||||
count = 0
|
||||
start = time.perf_counter()
|
||||
for i, chunk in enumerate(response.iter_content(1024 * 1024 * 4)):
|
||||
for chunk in response.iter_content(1024 * 1024 * 4):
|
||||
dl += len(chunk)
|
||||
file.write(chunk)
|
||||
if checksum:
|
||||
checksum.update(chunk)
|
||||
count += len(chunk)
|
||||
if is_gui is None:
|
||||
if clear:
|
||||
cls()
|
||||
logging.info(box_string)
|
||||
logging.info(header)
|
||||
logging.info(box_string)
|
||||
logging.info("")
|
||||
print(box_string)
|
||||
print(header)
|
||||
print(box_string)
|
||||
print("")
|
||||
if total_file_size > 1024:
|
||||
total_downloaded_string = f" ({round(float(dl / total_file_size * 100), 2)}%)"
|
||||
if i % 100 == 0:
|
||||
logging.info(f"{round(count / 1024 / 1024, 2)}MB Downloaded{file_size_string}{total_downloaded_string}\nAverage Download Speed: {round(dl//(time.perf_counter() - start) / 100000 / 8, 2)} MB/s")
|
||||
print(f"{round(count / 1024 / 1024, 2)}MB Downloaded{file_size_string}{total_downloaded_string}\nAverage Download Speed: {round(dl//(time.perf_counter() - start) / 100000 / 8, 2)} MB/s")
|
||||
|
||||
if verify_checksum is True:
|
||||
# Verify checksum
|
||||
# Note that this can be quite taxing on slower Macs
|
||||
checksum = hashlib.sha256()
|
||||
with location.open("rb") as file:
|
||||
chunk = file.read(1024 * 1024 * 16)
|
||||
while chunk:
|
||||
checksum.update(chunk)
|
||||
chunk = file.read(1024 * 1024 * 16)
|
||||
enable_sleep_after_running()
|
||||
return checksum
|
||||
enable_sleep_after_running()
|
||||
return True
|
||||
return checksum.hexdigest() if checksum else True
|
||||
else:
|
||||
cls()
|
||||
header = "# Could not establish Network Connection with provided link! #"
|
||||
box_length = len(header)
|
||||
box_string = "#" * box_length
|
||||
logging.info(box_string)
|
||||
logging.info(header)
|
||||
logging.info(box_string)
|
||||
print(box_string)
|
||||
print(header)
|
||||
print(box_string)
|
||||
if constants.Constants().url_patcher_support_pkg in link:
|
||||
# If we're downloading PatcherSupportPkg, present offline build
|
||||
logging.info("\nPlease grab the offline variant of OpenCore Legacy Patcher from Github:")
|
||||
logging.info(f"https://github.com/dortania/OpenCore-Legacy-Patcher/releases/download/{constants.Constants().patcher_version}/OpenCore-Patcher-TUI-Offline.app.zip")
|
||||
print("\nPlease grab the offline variant of OpenCore Legacy Patcher from Github:")
|
||||
print(f"https://github.com/dortania/OpenCore-Legacy-Patcher/releases/download/{constants.Constants().patcher_version}/OpenCore-Patcher-TUI-Offline.app.zip")
|
||||
else:
|
||||
logging.info(link)
|
||||
print(link)
|
||||
return None
|
||||
|
||||
|
||||
def download_apple_developer_portal(link, location, is_gui=None, verify_checksum=False):
|
||||
TOKEN_URL_BASE = "https://developerservices2.apple.com/services/download?path="
|
||||
remote_path = urllib.parse.urlparse(link).path
|
||||
token_url = urllib.parse.urlunparse(urllib.parse.urlparse(TOKEN_URL_BASE)._replace(query=urllib.parse.urlencode({"path": remote_path})))
|
||||
|
||||
try:
|
||||
response = SESSION.get(token_url, timeout=5)
|
||||
except (requests.exceptions.Timeout, requests.exceptions.TooManyRedirects, requests.exceptions.ConnectionError):
|
||||
logging.info(" - Could not contact Apple download servers")
|
||||
return None
|
||||
|
||||
try:
|
||||
response.raise_for_status()
|
||||
except requests.exceptions.HTTPError:
|
||||
if response.status_code == 400 and "The path specified is invalid" in response.text:
|
||||
logging.info(" - File does not exist on Apple download servers")
|
||||
else:
|
||||
logging.info(" - Could not request download authorization from Apple download servers")
|
||||
return None
|
||||
|
||||
return download_file(link, location, is_gui, verify_checksum)
|
||||
|
||||
|
||||
def dump_constants(constants):
|
||||
with open(os.path.join(os.path.expanduser('~'), 'Desktop', 'internal_data.txt'), 'w') as f:
|
||||
f.write(str(vars(constants)))
|
||||
@@ -593,7 +560,7 @@ def block_os_updaters():
|
||||
for bad_process in bad_processes:
|
||||
if bad_process in current_process:
|
||||
if pid != "":
|
||||
logging.info(f"- Killing Process: {pid} - {current_process.split('/')[-1]}")
|
||||
print(f"- Killing Process: {pid} - {current_process.split('/')[-1]}")
|
||||
subprocess.run(["kill", "-9", pid])
|
||||
break
|
||||
|
||||
|
||||
Reference in New Issue
Block a user