diff --git a/cros_download_latest_image b/bin/cros_download_latest_image similarity index 66% rename from cros_download_latest_image rename to bin/cros_download_latest_image index 716aae1d85..afaea78f67 100755 --- a/cros_download_latest_image +++ b/bin/cros_download_latest_image @@ -33,6 +33,8 @@ get_default_board DEFINE_string board "$DEFAULT_BOARD" \ "The name of the board to check for images." DEFINE_boolean incremental "$FLAGS_FALSE" "Download incremental build" +DEFINE_boolean enable_rootfs_verification "${FLAGS_TRUE}" \ + "Enable rootfs verification for the downloaded image." # Parse command line flags. FLAGS "$@" || exit 1 @@ -66,5 +68,30 @@ if [ ! -e $LATEST_IMAGE_DIR/chromiumos_base_image.bin ]; then || die "Could not unzip image.zip" fi +IMAGE_NAME=chromiumos_qemu_image.bin +IMAGE_FILE="${LATEST_IMAGE_DIR}"/"${IMAGE_NAME}" +ESP_DIR="${LATEST_IMAGE_DIR}/esp" + +cleanup() { + "$SCRIPTS_DIR/mount_gpt_image.sh" -u -e "${ESP_DIR}" +} + +# This might seem a bit strange, but rootfs verification is already on with the +# image, the only reason we've named this flag 'enable_rootfs_verfication' +# versus 'disable_xyz' is to stay constant with the +# 'noenable_rootfs_verification' flag used in build image to disable it. +if [ "${FLAGS_enable_rootfs_verification}" -eq "${FLAGS_FALSE}" ] ; then + trap cleanup INT TERM EXIT + # We only need to touch the ESP part + "$SCRIPTS_DIR/mount_gpt_image.sh" -i chromiumos_qemu_image.bin \ + -f "${LATEST_IMAGE_DIR}" -e "${ESP_DIR}" + + # Change the default to boot from the usb instead of vusb, usb is set + # to boot from /dev/sda + sudo sed -i -e 's/vusb/usb/g' "${ESP_DIR}/syslinux/default.cfg" + + sync; sync +fi + echo $LATEST_IMAGE_DIR exit 0