From 340f38d014ee10c9e31832526460704c3e360cbb Mon Sep 17 00:00:00 2001 From: Juerg Haefliger Date: Wed, 2 Jul 2014 12:38:37 +0200 Subject: [PATCH] Extend/fix support for extlinux bootloader Some extlinux packages install mbr.bin under /usr/lib/extlinux or /usr/lib/EXTLINUX so tese directories need to be checked as well. Also, there are packages that create a /boot/extlinux directory which needs to be taken into account. Finally, commit bccffc8bfdfea4c452a5558a27f4d16da9cab6c7 dropped the /boot prefix from the kernel and initrd references in the ext/syslinux config file which is simply a bug that needs fixing. Change-Id: Idb071c9b18ff557b0f0f76d0d754536f2deca904 Closes-Bug: 1335042 --- elements/vm/cleanup.d/51-bootloader | 24 +++++++++++++-------- elements/vm/finalise.d/51-bootloader | 31 +++++++++++++++++++++------- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/elements/vm/cleanup.d/51-bootloader b/elements/vm/cleanup.d/51-bootloader index 16514d5c..beb480fa 100755 --- a/elements/vm/cleanup.d/51-bootloader +++ b/elements/vm/cleanup.d/51-bootloader @@ -22,16 +22,22 @@ set -o pipefail source $_LIB/img-functions -# Dig up the initrd and kernel to use. -if [ -d $TARGET_ROOT/boot/syslinux ] ; then - select_boot_kernel_initrd $TARGET_ROOT +if [ -d $TARGET_ROOT/boot/extlinux ] ; then + CONF=$TARGET_ROOT/boot/extlinux/extlinux.conf +elif [ -d $TARGET_ROOT/boot/syslinux ] ; then + CONF=$TARGET_ROOT/boot/syslinux/syslinux.cfg +else + exit 0 +fi - cat > $TARGET_ROOT/boot/syslinux/syslinux.cfg<<_EOF_ +# Dig up the initrd and kernel to use. +select_boot_kernel_initrd $TARGET_ROOT + +sudo sh -c "cat > $CONF <<_EOF_ DEFAULT linux LABEL linux - KERNEL $KERNEL - APPEND ro root=LABEL=cloudimg-rootfs console=tty0 console=ttyS0,115200 - INITRD $RAMDISK -_EOF_ -fi + KERNEL /boot/$KERNEL + APPEND ro root=LABEL=cloudimg-rootfs console=tty0 console=ttyS0,115200 nofb nomodeset vga=normal + INITRD /boot/$RAMDISK +_EOF_" diff --git a/elements/vm/finalise.d/51-bootloader b/elements/vm/finalise.d/51-bootloader index d4771de9..20fc01b9 100755 --- a/elements/vm/finalise.d/51-bootloader +++ b/elements/vm/finalise.d/51-bootloader @@ -16,19 +16,34 @@ function install_extlinux { echo "Installing Extlinux..." - MBR=/usr/share/syslinux/mbr.bin - if [ ! -f $MBR ]; then - MBR=/usr/lib/syslinux/mbr.bin - if [ ! -f $MBR ]; then - echo "mbr.bin (from SYSLINUX) not found." - exit 1 + # Find and install mbr.bin + for MBR in /usr/share/syslinux/mbr.bin /usr/lib/syslinux/mbr.bin \ + /usr/lib/extlinux/mbr.bin /usr/lib/EXTLINUX/mbr.bin ; do + if [ -f $MBR ]; then + break fi + done + if [ ! -f $MBR ]; then + echo "mbr.bin (from EXT/SYSLINUX) not found." + exit 1 fi dd if=$MBR of=$BOOT_DEV - mkdir -p /boot/syslinux - extlinux --install /boot/syslinux + # Find any pre-created extlinux install directory + for EXTDIR in /boot/extlinux /boot/syslinux ; do + if [ -d $EXTDIR ] ; then + break + fi + done + if [ ! -d $EXTDIR ] ; then + # No install directory found so default to /boot/syslinux + EXTDIR=/boot/syslinux + mkdir -p $EXTDIR + fi + + # Finally install extlinux + extlinux --install $EXTDIR } function install_grub2 {