mirror of
https://github.com/outbackdingo/OpCore-Simplify.git
synced 2026-08-25 14:53:06 +00:00
Add valid kext check before saving
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from Scripts import github
|
from Scripts import github
|
||||||
|
from Scripts import kext_maestro
|
||||||
from Scripts import resource_fetcher
|
from Scripts import resource_fetcher
|
||||||
from Scripts import utils
|
from Scripts import utils
|
||||||
import os
|
import os
|
||||||
@@ -10,6 +11,7 @@ class gatheringFiles:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.utils = utils.Utils()
|
self.utils = utils.Utils()
|
||||||
self.github = github.Github()
|
self.github = github.Github()
|
||||||
|
self.kext = kext_maestro.KextMaestro()
|
||||||
self.fetcher = resource_fetcher.ResourceFetcher()
|
self.fetcher = resource_fetcher.ResourceFetcher()
|
||||||
self.dortania_builds_url = "https://raw.githubusercontent.com/dortania/build-repo/builds/latest.json"
|
self.dortania_builds_url = "https://raw.githubusercontent.com/dortania/build-repo/builds/latest.json"
|
||||||
self.ocbinarydata_url = "https://github.com/acidanthera/OcBinaryData/archive/refs/heads/master.zip"
|
self.ocbinarydata_url = "https://github.com/acidanthera/OcBinaryData/archive/refs/heads/master.zip"
|
||||||
@@ -90,7 +92,7 @@ class gatheringFiles:
|
|||||||
source_kext_path = os.path.join(self.temporary_dir, product_name, kext_path)
|
source_kext_path = os.path.join(self.temporary_dir, product_name, kext_path)
|
||||||
destination_kext_path = os.path.join(self.ock_files_dir, product_name, os.path.basename(kext_path))
|
destination_kext_path = os.path.join(self.ock_files_dir, product_name, os.path.basename(kext_path))
|
||||||
|
|
||||||
if "Contents" in kext_path or "Debug".lower() in kext_path.lower():
|
if "debug" in kext_path.lower() or "Contents" in kext_path or not self.kext.process_kext(os.path.join(self.temporary_dir, product_name), kext_path):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
shutil.move(source_kext_path, destination_kext_path)
|
shutil.move(source_kext_path, destination_kext_path)
|
||||||
@@ -124,8 +126,6 @@ class gatheringFiles:
|
|||||||
shutil.move(source_macserial_path, destination_macserial_path)
|
shutil.move(source_macserial_path, destination_macserial_path)
|
||||||
if os.name != "nt":
|
if os.name != "nt":
|
||||||
subprocess.run(["chmod", "+x", destination_macserial_path])
|
subprocess.run(["chmod", "+x", destination_macserial_path])
|
||||||
else:
|
|
||||||
raise FileNotFoundError("No bootloader or kexts files found in the product directory.")
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
+31
-29
@@ -293,6 +293,33 @@ class KextMaestro:
|
|||||||
shutil.copytree(source_kext_path, destination_kext_path, dirs_exist_ok=True)
|
shutil.copytree(source_kext_path, destination_kext_path, dirs_exist_ok=True)
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
def process_kext(self, kexts_directory, kext_path):
|
||||||
|
try:
|
||||||
|
plist_path = self.utils.find_matching_paths(os.path.join(kexts_directory, kext_path), extension_filter=".plist", name_filter="Info")[0][0]
|
||||||
|
bundle_info = self.utils.read_file(os.path.join(kexts_directory, kext_path, plist_path))
|
||||||
|
|
||||||
|
if isinstance(bundle_info.get("CFBundleIdentifier", None), (str, unicode)):
|
||||||
|
pass
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
|
executable_path = os.path.join("Contents", "MacOS", bundle_info.get("CFBundleExecutable", "None"))
|
||||||
|
if not os.path.exists(os.path.join(kexts_directory, kext_path, executable_path)):
|
||||||
|
executable_path = ""
|
||||||
|
|
||||||
|
return {
|
||||||
|
"BundlePath": kext_path.replace("\\", "/").lstrip("/"),
|
||||||
|
"Enabled": True,
|
||||||
|
"ExecutablePath": executable_path.replace("\\", "/").lstrip("/"),
|
||||||
|
"PlistPath": plist_path.replace("\\", "/").lstrip("/"),
|
||||||
|
"BundleIdentifier": bundle_info.get("CFBundleIdentifier"),
|
||||||
|
"BundleVersion": bundle_info.get("CFBundleVersion"),
|
||||||
|
"BundleLibraries": {
|
||||||
|
bundle_identifier: bundle_version
|
||||||
|
for bundle_identifier, bundle_version in bundle_info.get("OSBundleLibraries", {}).items()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def load_kexts(self, macos_version, kexts_directory):
|
def load_kexts(self, macos_version, kexts_directory):
|
||||||
kernel_add = []
|
kernel_add = []
|
||||||
@@ -315,36 +342,11 @@ class KextMaestro:
|
|||||||
kext_paths = self.utils.find_matching_paths(kexts_directory, extension_filter=".kext")
|
kext_paths = self.utils.find_matching_paths(kexts_directory, extension_filter=".kext")
|
||||||
bundle_list = []
|
bundle_list = []
|
||||||
|
|
||||||
for kext_path, type in kext_paths:
|
for kext_path, type in kext_paths:
|
||||||
try:
|
bundle_info = self.process_kext(kexts_directory, kext_path)
|
||||||
plist_path = self.utils.find_matching_paths(os.path.join(kexts_directory, kext_path), extension_filter=".plist", name_filter="Info")[0][0]
|
|
||||||
bundle_info = self.utils.read_file(os.path.join(kexts_directory, kext_path, plist_path))
|
|
||||||
except:
|
|
||||||
bundle_info = {}
|
|
||||||
|
|
||||||
if not isinstance(bundle_info.get("CFBundleIdentifier", None), (str, unicode)):
|
if bundle_info:
|
||||||
continue
|
bundle_list.append(bundle_info)
|
||||||
|
|
||||||
executable_path = os.path.join("Contents", "MacOS", bundle_info.get("CFBundleExecutable", "None"))
|
|
||||||
if not os.path.exists(os.path.join(kexts_directory, kext_path, executable_path)):
|
|
||||||
executable_path = ""
|
|
||||||
|
|
||||||
if bundle_info.get("CFBundleExecutable", "None") == "AirportItlwm" and self.utils.parse_darwin_version("24.0.0") <= self.utils.parse_darwin_version(macos_version):
|
|
||||||
bundle_info["IOKitPersonalities"]["itlwm"]["IOPCIMatch"] += " 0x43A014E4"
|
|
||||||
self.utils.write_file(os.path.join(kexts_directory, kext_path, plist_path), bundle_info)
|
|
||||||
|
|
||||||
bundle_list.append({
|
|
||||||
"BundlePath": kext_path.replace("\\", "/").lstrip("/"),
|
|
||||||
"Enabled": True,
|
|
||||||
"ExecutablePath": executable_path.replace("\\", "/").lstrip("/"),
|
|
||||||
"PlistPath": plist_path.replace("\\", "/").lstrip("/"),
|
|
||||||
"BundleIdentifier": bundle_info.get("CFBundleIdentifier"),
|
|
||||||
"BundleVersion": bundle_info.get("CFBundleVersion"),
|
|
||||||
"BundleLibraries": {
|
|
||||||
bundle_identifier: bundle_version
|
|
||||||
for bundle_identifier, bundle_version in bundle_info.get("OSBundleLibraries", {}).items()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
bundle_dict = {bundle["BundleIdentifier"]: bundle for bundle in bundle_list}
|
bundle_dict = {bundle["BundleIdentifier"]: bundle for bundle in bundle_list}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user