diff options
author | Lyndon Brown <jnqnfe@gmail.com> | 2020-03-28 08:46:40 +0000 |
---|---|---|
committer | Raphaƫl Hertzog <hertzog@debian.org> | 2020-04-23 15:09:56 +0200 |
commit | 46bce5a6d1360f402fb16e36b4a8d5d52a5a92b8 (patch) | |
tree | 64ce74d1dd96a91ada5ecf8ab248b542333b7ff4 | |
parent | 554a8d11088181e666a04558230e94b19f32f2d6 (diff) | |
download | vyos-live-build-46bce5a6d1360f402fb16e36b4a8d5d52a5a92b8.tar.gz vyos-live-build-46bce5a6d1360f402fb16e36b4a8d5d52a5a92b8.zip |
config: reorganise validation checks
splitting into two parts will make things much tidier
Gbp-Dch: Short
-rwxr-xr-x | functions/configuration.sh | 62 |
1 files changed, 37 insertions, 25 deletions
diff --git a/functions/configuration.sh b/functions/configuration.sh index be12f2173..593fce362 100755 --- a/functions/configuration.sh +++ b/functions/configuration.sh @@ -592,13 +592,47 @@ Prepare_config () Validate_config () { - if [ "${LB_BINARY_FILESYSTEM}" = "ntfs" ] && [ ! $(which ntfs-3g) ]; then - Echo_error "Using ntfs as the binary filesystem is currently only supported if ntfs-3g is installed on the host system." + Validate_config_permitted_values + Validate_config_dependencies +} + +# Check values are individually permitted, including: +# - value in list of available values +# - string lengths within permitted ranges +Validate_config_permitted_values () +{ + if ! In_list "${LIVE_IMAGE_TYPE}" iso iso-hybrid hdd tar netboot; then + Echo_error "You have specified an invalid value for --binary-image." exit 1 fi if echo ${LB_HDD_LABEL} | grep -qs ' '; then - Echo_error "There are currently no whitespaces supported in hdd labels." + Echo_error "Whitespace is not currently supported in hdd labels." + exit 1 + fi + + if [ "$(echo \"${LB_ISO_APPLICATION}\" | wc -c)" -gt 128 ]; then + Echo_warning "You have specified a value of LB_ISO_APPLICATION that is too long; the maximum length is 128 characters." + fi + + if [ "$(echo \"${LB_ISO_PREPARER}\" | wc -c)" -gt 128 ]; then + Echo_warning "You have specified a value of LB_ISO_PREPARER that is too long; the maximum length is 128 characters." + fi + + if [ "$(echo \"${LB_ISO_PUBLISHER}\" | wc -c)" -gt 128 ]; then + Echo_warning "You have specified a value of LB_ISO_PUBLISHER that is too long; the maximum length is 128 characters." + fi + + if [ "$(eval "echo \"${LB_ISO_VOLUME}\"" | wc -c)" -gt 32 ]; then + Echo_warning "You have specified a value of LB_ISO_VOLUME that is too long; the maximum length is 32 characters." + fi +} + +# Check option combinations and other extra stuff +Validate_config_dependencies () +{ + if [ "${LB_BINARY_FILESYSTEM}" = "ntfs" ] && [ ! $(which ntfs-3g) ]; then + Echo_error "Using ntfs as the binary filesystem is currently only supported if ntfs-3g is installed on the host system." exit 1 fi @@ -624,32 +658,10 @@ Validate_config () fi fi - if ! In_list "${LIVE_IMAGE_TYPE}" iso iso-hybrid hdd tar netboot; then - Echo_error "You have specified an invalid value for --binary-image." - exit 1 - fi - if [ "${LIVE_IMAGE_TYPE}" = "hdd" ] && [ "${LB_FIRST_BOOTLOADER}" = "grub-legacy" ]; then Echo_error "You have selected a combination of bootloader and image type that is currently not supported by live-build. Please use either another bootloader or a different image type." exit 1 fi - - if [ "$(echo \"${LB_ISO_APPLICATION}\" | wc -c)" -gt 128 ]; then - Echo_warning "You have specified a value of LB_ISO_APPLICATION that is too long; the maximum length is 128 characters." - fi - - if [ "$(echo \"${LB_ISO_PREPARER}\" | wc -c)" -gt 128 ]; then - Echo_warning "You have specified a value of LB_ISO_PREPARER that is too long; the maximum length is 128 characters." - fi - - if [ "$(echo \"${LB_ISO_PUBLISHER}\" | wc -c)" -gt 128 ]; then - Echo_warning "You have specified a value of LB_ISO_PUBLISHER that is too long; the maximum length is 128 characters." - fi - - if [ "$(eval "echo \"${LB_ISO_VOLUME}\"" | wc -c)" -gt 32 ]; then - Echo_warning "You have specified a value of LB_ISO_VOLUME that is too long; the maximum length is 32 characters." - fi - } Get_configuration () |