diff options
| author | Craig Jennings <c@cjennings.net> | 2026-04-26 19:23:15 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-04-26 19:23:15 -0500 |
| commit | 9f62328988e83413eb819ac1ab2021a414188a67 (patch) | |
| tree | 9ea06850663aa4f941fd0de8982b9019c6d2f983 | |
| parent | f02ba03c12599bdd61b5208c9a65f458ae05aa15 (diff) | |
| download | archangel-9f62328988e83413eb819ac1ab2021a414188a67.tar.gz archangel-9f62328988e83413eb819ac1ab2021a414188a67.zip | |
refactor: extract EFI_DIR constant for the install-time EFI mount point
The literal /mnt/efi appeared at 17 sites across installer/archangel and installer/lib/btrfs.sh. Renaming it (or pointing tests at a different mount) meant touching every site and risking incomplete sweeps. One canonical name in installer/lib/common.sh now backs every reference.
EFI_DIR has no trailing slash so the three expansion patterns in the codebase compose cleanly. Bare ($EFI_DIR), sub-path ($EFI_DIR/EFI/ZBM), and the index-suffix used by install_grub_all_efi for secondary EFI mounts (${EFI_DIR}${i}). The sync_efi_partitions staging path also moves from the literal /mnt/efi_sync to ${EFI_DIR}_sync, so it follows EFI_DIR if anyone ever changes the base.
Two follow-ups filed as separate :techdebt: items. MNTPOINT=/mnt extraction across the 50+ /mnt/... sites (pacstrap, arch-chroot, fstab writes), and the related /mnt${chroot_efi_dir} composition pattern at btrfs.sh:681-682. Both ship together when MNTPOINT lands.
Verified: bats 134 → 135 (+1 pinning EFI_DIR=/mnt/efi). Lint clean. All four expansion patterns smoke-tested at runtime and produce the original literal byte-for-byte. VM run skipped, pure constant substitution with zero behavior change.
| -rwxr-xr-x | installer/archangel | 24 | ||||
| -rw-r--r-- | installer/lib/btrfs.sh | 12 | ||||
| -rw-r--r-- | installer/lib/common.sh | 10 | ||||
| -rw-r--r-- | tests/unit/test_common.bats | 8 |
4 files changed, 36 insertions, 18 deletions
diff --git a/installer/archangel b/installer/archangel index 10ec68a..64718da 100755 --- a/installer/archangel +++ b/installer/archangel @@ -729,9 +729,9 @@ mount_efi() { step "Mounting EFI Partition" # EFI partition mounts at /efi - only holds ZFSBootMenu binary # /boot is a directory on ZFS root (kernels live on ZFS for snapshot safety) - mkdir -p /mnt/efi - mount "${EFI_PARTS[0]}" /mnt/efi - info "EFI partition ${EFI_PARTS[0]} mounted at /mnt/efi" + mkdir -p $EFI_DIR + mount "${EFI_PARTS[0]}" $EFI_DIR + info "EFI partition ${EFI_PARTS[0]} mounted at $EFI_DIR" } install_base() { @@ -964,13 +964,13 @@ configure_zfsbootmenu() { cp /etc/hostid /mnt/etc/hostid # Create ZFSBootMenu directory on EFI - mkdir -p /mnt/efi/EFI/ZBM + mkdir -p $EFI_DIR/EFI/ZBM # Download ZFSBootMenu release EFI binary # Using the bundled release which includes everything needed info "Downloading ZFSBootMenu..." local zbm_url="https://get.zfsbootmenu.org/efi" - if ! curl -fsSL -o /mnt/efi/EFI/ZBM/zfsbootmenu.efi "$zbm_url"; then + if ! curl -fsSL -o $EFI_DIR/EFI/ZBM/zfsbootmenu.efi "$zbm_url"; then error "Failed to download ZFSBootMenu" fi info "ZFSBootMenu binary installed." @@ -1163,7 +1163,7 @@ sync_efi_partitions() { step "Syncing EFI Partitions for Redundancy" - local temp_mount="/mnt/efi_sync" + local temp_mount="${EFI_DIR}_sync" for i in "${!EFI_PARTS[@]}"; do if [[ $i -eq 0 ]]; then @@ -1178,7 +1178,7 @@ sync_efi_partitions() { # Copy ZFSBootMenu binary to secondary EFI partitions mkdir -p "$temp_mount/EFI/ZBM" - cp /mnt/efi/EFI/ZBM/zfsbootmenu.efi "$temp_mount/EFI/ZBM/" + cp $EFI_DIR/EFI/ZBM/zfsbootmenu.efi "$temp_mount/EFI/ZBM/" umount "$temp_mount" done @@ -1257,7 +1257,7 @@ cleanup() { ZFS_PASSPHRASE="" info "Unmounting filesystems..." - umount /mnt/efi 2>/dev/null || true + umount $EFI_DIR 2>/dev/null || true info "Exporting ZFS pool..." zpool export "$POOL_NAME" @@ -1285,7 +1285,7 @@ install_failure_cleanup() { case "$FILESYSTEM" in zfs) - umount /mnt/efi 2>/dev/null || true + umount $EFI_DIR 2>/dev/null || true umount -R /mnt 2>/dev/null || true if zpool list "$POOL_NAME" >/dev/null 2>&1; then zpool export "$POOL_NAME" 2>/dev/null \ @@ -1294,7 +1294,7 @@ install_failure_cleanup() { fi ;; btrfs) - umount /mnt/efi 2>/dev/null || true + umount $EFI_DIR 2>/dev/null || true btrfs_cleanup 2>/dev/null || true btrfs_close_encryption 2>/dev/null || true ;; @@ -1461,8 +1461,8 @@ install_btrfs() { btrfs_make_filesystem btrfs_devices create_btrfs_subvolumes "${btrfs_devices[0]}" mount_btrfs_subvolumes "${btrfs_devices[0]}" - mkdir -p /mnt/efi - mount "${EFI_PARTS[0]}" /mnt/efi + mkdir -p $EFI_DIR + mount "${EFI_PARTS[0]}" $EFI_DIR # Base install + system config install_base diff --git a/installer/lib/btrfs.sh b/installer/lib/btrfs.sh index f1cfaac..09127b2 100644 --- a/installer/lib/btrfs.sh +++ b/installer/lib/btrfs.sh @@ -567,8 +567,8 @@ configure_grub() { step "Configuring GRUB Bootloader" # Mount EFI partition - mkdir -p /mnt/efi - mount "$efi_partition" /mnt/efi + mkdir -p $EFI_DIR + mount "$efi_partition" $EFI_DIR # Configure GRUB defaults for btrfs info "Setting GRUB configuration..." @@ -624,7 +624,7 @@ EOF # Create grub directory on EFI partition # GRUB modules on FAT32 EFI partition avoid btrfs subvolume path issues - mkdir -p /mnt/efi/grub + mkdir -p $EFI_DIR/grub # Install GRUB with boot-directory on EFI partition info "Installing GRUB to EFI partition..." @@ -665,12 +665,12 @@ install_grub_all_efi() { for efi_part in "${efi_partitions[@]}"; do # First EFI at /efi (already mounted), subsequent at /efi2, /efi3, etc. local chroot_efi_dir="/efi" - local mount_point="/mnt/efi" + local mount_point="$EFI_DIR" local bootloader_id="GRUB" if [[ $i -gt 1 ]]; then chroot_efi_dir="/efi${i}" - mount_point="/mnt/efi${i}" + mount_point="$EFI_DIR${i}" bootloader_id="GRUB-disk${i}" # Mount secondary EFI partitions @@ -887,7 +887,7 @@ btrfs_cleanup() { sync # Unmount EFI first - umount /mnt/efi 2>/dev/null || true + umount $EFI_DIR 2>/dev/null || true # Unmount all btrfs subvolumes (reverse order) for ((i=${#BTRFS_SUBVOLS[@]}-1; i>=0; i--)); do diff --git a/installer/lib/common.sh b/installer/lib/common.sh index 98220fa..d375a9c 100644 --- a/installer/lib/common.sh +++ b/installer/lib/common.sh @@ -3,6 +3,16 @@ # Source this file: source "$(dirname "$0")/lib/common.sh" ############################# +# Path Constants +############################# + +# Mount point for the primary EFI partition during install. Sub-paths +# compose with ${EFI_DIR}/...; secondary EFI partitions in multi-disk +# layouts use ${EFI_DIR}${i} (no trailing slash, so the index appends +# cleanly). +EFI_DIR="/mnt/efi" + +############################# # Output Functions ############################# diff --git a/tests/unit/test_common.bats b/tests/unit/test_common.bats index 0bb76a1..4d58bd9 100644 --- a/tests/unit/test_common.bats +++ b/tests/unit/test_common.bats @@ -324,3 +324,11 @@ Boot0001* ZFSBootMenu" [ "$status" -eq 1 ] [ -z "$output" ] } + +############################# +# Path constants +############################# + +@test "EFI_DIR is defined and equals /mnt/efi" { + [ "$EFI_DIR" = "/mnt/efi" ] +} |
