mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-11 16:27:19 +10:00
payloads: USe variable name for mounting
This commit is contained in:
@@ -106,8 +106,9 @@ class Constants:
|
||||
self.kdkless_version: str = "1.0.0"
|
||||
|
||||
# Get resource path
|
||||
self.current_path: Path = Path(__file__).parent.parent.resolve()
|
||||
self.payload_path: Path = self.current_path / Path("payloads")
|
||||
self.current_path: Path = Path(__file__).parent.parent.resolve()
|
||||
self.original_path: Path = Path(__file__).parent.parent.resolve()
|
||||
self.payload_path: Path = self.current_path / Path("payloads")
|
||||
|
||||
# Patcher Settings
|
||||
## Internal settings
|
||||
@@ -225,6 +226,11 @@ class Constants:
|
||||
]
|
||||
|
||||
# Payload Location
|
||||
|
||||
# Support Disk Images
|
||||
@property
|
||||
def payload_path_dmg(self):
|
||||
return self.original_path / Path("payloads.dmg")
|
||||
# OpenCore
|
||||
@property
|
||||
def opencore_zip_source(self):
|
||||
|
||||
@@ -36,7 +36,7 @@ class RoutePayloadDiskImage:
|
||||
self._unmount_active_dmgs(unmount_all_active=False)
|
||||
output = subprocess.run(
|
||||
[
|
||||
"hdiutil", "attach", "-noverify", f"{self.constants.payload_path}.dmg",
|
||||
"hdiutil", "attach", "-noverify", f"{self.constants.payload_path_dmg}",
|
||||
"-mountpoint", Path(self.temp_dir.name / Path("payloads")),
|
||||
"-nobrowse",
|
||||
"-shadow", Path(self.temp_dir.name / Path("payloads_overlay")),
|
||||
@@ -55,7 +55,7 @@ class RoutePayloadDiskImage:
|
||||
logging.info(f"Return Code: {output.returncode}")
|
||||
|
||||
|
||||
def _unmount_active_dmgs(self, unmount_all_active=True) -> None:
|
||||
def _unmount_active_dmgs(self, unmount_all_active: bool = True) -> None:
|
||||
"""
|
||||
Unmounts disk images associated with OCLP
|
||||
|
||||
@@ -70,20 +70,22 @@ class RoutePayloadDiskImage:
|
||||
dmg_info = subprocess.run(["hdiutil", "info", "-plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
dmg_info = plistlib.loads(dmg_info.stdout)
|
||||
|
||||
for image in dmg_info["images"]:
|
||||
if image["image-path"].endswith("payloads.dmg"):
|
||||
if unmount_all_active is False:
|
||||
# Check that only our personal payloads.dmg is unmounted
|
||||
if "shadow-path" in image:
|
||||
if self.temp_dir.name in image["shadow-path"]:
|
||||
logging.info("- Unmounting personal payloads.dmg")
|
||||
subprocess.run(
|
||||
["hdiutil", "detach", image["system-entities"][0]["dev-entry"], "-force"],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
||||
)
|
||||
else:
|
||||
logging.info(f"- Unmounting payloads.dmg at: {image['system-entities'][0]['dev-entry']}")
|
||||
subprocess.run(
|
||||
["hdiutil", "detach", image["system-entities"][0]["dev-entry"], "-force"],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
||||
)
|
||||
|
||||
for variant in ["Universal-Binaries.dmg", "payloads.dmg"]:
|
||||
for image in dmg_info["images"]:
|
||||
if image["image-path"].endswith(variant):
|
||||
if unmount_all_active is False:
|
||||
# Check that only our personal payloads.dmg is unmounted
|
||||
if "shadow-path" in image:
|
||||
if self.temp_dir.name in image["shadow-path"]:
|
||||
logging.info(f"- Unmounting personal {variant}")
|
||||
subprocess.run(
|
||||
["hdiutil", "detach", image["system-entities"][0]["dev-entry"], "-force"],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
||||
)
|
||||
else:
|
||||
logging.info(f"- Unmounting {variant} at: {image['system-entities'][0]['dev-entry']}")
|
||||
subprocess.run(
|
||||
["hdiutil", "detach", image["system-entities"][0]["dev-entry"], "-force"],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
||||
)
|
||||
Reference in New Issue
Block a user