From 3adaa549e0020f708d0e559baefa771a164eadc8 Mon Sep 17 00:00:00 2001 From: Chris Sosa Date: Thu, 6 May 2010 17:52:32 -0700 Subject: [PATCH] Only allows mod_image_for_test for default from behavior. BUG=1970 TEST=Running archive build with clean build and producing a test image and normal image and zip file. Also running with custom from and getting an error code with test_mod=true This change is required because mod_image_for_test requires it to be inside chroot. Since the buildbot is the main user of this script, this deals with that use case. Other users of this script will have to run mod_image_for_test manually outside of archive_build Review URL: http://codereview.chromium.org/2008001 --- archive_build.sh | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/archive_build.sh b/archive_build.sh index 27648211f6..d050fd52ca 100755 --- a/archive_build.sh +++ b/archive_build.sh @@ -38,16 +38,28 @@ DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes" FLAGS "$@" || exit 1 eval set -- "${FLAGS_ARGV}" +# Set if default from path is used +DEFAULT_USED= + # Reset "default" FLAGS_from based on passed-in board if not set on cmd-line if [ "$FLAGS_from" = "$DEFAULT_FROM" ] then - FLAGS_from="${IMAGES_DIR}/$FLAGS_board/$(ls -t1 \ - $IMAGES_DIR/$FLAGS_board 2>&-| head -1)" + FLAGS_from="${IMAGES_DIR}/$FLAGS_board/$(ls -t1 \ + $IMAGES_DIR/$FLAGS_board 2>&-| head -1)" + DEFAULT_USED=1 fi # Die on any errors. set -e +if [ -z $DEFAULT_USED ] && [ $FLAGS_test_mod -eq $FLAGS_TRUE ] +then + echo "test_mod requires that the default from path be used." + echo "If non default behavior is desired, run mod_image_for_test manually" + echo "re-run archive build without test_mod" + exit 1 +fi + if [ ! -d "$FLAGS_from" ] then echo "$FLAGS_from does not exist. Exiting..." @@ -94,10 +106,10 @@ if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] then echo "Modifying image for test" SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin" - cp -f "${SRC_IMAGE}" "${FLAGS_from}/chromiumos_test_image.bin" - SRC_IMAGE="${FLAGS_from}/chromiumos_test_image.bin" - "${SCRIPTS_DIR}/mod_image_for_test.sh" --board $FLAGS_board --yes --image \ - "${SRC_IMAGE}" + cp -f "${SRC_IMAGE}" "${FLAGS_from}/chromiumos_image_bkup.bin" + ./enter_chroot.sh -- ./mod_image_for_test.sh --board $FLAGS_board --yes + mv "$SRC_IMAGE" "${FLAGS_from}/chromiumos_test_image.bin" + mv "${FLAGS_from}/chromiumos_image_bkup.bin" "$SRC_IMAGE" cd "${FLAGS_chroot}/build/${FLAGS_board}/usr/local" echo "Archiving autotest build artifacts" tar cjf "${FLAGS_from}/autotest.tar.bz2" autotest