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 <cwolfe@chromium.org>
Reviewed-by: Jon Kliegman <kliegs@chromium.org>
Commit-Ready: Chris Wolfe <cwolfe@chromium.org>
This commit is contained in:
Chris Wolfe 2012-01-31 17:38:25 -05:00 committed by Gerrit
parent bcb72afd00
commit fe7aac1f82

View File

@ -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