Index: common.sh |
diff --git a/common.sh b/common.sh |
index b7d428dab5bcca65bb2f042eb2aa63acea944761..1c5e36a6e7f2c305a3f064e01c8c8b30aa64727b 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 PV_CAT for convenience |
+PV_OK=1 |
sosa
2010/11/30 22:01:43
These vars are pretty short, watch out for name co
sjg
2010/12/01 00:57:05
Done
|
+PV_CAT=pv |
+pv -V >/dev/null || PV_OK=0 |
+if [ $PV_OK -eq 0 ]; then |
+ 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 |
sosa
2010/11/30 22:01:43
Check for name collisions in other files
|
+CHROMEOS_IMAGE_NAME="chromiumos_image.bin" |
+CHROMEOS_TEST_IMAGE_NAME="chromiumos_test_image.bin" |
+ |
sjg
2010/12/01 00:57:05
There are none.
cd .../src/scripts
grep CHROMEOS_
|
+ |
# Directory locations inside the dev chroot |
CHROOT_TRUNK_DIR="/home/$USER/trunk" |
@@ -526,3 +540,41 @@ 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, SRC_IMAGE should contain the image pathname to modify |
+# On exit, SRC_IMAGE contains the pathname of the resulting test image |
sosa
2010/11/30 22:01:43
Treat this more like a function ... i.e. don't mo
sjg
2010/12/01 00:57:05
Actually this is hard, because mod_image_for_test
sjg
2010/12/01 20:02:31
OK have piped the script to stderr as you suggest.
|
+ |
+prepare_test_image() { |
sosa
2010/11/30 22:01:43
Indent
|
+# If we're asked to modify the image for test, then let's make a copy and |
+# modify that instead. |
+# Check for manufacturing image. |
+if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then |
+ EXTRA_ARGS="--factory" |
sosa
2010/11/30 22:01:43
use locals
|
+fi |
+ |
+# Check for install shim. |
+if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] ; then |
sosa
2010/11/30 22:01:43
style is no space between ] and ;. This has chang
|
+ EXTRA_ARGS="--factory_install" |
+fi |
+ |
+# Check for forcing copy of image |
+if [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ] ; then |
+ EXTRA_ARGS+="--force_copy" |
sosa
2010/11/30 22:01:43
Does this work? +=? Is that a bashism? Why not
|
+fi |
+ |
+# modified the image for test, creating a new test image |
sosa
2010/11/30 22:01:43
s/m/M
|
+"${SCRIPTS_DIR}/mod_image_for_test.sh" --board=${FLAGS_board} --image \ |
sosa
2010/11/30 22:01:43
Use = consistently in options
|
+ "${SRC_IMAGE}" --noinplace ${EXTRA_ARGS} |
+ |
+# from now on we use the just-created test image |
sosa
2010/11/30 22:01:43
s/f/F
|
+SRC_IMAGE="${FLAGS_from}/${CHROMEOS_TEST_IMAGE_NAME}" |
+echo "Source test image is: ${SRC_IMAGE}" |
+} |