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

Unified Diff: common.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
« no previous file with comments | « no previous file | image_to_usb.sh » ('j') | image_to_usb.sh » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common.sh
diff --git a/common.sh b/common.sh
index b7d428dab5bcca65bb2f042eb2aa63acea944761..4b30149a2050e4bddb79a107b264de4a64a16c0f 100644
--- a/common.sh
+++ b/common.sh
@@ -14,6 +14,14 @@
# and dpkg-buildpackage
NUM_JOBS=`grep -c "^processor" /proc/cpuinfo`
+# True if we have the 'pv' utility - also set up COMMON_PV_CAT for convenience
+COMMON_PV_OK=1
+COMMON_PV_CAT=pv
+pv -V >/dev/null 2>&1 || COMMON_PV_OK=0
+if [ $COMMON_PV_OK -eq 0 ]; then
+ COMMON_PV_CAT=cat
+fi
+
# Store location of the calling script.
TOP_SCRIPT_DIR="${TOP_SCRIPT_DIR:-$(dirname $0)}"
@@ -127,6 +135,12 @@ else
INSIDE_CHROOT=0
fi
+
+# Standard filenames
+CHROMEOS_IMAGE_NAME="chromiumos_image.bin"
+CHROMEOS_TEST_IMAGE_NAME="chromiumos_test_image.bin"
+
+
# Directory locations inside the dev chroot
CHROOT_TRUNK_DIR="/home/$USER/trunk"
@@ -526,3 +540,45 @@ chroot_hacks_from_outside() {
sudo bash -c "echo root ALL=\(ALL\) ALL >> \"${chroot_dir}/etc/sudoers\""
fi
}
+
+# This function converts a chromiumos image into a test image, either
+# in place or by copying to a new test image filename first. It honors
+# the following flags (see mod_image_for_test.sh)
+#
+# --factory
+# --factory_install
+# --force_copy
+#
+# On entry, pass the image pathname to modify
+# On exit, it echoes the pathname of the resulting test image
+#
+# Usage:
+# SRC_IMAGE=$(prepare_test_image "/path/to/image")
sosa 2010/12/01 20:37:45 Dcoument both $1 and $2 ... i only see $1 specifie
+
sosa 2010/12/01 20:37:45 Remove extra line here
+prepare_test_image() {
+ # If we're asked to modify the image for test, then let's make a copy and
+ # modify that instead.
+ # Check for manufacturing image.
+ local args
+
+ if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then
+ args="--factory"
+ fi
+
+ # Check for install shim.
+ if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]; then
sosa 2010/12/01 20:37:45 Just checking but these two can't be set at the sa
sjg 2010/12/01 20:54:00 Yes I noticed this - I copied the code as before.
+ args="--factory_install"
+ fi
+
+ # Check for forcing copy of image
+ if [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ]; then
+ args="$args --force_copy"
sosa 2010/12/01 20:37:45 ${args}
+ fi
+
+ # Modify the image for test, creating a new test image
+ "${SCRIPTS_DIR}/mod_image_for_test.sh" --board=${FLAGS_board} --image=\
sosa 2010/12/01 20:37:45 I believe having the = at the break point will fai
sjg 2010/12/01 20:54:00 It seems to work, but I have changed it
+ "$1/$2" --noinplace ${args} >/dev/stderr
+
+ # From now on we use the just-created test image
+ echo "$1/${CHROMEOS_TEST_IMAGE_NAME}"
+}
« no previous file with comments | « no previous file | image_to_usb.sh » ('j') | image_to_usb.sh » ('J')

Powered by Google App Engine
This is Rietveld 408576698