summaryrefslogtreecommitdiff
path: root/functions/configuration.sh
diff options
context:
space:
mode:
authorLyndon Brown <jnqnfe@gmail.com>2020-05-04 14:28:37 +0100
committerLyndon Brown <jnqnfe@gmail.com>2020-05-04 21:40:13 +0100
commit3f840aeeba982a858a881271a3bb48bca5b50dd8 (patch)
tree028cabca052c064e2bb566dbdaee78a05422f505 /functions/configuration.sh
parentf3a818da9ab1998944c20b0847a733bbdacb61d8 (diff)
downloadvyos-live-build-3f840aeeba982a858a881271a3bb48bca5b50dd8.tar.gz
vyos-live-build-3f840aeeba982a858a881271a3bb48bca5b50dd8.zip
fully validate BIOS/EFI bootloader combinations
thus far, config bootloader validation only did the basic check that each bootloader specified was a known and supported bootloader, it did not check combinations. it now checks combinations, and strips out the previous "bootloader role" stuff. the no-bootloaders warning is duplicated, covering two slightly different situations (empty string, and whitespace string). this is anticipated to be just temporary, with this just being the first step in better handling bootloader selections. Gbp-Dch: Short
Diffstat (limited to 'functions/configuration.sh')
-rwxr-xr-xfunctions/configuration.sh33
1 files changed, 28 insertions, 5 deletions
diff --git a/functions/configuration.sh b/functions/configuration.sh
index 6b5cfdc63..85873bdcd 100755
--- a/functions/configuration.sh
+++ b/functions/configuration.sh
@@ -576,12 +576,35 @@ Validate_config_permitted_values ()
Echo_warning "You have specified no bootloaders; I predict that you will experience some problems!"
else
local BOOTLOADER
- for BOOTLOADER in ${LB_BOOTLOADERS}; do
- if ! In_list "${BOOTLOADER}" grub-legacy grub-pc grub-efi syslinux; then
- Echo_error "The following is not a valid bootloader: '%s'" "${BOOTLOADER}"
- exit 1
- fi
+ local BOOTLOADERS_BIOS=0
+ local BOOTLOADERS_EFI=0
+ for BOOTLOADER in $LB_BOOTLOADERS; do
+ # Note, multiple instances of the same bootloader should be rejected,
+ # to avoid issues (e.g. in `binary_iso` bootloader handling).
+ case "${BOOTLOADER}" in
+ grub-legacy|grub-pc|syslinux)
+ BOOTLOADERS_BIOS=$(( $BOOTLOADERS_BIOS + 1 ))
+ ;;
+ grub-efi)
+ BOOTLOADERS_EFI=$(( $BOOTLOADERS_EFI + 1 ))
+ ;;
+ *)
+ Echo_error "The following is not a valid bootloader: '%s'" "${BOOTLOADER}"
+ exit 1
+ ;;
+ esac
done
+ if [ $BOOTLOADERS_BIOS -ge 2 ]; then
+ Echo_error "Invalid bootloader selection. Multiple BIOS instances specified."
+ exit 1
+ fi
+ if [ $BOOTLOADERS_EFI -ge 2 ]; then
+ Echo_error "Invalid bootloader selection. Multiple EFI instances specified."
+ exit 1
+ fi
+ if [ $BOOTLOADERS_BIOS -eq 0 ] && [ $BOOTLOADERS_EFI -eq 0 ]; then
+ Echo_warning "You have specified no bootloaders; I predict that you will experience some problems!"
+ fi
fi
local CACHE_STAGE