payloads: USe variable name for mounting

This commit is contained in:
Mykola Grymalyuk
2023-05-04 12:43:06 -06:00
parent 15103007a5
commit c308bcb993
2 changed files with 29 additions and 21 deletions

View File

@@ -107,6 +107,7 @@ class Constants:
# Get resource path # Get resource path
self.current_path: Path = Path(__file__).parent.parent.resolve() 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") self.payload_path: Path = self.current_path / Path("payloads")
# Patcher Settings # Patcher Settings
@@ -225,6 +226,11 @@ class Constants:
] ]
# Payload Location # Payload Location
# Support Disk Images
@property
def payload_path_dmg(self):
return self.original_path / Path("payloads.dmg")
# OpenCore # OpenCore
@property @property
def opencore_zip_source(self): def opencore_zip_source(self):

View File

@@ -36,7 +36,7 @@ class RoutePayloadDiskImage:
self._unmount_active_dmgs(unmount_all_active=False) self._unmount_active_dmgs(unmount_all_active=False)
output = subprocess.run( 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")), "-mountpoint", Path(self.temp_dir.name / Path("payloads")),
"-nobrowse", "-nobrowse",
"-shadow", Path(self.temp_dir.name / Path("payloads_overlay")), "-shadow", Path(self.temp_dir.name / Path("payloads_overlay")),
@@ -55,7 +55,7 @@ class RoutePayloadDiskImage:
logging.info(f"Return Code: {output.returncode}") 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 Unmounts disk images associated with OCLP
@@ -70,19 +70,21 @@ class RoutePayloadDiskImage:
dmg_info = subprocess.run(["hdiutil", "info", "-plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) dmg_info = subprocess.run(["hdiutil", "info", "-plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
dmg_info = plistlib.loads(dmg_info.stdout) dmg_info = plistlib.loads(dmg_info.stdout)
for variant in ["Universal-Binaries.dmg", "payloads.dmg"]:
for image in dmg_info["images"]: for image in dmg_info["images"]:
if image["image-path"].endswith("payloads.dmg"): if image["image-path"].endswith(variant):
if unmount_all_active is False: if unmount_all_active is False:
# Check that only our personal payloads.dmg is unmounted # Check that only our personal payloads.dmg is unmounted
if "shadow-path" in image: if "shadow-path" in image:
if self.temp_dir.name in image["shadow-path"]: if self.temp_dir.name in image["shadow-path"]:
logging.info("- Unmounting personal payloads.dmg") logging.info(f"- Unmounting personal {variant}")
subprocess.run( subprocess.run(
["hdiutil", "detach", image["system-entities"][0]["dev-entry"], "-force"], ["hdiutil", "detach", image["system-entities"][0]["dev-entry"], "-force"],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT stdout=subprocess.PIPE, stderr=subprocess.STDOUT
) )
else: else:
logging.info(f"- Unmounting payloads.dmg at: {image['system-entities'][0]['dev-entry']}") logging.info(f"- Unmounting {variant} at: {image['system-entities'][0]['dev-entry']}")
subprocess.run( subprocess.run(
["hdiutil", "detach", image["system-entities"][0]["dev-entry"], "-force"], ["hdiutil", "detach", image["system-entities"][0]["dev-entry"], "-force"],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT stdout=subprocess.PIPE, stderr=subprocess.STDOUT