From c9dfcaf48081be1d9127bbf2e8d34ddcd7a23576 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 19 Oct 2011 16:52:23 -0400 Subject: [PATCH] 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 Reviewed-by: David James Tested-by: Mike Frysinger Commit-Ready: Mike Frysinger --- get_latest_image.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get_latest_image.sh b/get_latest_image.sh index 6038fc88d5..1044caaf88 100755 --- a/get_latest_image.sh +++ b/get_latest_image.sh @@ -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