From 5bfa0c8d2013d075b72907d0a9552877b66c542c Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Fri, 5 Sep 2014 19:24:41 -0700 Subject: [PATCH] build: switch from SYSLINUX to GRUB2 The new grub install script must be called after the image is unmounted and the old bootloaders script doesn't need to touch grub at all. For now we will continue to use the existing syslinux configs but interpreted by grub. Beyond the grub menu flashing by during boot everything should still be functionally equivalent. --- build_library/build_image_util.sh | 12 ++++- build_library/configure_bootloaders.sh | 67 +++++--------------------- build_library/disk_layout.json | 2 +- 3 files changed, 23 insertions(+), 58 deletions(-) diff --git a/build_library/build_image_util.sh b/build_library/build_image_util.sh index b909e1204e..742116e4ac 100755 --- a/build_library/build_image_util.sh +++ b/build_library/build_image_util.sh @@ -204,6 +204,7 @@ finish_image() { local disk_layout="$2" local root_fs_dir="$3" local image_contents="$4" + local install_grub=0 local disk_img="${BUILD_DIR}/${image_name}" @@ -220,10 +221,10 @@ finish_image() { # Only configure bootloaders if there is a boot partition if mountpoint -q "${root_fs_dir}"/boot; then + install_grub=1 ${BUILD_LIBRARY_DIR}/configure_bootloaders.sh \ --arch=${ARCH} \ --disk_layout="${disk_layout}" \ - --disk_image="${disk_img}" \ --boot_dir="${root_fs_dir}"/usr/boot \ --esp_dir="${root_fs_dir}"/boot \ --boot_args="${FLAGS_boot_args}" @@ -249,4 +250,13 @@ finish_image() { rm -rf "${BUILD_DIR}"/configroot cleanup_mounts "${root_fs_dir}" trap - EXIT + + # This script must mount the ESP partition differently, so run it after unmount + if [[ "${install_grub}" -eq 1 ]]; then + local target + for target in i386-pc x86_64-efi; do + ${BUILD_LIBRARY_DIR}/grub_install.sh \ + --target="${target}" --disk_image="${disk_img}" + done + fi } diff --git a/build_library/configure_bootloaders.sh b/build_library/configure_bootloaders.sh index 7458838646..09470c6f53 100755 --- a/build_library/configure_bootloaders.sh +++ b/build_library/configure_bootloaders.sh @@ -24,7 +24,6 @@ DEFINE_string boot_args "" \ "Additional boot arguments to pass to the commandline (Default: '')" DEFINE_string disk_layout "base" \ "The disk layout type to use for this image." -DEFINE_string disk_image "" "The disk image." # Parse flags FLAGS "$@" || exit 1 @@ -52,6 +51,7 @@ SYSLINUX_DIR="${FLAGS_boot_dir}/syslinux" # Build configuration files for pygrub/pvgrub configure_pvgrub() { + info "Installing legacy PV-GRUB configuration" sudo mkdir -p "${GRUB_DIR}" # Add hvc0 for hypervisors @@ -68,18 +68,21 @@ title CoreOS B Root root (hd0,0) kernel /syslinux/vmlinuz.B ${grub_args} ${slot_b_args} EOF - info "Emitted ${GRUB_DIR}/menu.lst.A" sudo_clobber "${GRUB_DIR}/menu.lst.B" <