summaryrefslogtreecommitdiff
path: root/scripts/build/binary_loopback_cfg
diff options
context:
space:
mode:
authorRaphaël Hertzog <hertzog@debian.org>2016-12-02 22:41:55 +0100
committerRaphaël Hertzog <hertzog@debian.org>2016-12-02 23:04:13 +0100
commitf7bb86fd584b0e495ff4c675a60e505af9977036 (patch)
treee039ddeca7b816933fac33fab3e6c8d160b2561c /scripts/build/binary_loopback_cfg
parent9c974b26bf532ba76f6d66423310f6d95b1ff1f7 (diff)
downloadvyos-live-build-f7bb86fd584b0e495ff4c675a60e505af9977036.tar.gz
vyos-live-build-f7bb86fd584b0e495ff4c675a60e505af9977036.zip
Clean up grub configuration code
* Use only long kernel names. * Put advanced options in a submenu. * Use distro-agnostic labels. * Don't generate entries with kernel version when we have a single version.
Diffstat (limited to 'scripts/build/binary_loopback_cfg')
-rwxr-xr-xscripts/build/binary_loopback_cfg213
1 files changed, 71 insertions, 142 deletions
diff --git a/scripts/build/binary_loopback_cfg b/scripts/build/binary_loopback_cfg
index 8a7b41815..d8fa44878 100755
--- a/scripts/build/binary_loopback_cfg
+++ b/scripts/build/binary_loopback_cfg
@@ -64,7 +64,7 @@ Grub_live_entry ()
local INITRD="${3}"
local APPEND="${4}"
- LINUX_LIVE="${LINUX_LIVE}\nmenuentry \"Debian GNU/Linux - ${LABEL}\" {"
+ LINUX_LIVE="${LINUX_LIVE}\nmenuentry \"${LABEL}\" {"
Grub_live_entry_commands "${KERNEL}" "${INITRD}" "${APPEND} findiso=\${iso_path}"
LINUX_LIVE="${LINUX_LIVE}\n}"
}
@@ -72,19 +72,30 @@ Grub_live_entry ()
Grub_install_entry ()
{
LABEL="${1}"
- KERNEL="${2}"
- INITRD="${3}"
- APPEND="${4}"
+ TYPE="${2}"
+ KERNEL="${3}"
+ INITRD="${4}"
+ APPEND="${5}"
- if [ "${LABEL}" != "rescue" ] && [ "${LABEL}" != "rescuegui" ]
+ if [ "${TYPE}" != "rescue" ] && [ "${TYPE}" != "rescuegui" ]
then
APPEND="${APPEND} quiet"
fi
- LINUX_INSTALL="${LINUX_INSTALL}\nmenuentry \"Debian GNU/Linux - ${LABEL}\" {"
- LINUX_INSTALL="${LINUX_INSTALL}\nlinux\t\t/${KERNEL} ${APPEND} LB_BOOTAPPEND_INSTALL"
- LINUX_INSTALL="${LINUX_INSTALL}\ninitrd\t\t/${INITRD}"
- LINUX_INSTALL="${LINUX_INSTALL}\n}"
+ if [ -z "$LINUX_INSTALL" ]; then
+ # First entry recorded in LINUX_INSTALL
+ LINUX_INSTALL="#\t \"Installer\"\n"
+ LINUX_INSTALL="${LINUX_INSTALL}\nmenuentry \"${LABEL}\" {"
+ LINUX_INSTALL="${LINUX_INSTALL}\nlinux\t\t/${KERNEL} ${APPEND} LB_BOOTAPPEND_INSTALL"
+ LINUX_INSTALL="${LINUX_INSTALL}\ninitrd\t\t/${INITRD}"
+ LINUX_INSTALL="${LINUX_INSTALL}\n}"
+ else
+ # Remaining entries recorded in LINUX_ADVANCED_INSTALL
+ LINUX_ADVANCED_INSTALL="${LINUX_ADVANCED_INSTALL}\nmenuentry \"${LABEL}\" {"
+ LINUX_ADVANCED_INSTALL="${LINUX_ADVANCED_INSTALL}\nlinux\t\t/${KERNEL} ${APPEND} LB_BOOTAPPEND_INSTALL"
+ LINUX_ADVANCED_INSTALL="${LINUX_ADVANCED_INSTALL}\ninitrd\t\t/${INITRD}"
+ LINUX_ADVANCED_INSTALL="${LINUX_ADVANCED_INSTALL}\n}"
+ fi
}
Grub_live_autodetect_entry ()
@@ -96,7 +107,7 @@ Grub_live_autodetect_entry ()
local _486_INITRD="${5}"
local APPEND="${6}"
- LINUX_LIVE="${LINUX_LIVE}\nmenuentry \"Debian GNU/Linux - ${LABEL}\" {"
+ LINUX_LIVE="${LINUX_LIVE}\nmenuentry \"${LABEL}\" {"
LINUX_LIVE="${LINUX_LIVE}\nif cpuid -l ; then"
Grub_live_entry_commands "${AMD64_KERNEL}" "${AMD64_INITRD}" "${APPEND} findiso=\${iso_path}"
LINUX_LIVE="${LINUX_LIVE}\nelse"
@@ -200,141 +211,57 @@ fi
LB_BOOTAPPEND_LIVE="$(echo ${LB_BOOTAPPEND_LIVE} | sed -e 's| ||')"
# Assembling kernel configuration
-# If Bootloader is not syslinux that means
-# binary_syslinux it's not going to rename kernel filenames in a later stage.
-# We will use binary_grub2 algorithm which does not rename kernel filenames.
-
-FOUND_SYSLINUX=""
-OLDIFS="$IFS"
-IFS=","
-for BOOTLOADER in ${LB_BOOTLOADERS}
-do
-
- case ${BOOTLOADER} in
- "syslinux" )
- FOUND_SYSLINUX="True"
- break ;;
- esac
+_AMD64_486_NUMBER="0"
+for _FLAVOUR in ${LB_LINUX_FLAVOURS}
+do
+ if [ "${_FLAVOUR}" = "amd64" -o "${_FLAVOUR}" = "486" ] ; then
+ _AMD64_486_NUMBER="$((${_AMD64_486_NUMBER} + 1))"
+ fi
done
-IFS="$OLDIFS"
-
-if [ -z ${FOUND_SYSLINUX} ]
-then
- _AMD64_486_NUMBER="0"
+if [ "${_AMD64_486_NUMBER}" -ge 2 ] ; then
+ # Default entries
+ AMD64_KERNEL="$(basename chroot/boot/vmlinuz-*amd64)"
+ AMD64_INITRD="initrd.img-$(echo ${AMD64_KERNEL} | sed -e 's|vmlinuz-||')"
+ _486_KERNEL="$(basename chroot/boot/vmlinuz-*486)"
+ _486_INITRD="initrd.img-$(echo ${_486_KERNEL} | sed -e 's|vmlinuz-||')"
+
+ Grub_live_autodetect_entry "live (autodetect)" \
+ "${INITFS}/${AMD64_KERNEL}" \
+ "${INITFS}/${AMD64_INITRD}" \
+ "${INITFS}/${_486_KERNEL}" \
+ "${INITFS}/${_486_INITRD}"
+fi
- for _FLAVOUR in ${LB_LINUX_FLAVOURS}
- do
- if [ "${_FLAVOUR}" = "amd64" -o "${_FLAVOUR}" = "486" ] ; then
- _AMD64_486_NUMBER="$((${_AMD64_486_NUMBER} + 1))"
- fi
- done
+# Default entries
+DEFAULT_FLAVOUR="$(echo ${LB_LINUX_FLAVOURS} | awk '{ print $1 }')"
+DEFAULT_KERNEL="$(basename chroot/boot/vmlinuz-*${DEFAULT_FLAVOUR})"
+DEFAULT_INITRD="initrd.img-$(echo ${DEFAULT_KERNEL} | sed -e 's|vmlinuz-||')"
- if [ "${_AMD64_486_NUMBER}" -ge 2 ] ; then
- # Default entries
- AMD64_KERNEL="$(basename chroot/boot/vmlinuz-*amd64)"
- AMD64_INITRD="initrd.img-$(echo ${AMD64_KERNEL} | sed -e 's|vmlinuz-||')"
- _486_KERNEL="$(basename chroot/boot/vmlinuz-*486)"
- _486_INITRD="initrd.img-$(echo ${_486_KERNEL} | sed -e 's|vmlinuz-||')"
-
- Grub_live_autodetect_entry "live (autodetect)" \
- "${INITFS}/${AMD64_KERNEL}" \
- "${INITFS}/${AMD64_INITRD}" \
- "${INITFS}/${_486_KERNEL}" \
- "${INITFS}/${_486_INITRD}"
- fi
+Grub_live_entry "Boot live system" "${INITFS}/${DEFAULT_KERNEL}" "${INITFS}/${DEFAULT_INITRD}"
- # Default entries
- DEFAULT_FLAVOUR="$(echo ${LB_LINUX_FLAVOURS} | awk '{ print $1 }')"
- DEFAULT_KERNEL="$(basename chroot/boot/vmlinuz-*${DEFAULT_FLAVOUR})"
- DEFAULT_INITRD="initrd.img-$(echo ${DEFAULT_KERNEL} | sed -e 's|vmlinuz-||')"
-
- Grub_live_entry "live" "${INITFS}/${DEFAULT_KERNEL}" "${INITFS}/${DEFAULT_INITRD}"
+if [ "${LB_BOOTAPPEND_FAILSAFE}" != "none" ]
+then
+ Grub_live_entry "Boot live system (fail-safe mode)" "${INITFS}/${DEFAULT_KERNEL}" "${INITFS}/${DEFAULT_INITRD}" "${LB_BOOTAPPEND_FAILSAFE}"
+fi
- if [ "${LB_BOOTAPPEND_FAILSAFE}" != "none" ]
- then
- Grub_live_entry "live (fail-safe mode)" "${INITFS}/${DEFAULT_KERNEL}" "${INITFS}/${DEFAULT_INITRD}" "${LB_BOOTAPPEND_FAILSAFE}"
- fi
+_COUNT=0
+for KERNEL in chroot/boot/vmlinuz-*; do
+ _COUNT=$(( $COUNT + 1 ))
+done
+if [ $_COUNT -gt 1 ]; then
for KERNEL in chroot/boot/vmlinuz-*
do
VERSION="$(basename ${KERNEL} | sed -e 's|vmlinuz-||')"
- Grub_live_entry "live, kernel ${VERSION}" "${INITFS}/$(basename ${KERNEL})" "${INITFS}/initrd.img-${VERSION}"
- Grub_live_entry "live, kernel ${VERSION} (fail-safe mode)" "${INITFS}/$(basename ${KERNEL})" "${INITFS}/initrd.img-${VERSION}" "${LB_BOOTAPPEND_FAILSAFE}"
- done
-else # LB_BOOTLOADERS does not contain syslinux
-# If one of the bootloader is syslinux that means
-# binary_syslinux it's going to rename kernel filenames.
-# We will use binary_syslinux algorithm but without renaming kernel filenames.
-# That will ensure binary_syslinux will find the original kernel filenames.
- #if [ -e "${_TARGET}/live.cfg.in" ]
- #then
- # This is all rather suboptimal.. needs prettifying at some point
- _FLAVOURS="$(echo ${LB_LINUX_FLAVOURS} | wc -w)"
-
- case "${_FLAVOURS}" in
- 1)
- Grub_live_entry "live (${LB_LINUX_FLAVOURS})" "${INITFS}/vmlinuz" "${INITFS}/initrd.img" "${LB_BOOTAPPEND_LIVE}"
- Grub_live_entry "live (${LB_LINUX_FLAVOURS}) (failsafe mode)" "${INITFS}/vmlinuz" "${INITFS}/initrd.img" "${LB_BOOTAPPEND_LIVE_FAILSAFE}"
- ;;
-
- *)
- _AMD64_486_NUMBER="0"
-
- for _FLAVOUR in ${LB_LINUX_FLAVOURS}
- do
- if [ "${_FLAVOUR}" = "amd64" -o "${_FLAVOUR}" = "486" ] ; then
- _AMD64_486_NUMBER="$((${_AMD64_486_NUMBER} + 1))"
- fi
- done
-
- _NUMBER="0"
- for _FLAVOUR in ${LB_LINUX_FLAVOURS}
- do
- _NUMBER="$((${_NUMBER} + 1))"
- if [ "${_FLAVOUR}" = "amd64" ] ; then
- AMD64_KERNEL="vmlinuz${_NUMBER}"
- AMD64_INITRD="initrd${_NUMBER}.img"
- fi
-
- if [ "${_FLAVOUR}" = "486" ] ; then
- _486_KERNEL="vmlinuz${_NUMBER}"
- _486_INITRD="initrd${_NUMBER}.img"
- fi
- done
-
- _NUMBER="0"
-
- for _FLAVOUR in ${LB_LINUX_FLAVOURS}
- do
- _NUMBER="$((${_NUMBER} + 1))"
-
- if [ "${_NUMBER}" -gt 1 ]
- then
- Grub_live_entry "live (${_FLAVOUR})" "${INITFS}/vmlinuz${_NUMBER}" "${INITFS}/initrd${_NUMBER}.img" "${LB_BOOTAPPEND_LIVE}"
- Grub_live_entry "live (${_FLAVOUR}) (failsafe mode)" "${INITFS}/vmlinuz${_NUMBER}" "${INITFS}/initrd${_NUMBER}.img" "${LB_BOOTAPPEND_LIVE_FAILSAFE}"
-
- else
- if [ "${_AMD64_486_NUMBER}" -ge 2 ] ; then
-
- Grub_live_autodetect_entry "live (autodetect)" \
- "${INITFS}/${AMD64_KERNEL}" \
- "${INITFS}/${AMD64_INITRD}" \
- "${INITFS}/${_486_KERNEL}" \
- "${INITFS}/${_486_INITRD}"
- fi
-
- Grub_live_entry "live (${_FLAVOUR})" "${INITFS}/vmlinuz${_NUMBER}" "${INITFS}/initrd${_NUMBER}.img" "${LB_BOOTAPPEND_LIVE}"
- Grub_live_entry "live (${_FLAVOUR}) (failsafe mode)" "${INITFS}/vmlinuz${_NUMBER}" "${INITFS}/initrd${_NUMBER}.img" "${LB_BOOTAPPEND_LIVE_FAILSAFE}"
- fi
-
- done
+ Grub_live_entry "Boot live system, kernel ${VERSION}" "${INITFS}/$(basename ${KERNEL})" "${INITFS}/initrd.img-${VERSION}"
- ;;
- esac
- #fi
+ if [ "${LB_BOOTAPPEND_FAILSAFE}" != "none" ]; then
+ Grub_live_entry "Boot live system, kernel ${VERSION} (fail-safe mode)" "${INITFS}/$(basename ${KERNEL})" "${INITFS}/initrd.img-${VERSION}" "${LB_BOOTAPPEND_FAILSAFE}"
+ fi
+ done
fi
LINUX_LIVE="$(/bin/echo ${LINUX_LIVE} | sed -e 's|binary||g' -e 's|//|/|g')"
@@ -342,7 +269,6 @@ LINUX_LIVE="$(/bin/echo ${LINUX_LIVE} | sed -e 's|binary||g' -e 's|//|/|g')"
if [ "${LB_DEBIAN_INSTALLER}" != "false" ]
then
LINUX_LIVE="#\t \"Live\"\n${LINUX_LIVE}"
- LINUX_INSTALL="#\t \"Installer\"\n"
VMLINUZ_DI="install/vmlinuz"
INITRD_DI="install/initrd.gz"
@@ -352,17 +278,20 @@ then
INITRD_GI="install/gtk/initrd.gz"
APPEND_GI="video=vesa:ywrap,mtrr vga=788"
- Grub_install_entry "install" "${VMLINUZ_DI}" "${INITRD_DI}" "${APPEND_DI}"
- Grub_install_entry "installgui" "${VMLINUZ_GI}" "${INITRD_GI}" "${APPEND_GI}"
- Grub_install_entry "expert" "${VMLINUZ_DI}" "${INITRD_DI}" "priority=low ${APPEND_DI}"
- Grub_install_entry "expertgui" "${VMLINUZ_GI}" "${INITRD_GI}" "priority=low ${APPEND_GI}"
- Grub_install_entry "rescue" "${VMLINUZ_DI}" "${INITRD_DI}" "rescue/enable=true ${APPEND_DI}"
- Grub_install_entry "rescuegui" "${VMLINUZ_GI}" "${INITRD_GI}" "rescue/enable=true ${APPEND_GI}"
- Grub_install_entry "auto" "${VMLINUZ_DI}" "${INITRD_DI}" "auto=true priority=critical ${APPEND_DI}"
- Grub_install_entry "autogui" "${VMLINUZ_GI}" "${INITRD_GI}" "auto=true priority=critical ${APPEND_GI}"
+ Grub_install_entry "Start installer" "installgui" "${VMLINUZ_GI}" "${INITRD_GI}" "${APPEND_GI}"
+
+ Grub_install_entry "Install in graphical mode" "installgui" "${VMLINUZ_GI}" "${INITRD_GI}" "${APPEND_GI}"
+ Grub_install_entry "Install in text mode" "install" "${VMLINUZ_DI}" "${INITRD_DI}" "${APPEND_DI}"
+ Grub_install_entry "Expert install in graphical mode" "expertgui" "${VMLINUZ_GI}" "${INITRD_GI}" "priority=low ${APPEND_GI}"
+ Grub_install_entry "Expert install in text mode" "expert" "${VMLINUZ_DI}" "${INITRD_DI}" "priority=low ${APPEND_DI}"
+ Grub_install_entry "Automatic install in graphical mode" "autogui" "${VMLINUZ_GI}" "${INITRD_GI}" "auto=true priority=critical ${APPEND_GI}"
+ Grub_install_entry "Automatic install in text mode" "auto" "${VMLINUZ_DI}" "${INITRD_DI}" "auto=true priority=critical ${APPEND_DI}"
+ Grub_install_entry "Rescue system in graphical mode" "rescuegui" "${VMLINUZ_GI}" "${INITRD_GI}" "rescue/enable=true ${APPEND_GI}"
+ Grub_install_entry "Rescue system in text mode" "rescue" "${VMLINUZ_DI}" "${INITRD_DI}" "rescue/enable=true ${APPEND_DI}"
fi
LINUX_INSTALL="$(/bin/echo ${LINUX_INSTALL} | sed -e 's|binary||g' -e 's|//|/|g')"
+LINUX_ADVANCED_INSTALL="$(/bin/echo ${LINUX_ADVANCED_INSTALL} | sed -e 's|binary||g' -e 's|//|/|g')"
# Assembling memtest configuration
if [ -f "${DESTDIR_LIVE}"/memtest ]
@@ -376,7 +305,7 @@ fi
mkdir -p binary/boot/grub
cp -a "${_SOURCE}"/* binary/boot/grub/
-sed -i -e "s|LINUX_LIVE|${LINUX_LIVE}|" -e "s|LINUX_INSTALL|${LINUX_INSTALL}|" -e "s|MEMTEST|${MEMTEST}|" binary/boot/grub/*.cfg
+sed -i -e "s|LINUX_LIVE|${LINUX_LIVE}|" -e "s|LINUX_ADVANCED_INSTALL|${LINUX_ADVANCED_INSTALL}|" -e "s|LINUX_INSTALL|${LINUX_INSTALL}|" -e "s|MEMTEST|${MEMTEST}|" binary/boot/grub/*.cfg
sed -i -e "s#LB_BOOTAPPEND_INSTALL#${LB_BOOTAPPEND_INSTALL}#" -e "s#LB_BOOTAPPEND_LIVE#${LB_BOOTAPPEND_LIVE}#" binary/boot/grub/*.cfg
sed -i -e 's|\ $||g' binary/boot/grub/*.cfg