summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--setup-disk.in18
-rwxr-xr-xtests/setup_disk_test27
2 files changed, 40 insertions, 5 deletions
diff --git a/setup-disk.in b/setup-disk.in
index 6fb3075..1f70835 100644
--- a/setup-disk.in
+++ b/setup-disk.in
@@ -285,13 +285,25 @@ get_bootopt() {
done
}
+find_efi_directory() {
+ local mnt="$1" dir=
+ for dir in boot/efi boot; do
+ if [ "$(find_mount_fs "$mnt"/$dir)" = vfat ]; then
+ echo "$mnt"/$dir
+ return
+ fi
+ done
+ return 1
+}
+
# setup GRUB bootloader
setup_grub() {
local mnt="$1" root="$2" modules="$3" kernel_opts="$4" bootdev="$5"
# install GRUB efi mode
if [ -n "$USE_EFI" ]; then
local target fwa
- local efi_directory="$mnt"/boot/efi
+ local efi_directory=$(find_efi_directory "$mnt") || \
+ echo "WARNING: EFI directory was not found" >&2
case "$ARCH" in
x86_64) target=x86_64-efi ; fwa=x64 ;;
x86) target=i386-efi ; fwa=ia32 ;;
@@ -299,9 +311,7 @@ setup_grub() {
aarch64) target=arm64-efi ; fwa=aa64 ;;
riscv64) target=riscv64-efi ; fwa=riscv64 ;;
esac
- if [ -n "$USE_CRYPT" ]; then
- efi_directory="$mnt"/boot
- fi
+
# currently disabling nvram so grub doesnt call efibootmgr
# installing to alpine directory so other distros dont overwrite it
$MOCK grub-install --target=$target --efi-directory="$efi_directory" \
diff --git a/tests/setup_disk_test b/tests/setup_disk_test
index 061caa3..d7951ea 100755
--- a/tests/setup_disk_test
+++ b/tests/setup_disk_test
@@ -10,7 +10,8 @@ init_tests \
setup_disk_func_setup_partitions_gpt \
setup_disk_func_find_efi_size \
setup_disk_non_existing_block_dev \
- setup_disk_install_mounted_root_nvme
+ setup_disk_install_mounted_root_nvme \
+ setup_disk_install_mounted_root_efi_boot
setup_disk_usage_body() {
test_usage setup-disk
@@ -223,3 +224,27 @@ setup_disk_install_mounted_root_nvme_body() {
cat target/etc/default/grub
}
+
+setup_disk_install_mounted_root_efi_boot_body() {
+ init_env
+ mkdir -p target/boot \
+ sys/firmware/efi
+
+ # simulate nvme0n1p2 being mounted
+ fake_mount "/dev/vda2 $PWD/target ext4 rw,noatime,data=ordered 0 0"
+ fake_mount "/dev/vda1 $PWD/target/boot vfat rw,relatime,fmask=0022 0 0"
+
+ atf_check -s exit:0 \
+ -o match:"Installing system on /dev/vda2" \
+ -o match:"grub-install .* --efi-directory=$PWD/target/boot .* --boot-directory=$PWD/target/boot" \
+ -o match:"install -D $PWD/target/boot/EFI/alpine/grub.*efi $PWD/target/boot/EFI/boot/bootaa64.efi" \
+ setup-disk -v target
+
+ atf_check \
+ -o match:"/dev/vda2 / ext4 rw,noatime,data=ordered 0 1" \
+ -o match:"/dev/vda1 /boot vfat rw,relatime,fmask=0022 0 2" \
+ cat target/etc/fstab
+
+ atf_check -o match:"GRUB_CMDLINE_LINUX_DEFAULT=.*ext4" \
+ cat target/etc/default/grub
+}