mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-25 07:31:01 +02:00
build_image: Merge x86 and ARM where possible.
- I looked at all of the x86 and ARM paths through out build image scripts, these changes clean up stale comments, stale code, and unforks some small things. BUG=none TEST=Built images for x86-generic, arm-generic and tegra2-seaboard, booted tegra2-seaboard image. Review URL: http://codereview.chromium.org/3448022 Change-Id: Ibad2774ff2cbf5f15528454506542b87e43e24a2
This commit is contained in:
parent
b5ab343a0d
commit
e3049de00f
@ -86,9 +86,6 @@ DEFINE_integer verity_max_ios 1024 \
|
|||||||
DEFINE_string verity_algorithm "sha1" \
|
DEFINE_string verity_algorithm "sha1" \
|
||||||
"Cryptographic hash algorithm used for kernel vboot."
|
"Cryptographic hash algorithm used for kernel vboot."
|
||||||
|
|
||||||
DEFINE_string arm_extra_bootargs "" \
|
|
||||||
"Additional command line options to pass to the ARM kernel."
|
|
||||||
|
|
||||||
DEFINE_string keys_dir "/usr/share/vboot/devkeys" \
|
DEFINE_string keys_dir "/usr/share/vboot/devkeys" \
|
||||||
"Directory containing the signing keys."
|
"Directory containing the signing keys."
|
||||||
|
|
||||||
@ -199,8 +196,7 @@ make_image_bootable() {
|
|||||||
sudo dd if="${FLAGS_output_dir}/vmlinuz.image" of="${image}" \
|
sudo dd if="${FLAGS_output_dir}/vmlinuz.image" of="${image}" \
|
||||||
conv=notrunc bs=512 seek=${koffset}
|
conv=notrunc bs=512 seek=${koffset}
|
||||||
|
|
||||||
# Update the bootloaders. For legacy/efi x86, the EFI system partition
|
# Update the bootloaders. The EFI system partition will be updated.
|
||||||
# will be updated and for arm, the mbr will be updated (for u-boot).
|
|
||||||
local kernel_part=
|
local kernel_part=
|
||||||
local usb_disk="${FLAGS_usb_disk}"
|
local usb_disk="${FLAGS_usb_disk}"
|
||||||
|
|
||||||
@ -218,17 +214,8 @@ make_image_bootable() {
|
|||||||
# Install syslinux on the EFI System Partition.
|
# Install syslinux on the EFI System Partition.
|
||||||
kernel_part="${kernel_part} --install_syslinux"
|
kernel_part="${kernel_part} --install_syslinux"
|
||||||
elif [[ "${FLAGS_arch}" = "arm" ]]; then
|
elif [[ "${FLAGS_arch}" = "arm" ]]; then
|
||||||
# TODO(wad) mmcblk1p3 is hardcoded for arm for now!
|
# These flags are not used for ARM update_bootloaders.sh
|
||||||
usb_disk="/dev/mmcblk1p3"
|
kernel_part=""
|
||||||
# ARM doesn't support using the kernel image for kernel cmdline flags yet.
|
|
||||||
kernel_part="--kernel_cmdline=\"${FLAGS_arm_extra_bootargs}\" "
|
|
||||||
# TODO(wad) Integrate dmtable extraction into the arm build
|
|
||||||
# E.g. $(cat ${FLAGS_output_dir}/boot.config | tr -s '\n' ' ')"
|
|
||||||
local kpart_offset="--kernel_partition_offset=${koffset}"
|
|
||||||
local kpart_size="--kernel_partition_sectors="
|
|
||||||
kpart_size="${kpart_size}$(partsize ${image} 2)"
|
|
||||||
kernel_part="${kernel_part} ${kpart_size} ${kpart_offset}"
|
|
||||||
info "Using addition bootloader arguments: ${kernel_part}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update partition 12
|
# Update partition 12
|
||||||
|
17
build_gpt.sh
17
build_gpt.sh
@ -21,8 +21,6 @@ DEFINE_string arch "" \
|
|||||||
"The target architecture (\"arm\" or \"x86\")."
|
"The target architecture (\"arm\" or \"x86\")."
|
||||||
DEFINE_string board "$DEFAULT_BOARD" \
|
DEFINE_string board "$DEFAULT_BOARD" \
|
||||||
"The board to build an image for."
|
"The board to build an image for."
|
||||||
DEFINE_string arm_extra_bootargs "" \
|
|
||||||
"Additional command line options to pass to the ARM kernel."
|
|
||||||
DEFINE_integer rootfs_partition_size 1024 \
|
DEFINE_integer rootfs_partition_size 1024 \
|
||||||
"rootfs parition size in MBs."
|
"rootfs parition size in MBs."
|
||||||
|
|
||||||
@ -109,8 +107,7 @@ if [ ! -s ${ESP_IMG} ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# We'll need some code to put in the PMBR, for booting on legacy BIOS. Some ARM
|
# We'll need some code to put in the PMBR, for booting on legacy BIOS.
|
||||||
# systems will use a U-Boot script temporarily, but it goes in the same place.
|
|
||||||
if [[ "$ARCH" = "arm" ]]; then
|
if [[ "$ARCH" = "arm" ]]; then
|
||||||
PMBRCODE=/dev/zero
|
PMBRCODE=/dev/zero
|
||||||
else
|
else
|
||||||
@ -122,18 +119,6 @@ fi
|
|||||||
install_gpt $OUTDEV $(numsectors $ROOTFS_IMG) $(numsectors $STATEFUL_IMG) \
|
install_gpt $OUTDEV $(numsectors $ROOTFS_IMG) $(numsectors $STATEFUL_IMG) \
|
||||||
$PMBRCODE $(numsectors $ESP_IMG) false $FLAGS_rootfs_partition_size
|
$PMBRCODE $(numsectors $ESP_IMG) false $FLAGS_rootfs_partition_size
|
||||||
|
|
||||||
if [[ "$ARCH" = "arm" ]]; then
|
|
||||||
# assume /dev/mmcblk1. we could not get this from ${OUTDEV}
|
|
||||||
DEVICE=1
|
|
||||||
MBR_SCRIPT_UIMG=$(make_arm_mbr \
|
|
||||||
${START_KERN_A} \
|
|
||||||
${NUM_KERN_SECTORS} \
|
|
||||||
${DEVICE} \
|
|
||||||
"${FLAGS_arm_extra_bootargs}")
|
|
||||||
sudo dd bs=1 count=`stat --printf="%s" ${MBR_SCRIPT_UIMG}` \
|
|
||||||
if="$MBR_SCRIPT_UIMG" of=${OUTDEV} conv=notrunc
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Emit helpful scripts for testers, etc.
|
# Emit helpful scripts for testers, etc.
|
||||||
${SCRIPTS_DIR}/emit_gpt_scripts.sh "${OUTDEV}" "${IMAGEDIR}"
|
${SCRIPTS_DIR}/emit_gpt_scripts.sh "${OUTDEV}" "${IMAGEDIR}"
|
||||||
|
|
||||||
|
@ -49,8 +49,6 @@ DEFINE_boolean factory_install ${FLAGS_FALSE} \
|
|||||||
is also required in image_to_usb."
|
is also required in image_to_usb."
|
||||||
DEFINE_boolean dev_install ${FLAGS_FALSE} \
|
DEFINE_boolean dev_install ${FLAGS_FALSE} \
|
||||||
"Build a smaller image to overlay the dev recovery install shim on"
|
"Build a smaller image to overlay the dev recovery install shim on"
|
||||||
DEFINE_string arm_extra_bootargs "" \
|
|
||||||
"Additional command line options to pass to the ARM kernel."
|
|
||||||
DEFINE_integer rootfs_partition_size 1024 \
|
DEFINE_integer rootfs_partition_size 1024 \
|
||||||
"rootfs partition size in MiBs."
|
"rootfs partition size in MiBs."
|
||||||
DEFINE_integer rootfs_size 720 \
|
DEFINE_integer rootfs_size 720 \
|
||||||
@ -360,7 +358,6 @@ create_boot_desc() {
|
|||||||
--verity_algorithm="${FLAGS_verity_algorithm}"
|
--verity_algorithm="${FLAGS_verity_algorithm}"
|
||||||
--keys_dir="${DEVKEYSDIR}"
|
--keys_dir="${DEVKEYSDIR}"
|
||||||
--usb_disk="${FLAGS_usb_disk}"
|
--usb_disk="${FLAGS_usb_disk}"
|
||||||
--arm_extra_bootargs="${FLAGS_arm_extra_bootargs}"
|
|
||||||
--nocleanup_dirs
|
--nocleanup_dirs
|
||||||
${enable_rootfs_verification_flag}
|
${enable_rootfs_verification_flag}
|
||||||
EOF
|
EOF
|
||||||
@ -637,8 +634,7 @@ create_base_image() {
|
|||||||
|
|
||||||
# cros_make_image_bootable will clobber vmlinuz.image for x86.
|
# cros_make_image_bootable will clobber vmlinuz.image for x86.
|
||||||
# Until then, just copy the kernel to vmlinuz.image. It is
|
# Until then, just copy the kernel to vmlinuz.image. It is
|
||||||
# expected in build_gpt.sh and needed by ARM until it supports the
|
# expected in build_gpt.sh.
|
||||||
# full, signed kernel partition format.
|
|
||||||
cp "${ROOT_FS_DIR}/boot/vmlinuz" "${OUTPUT_DIR}/vmlinuz.image"
|
cp "${ROOT_FS_DIR}/boot/vmlinuz" "${OUTPUT_DIR}/vmlinuz.image"
|
||||||
|
|
||||||
# Create an empty esp image to be updated in by update_bootloaders.sh.
|
# Create an empty esp image to be updated in by update_bootloaders.sh.
|
||||||
@ -652,7 +648,6 @@ create_base_image() {
|
|||||||
${SCRIPTS_DIR}/build_gpt.sh \
|
${SCRIPTS_DIR}/build_gpt.sh \
|
||||||
--arch=${ARCH} \
|
--arch=${ARCH} \
|
||||||
--board=${FLAGS_board} \
|
--board=${FLAGS_board} \
|
||||||
--arm_extra_bootargs="${FLAGS_arm_extra_bootargs}" \
|
|
||||||
--rootfs_partition_size=${FLAGS_rootfs_partition_size} \
|
--rootfs_partition_size=${FLAGS_rootfs_partition_size} \
|
||||||
"${OUTPUT_DIR}" \
|
"${OUTPUT_DIR}" \
|
||||||
"${OUTPUT_DIR}/${image_name}"
|
"${OUTPUT_DIR}/${image_name}"
|
||||||
|
@ -26,8 +26,7 @@ fi
|
|||||||
|
|
||||||
info "Creating a new esp image at ${FLAGS_to}" anyway.
|
info "Creating a new esp image at ${FLAGS_to}" anyway.
|
||||||
# Create EFI System Partition to boot stock EFI BIOS (but not ChromeOS EFI
|
# Create EFI System Partition to boot stock EFI BIOS (but not ChromeOS EFI
|
||||||
# BIOS). We only need this for x86, but it's simpler and safer to keep the
|
# BIOS). ARM uses this space to determine which partition is bootable.
|
||||||
# disk images the same for both x86 and ARM.
|
|
||||||
# NOTE: The size argument for mkfs.vfat is in 1024-byte blocks.
|
# NOTE: The size argument for mkfs.vfat is in 1024-byte blocks.
|
||||||
# We'll hard-code it to 16M for now.
|
# We'll hard-code it to 16M for now.
|
||||||
ESP_BLOCKS=16384
|
ESP_BLOCKS=16384
|
||||||
|
@ -243,15 +243,12 @@ then
|
|||||||
echo "Installation must be done from inside the chroot."
|
echo "Installation must be done from inside the chroot."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
#TODO(kwaters): fix when verified root works on ARM
|
|
||||||
[ "${FLAGS_arch}" = "ARM" ] && SKIP_VBLOCK="--skip_vblock"
|
|
||||||
|
|
||||||
echo "Installing ${SRC_IMAGE} to ${FLAGS_to}..."
|
echo "Installing ${SRC_IMAGE} to ${FLAGS_to}..."
|
||||||
"${FLAGS_build_root}/${FLAGS_board}/usr/sbin/chromeos-install" \
|
"${FLAGS_build_root}/${FLAGS_board}/usr/sbin/chromeos-install" \
|
||||||
--yes \
|
--yes \
|
||||||
--skip_src_removable \
|
--skip_src_removable \
|
||||||
--skip_dst_removable \
|
--skip_dst_removable \
|
||||||
${SKIP_VBLOCK:-} \
|
|
||||||
--arch="${FLAGS_arch}" \
|
--arch="${FLAGS_arch}" \
|
||||||
--payload_image="${SRC_IMAGE}" \
|
--payload_image="${SRC_IMAGE}" \
|
||||||
--dst="${FLAGS_to}"
|
--dst="${FLAGS_to}"
|
||||||
|
@ -21,7 +21,7 @@ DEFINE_boolean install_syslinux ${FLAGS_FALSE} \
|
|||||||
DEFINE_string from "/tmp/boot" \
|
DEFINE_string from "/tmp/boot" \
|
||||||
"Path the legacy bootloader templates are copied from. (Default /tmp/boot)"
|
"Path the legacy bootloader templates are copied from. (Default /tmp/boot)"
|
||||||
DEFINE_string to "/tmp/esp.img" \
|
DEFINE_string to "/tmp/esp.img" \
|
||||||
"Path to esp image or ARM output MBR (Default: /tmp/esp.img)"
|
"Path to esp image (Default: /tmp/esp.img)"
|
||||||
DEFINE_integer to_offset 0 \
|
DEFINE_integer to_offset 0 \
|
||||||
"Offset in bytes into 'to' if it is a file (Default: 0)"
|
"Offset in bytes into 'to' if it is a file (Default: 0)"
|
||||||
DEFINE_integer to_size -1 \
|
DEFINE_integer to_size -1 \
|
||||||
@ -39,7 +39,7 @@ DEFINE_string kernel_partition_offset "0" \
|
|||||||
DEFINE_string kernel_partition_sectors "0" \
|
DEFINE_string kernel_partition_sectors "0" \
|
||||||
"Kernel partition sectors (Default: 0)"
|
"Kernel partition sectors (Default: 0)"
|
||||||
DEFINE_string usb_disk /dev/sdb3 \
|
DEFINE_string usb_disk /dev/sdb3 \
|
||||||
"Path syslinux should use to do a usb (or arm!) boot. Default: /dev/sdb3"
|
"Path syslinux should use to do a usb boot. Default: /dev/sdb3"
|
||||||
|
|
||||||
# Parse flags
|
# Parse flags
|
||||||
FLAGS "$@" || exit 1
|
FLAGS "$@" || exit 1
|
||||||
@ -102,8 +102,7 @@ if [[ ! -e "${FLAGS_to}" ]]; then
|
|||||||
# This shouldn't happen.
|
# This shouldn't happen.
|
||||||
info "Creating a new esp image at ${FLAGS_to}" anyway.
|
info "Creating a new esp image at ${FLAGS_to}" anyway.
|
||||||
# Create EFI System Partition to boot stock EFI BIOS (but not ChromeOS EFI
|
# Create EFI System Partition to boot stock EFI BIOS (but not ChromeOS EFI
|
||||||
# BIOS). We only need this for x86, but it's simpler and safer to keep the
|
# BIOS). ARM uses this space to determine which partition is bootable.
|
||||||
# disk images the same for both x86 and ARM.
|
|
||||||
# NOTE: The size argument for mkfs.vfat is in 1024-byte blocks.
|
# NOTE: The size argument for mkfs.vfat is in 1024-byte blocks.
|
||||||
# We'll hard-code it to 16M for now.
|
# We'll hard-code it to 16M for now.
|
||||||
ESP_BLOCKS=16384
|
ESP_BLOCKS=16384
|
||||||
|
Loading…
x
Reference in New Issue
Block a user