Added new multi bootloader helper functions
* Added: functions/bootloaders.sh . This file adds bootloader functions that are heavily used in efi scenarios where a bootloader can act as a first or an extra bootloader. Since the introduction of the new switch: --bootloaders you can setup it like this: --bootloaders=syslinux,grub-efi . This means that syslinux is the first bootloader and grub-efi is the extra bootloader. * Added new bootloader functions: Check_Non_First_Bootloader and Check_Non_Extra_Bootloader. These functions let each one of the bootloaders abort the build because they cannot perform a role either as a first bootloader or as an extra bootloader. * Added bootloader functions: Check_First_Bootloader_Role, Check_Extra_Bootloader_Role and Check_Any_Bootloader_Role These functions let bootloaders to force their default role in a single line. At the same time many binary bootloaders were rewritten to make use of the new bootloader role functions explained above. These roles were enforced: binary_grub-legacy : First bootloader binary_grub-pc : Either first or extra bootloader binary_syslinux : Either first or extra bootloader If a bootloader is tried to be used in a role that it's not meant to be used then the build fails because that might lead to a non-bootable system.
This commit is contained in:
parent
0624064d44
commit
9d1a983cc8
|
@ -0,0 +1,128 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
## live-build(7) - System Build Scripts
|
||||||
|
## Copyright (C) 2016 Adrian Gibanel Lopez <adrian15sgd@gmail.com>
|
||||||
|
##
|
||||||
|
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
|
||||||
|
## 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 ()
|
||||||
|
{
|
||||||
|
EVAL_BOOTLOADER="${1}"
|
||||||
|
OLDIFS="$IFS"
|
||||||
|
IFS=","
|
||||||
|
for BOOTLOADER in ${LB_BOOTLOADERS}
|
||||||
|
do
|
||||||
|
if [ "${BOOTLOADER}" = "${EVAL_BOOTLOADER}" ]
|
||||||
|
then
|
||||||
|
IFS="$OLDIFS"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
IFS="$OLDIFS"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Is_Extra_Bootloader ()
|
||||||
|
{
|
||||||
|
EVAL_EXTRA_BOOTLOADER="${1}"
|
||||||
|
|
||||||
|
if Is_First_Bootloader "${EVAL_EXTRA_BOOTLOADER}"
|
||||||
|
then
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
if Is_Bootloader "${EVAL_EXTRA_BOOTLOADER}"
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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."
|
||||||
|
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."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
Check_First_Bootloader_Role ()
|
||||||
|
{
|
||||||
|
FIRST_BOOTLOADER_ROLE="${1}"
|
||||||
|
Check_Non_Extra_Bootloader "${FIRST_BOOTLOADER_ROLE}"
|
||||||
|
|
||||||
|
if Is_First_Bootloader "${FIRST_BOOTLOADER_ROLE}"
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Check_Extra_Bootloader_Role ()
|
||||||
|
{
|
||||||
|
EXTRA_BOOTLOADER_ROLE="${1}"
|
||||||
|
Check_Non_First_Bootloader "${EXTRA_BOOTLOADER_ROLE}"
|
||||||
|
|
||||||
|
if Is_Extra_Bootloader "${EXTRA_BOOTLOADER_ROLE}"
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
}
|
|
@ -537,7 +537,7 @@ Set_defaults ()
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LB_PRIMARY_BOOTLOADER=$(echo "${LB_BOOTLOADERS}" | awk -F, '{ print $1 }')
|
LB_FIRST_BOOTLOADER=$(echo "${LB_BOOTLOADERS}" | awk -F, '{ print $1 }')
|
||||||
|
|
||||||
# Setting checksums
|
# Setting checksums
|
||||||
case "${LB_MODE}" in
|
case "${LB_MODE}" in
|
||||||
|
@ -847,7 +847,7 @@ Check_defaults ()
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${LB_PRIMARY_BOOTLOADER}" = "syslinux" ]
|
if [ "${LB_FIRST_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
|
||||||
|
@ -861,7 +861,7 @@ Check_defaults ()
|
||||||
|
|
||||||
case "${LIVE_IMAGE_TYPE}" in
|
case "${LIVE_IMAGE_TYPE}" in
|
||||||
hdd*)
|
hdd*)
|
||||||
case "${LB_PRIMARY_BOOTLOADER}" in
|
case "${LB_FIRST_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,22 +24,7 @@ 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
|
||||||
|
|
||||||
FOUND_MYSELF=""
|
Check_First_Bootloader_Role "grub-legacy"
|
||||||
IFS=","
|
|
||||||
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
|
|
||||||
|
|
||||||
Echo_message "Begin installing grub-legacy..."
|
Echo_message "Begin installing grub-legacy..."
|
||||||
|
|
||||||
|
|
|
@ -24,24 +24,7 @@ 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
|
||||||
|
|
||||||
FOUND_MYSELF=""
|
Check_Any_Bootloader_Role "grub-pc"
|
||||||
OLDIFS="$IFS"
|
|
||||||
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
|
|
||||||
|
|
||||||
Echo_message "Begin installing grub-pc..."
|
Echo_message "Begin installing grub-pc..."
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
case ${LB_PRIMARY_BOOTLOADER} in
|
case ${LB_FIRST_BOOTLOADER} in
|
||||||
syslinux)
|
syslinux)
|
||||||
case ${LB_BINARY_FILESYSTEM} in
|
case ${LB_BINARY_FILESYSTEM} in
|
||||||
fat*|ntfs)
|
fat*|ntfs)
|
||||||
|
@ -182,7 +182,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_PRIMARY_BOOTLOADER}" = "syslinux" ]
|
if [ "${LB_FIRST_BOOTLOADER}" = "syslinux" ]
|
||||||
then
|
then
|
||||||
dd if=chroot/usr/lib/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z])/mbr.bin of=${FREELO} bs=440 count=1
|
dd if=chroot/usr/lib/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z])/mbr.bin of=${FREELO} bs=440 count=1
|
||||||
fi
|
fi
|
||||||
|
@ -202,7 +202,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_PRIMARY_BOOTLOADER}" = "syslinux" ]
|
if [ "${LB_FIRST_BOOTLOADER}" = "syslinux" ]
|
||||||
then
|
then
|
||||||
dd if=/usr/lib/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z])/mbr.bin of=${FREELO} bs=440 count=1
|
dd if=/usr/lib/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z])/mbr.bin of=${FREELO} bs=440 count=1
|
||||||
fi
|
fi
|
||||||
|
@ -268,7 +268,7 @@ cp -T ${CP_OPTIONS} binary/ chroot/binary.tmp
|
||||||
|
|
||||||
FIXME()
|
FIXME()
|
||||||
{
|
{
|
||||||
if [ "${LB_PRIMARY_BOOTLOADER}" = "grub" ]
|
if [ "${LB_FIRST_BOOTLOADER}" = "grub" ]
|
||||||
then
|
then
|
||||||
|
|
||||||
cat > chroot/grub.sh << EOF
|
cat > chroot/grub.sh << EOF
|
||||||
|
|
|
@ -149,7 +149,7 @@ esac
|
||||||
# XORRISO_OPTIONS="${XORRISO_OPTIONS} -m ${XORRISO_EXCLUDE}"
|
# XORRISO_OPTIONS="${XORRISO_OPTIONS} -m ${XORRISO_EXCLUDE}"
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
if [ "${LB_PRIMARY_BOOTLOADER}" = "grub-pc" ]
|
if [ "${LB_FIRST_BOOTLOADER}" = "grub-pc" ]
|
||||||
then
|
then
|
||||||
|
|
||||||
cat > binary.sh << EOF
|
cat > binary.sh << EOF
|
||||||
|
|
|
@ -24,24 +24,7 @@ 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
|
||||||
|
|
||||||
FOUND_MYSELF=""
|
Check_Any_Bootloader_Role "syslinux"
|
||||||
OLDIFS="$IFS"
|
|
||||||
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
|
|
||||||
|
|
||||||
Echo_message "Begin installing syslinux..."
|
Echo_message "Begin installing syslinux..."
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue