sys_patch.py: Handle migrated kexts from old installs

This commit is contained in:
Mykola Grymalyuk
2022-10-26 14:50:04 -06:00
parent db015ad79c
commit 604fb7e28f
2 changed files with 12 additions and 0 deletions
+2
View File
@@ -5,6 +5,8 @@
- ie. stock SSD found in MacBookAir6,x
- Lax KDK N-1 logic to allow 1 minor version difference
- ex. Allow 13.0 KDK on 13.1
- Clean out `/Library/Extensions` on KDK-less root patches
- Ensures old, incompatible kexts are not linked against
## 0.5.0
- Ventura Specific Updates:
+10
View File
@@ -36,6 +36,7 @@ import plistlib
import shutil
import subprocess
from pathlib import Path
from datetime import datetime
from resources import constants, utilities, sys_patch_download, sys_patch_detect, sys_patch_auto, sys_patch_helpers, kdk_handler
from data import os_data
@@ -354,6 +355,15 @@ class PatchSysVolume:
continue
self.remove_file("/Library/Extensions", file)
# Handle situations where users migrated from older OSes with a lot of garbage in /L*/E*
# ex. Nvidia Web Drivers, NetUSB, dosdude1's patches, etc.
# Delete if file's age is older than October 2021 (year before Ventura)
if self.constants.detected_os < os_data.os_data.ventura:
return
for file in Path("/Library/Extensions").glob("*.kext"):
if datetime.fromtimestamp(file.stat().st_mtime) < datetime(2021, 10, 1):
self.remove_file("/Library/Extensions", file.name)
def write_patchset(self, patchset):
destination_path = f"{self.mount_location}/System/Library/CoreServices"
file_name = "OpenCore-Legacy-Patcher.plist"