Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Unified Diff: mod_image_for_test.sh

Issue 5271010: Factored out the code to copy an image and modify it for test (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git@master
Patch Set: Changes as suggested Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« image_to_usb.sh ('K') | « image_to_vm.sh ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mod_image_for_test.sh
diff --git a/mod_image_for_test.sh b/mod_image_for_test.sh
index 97aa5e0cc7c3dddd686a04d84b1b4d63cb853490..52bd99d3a70e51370c5a71f3972b6d9b0a3c0ac4 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 \
+ "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"
+DEFINE_boolean force_copy ${FLAGS_FALSE} \
+ "Always rebuild test image if --noinplace"
# 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}")"
+
+# Copy the image to a test location if required
+if [ ${FLAGS_inplace} -eq ${FLAGS_FALSE} ]; then
+ 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..."
+ ${COMMON_PV_CAT} "${FLAGS_image}" >"${TEST_PATHNAME}" \
+ || die "Cannot copy ${FLAGS_image} to test image"
+ FLAGS_image="${TEST_PATHNAME}"
+ else
+ echo "Using cached test image"
sosa 2010/12/01 20:37:45 Don't you have to set FLAGS_image here too? Might
sjg 2010/12/01 20:54:00 Actually it is a flag, and is set further up the f
+ 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
« image_to_usb.sh ('K') | « image_to_vm.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698