[O] Fix invalid kext loading

This commit is contained in:
Azalea (on HyDEV-Daisy)
2022-11-03 23:54:33 -04:00
parent e4c37d0066
commit d492048177
2 changed files with 5 additions and 3 deletions
+2 -1
View File
@@ -254,8 +254,9 @@ def enable(names: list[str], kexts: list[Kext], efi: Path):
def find_kexts(efi: Path) -> list[Kext]:
kexts_dir = efi / 'OC' / 'Kexts'
kexts = [str(f) for f in os.listdir(kexts_dir)]
kexts = [kexts_dir / f for f in kexts if f.lower().endswith('.kext')]
kexts = [kexts_dir / f for f in kexts if f.lower().endswith('.kext') and not f.startswith("._")]
kexts = [Kext.from_path(k) for k in kexts]
kexts = [k for k in kexts if k]
return kexts
+3 -2
View File
@@ -4,6 +4,7 @@ import plistlib
from dataclasses import dataclass
from datetime import datetime
from pathlib import Path
from typing import Optional
@dataclass()
@@ -17,11 +18,11 @@ class Kext:
min_os: str | None = None
@classmethod
def from_path(cls, path: Path) -> 'Kext':
def from_path(cls, path: Path) -> Optional['Kext']:
# Find plist file
plist = path / 'Contents' / 'Info.plist'
if not plist.is_file():
print(f'Error loading {path.name}: Cannot find Info.plist')
return None
# Load plist file
plist = plistlib.loads(plist.read_bytes())