Multi bootloader support
Note: OLDIFS use makes IFS to be reset to "" instead to it being unset. Either we need to detect if old IFS was unset to unset it or we need a proper way of setting it as a local variable. Even more IFS it's not currently used in Check_package (which it's called from: binary_hdd). we should have a clean way of resetting/unsetting IFS when calling Check_package. The other approach it's to explicitly define IFS with its default value in the places inside live-build code where we implicitly suppose that it's going to have its default value.
This commit is contained in:
parent
d43874c405
commit
d515ae5684
|
@ -536,11 +536,11 @@ Set_defaults ()
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Setting bootloader
|
# Setting bootloader
|
||||||
if [ -z "${LB_BOOTLOADER}" ]
|
if [ -z "${LB_BOOTLOADERS}" ]
|
||||||
then
|
then
|
||||||
case "${LB_ARCHITECTURES}" in
|
case "${LB_ARCHITECTURES}" in
|
||||||
amd64|i386)
|
amd64|i386)
|
||||||
LB_BOOTLOADER="syslinux"
|
LB_BOOTLOADERS="syslinux"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
@ -853,7 +853,10 @@ Check_defaults ()
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${LB_BOOTLOADER}" = "syslinux" ]
|
|
||||||
|
LB_PRIMARY_BOOTLOADER=$(echo "${LB_BOOTLOADERS}" | awk -F, '{ print $1 }')
|
||||||
|
|
||||||
|
if [ "${LB_PRIMARY_BOOTLOADER}" = "syslinux" ]
|
||||||
then
|
then
|
||||||
# syslinux + fat or ntfs, or extlinux + ext[234] or btrfs
|
# syslinux + fat or ntfs, or extlinux + ext[234] or btrfs
|
||||||
case "${LB_BINARY_FILESYSTEM}" in
|
case "${LB_BINARY_FILESYSTEM}" in
|
||||||
|
@ -867,7 +870,7 @@ Check_defaults ()
|
||||||
|
|
||||||
case "${LIVE_IMAGE_TYPE}" in
|
case "${LIVE_IMAGE_TYPE}" in
|
||||||
hdd*)
|
hdd*)
|
||||||
case "${LB_BOOTLOADER}" in
|
case "${LB_PRIMARY_BOOTLOADER}" in
|
||||||
grub)
|
grub)
|
||||||
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."
|
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
|
exit 1
|
||||||
|
|
|
@ -24,9 +24,21 @@ Arguments "${@}"
|
||||||
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
|
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
|
||||||
Set_defaults
|
Set_defaults
|
||||||
|
|
||||||
if [ "${LB_BOOTLOADER}" != "grub-legacy" ]
|
FOUND_MYSELF=""
|
||||||
then
|
IFS=","
|
||||||
exit 0
|
for BOOTLOADER in ${LB_BOOTLOADERS}
|
||||||
|
do
|
||||||
|
|
||||||
|
case ${BOOTLOADER} in
|
||||||
|
"grub-legacy" )
|
||||||
|
FOUND_MYSELF="True"
|
||||||
|
break ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z ${FOUND_MYSELF} ] ; then
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
Echo_message "Begin installing grub-legacy..."
|
Echo_message "Begin installing grub-legacy..."
|
||||||
|
|
|
@ -24,9 +24,23 @@ Arguments "${@}"
|
||||||
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
|
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
|
||||||
Set_defaults
|
Set_defaults
|
||||||
|
|
||||||
if [ "${LB_BOOTLOADER}" != "grub-pc" ]
|
FOUND_MYSELF=""
|
||||||
then
|
OLDIFS="$IFS"
|
||||||
exit 0
|
IFS=","
|
||||||
|
for BOOTLOADER in ${LB_BOOTLOADERS}
|
||||||
|
do
|
||||||
|
|
||||||
|
case ${BOOTLOADER} in
|
||||||
|
"grub-pc" )
|
||||||
|
FOUND_MYSELF="True"
|
||||||
|
break ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
done
|
||||||
|
IFS="$OLDIFS"
|
||||||
|
|
||||||
|
if [ -z ${FOUND_MYSELF} ] ; then
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
Echo_message "Begin installing grub-pc..."
|
Echo_message "Begin installing grub-pc..."
|
||||||
|
|
|
@ -57,26 +57,34 @@ esac
|
||||||
Check_package chroot /usr/share/doc/mtools mtools
|
Check_package chroot /usr/share/doc/mtools mtools
|
||||||
Check_package chroot /sbin/parted parted
|
Check_package chroot /sbin/parted parted
|
||||||
|
|
||||||
case "${LB_BOOTLOADER}" in
|
echo "${LB_BOOTLOADERS}" | \
|
||||||
grub)
|
while IFS="," read -r BOOTLOADER
|
||||||
Check_package chroot /usr/sbin/grub grub
|
do
|
||||||
;;
|
case "${BOOTLOADER}" in
|
||||||
|
grub)
|
||||||
|
Check_package chroot /usr/sbin/grub grub
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
syslinux)
|
LB_PRIMARY_BOOTLOADER=$(echo "${LB_BOOTLOADERS}" | awk -F, '{ print $1 }')
|
||||||
case ${LB_BINARY_FILESYSTEM} in
|
|
||||||
fat*|ntfs)
|
case ${LB_PRIMARY_BOOTLOADER} in
|
||||||
_BOOTLOADER=syslinux
|
syslinux)
|
||||||
;;
|
case ${LB_BINARY_FILESYSTEM} in
|
||||||
ext[234]|btrfs)
|
fat*|ntfs)
|
||||||
_BOOTLOADER=extlinux
|
_BOOTLOADER=syslinux
|
||||||
;;
|
;;
|
||||||
*)
|
ext[234]|btrfs)
|
||||||
Echo_error "syslinux/extlinux doesn't support ${LB_BINARY_FILESYSTEM}"
|
_BOOTLOADER=extlinux
|
||||||
exit 1
|
;;
|
||||||
;;
|
*)
|
||||||
esac
|
Echo_error "syslinux/extlinux doesn't support ${LB_BINARY_FILESYSTEM}"
|
||||||
Check_package chroot /usr/bin/${_BOOTLOADER} ${_BOOTLOADER}
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
esac
|
||||||
|
Check_package chroot /usr/bin/${_BOOTLOADER} ${_BOOTLOADER}
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Restoring cache
|
# Restoring cache
|
||||||
|
@ -168,7 +176,7 @@ case "${LB_BUILD_WITH_CHROOT}" in
|
||||||
Chroot chroot "parted -s ${FREELO} set 1 boot on" || true
|
Chroot chroot "parted -s ${FREELO} set 1 boot on" || true
|
||||||
Chroot chroot "parted -s ${FREELO} set 1 lba off" || true
|
Chroot chroot "parted -s ${FREELO} set 1 lba off" || true
|
||||||
|
|
||||||
if [ "${LB_BOOTLOADER}" = "syslinux" ]
|
if [ "${LB_PRIMARY_BOOTLOADER}" = "syslinux" ]
|
||||||
then
|
then
|
||||||
dd if=chroot/usr/lib/SYSLINUX/mbr.bin of=${FREELO} bs=440 count=1
|
dd if=chroot/usr/lib/SYSLINUX/mbr.bin of=${FREELO} bs=440 count=1
|
||||||
fi
|
fi
|
||||||
|
@ -180,7 +188,7 @@ case "${LB_BUILD_WITH_CHROOT}" in
|
||||||
parted -s "${FREELO}" set 1 boot on || true
|
parted -s "${FREELO}" set 1 boot on || true
|
||||||
parted -s "${FREELO}" set 1 lba off || true
|
parted -s "${FREELO}" set 1 lba off || true
|
||||||
|
|
||||||
if [ "${LB_BOOTLOADER}" = "syslinux" ]
|
if [ "${LB_PRIMARY_BOOTLOADER}" = "syslinux" ]
|
||||||
then
|
then
|
||||||
dd if=/usr/lib/SYSLINUX/mbr.bin of=${FREELO} bs=440 count=1
|
dd if=/usr/lib/SYSLINUX/mbr.bin of=${FREELO} bs=440 count=1
|
||||||
fi
|
fi
|
||||||
|
@ -246,7 +254,7 @@ cp -T ${CP_OPTIONS} binary/ chroot/binary.tmp
|
||||||
|
|
||||||
FIXME()
|
FIXME()
|
||||||
{
|
{
|
||||||
if [ "${LB_BOOTLOADER}" = "grub" ]
|
if [ "${LB_PRIMARY_BOOTLOADER}" = "grub" ]
|
||||||
then
|
then
|
||||||
|
|
||||||
cat > chroot/grub.sh << EOF
|
cat > chroot/grub.sh << EOF
|
||||||
|
|
|
@ -107,8 +107,10 @@ then
|
||||||
XORRISO_OPTIONS="${XORRISO_OPTIONS} -V \"${LB_ISO_VOLUME}\""
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -V \"${LB_ISO_VOLUME}\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
LB_PRIMARY_BOOTLOADER=$(echo "${LB_BOOTLOADERS}" | awk -F, '{ print $1 }')
|
||||||
|
|
||||||
# Handle xorriso architecture specific options
|
# Handle xorriso architecture specific options
|
||||||
case "${LB_BOOTLOADER}" in
|
case "${LB_PRIMARY_BOOTLOADER}" in
|
||||||
grub)
|
grub)
|
||||||
XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
|
||||||
XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/grub/stage2_eltorito"
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/grub/stage2_eltorito"
|
||||||
|
@ -149,7 +151,7 @@ esac
|
||||||
# XORRISO_OPTIONS="${XORRISO_OPTIONS} -m ${XORRISO_EXCLUDE}"
|
# XORRISO_OPTIONS="${XORRISO_OPTIONS} -m ${XORRISO_EXCLUDE}"
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
if [ "${LB_BOOTLOADER}" = "grub-pc" ]
|
if [ "${LB_PRIMARY_BOOTLOADER}" = "grub-pc" ]
|
||||||
then
|
then
|
||||||
|
|
||||||
cat > binary.sh << EOF
|
cat > binary.sh << EOF
|
||||||
|
|
|
@ -24,9 +24,23 @@ Arguments "${@}"
|
||||||
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
|
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
|
||||||
Set_defaults
|
Set_defaults
|
||||||
|
|
||||||
if [ "${LB_BOOTLOADER}" != "syslinux" ]
|
FOUND_MYSELF=""
|
||||||
then
|
OLDIFS="$IFS"
|
||||||
exit 0
|
IFS=","
|
||||||
|
for BOOTLOADER in ${LB_BOOTLOADERS}
|
||||||
|
do
|
||||||
|
|
||||||
|
case ${BOOTLOADER} in
|
||||||
|
"syslinux" )
|
||||||
|
FOUND_MYSELF="True"
|
||||||
|
break ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
done
|
||||||
|
IFS="$OLDIFS"
|
||||||
|
|
||||||
|
if [ -z ${FOUND_MYSELF} ] ; then
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
Echo_message "Begin installing syslinux..."
|
Echo_message "Begin installing syslinux..."
|
||||||
|
|
|
@ -32,7 +32,7 @@ USAGE="${PROGRAM} [--apt apt|aptitude]\n\
|
||||||
\t [--bootappend-install PARAMETER|\"PARAMETERS\"]\n\
|
\t [--bootappend-install PARAMETER|\"PARAMETERS\"]\n\
|
||||||
\t [--bootappend-live PARAMETER|\"PARAMETERS\"]\n\
|
\t [--bootappend-live PARAMETER|\"PARAMETERS\"]\n\
|
||||||
\t [--bootappend-live-failsafe PARAMETER|\"PARAMETERS\"]\n\
|
\t [--bootappend-live-failsafe PARAMETER|\"PARAMETERS\"]\n\
|
||||||
\t [--bootloader grub-legacy|grub-pc|syslinux]\n\
|
\t [--bootloaders grub-legacy|grub-pc|syslinux]\n\
|
||||||
\t [--cache true|false]\n\
|
\t [--cache true|false]\n\
|
||||||
\t [--cache-indices true|false]\n\
|
\t [--cache-indices true|false]\n\
|
||||||
\t [--cache-packages true|false]\n\
|
\t [--cache-packages true|false]\n\
|
||||||
|
@ -137,7 +137,7 @@ Local_arguments ()
|
||||||
archive-areas:,parent-archive-areas:,chroot-filesystem:,
|
archive-areas:,parent-archive-areas:,chroot-filesystem:,
|
||||||
gzip-options:,image-name:,interactive:,keyring-packages:,linux-flavours:,linux-packages:,
|
gzip-options:,image-name:,interactive:,keyring-packages:,linux-flavours:,linux-packages:,
|
||||||
security:,updates:,backports:,binary-filesystem:,binary-images:,
|
security:,updates:,backports:,binary-filesystem:,binary-images:,
|
||||||
apt-indices:,bootappend-install:,bootappend-live:,bootappend-live-failsafe:,bootloader:,checksums:,compression:,config:,zsync:,build-with-chroot:,
|
apt-indices:,bootappend-install:,bootappend-live:,bootappend-live-failsafe:,bootloaders:,checksums:,compression:,config:,zsync:,build-with-chroot:,
|
||||||
debian-installer:,debian-installer-distribution:,debian-installer-preseedfile:,debian-installer-gui:,
|
debian-installer:,debian-installer-distribution:,debian-installer-preseedfile:,debian-installer-gui:,
|
||||||
grub-splash:,isohybrid-options:,hdd-label:,hdd-size:,iso-application:,iso-preparer:,iso-publisher:,
|
grub-splash:,isohybrid-options:,hdd-label:,hdd-size:,iso-application:,iso-preparer:,iso-publisher:,
|
||||||
iso-volume:,jffs2-eraseblock:,memtest:,net-root-filesystem:,net-root-mountoptions:,
|
iso-volume:,jffs2-eraseblock:,memtest:,net-root-filesystem:,net-root-mountoptions:,
|
||||||
|
@ -491,8 +491,8 @@ Local_arguments ()
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--bootloader)
|
--bootloaders)
|
||||||
LB_BOOTLOADER="${2}"
|
LB_BOOTLOADERS="${2}"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
@ -1149,9 +1149,9 @@ LB_BOOTAPPEND_INSTALL="${LB_BOOTAPPEND_INSTALL}"
|
||||||
# (Default: empty)
|
# (Default: empty)
|
||||||
LB_BOOTAPPEND_LIVE_FAILSAFE="${LB_BOOTAPPEND_LIVE_FAILSAFE}"
|
LB_BOOTAPPEND_LIVE_FAILSAFE="${LB_BOOTAPPEND_LIVE_FAILSAFE}"
|
||||||
|
|
||||||
# \$LB_BOOTLOADER: set bootloader
|
# \$LB_BOOTLOADERS: set bootloaders
|
||||||
# (Default: ${LB_BOOTLOADER})
|
# (Default: ${LB_BOOTLOADERS})
|
||||||
LB_BOOTLOADER="${LB_BOOTLOADER}"
|
LB_BOOTLOADERS="${LB_BOOTLOADERS}"
|
||||||
|
|
||||||
# \$LB_CHECKSUMS: set checksums
|
# \$LB_CHECKSUMS: set checksums
|
||||||
# (Default: ${LB_CHECKSUMS})
|
# (Default: ${LB_CHECKSUMS})
|
||||||
|
|
|
@ -52,8 +52,15 @@ fi
|
||||||
# Download sources
|
# Download sources
|
||||||
Chroot chroot "dpkg --get-selections" | awk '{ print $1 }' > source-selection.txt
|
Chroot chroot "dpkg --get-selections" | awk '{ print $1 }' > source-selection.txt
|
||||||
|
|
||||||
|
echo "${LB_BOOTLOADERS}" | \
|
||||||
|
while IFS="," read -r BOOTLOADER
|
||||||
|
do
|
||||||
|
cat >> source-selection.txt << EOF
|
||||||
|
${BOOTLOADER}
|
||||||
|
EOF
|
||||||
|
done
|
||||||
|
|
||||||
cat >> source-selection.txt << EOF
|
cat >> source-selection.txt << EOF
|
||||||
${LB_BOOTLOADER}
|
|
||||||
live-build
|
live-build
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue