From fe7aac1f82856d581b261a585fdc1c78b729d4b5 Mon Sep 17 00:00:00 2001 From: Chris Wolfe Date: Tue, 31 Jan 2012 17:38:25 -0500 Subject: [PATCH] image_to_usb: Add error for missing image Add a clearer error message if the source image was not found. This can occur if the --from directory exists, but the selected image within it does not. An easy case is --from'ing a directory from a chromeos-images zip. Previously image_to_usb would copy zero bytes and return success. BUG=None TEST=Ran image_to_usb.sh for default, directory and .bin --froms. Change-Id: I826f2bbc8effd9554f558e517b51cc03b4f832d5 Reviewed-on: https://gerrit.chromium.org/gerrit/15120 Tested-by: Chris Wolfe Reviewed-by: Jon Kliegman Commit-Ready: Chris Wolfe --- image_to_usb.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/image_to_usb.sh b/image_to_usb.sh index eea95f296a..b1e79c236d 100755 --- a/image_to_usb.sh +++ b/image_to_usb.sh @@ -216,6 +216,12 @@ else SRC_IMAGE="${FLAGS_from}/${FLAGS_image_name}" fi +if [ ! -f "${SRC_IMAGE}" ]; then + echo "Could not find the source image:" + echo " ${SRC_IMAGE}" + exit 1 +fi + # Let's do it. if [ -b "${FLAGS_to}" ]; then # Output to a block device (i.e., a real USB key / SD card), so need sudo dd