Index: mod_image_for_test.sh |
diff --git a/mod_image_for_test.sh b/mod_image_for_test.sh |
index 97aa5e0cc7c3dddd686a04d84b1b4d63cb853490..325c7300876bca27d585945d19db09e58be3d82d 100755 |
--- a/mod_image_for_test.sh |
+++ b/mod_image_for_test.sh |
@@ -33,6 +33,12 @@ DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" y |
DEFINE_string build_root "/build" \ |
"The root location for board sysroots." |
DEFINE_boolean fast ${DEFAULT_FAST} "Call many emerges in parallel" |
+DEFINE_boolean inplace $FLAGS_TRUE \ |
sjg
2010/11/30 21:07:29
I used 'inplace' since possibly this could become
|
+ "Modify/overwrite the image ${CHROMEOS_IMAGE_NAME} in place. \ |
+Otherwise the image will be copied to ${CHROMEOS_TEST_IMAGE_NAME} \ |
+if needed, and modified there" o |
sosa
2010/11/30 22:01:43
Short var doesn't really help here?
sjg
2010/12/01 20:02:31
Yes have r3emoved it.
|
+DEFINE_boolean force_copy ${FLAGS_FALSE} \ |
sosa
2010/11/30 22:01:43
Use exact def ... i.e. always rebuild test image i
|
+ "If --noinplace, always copy test image" |
# Parse command line |
@@ -56,7 +62,7 @@ fi |
# We have a board name but no image set. Use image at default location |
if [ -z $FLAGS_image ] ; then |
IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" |
- FILENAME="chromiumos_image.bin" |
+ FILENAME="${CHROMEOS_IMAGE_NAME}" |
FLAGS_image="${IMAGES_DIR}/$(ls -t $IMAGES_DIR 2>&-| head -1)/${FILENAME}" |
fi |
@@ -155,6 +161,25 @@ install_autotest() { |
# main process begins here. |
+IMAGE_DIR="$(dirname "$FLAGS_image")" |
sosa
2010/11/30 22:01:43
{}
|
+ |
+# Copy the image to a test location if required |
+if [ $FLAGS_inplace -eq $FLAGS_FALSE ]; then |
sosa
2010/11/30 22:01:43
be consistent with use of {}
|
+ TEST_PATHNAME="${IMAGE_DIR}/${CHROMEOS_TEST_IMAGE_NAME}" |
+ if [ ! -f "${TEST_PATHNAME}" ] || \ |
+ [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ] ; then |
+ echo "Creating test image from original..." |
+ $PV_CAT "${FLAGS_image}" >"$TEST_PATHNAME" \ |
+ || die "Cannot copy ${FLAGS_image} to test image" |
+ FLAGS_image="${TEST_PATHNAME}" |
+ else |
+ echo "Using cached test image" |
+ fi |
+ |
+ # No need to confirm now, since we are not overwriting the main image |
+ FLAGS_yes="$FLAGS_TRUE" |
+fi |
+ |
# Make sure this is really what the user wants, before nuking the device |
if [ $FLAGS_yes -ne $FLAGS_TRUE ]; then |
read -p "Modifying image ${FLAGS_image} for test; are you sure (y/N)? " SURE |