Add support for renaming macWK boot.efi files

This prevents those boot entries from appearing in the macOS boot menu
This commit is contained in:
2Shirt 2021-12-14 20:59:21 -07:00
parent 6b3524cde8
commit 82a2e7f85c
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -59,7 +59,7 @@ UFD_LABEL = f'{KIT_NAME_SHORT}_UFD'
# Functions
def apply_image(part_path, image_path):
def apply_image(part_path, image_path, hide_macos_boot=True):
"""Apply raw image to dev_path using dd."""
cmd = [
'sudo',
@ -70,6 +70,24 @@ def apply_image(part_path, image_path):
]
run_program(cmd)
# Bail?
if not ('macwk' in image_path.name.lower() and hide_macos_boot):
return
# Hide macOS boot files
boot_efi_path = '/mnt/TMP/System/Library/CoreServices/boot.efi'
linux.mount(source=part_path, mount_point='/mnt/TMP', read_write=True)
if os.path.exists(boot_efi_path):
try:
os.rename(
boot_efi_path,
boot_efi_path.replace('boot.efi', 'secretboot.efi'),
)
except OSError:
# Ignore for now?
pass
linux.unmount(source_or_mountpoint='/mnt/TMP')
def build_ufd():
# pylint: disable=too-many-statements