diff options
author | Lyndon Brown <jnqnfe@gmail.com> | 2020-03-12 04:49:30 +0000 |
---|---|---|
committer | Raphaƫl Hertzog <hertzog@debian.org> | 2020-03-13 16:03:48 +0000 |
commit | 1cbe8f8aac2f8332a4a50f60d803e2a2e95cf978 (patch) | |
tree | 08ca0778cb03ed734370ce8c599c85da4a908f2b /functions/bootloaders.sh | |
parent | b27927724a5da017796d16de47979116d01455dc (diff) | |
download | vyos-live-build-1cbe8f8aac2f8332a4a50f60d803e2a2e95cf978.tar.gz vyos-live-build-1cbe8f8aac2f8332a4a50f60d803e2a2e95cf978.zip |
functions/bootloaders: tidy and simplify
Diffstat (limited to 'functions/bootloaders.sh')
-rwxr-xr-x | functions/bootloaders.sh | 98 |
1 files changed, 26 insertions, 72 deletions
diff --git a/functions/bootloaders.sh b/functions/bootloaders.sh index 832d4eea1..36e132fb5 100755 --- a/functions/bootloaders.sh +++ b/functions/bootloaders.sh @@ -8,28 +8,12 @@ ## This is free software, and you are welcome to redistribute it ## under certain conditions; see COPYING for details. -Is_First_Bootloader () -{ - EVAL_FIRST_BOOTLOADER="${1}" - - if [ "${LB_FIRST_BOOTLOADER}" = "${EVAL_FIRST_BOOTLOADER}" ] - then - return 0 - else - return 1 - fi - -} - -Is_Bootloader () +Is_Requested_Bootloader () { - EVAL_BOOTLOADER="${1}" OLDIFS="$IFS" IFS="," - for BOOTLOADER in ${LB_BOOTLOADERS} - do - if [ "${BOOTLOADER}" = "${EVAL_BOOTLOADER}" ] - then + for BOOTLOADER in ${LB_BOOTLOADERS}; do + if [ "${BOOTLOADER}" = "${1}" ]; then IFS="$OLDIFS" return 0 fi @@ -38,92 +22,62 @@ Is_Bootloader () return 1 } -Is_Extra_Bootloader () +Is_First_Bootloader () { - EVAL_EXTRA_BOOTLOADER="${1}" - - if Is_First_Bootloader "${EVAL_EXTRA_BOOTLOADER}" - then + if [ "${LB_FIRST_BOOTLOADER}" != "${1}" ]; then return 1 - else - if Is_Bootloader "${EVAL_EXTRA_BOOTLOADER}" - then - return 0 - fi fi - return 1 + return 0 +} +Is_Extra_Bootloader () +{ + if Is_First_Bootloader "${1}"; then + return 1 + fi + if ! Is_Requested_Bootloader "${1}"; then + return 1 + fi + return 0 } Check_Non_First_Bootloader () { - NON_FIRST_BOOTLOADER="${1}" - - if Is_First_Bootloader "${NON_FIRST_BOOTLOADER}" - then - Echo_error "Bootloader: ${NON_FIRST_BOOTLOADER} not supported as a first bootloader." + if Is_First_Bootloader "${1}"; then + Echo_error "Bootloader: \`${1}\` is not supported as a first bootloader." exit 1 - else - return 0 fi } - Check_Non_Extra_Bootloader () { - NON_EXTRA_BOOTLOADER="${1}" - - if Is_Extra_Bootloader "${NON_EXTRA_BOOTLOADER}" - then - Echo_error "Bootloader: ${NON_EXTRA_BOOTLOADER} not supported as a extra bootloader." + if Is_Extra_Bootloader "${1}"; then + Echo_error "Bootloader: \`${1}\` is not supported as a extra bootloader." exit 1 - else - return 0 fi } Check_First_Bootloader_Role () { - FIRST_BOOTLOADER_ROLE="${1}" - Check_Non_Extra_Bootloader "${FIRST_BOOTLOADER_ROLE}" + Check_Non_Extra_Bootloader "${1}" - if Is_First_Bootloader "${FIRST_BOOTLOADER_ROLE}" - then - return 0 - else + if ! Is_First_Bootloader "${1}"; then exit 0 fi - } Check_Extra_Bootloader_Role () { - EXTRA_BOOTLOADER_ROLE="${1}" - Check_Non_First_Bootloader "${EXTRA_BOOTLOADER_ROLE}" + Check_Non_First_Bootloader "${1}" - if Is_Extra_Bootloader "${EXTRA_BOOTLOADER_ROLE}" - then - return 0 - else + if ! Is_Extra_Bootloader "${1}"; then exit 0 fi - } Check_Any_Bootloader_Role () { - ANY_BOOTLOADER_ROLE="${1}" - - if Is_First_Bootloader "${ANY_BOOTLOADER_ROLE}" - then - return 0 - fi - - if Is_Extra_Bootloader "${ANY_BOOTLOADER_ROLE}" - then - return 0 + if ! Is_Requested_Bootloader "${1}"; then + exit 0 fi - - exit 0 - } |