From f73797158e631d9fa2d4c9994e2feff542a7501b Mon Sep 17 00:00:00 2001
From: Lyndon Brown <jnqnfe@gmail.com>
Date: Sat, 28 Mar 2020 02:21:36 +0000
Subject: 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
---
 functions/bootloaders.sh    | 4 ----
 functions/defaults.sh       | 3 ++-
 manpages/en/lb_config.1     | 2 +-
 scripts/build/binary_hdd    | 2 +-
 scripts/build/binary_iso    | 3 ---
 scripts/build/source_debian | 2 +-
 6 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/functions/bootloaders.sh b/functions/bootloaders.sh
index 14e50ac4c..a6883a67f 100755
--- a/functions/bootloaders.sh
+++ b/functions/bootloaders.sh
@@ -10,16 +10,12 @@
 
 Is_Requested_Bootloader ()
 {
-	local OLDIFS="$IFS"
-	local IFS=","
 	local BOOTLOADER
 	for BOOTLOADER in ${LB_BOOTLOADERS}; do
 		if [ "${BOOTLOADER}" = "${1}" ]; then
-			IFS="$OLDIFS"
 			return 0
 		fi
 	done
-	IFS="$OLDIFS"
 	return 1
 }
 
diff --git a/functions/defaults.sh b/functions/defaults.sh
index f1bb85dce..85efca7df 100755
--- a/functions/defaults.sh
+++ b/functions/defaults.sh
@@ -381,8 +381,9 @@ Set_config_defaults ()
 				;;
 		esac
 	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
 	LB_CHECKSUMS="${LB_CHECKSUMS:-sha256}"
diff --git a/manpages/en/lb_config.1 b/manpages/en/lb_config.1
index 31d63d72e..c011ad496 100644
--- a/manpages/en/lb_config.1
+++ b/manpages/en/lb_config.1
@@ -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
 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
-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
 sets the architectures to use foreign bootstrap. Defaults to empty.
 .IP "\fB\-\-bootstrap\-qemu\-exclude \fIPACKAGES\fR" 4
diff --git a/scripts/build/binary_hdd b/scripts/build/binary_hdd
index b81c301da..437913929 100755
--- a/scripts/build/binary_hdd
+++ b/scripts/build/binary_hdd
@@ -53,7 +53,7 @@ Check_package chroot /sbin/parted parted
 Check_package host /sbin/fdisk fdisk
 Check_package host /sbin/losetup mount
 
-for BOOTLOADER in $(echo "${LB_BOOTLOADERS}" | tr "," "\n"); do
+for BOOTLOADER in ${LB_BOOTLOADERS}; do
 	case "${BOOTLOADER}" in
 		grub-legacy)
 			Check_package chroot /usr/sbin/grub grub
diff --git a/scripts/build/binary_iso b/scripts/build/binary_iso
index eef752f80..9f1b11a86 100755
--- a/scripts/build/binary_iso
+++ b/scripts/build/binary_iso
@@ -104,8 +104,6 @@ fi
 # 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)"
 
-OLDIFS="$IFS"
-IFS=","
 BOOTLOADER_NUMBER=0
 for BOOTLOADER in ${LB_BOOTLOADERS}
 do
@@ -156,7 +154,6 @@ do
 	esac
 
 done
-IFS="$OLDIFS"
 
 #if [ "${LB_DEBIAN_INSTALLER}" != "live" ]
 #then
diff --git a/scripts/build/source_debian b/scripts/build/source_debian
index b9899b2bc..5e37edbca 100755
--- a/scripts/build/source_debian
+++ b/scripts/build/source_debian
@@ -54,7 +54,7 @@ Chroot chroot "sh source-selection.sh"
 rm -f chroot/source-selection.sh
 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
 done
 
-- 
cgit v1.2.3