From 1e4d0c0b3d5d051b15df9fc6814a3220e343e80e Mon Sep 17 00:00:00 2001 From: Rahul Chaturvedi Date: Thu, 20 Oct 2011 16:44:25 +0530 Subject: [PATCH] Add the enable_rootfs_verification flag to cros_download_latest_image. BUG=chromium-os:10993 TEST=Downloaded a latest image via cros_download_latest_image with rootfs verification enabled and disabled; confirmed that the results were as expected. Change-Id: I489a20452bd29ac13fa45fec66214a045086634d Reviewed-on: http://gerrit.chromium.org/gerrit/10405 Reviewed-by: Zelidrag Hornung Commit-Ready: Rahul Chaturvedi Tested-by: Rahul Chaturvedi --- .../cros_download_latest_image | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) rename cros_download_latest_image => bin/cros_download_latest_image (66%) 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