From 6e448ae31a2740d8dc3e49a5ebbea6f39d9e9735 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 3 Mar 2011 11:20:54 -0800 Subject: [PATCH] Select factory image when --factory is given prepare_test_image would prepare the correct image (test or factory) but its return value would always specify the test image. This meant that image_to_usb.sh would pick up the wrong image. This commit fixes this. BUG=chromium-os:12377 TEST=./image_to_usb --from=... --to=/dev/sdb also with --factory also with --test Make sure it picks up the correct image in each case. Change-Id: I165b604b448a6c938a47e57a667bd5f001626efe Review URL: http://codereview.chromium.org/6609016 --- common.sh | 6 +++++- mod_image_for_test.sh | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/common.sh b/common.sh index 09094a8bc8..18e04cdd9a 100644 --- a/common.sh +++ b/common.sh @@ -645,7 +645,11 @@ prepare_test_image() { --image="$1/$2" --noinplace ${args} # From now on we use the just-created test image - CHROMEOS_RETURN_VAL="$1/${CHROMEOS_TEST_IMAGE_NAME}" + if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then + CHROMEOS_RETURN_VAL="$1/${CHROMEOS_FACTORY_TEST_IMAGE_NAME}" + else + CHROMEOS_RETURN_VAL="$1/${CHROMEOS_TEST_IMAGE_NAME}" + fi } # Check that the specified file exists. If the file path is empty or the file diff --git a/mod_image_for_test.sh b/mod_image_for_test.sh index 822a293262..769941850b 100755 --- a/mod_image_for_test.sh +++ b/mod_image_for_test.sh @@ -178,8 +178,10 @@ IMAGE_DIR="$(dirname "${FLAGS_image}")" if [ ${FLAGS_inplace} -eq ${FLAGS_FALSE} ]; then if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then TEST_PATHNAME="${IMAGE_DIR}/${CHROMEOS_FACTORY_TEST_IMAGE_NAME}" + typename="factory" else TEST_PATHNAME="${IMAGE_DIR}/${CHROMEOS_TEST_IMAGE_NAME}" + typename="test" fi if [ ! -f "${TEST_PATHNAME}" ] || \ [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ] ; then @@ -188,7 +190,7 @@ if [ ${FLAGS_inplace} -eq ${FLAGS_FALSE} ]; then || die "Cannot copy ${FLAGS_image} to test image" FLAGS_image="${TEST_PATHNAME}" else - echo "Using cached test image" + echo "Using cached ${typename} image" exit fi