bootloaders: improve bootloader list handling

two parts of the code worked with both comma and space separated lists,
while two others only worked with comma separated.

swapping out commas with spaces when we setup the var in
Set_config_defaults() means that individual scripts no longer need to worry
about it and everything supports both; and that we can avoid the
IFS/OLDIFS mess.

Gbp-Dch: Short
This commit is contained in:
Lyndon Brown 2020-03-28 02:21:36 +00:00
parent ae9143141d
commit f73797158e
6 changed files with 5 additions and 11 deletions

View File

@ -10,16 +10,12 @@
Is_Requested_Bootloader () Is_Requested_Bootloader ()
{ {
local OLDIFS="$IFS"
local IFS=","
local BOOTLOADER local BOOTLOADER
for BOOTLOADER in ${LB_BOOTLOADERS}; do for BOOTLOADER in ${LB_BOOTLOADERS}; do
if [ "${BOOTLOADER}" = "${1}" ]; then if [ "${BOOTLOADER}" = "${1}" ]; then
IFS="$OLDIFS"
return 0 return 0
fi fi
done done
IFS="$OLDIFS"
return 1 return 1
} }

View File

@ -381,8 +381,9 @@ Set_config_defaults ()
;; ;;
esac esac
fi fi
LB_BOOTLOADERS="$(echo "${LB_BOOTLOADERS}" | tr "," " ")"
LB_FIRST_BOOTLOADER=$(echo "${LB_BOOTLOADERS}" | awk -F, '{ print $1 }') LB_FIRST_BOOTLOADER=$(echo "${LB_BOOTLOADERS}" | awk '{ print $1 }')
# Setting checksums # Setting checksums
LB_CHECKSUMS="${LB_CHECKSUMS:-sha256}" LB_CHECKSUMS="${LB_CHECKSUMS:-sha256}"

View File

@ -286,7 +286,7 @@ sets boot parameters specific to debian\-live. A complete list of boot parameter
.IP "\fB\-\-bootappend\-live\-failsafe\fR \fIPARAMETER\fR|""\fIPARAMETERS\fR""" 4 .IP "\fB\-\-bootappend\-live\-failsafe\fR \fIPARAMETER\fR|""\fIPARAMETERS\fR""" 4
sets boot parameters specific to debian\-live failsafe boot entries. A complete list of boot parameters can be found in the \fIlive\-boot\fR(7) and \fIlive\-config\fR(7) manual pages. sets boot parameters specific to debian\-live failsafe boot entries. A complete list of boot parameters can be found in the \fIlive\-boot\fR(7) and \fIlive\-config\fR(7) manual pages.
.IP "\fB\-\-bootloaders\fR grub-legacy|grub-pc|syslinux|grub-efi" 4 .IP "\fB\-\-bootloaders\fR grub-legacy|grub-pc|syslinux|grub-efi" 4
defines which bootloaders to use in the generated image. This only has an effect if the selected binary image type lets you choose the bootloader. For example, if you build an ISO then syslinux (or more precise, isolinux) is always used. Also note that not all combinations of binary images types and bootloaders are supported (\fBlb config\fR will fail to create such an unsupported configuration and will give a explanation about it). For HDD images on amd64 and i386, the default is syslinux. This option supports more than one bootloader to be specified (comma separated) in order to allow for both BIOS and EFI bootloaders to be included, though note that only one of each type can be used (i.e. do not try to use two BIOS bootloaders). defines which bootloaders to use in the generated image. This only has an effect if the selected binary image type lets you choose the bootloader. For example, if you build an ISO then syslinux (or more precise, isolinux) is always used. Also note that not all combinations of binary images types and bootloaders are supported (\fBlb config\fR will fail to create such an unsupported configuration and will give a explanation about it). For HDD images on amd64 and i386, the default is syslinux. This option supports more than one bootloader to be specified (space or comma separated) in order to allow for both BIOS and EFI bootloaders to be included, though note that only one of each type can be used (i.e. do not try to use two BIOS bootloaders).
.IP "\fB\-\-bootstrap\-qemu\-arch \fIARCH\fR" 4 .IP "\fB\-\-bootstrap\-qemu\-arch \fIARCH\fR" 4
sets the architectures to use foreign bootstrap. Defaults to empty. sets the architectures to use foreign bootstrap. Defaults to empty.
.IP "\fB\-\-bootstrap\-qemu\-exclude \fIPACKAGES\fR" 4 .IP "\fB\-\-bootstrap\-qemu\-exclude \fIPACKAGES\fR" 4

View File

@ -53,7 +53,7 @@ Check_package chroot /sbin/parted parted
Check_package host /sbin/fdisk fdisk Check_package host /sbin/fdisk fdisk
Check_package host /sbin/losetup mount Check_package host /sbin/losetup mount
for BOOTLOADER in $(echo "${LB_BOOTLOADERS}" | tr "," "\n"); do for BOOTLOADER in ${LB_BOOTLOADERS}; do
case "${BOOTLOADER}" in case "${BOOTLOADER}" in
grub-legacy) grub-legacy)
Check_package chroot /usr/sbin/grub grub Check_package chroot /usr/sbin/grub grub

View File

@ -104,8 +104,6 @@ fi
# Set an explicit modification date # Set an explicit modification date
XORRISO_OPTIONS="${XORRISO_OPTIONS} --modification-date=$(date --utc --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y%m%d%H%m%S00)" XORRISO_OPTIONS="${XORRISO_OPTIONS} --modification-date=$(date --utc --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y%m%d%H%m%S00)"
OLDIFS="$IFS"
IFS=","
BOOTLOADER_NUMBER=0 BOOTLOADER_NUMBER=0
for BOOTLOADER in ${LB_BOOTLOADERS} for BOOTLOADER in ${LB_BOOTLOADERS}
do do
@ -156,7 +154,6 @@ do
esac esac
done done
IFS="$OLDIFS"
#if [ "${LB_DEBIAN_INSTALLER}" != "live" ] #if [ "${LB_DEBIAN_INSTALLER}" != "live" ]
#then #then

View File

@ -54,7 +54,7 @@ Chroot chroot "sh source-selection.sh"
rm -f chroot/source-selection.sh rm -f chroot/source-selection.sh
mv chroot/source-selection.txt ./ mv chroot/source-selection.txt ./
for BOOTLOADER in $(echo "${LB_BOOTLOADERS}" | tr "," "\n"); do for BOOTLOADER in ${LB_BOOTLOADERS}; do
echo "${BOOTLOADER}" >> source-selection.txt echo "${BOOTLOADER}" >> source-selection.txt
done done