Index: common.sh |
diff --git a/common.sh b/common.sh |
index b7d428dab5bcca65bb2f042eb2aa63acea944761..c3ca5998a5f307b0273a32d2e048a73c9a5e0b1f 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)}" |
@@ -106,7 +114,7 @@ DEFAULT_BUILD_ROOT=${CHROMEOS_BUILD_ROOT:-"$SRC_ROOT/build"} |
# Set up a global ALL_BOARDS value |
if [ -d $SRC_ROOT/overlays ]; then |
ALL_BOARDS=$(cd $SRC_ROOT/overlays;ls -1d overlay-* 2>&-|sed 's,overlay-,,g') |
-fi |
+fi |
# Strip CR |
ALL_BOARDS=$(echo $ALL_BOARDS) |
# Set a default BOARD |
@@ -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" |
Nick Sanders
2010/12/02 00:01:48
Can you modify the output name based on test/facto
sjg
2010/12/02 00:28:52
I haven't added constants for these also at this s
|
+ |
+ |
# Directory locations inside the dev chroot |
CHROOT_TRUNK_DIR="/home/$USER/trunk" |
@@ -526,3 +540,44 @@ 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 directory containing the image, and the image filename |
+# On exit, it echoes the pathname of the resulting test image |
+# |
+# Usage: |
+# SRC_IMAGE=$(prepare_test_image "directory" "imagefile") |
+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 |
+ args="--factory_install" |
+ fi |
+ |
+ # Check for forcing copy of image |
+ if [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ]; then |
+ args="${args} --force_copy" |
+ fi |
+ |
+ # Modify the image for test, creating a new test image |
+ "${SCRIPTS_DIR}/mod_image_for_test.sh" --board=${FLAGS_board} \ |
+ --image="$1/$2" --noinplace ${args} >/dev/stderr |
Nick Sanders
2010/12/02 00:07:51
Can you get this output on stdout? It doesn't seem
sjg
2010/12/02 00:28:52
Chris suggested making this a function which takes
|
+ |
+ # From now on we use the just-created test image |
+ echo "$1/${CHROMEOS_TEST_IMAGE_NAME}" |
+} |