| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # Script to archive build results. Used by the buildbots. | 7 # Script to archive build results. Used by the buildbots. |
| 8 | 8 |
| 9 # Load common constants. This should be the first executable line. | 9 # Load common constants. This should be the first executable line. |
| 10 # The path to common.sh should be relative to your script's location. | 10 # The path to common.sh should be relative to your script's location. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 DEFINE_string zipname "image.zip" "Name of zip file to create." | 31 DEFINE_string zipname "image.zip" "Name of zip file to create." |
| 32 DEFINE_boolean official_build $FLAGS_FALSE "Set CHROMEOS_OFFICIAL=1 for release
builds." | 32 DEFINE_boolean official_build $FLAGS_FALSE "Set CHROMEOS_OFFICIAL=1 for release
builds." |
| 33 DEFINE_string build_number "" \ | 33 DEFINE_string build_number "" \ |
| 34 "The build-bot build number (when called by buildbot only)." "b" | 34 "The build-bot build number (when called by buildbot only)." "b" |
| 35 DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes" | 35 DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes" |
| 36 | 36 |
| 37 # Parse command line | 37 # Parse command line |
| 38 FLAGS "$@" || exit 1 | 38 FLAGS "$@" || exit 1 |
| 39 eval set -- "${FLAGS_ARGV}" | 39 eval set -- "${FLAGS_ARGV}" |
| 40 | 40 |
| 41 # Set if default from path is used |
| 42 DEFAULT_USED= |
| 43 |
| 41 # Reset "default" FLAGS_from based on passed-in board if not set on cmd-line | 44 # Reset "default" FLAGS_from based on passed-in board if not set on cmd-line |
| 42 if [ "$FLAGS_from" = "$DEFAULT_FROM" ] | 45 if [ "$FLAGS_from" = "$DEFAULT_FROM" ] |
| 43 then | 46 then |
| 44 FLAGS_from="${IMAGES_DIR}/$FLAGS_board/$(ls -t1 \ | 47 FLAGS_from="${IMAGES_DIR}/$FLAGS_board/$(ls -t1 \ |
| 45 $IMAGES_DIR/$FLAGS_board 2>&-| head -1)" | 48 $IMAGES_DIR/$FLAGS_board 2>&-| head -1)" |
| 49 DEFAULT_USED=1 |
| 46 fi | 50 fi |
| 47 | 51 |
| 48 # Die on any errors. | 52 # Die on any errors. |
| 49 set -e | 53 set -e |
| 50 | 54 |
| 55 if [ -z $DEFAULT_USED ] && [ $FLAGS_test_mod -eq $FLAGS_TRUE ] |
| 56 then |
| 57 echo "test_mod requires that the default from path be used." |
| 58 echo "If non default behavior is desired, run mod_image_for_test manually" |
| 59 echo "re-run archive build without test_mod" |
| 60 exit 1 |
| 61 fi |
| 62 |
| 51 if [ ! -d "$FLAGS_from" ] | 63 if [ ! -d "$FLAGS_from" ] |
| 52 then | 64 then |
| 53 echo "$FLAGS_from does not exist. Exiting..." | 65 echo "$FLAGS_from does not exist. Exiting..." |
| 54 exit 1 | 66 exit 1 |
| 55 fi | 67 fi |
| 56 | 68 |
| 57 if [ $FLAGS_official_build -eq $FLAGS_TRUE ] | 69 if [ $FLAGS_official_build -eq $FLAGS_TRUE ] |
| 58 then | 70 then |
| 59 CHROMEOS_OFFICIAL=1 | 71 CHROMEOS_OFFICIAL=1 |
| 60 fi | 72 fi |
| (...skipping 26 matching lines...) Expand all Loading... |
| 87 echo "archive to file: $ZIPFILE" | 99 echo "archive to file: $ZIPFILE" |
| 88 | 100 |
| 89 rm -rf "$OUTDIR" | 101 rm -rf "$OUTDIR" |
| 90 mkdir -p "$OUTDIR" | 102 mkdir -p "$OUTDIR" |
| 91 | 103 |
| 92 # Modify image for test if flag set. | 104 # Modify image for test if flag set. |
| 93 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] | 105 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] |
| 94 then | 106 then |
| 95 echo "Modifying image for test" | 107 echo "Modifying image for test" |
| 96 SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin" | 108 SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin" |
| 97 cp -f "${SRC_IMAGE}" "${FLAGS_from}/chromiumos_test_image.bin" | 109 cp -f "${SRC_IMAGE}" "${FLAGS_from}/chromiumos_image_bkup.bin" |
| 98 SRC_IMAGE="${FLAGS_from}/chromiumos_test_image.bin" | 110 ./enter_chroot.sh -- ./mod_image_for_test.sh --board $FLAGS_board --yes |
| 99 "${SCRIPTS_DIR}/mod_image_for_test.sh" --board $FLAGS_board --yes --image \ | 111 mv "$SRC_IMAGE" "${FLAGS_from}/chromiumos_test_image.bin" |
| 100 "${SRC_IMAGE}" | 112 mv "${FLAGS_from}/chromiumos_image_bkup.bin" "$SRC_IMAGE" |
| 101 cd "${FLAGS_chroot}/build/${FLAGS_board}/usr/local" | 113 cd "${FLAGS_chroot}/build/${FLAGS_board}/usr/local" |
| 102 echo "Archiving autotest build artifacts" | 114 echo "Archiving autotest build artifacts" |
| 103 tar cjf "${FLAGS_from}/autotest.tar.bz2" autotest | 115 tar cjf "${FLAGS_from}/autotest.tar.bz2" autotest |
| 104 fi | 116 fi |
| 105 | 117 |
| 106 # Zip the build | 118 # Zip the build |
| 107 echo "Compressing and archiving build..." | 119 echo "Compressing and archiving build..." |
| 108 cd "$FLAGS_from" | 120 cd "$FLAGS_from" |
| 109 zip -r "$ZIPFILE" * | 121 zip -r "$ZIPFILE" * |
| 110 cd - | 122 cd - |
| (...skipping 17 matching lines...) Expand all Loading... |
| 128 if [ $FLAGS_keep_max -gt 0 ] | 140 if [ $FLAGS_keep_max -gt 0 ] |
| 129 then | 141 then |
| 130 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." | 142 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." |
| 131 cd "$FLAGS_to" | 143 cd "$FLAGS_to" |
| 132 # +2 because line numbers start at 1 and need to skip LATEST file | 144 # +2 because line numbers start at 1 and need to skip LATEST file |
| 133 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` | 145 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` |
| 134 cd - | 146 cd - |
| 135 fi | 147 fi |
| 136 | 148 |
| 137 echo "Done." | 149 echo "Done." |
| OLD | NEW |