installer.py: Add CoW support check

HFS+ root volumes do not support CoW
This commit is contained in:
Mykola Grymalyuk
2022-07-07 19:26:02 -06:00
parent 28c4909b7e
commit fb732ff069
2 changed files with 12 additions and 1 deletions

View File

@@ -363,10 +363,17 @@ def generate_installer_creation_script(tmp_location, installer_path, disk):
subprocess.run(["rm", "-rf", str(file)])
# Copy installer to tmp (use CoW to avoid extra disk writes)
subprocess.run(["cp", "-cR", installer_path, ia_tmp])
args = ["cp", "-cR", installer_path, ia_tmp]
if utilities.check_filesystem_type() != "apfs":
# HFS+ disks do not support CoW
args[1] = "-R"
subprocess.run(args)
# Adjust installer_path to point to the copied installer
installer_path = Path(ia_tmp) / Path(Path(installer_path).name)
if not Path(installer_path).exists():
print(f"Failed to copy installer to {ia_tmp}")
return False
createinstallmedia_path = str(Path(installer_path) / Path("Contents/Resources/createinstallmedia"))
plist_path = str(Path(installer_path) / Path("Contents/Info.plist"))

View File

@@ -93,6 +93,10 @@ def check_seal():
else:
return False
def check_filesystem_type():
# Expected to return 'apfs' or 'hfs'
filesystem_type = plistlib.loads(subprocess.run(["diskutil", "info", "-plist", "/"], stdout=subprocess.PIPE).stdout.decode().strip().encode())
return filesystem_type["FilesystemType"]
def csr_dump():
# Based off sip_config.py