From fb732ff0691c852f2c0ed79c9376abbfd90fe0c9 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Thu, 7 Jul 2022 19:26:02 -0600 Subject: [PATCH] installer.py: Add CoW support check HFS+ root volumes do not support CoW --- resources/installer.py | 9 ++++++++- resources/utilities.py | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/resources/installer.py b/resources/installer.py index 0217087cc..b6ec28cdb 100644 --- a/resources/installer.py +++ b/resources/installer.py @@ -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")) diff --git a/resources/utilities.py b/resources/utilities.py index 71d3864dd..6ea3fb514 100644 --- a/resources/utilities.py +++ b/resources/utilities.py @@ -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