#!/bin/bash # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # Helper script to generate GRUB bootloader configuration files for # x86 platforms. SCRIPT_ROOT=$(readlink -f $(dirname "$0")/..) . "${SCRIPT_ROOT}/common.sh" || exit 1 # We're invoked only by build_image, which runs in the chroot assert_inside_chroot # Flags. DEFINE_string arch "x86" \ "The boot architecture: arm or x86. (Default: x86)" DEFINE_string boot_dir "/tmp/boot" \ "Path to boot directory in root filesystem (Default: /tmp/boot)" DEFINE_string esp_dir "" \ "Path to ESP partition mount point (Default: none)" 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." # Parse flags FLAGS "$@" || exit 1 eval set -- "${FLAGS_ARGV}" switch_to_strict_mode # Common kernel command-line args common_args="console=tty0 ro noswap cros_legacy" common_args="${common_args} ${FLAGS_boot_args}" # Get partition UUIDs from the json config get_uuid() { "${BUILD_LIBRARY_DIR}/disk_util" --disk_layout="${FLAGS_disk_layout}" \ readuuid "$1" } # Filesystem args differ between the old and new usr layouts. if [[ "${FLAGS_disk_layout}" == *-usr ]]; then root_args="root=LABEL=ROOT rootflags=subvol=root" gptprio_args="${root_args} usr=gptprio:" slot_a_args="${root_args} usr=PARTUUID=$(get_uuid USR-A)" slot_b_args="${root_args} usr=PARTUUID=$(get_uuid USR-B)" else gptprio_args="root=gptprio:" slot_a_args="root=PARTUUID=$(get_uuid ROOT-A)" slot_b_args="root=PARTUUID=$(get_uuid ROOT-B)" fi GRUB_DIR="${FLAGS_boot_dir}/grub" SYSLINUX_DIR="${FLAGS_boot_dir}/syslinux" # Build configuration files for pygrub/pvgrub configure_grub() { sudo mkdir -p "${GRUB_DIR}" # Add hvc0 for hypervisors grub_args="${common_args} console=hvc0" sudo_clobber "${GRUB_DIR}/menu.lst.A" <