get_latest_image: ignore files when searching for latest images

If files are in the board build dir with newer mtimes than the dirs
or symlinks, then the get_latest_image code selects the file instead
of the latest dir.  And then it all falls down:
	Cannot find image directory /path/to/file

So tweak the look up code by having bash do the expansion of dirs
only, and then let ls do the mtime sorting.

BUG=None
TEST=`./image_to_usb.sh --board=x86-alex -y --to=/dev/sdb` still works after deleting "latest"
Change-Id: Ic06a2ddd0206748d35cb7762009df67a267d4746
Reviewed-on: http://gerrit.chromium.org/gerrit/10258
Reviewed-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Mike Frysinger 2011-10-19 16:52:23 -04:00 committed by Gerrit
parent 6bae49985e
commit c9dfcaf480

View File

@ -50,7 +50,7 @@ IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}"
if [ -L ${IMAGES_DIR}/latest ] ; then
DEFAULT_FROM="${IMAGES_DIR}/`readlink ${IMAGES_DIR}/latest`"
else
DEFAULT_FROM="${IMAGES_DIR}/`ls -t $IMAGES_DIR | head -1`"
DEFAULT_FROM=$(ls -dt "$IMAGES_DIR"/*/ | head -1)
fi
echo $DEFAULT_FROM