| 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 # --- BEGIN COMMON.SH BOILERPLATE --- |
| 10 # The path to common.sh should be relative to your script's location. | 10 # Load common CrOS utilities. Inside the chroot this file is installed in |
| 11 . "$(dirname "$0")/common.sh" | 11 # /usr/lib/crosutils. Outside the chroot we find it relative to the script's |
| 12 # location. |
| 13 find_common_sh() { |
| 14 local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) |
| 15 local path |
| 16 |
| 17 SCRIPT_ROOT= |
| 18 for path in "${common_paths[@]}"; do |
| 19 if [ -r "${path}/common.sh" ]; then |
| 20 SCRIPT_ROOT=${path} |
| 21 break |
| 22 fi |
| 23 done |
| 24 } |
| 25 |
| 26 find_common_sh |
| 27 . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) |
| 28 # --- END COMMON.SH BOILERPLATE --- |
| 12 | 29 |
| 13 # Script must be run outside the chroot | 30 # Script must be run outside the chroot |
| 14 assert_outside_chroot | 31 assert_outside_chroot |
| 15 | 32 |
| 16 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images" | 33 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images" |
| 17 # Default to the most recent image | 34 # Default to the most recent image |
| 18 DEFAULT_TO="${GCLIENT_ROOT}/archive" | 35 DEFAULT_TO="${GCLIENT_ROOT}/archive" |
| 19 DEFAULT_FROM="${IMAGES_DIR}/$DEFAULT_BOARD/$(ls -t1 \ | 36 DEFAULT_FROM="${IMAGES_DIR}/$DEFAULT_BOARD/$(ls -t1 \ |
| 20 $IMAGES_DIR/$DEFAULT_BOARD 2>&-| head -1)" | 37 $IMAGES_DIR/$DEFAULT_BOARD 2>&-| head -1)" |
| 21 | 38 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 36 "Directory to archive" | 53 "Directory to archive" |
| 37 DEFINE_string gsutil "gsutil" \ | 54 DEFINE_string gsutil "gsutil" \ |
| 38 "Location of gsutil" | 55 "Location of gsutil" |
| 39 DEFINE_string gsd_gen_index "" \ | 56 DEFINE_string gsd_gen_index "" \ |
| 40 "Location of gsd_generate_index.py" | 57 "Location of gsd_generate_index.py" |
| 41 DEFINE_string acl "private" \ | 58 DEFINE_string acl "private" \ |
| 42 "ACL to set on GSD archives" | 59 "ACL to set on GSD archives" |
| 43 DEFINE_string gsutil_archive "" \ | 60 DEFINE_string gsutil_archive "" \ |
| 44 "Optional datastore archive location" | 61 "Optional datastore archive location" |
| 45 DEFINE_integer keep_max 0 "Maximum builds to keep in archive (0=all)" | 62 DEFINE_integer keep_max 0 "Maximum builds to keep in archive (0=all)" |
| 46 DEFINE_boolean official_build $FLAGS_FALSE "Set CHROMEOS_OFFICIAL=1 for release
builds." | 63 DEFINE_boolean official_build $FLAGS_FALSE \ |
| 64 "Set CHROMEOS_OFFICIAL=1 for release builds." |
| 47 DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes" | 65 DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes" |
| 48 DEFINE_boolean prebuilt_upload $FLAGS_FALSE "Upload prebuilt binary packages." | 66 DEFINE_boolean prebuilt_upload $FLAGS_FALSE "Upload prebuilt binary packages." |
| 49 DEFINE_string to "$DEFAULT_TO" "Directory of build archive" | 67 DEFINE_string to "$DEFAULT_TO" "Directory of build archive" |
| 50 DEFINE_string zipname "image.zip" "Name of zip file to create." | 68 DEFINE_string zipname "image.zip" "Name of zip file to create." |
| 51 | 69 |
| 52 # Parse command line | 70 # Parse command line |
| 53 FLAGS "$@" || exit 1 | 71 FLAGS "$@" || exit 1 |
| 54 eval set -- "${FLAGS_ARGV}" | 72 eval set -- "${FLAGS_ARGV}" |
| 55 | 73 |
| 56 # Set if default from path is used | 74 # Set if default from path is used |
| 57 DEFAULT_USED= | 75 DEFAULT_USED= |
| 58 | 76 |
| 59 # Reset "default" FLAGS_from based on passed-in board if not set on cmd-line | 77 # Reset "default" FLAGS_from based on passed-in board if not set on cmd-line |
| 60 if [ "$FLAGS_from" = "$DEFAULT_FROM" ] | 78 if [ "$FLAGS_from" = "$DEFAULT_FROM" ]; then |
| 61 then | |
| 62 # Keep the directory name of the current image set (*.bin). | 79 # Keep the directory name of the current image set (*.bin). |
| 63 IMG_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" | 80 IMG_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" |
| 64 FLAGS_from="${IMAGES_DIR}/${FLAGS_board}/${IMG_DIR}" | 81 FLAGS_from="${IMAGES_DIR}/${FLAGS_board}/${IMG_DIR}" |
| 65 DEFAULT_USED=1 | 82 DEFAULT_USED=1 |
| 66 fi | 83 fi |
| 67 | 84 |
| 68 # Die on any errors. | 85 # Die on any errors. |
| 69 set -e | 86 set -e |
| 70 | 87 |
| 71 if [ -z "$DEFAULT_USED" ] | 88 if [ -z "$DEFAULT_USED" ]; then |
| 72 then | |
| 73 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] || \ | 89 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] || \ |
| 74 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] || \ | 90 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] || \ |
| 75 [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] | 91 [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] |
| 76 then | 92 then |
| 77 echo "test_mod requires that the default from path be used." | 93 echo "test_mod requires that the default from path be used." |
| 78 echo "If non default behavior is desired, run mod_image_for_test manually" | 94 echo "If non default behavior is desired, run mod_image_for_test manually" |
| 79 echo "re-run archive build without test_mod" | 95 echo "re-run archive build without test_mod" |
| 80 exit 1 | 96 exit 1 |
| 81 fi | 97 fi |
| 82 fi | 98 fi |
| 83 | 99 |
| 84 if [ ! -d "$FLAGS_from" ] | 100 if [ ! -d "$FLAGS_from" ]; then |
| 85 then | |
| 86 echo "$FLAGS_from does not exist. Exiting..." | 101 echo "$FLAGS_from does not exist. Exiting..." |
| 87 exit 1 | 102 exit 1 |
| 88 fi | 103 fi |
| 89 | 104 |
| 90 if [ $FLAGS_official_build -eq $FLAGS_TRUE ] | 105 if [ $FLAGS_official_build -eq $FLAGS_TRUE ]; then |
| 91 then | |
| 92 CHROMEOS_OFFICIAL=1 | 106 CHROMEOS_OFFICIAL=1 |
| 93 fi | 107 fi |
| 94 | 108 |
| 95 # Get version information | 109 # Get version information |
| 96 . ${SRC_ROOT}/third_party/chromiumos-overlay/chromeos/config/chromeos_version.sh | 110 . ${SRC_ROOT}/third_party/chromiumos-overlay/chromeos/config/chromeos_version.sh |
| 97 | 111 |
| 98 # Get git hash | 112 # Get git hash |
| 99 # Use git:8 chars of sha1 | 113 # Use git:8 chars of sha1 |
| 100 REVISION=$(git rev-parse HEAD) | 114 REVISION=$(git rev-parse HEAD) |
| 101 REVISION=${REVISION:0:8} | 115 REVISION=${REVISION:0:8} |
| 102 | 116 |
| 103 # Use the version number plus revision as the last change. (Need both, since | 117 # Use the version number plus revision as the last change. (Need both, since |
| 104 # trunk builds multiple times with the same version string.) | 118 # trunk builds multiple times with the same version string.) |
| 105 LAST_CHANGE="${CHROMEOS_VERSION_STRING}-r${REVISION}" | 119 LAST_CHANGE="${CHROMEOS_VERSION_STRING}-r${REVISION}" |
| 106 if [ -n "$FLAGS_build_number" ] | 120 if [ -n "$FLAGS_build_number" ]; then |
| 107 then | |
| 108 LAST_CHANGE="$LAST_CHANGE-b${FLAGS_build_number}" | 121 LAST_CHANGE="$LAST_CHANGE-b${FLAGS_build_number}" |
| 109 fi | 122 fi |
| 110 | 123 |
| 111 # The Chromium buildbot scripts only create a clickable link to the archive | 124 # The Chromium buildbot scripts only create a clickable link to the archive |
| 112 # if an output line of the form "last change: XXX" exists | 125 # if an output line of the form "last change: XXX" exists |
| 113 echo "last change: $LAST_CHANGE" | 126 echo "last change: $LAST_CHANGE" |
| 114 echo "archive from: $FLAGS_from" | 127 echo "archive from: $FLAGS_from" |
| 115 | 128 |
| 116 # Create the output directory | 129 # Create the output directory |
| 117 OUTDIR="${FLAGS_to}/${LAST_CHANGE}" | 130 OUTDIR="${FLAGS_to}/${LAST_CHANGE}" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 134 MOD_ARGS=$2 | 147 MOD_ARGS=$2 |
| 135 OUTPUT_IMAGE=$1 | 148 OUTPUT_IMAGE=$1 |
| 136 cp -f "${SRC_IMAGE}" "${BACKUP_IMAGE}" | 149 cp -f "${SRC_IMAGE}" "${BACKUP_IMAGE}" |
| 137 ./enter_chroot.sh -- ./mod_image_for_test.sh --board $FLAGS_board \ | 150 ./enter_chroot.sh -- ./mod_image_for_test.sh --board $FLAGS_board \ |
| 138 --yes ${MOD_ARGS} | 151 --yes ${MOD_ARGS} |
| 139 mv "${SRC_IMAGE}" "${OUTPUT_IMAGE}" | 152 mv "${SRC_IMAGE}" "${OUTPUT_IMAGE}" |
| 140 mv "${BACKUP_IMAGE}" "${SRC_IMAGE}" | 153 mv "${BACKUP_IMAGE}" "${SRC_IMAGE}" |
| 141 } | 154 } |
| 142 | 155 |
| 143 # Modify image for test if flag set. | 156 # Modify image for test if flag set. |
| 144 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] | 157 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ]; then |
| 145 then | |
| 146 echo "Modifying image for test" | 158 echo "Modifying image for test" |
| 147 do_chroot_mod "${FLAGS_from}/chromiumos_test_image.bin" "" | 159 do_chroot_mod "${FLAGS_from}/chromiumos_test_image.bin" "" |
| 148 | 160 |
| 149 pushd "${FLAGS_chroot}/build/${FLAGS_board}/usr/local" | 161 pushd "${FLAGS_chroot}/build/${FLAGS_board}/usr/local" |
| 150 echo "Archiving autotest build artifacts" | 162 echo "Archiving autotest build artifacts" |
| 151 tar cjf "${FLAGS_from}/autotest.tar.bz2" --checkpoint=1000 autotest | 163 tar cjf "${FLAGS_from}/autotest.tar.bz2" --checkpoint=1000 autotest |
| 152 popd | 164 popd |
| 153 fi | 165 fi |
| 154 | 166 |
| 155 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] | 167 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ]; then |
| 156 then | |
| 157 echo "Modifying image for factory test" | 168 echo "Modifying image for factory test" |
| 158 do_chroot_mod "${FLAGS_from}/chromiumos_factory_image.bin" \ | 169 do_chroot_mod "${FLAGS_from}/chromiumos_factory_image.bin" \ |
| 159 "--factory" | 170 "--factory" |
| 160 fi | 171 fi |
| 161 | 172 |
| 162 # Modify for recovery | 173 # Modify for recovery |
| 163 if [ $FLAGS_official_build -eq $FLAGS_TRUE ] | 174 if [ $FLAGS_official_build -eq $FLAGS_TRUE ]; then |
| 164 then | |
| 165 BUILDVER="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" | 175 BUILDVER="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" |
| 166 CHROOT_IMAGE_DIR=/home/$USER/trunk/src/build/images/$FLAGS_board/$BUILDVER | 176 CHROOT_IMAGE_DIR=/home/$USER/trunk/src/build/images/$FLAGS_board/$BUILDVER |
| 167 ./enter_chroot.sh -- ./mod_image_for_recovery.sh --board $FLAGS_board \ | 177 ./enter_chroot.sh -- ./mod_image_for_recovery.sh --board $FLAGS_board \ |
| 168 --image $CHROOT_IMAGE_DIR/chromiumos_base_image.bin | 178 --image $CHROOT_IMAGE_DIR/chromiumos_base_image.bin |
| 169 fi | 179 fi |
| 170 | 180 |
| 171 # Remove the developer build if test image is also built. | 181 # Remove the developer build if test image is also built. |
| 172 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] ; then | 182 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] ; then |
| 173 rm -f ${SRC_IMAGE} | 183 rm -f ${SRC_IMAGE} |
| 174 fi | 184 fi |
| 175 | 185 |
| 176 # Build differently sized shims. Currently only factory install shim is | 186 # Build differently sized shims. Currently only factory install shim is |
| 177 # supported, TODO(tgao): Add developer shim. | 187 # supported, TODO(tgao): Add developer shim. |
| 178 if [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] | 188 if [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then |
| 179 then | |
| 180 echo "Building factory install shim." | 189 echo "Building factory install shim." |
| 181 # HACK: The build system can't currently handle more than one image size | 190 # HACK: The build system can't currently handle more than one image size |
| 182 # at a time. Therefor eit's necessary to do another round of build after | 191 # at a time. Therefor eit's necessary to do another round of build after |
| 183 # archiving the original build. This should be fixed in Chromite. | 192 # archiving the original build. This should be fixed in Chromite. |
| 184 | 193 |
| 185 # HACK: cbuild has a special case when running on chrome-bot that | 194 # HACK: cbuild has a special case when running on chrome-bot that |
| 186 # zeroes out the current revision, which makes calling build_image directly | 195 # zeroes out the current revision, which makes calling build_image directly |
| 187 # fail. You must explictly call replace and specify a unique name numerically | 196 # fail. You must explictly call replace and specify a unique name numerically |
| 188 # using build_attempt. | 197 # using build_attempt. |
| 189 ./enter_chroot.sh -- ./build_image --board $FLAGS_board --factory_install \ | 198 ./enter_chroot.sh -- ./build_image --board $FLAGS_board --factory_install \ |
| 190 --replace --build_attempt 7 | 199 --replace --build_attempt 7 |
| 191 | 200 |
| 192 # Get the install shim dir: It is the newest build. | 201 # Get the install shim dir: It is the newest build. |
| 193 # This is the output dir for the factory shim, the factory test and | 202 # This is the output dir for the factory shim, the factory test and |
| 194 # release images will remain in IMG_DIR, defined previously. | 203 # release images will remain in IMG_DIR, defined previously. |
| 195 SHIM_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" | 204 SHIM_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" |
| 196 | 205 |
| 197 echo "Factory image dir: ${IMG_DIR}" | 206 echo "Factory image dir: ${IMG_DIR}" |
| 198 echo "Factory install shim dir: ${SHIM_DIR}" | 207 echo "Factory install shim dir: ${SHIM_DIR}" |
| 199 fi | 208 fi |
| 200 | 209 |
| 201 # Zip the build | 210 # Zip the build |
| 202 echo "Compressing and archiving build..." | 211 echo "Compressing and archiving build..." |
| 203 cd "$FLAGS_from" | 212 cd "$FLAGS_from" |
| 204 MANIFEST=`ls | grep -v factory` | 213 MANIFEST=`ls | grep -v factory` |
| 205 zip -r "${ZIPFILE}" ${MANIFEST} | 214 zip -r "${ZIPFILE}" ${MANIFEST} |
| 206 | 215 |
| 207 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ | 216 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ |
| 208 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] | 217 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then |
| 209 then | |
| 210 # We need to have directory structure for factory package, as | 218 # We need to have directory structure for factory package, as |
| 211 # signing and packaging utilities need unpack_partitions.sh. | 219 # signing and packaging utilities need unpack_partitions.sh. |
| 212 echo "Compressing factory software" | 220 echo "Compressing factory software" |
| 213 pushd .. | 221 pushd .. |
| 214 [ -n "${SHIM_DIR}" ] && rm -f factory_shim && ln -s "${SHIM_DIR}" factory_shim | 222 [ -n "${SHIM_DIR}" ] && rm -f factory_shim && ln -s "${SHIM_DIR}" factory_shim |
| 215 [ -n "${IMG_DIR}" ] && rm -f factory_test && ln -s "${IMG_DIR}" factory_test | 223 [ -n "${IMG_DIR}" ] && rm -f factory_test && ln -s "${IMG_DIR}" factory_test |
| 216 | 224 |
| 217 # Restore "latest" status to the original image. | 225 # Restore "latest" status to the original image. |
| 218 # The "latest" symlink and latest timestamp are used extensively | 226 # The "latest" symlink and latest timestamp are used extensively |
| 219 # throughout the build scripts rather than explicitly specifying an image. | 227 # throughout the build scripts rather than explicitly specifying an image. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 then | 269 then |
| 262 echo "Creating hwqual archive" | 270 echo "Creating hwqual archive" |
| 263 HWQUAL_NAME="chromeos-hwqual-${FLAGS_board}-${CHROMEOS_VERSION_STRING}" | 271 HWQUAL_NAME="chromeos-hwqual-${FLAGS_board}-${CHROMEOS_VERSION_STRING}" |
| 264 "${SCRIPTS_DIR}/archive_hwqual" --from "${OUTDIR}" \ | 272 "${SCRIPTS_DIR}/archive_hwqual" --from "${OUTDIR}" \ |
| 265 --output_tag "${HWQUAL_NAME}" | 273 --output_tag "${HWQUAL_NAME}" |
| 266 gsutil_archive "${OUTDIR}/${HWQUAL_NAME}.tar.bz2" \ | 274 gsutil_archive "${OUTDIR}/${HWQUAL_NAME}.tar.bz2" \ |
| 267 "${LAST_CHANGE}/${HWQUAL_NAME}.tar.bz2" | 275 "${LAST_CHANGE}/${HWQUAL_NAME}.tar.bz2" |
| 268 fi | 276 fi |
| 269 | 277 |
| 270 | 278 |
| 271 if [ $FLAGS_prebuilt_upload -eq $FLAGS_TRUE ] | 279 if [ $FLAGS_prebuilt_upload -eq $FLAGS_TRUE ]; then |
| 272 then | |
| 273 # Construct prebuilt upload command. | 280 # Construct prebuilt upload command. |
| 274 # This will upload prebuilt packages to Google Storage. | 281 # This will upload prebuilt packages to Google Storage. |
| 275 prebuilt_cmd="${SCRIPTS_DIR}/prebuilt.py" | 282 prebuilt_cmd="${SCRIPTS_DIR}/prebuilt.py" |
| 276 prebuilt_cmd="$prebuilt_cmd -u gs://chromeos-prebuilt --git-sync -V master" | 283 prebuilt_cmd="$prebuilt_cmd -u gs://chromeos-prebuilt --git-sync -V master" |
| 277 prebuilt_cmd="$prebuilt_cmd -p ${GCLIENT_ROOT} -b ${FLAGS_board}" | 284 prebuilt_cmd="$prebuilt_cmd -p ${GCLIENT_ROOT} -b ${FLAGS_board}" |
| 278 | 285 |
| 279 if [ "${FLAGS_board}" == "x86-generic" ] | 286 if [ "${FLAGS_board}" == "x86-generic" ] |
| 280 then | 287 then |
| 281 prebuilt_cmd="$prebuilt_cmd --sync-host" | 288 prebuilt_cmd="$prebuilt_cmd --sync-host" |
| 282 fi | 289 fi |
| 283 | 290 |
| 284 echo "Running $prebuilt_cmd" | 291 echo "Running $prebuilt_cmd" |
| 285 $prebuilt_cmd | 292 $prebuilt_cmd |
| 286 fi | 293 fi |
| 287 | 294 |
| 288 gsutil_archive "${ZIPFILE}" "${LAST_CHANGE}/${FLAGS_zipname}" | 295 gsutil_archive "${ZIPFILE}" "${LAST_CHANGE}/${FLAGS_zipname}" |
| 289 | 296 |
| 290 if [ $FLAGS_archive_debug -eq $FLAGS_TRUE ] | 297 if [ $FLAGS_archive_debug -eq $FLAGS_TRUE ]; then |
| 291 then | |
| 292 echo "Generating Breakpad symbols" | 298 echo "Generating Breakpad symbols" |
| 293 ! ${SCRIPTS_DIR}/cros_generate_breakpad_symbols --board=${FLAGS_board} | 299 ! ${SCRIPTS_DIR}/cros_generate_breakpad_symbols --board=${FLAGS_board} |
| 294 echo "Creating debug archive" | 300 echo "Creating debug archive" |
| 295 pushd "${FLAGS_chroot}/build/${FLAGS_board}/usr/lib" | 301 pushd "${FLAGS_chroot}/build/${FLAGS_board}/usr/lib" |
| 296 sudo tar czf "${OUTDIR}/debug.tgz" --checkpoint=1000 --exclude\ | 302 sudo tar czf "${OUTDIR}/debug.tgz" --checkpoint=1000 --exclude\ |
| 297 debug/usr/local/autotest --exclude debug/tests debug | 303 debug/usr/local/autotest --exclude debug/tests debug |
| 298 CMD="chown \${SUDO_UID}:\${SUDO_GID} ${OUTDIR}/debug.tgz" | 304 CMD="chown \${SUDO_UID}:\${SUDO_GID} ${OUTDIR}/debug.tgz" |
| 299 sudo sh -c "${CMD}" | 305 sudo sh -c "${CMD}" |
| 300 popd | 306 popd |
| 301 gsutil_archive "${OUTDIR}/debug.tgz" "${LAST_CHANGE}/debug.tgz" | 307 gsutil_archive "${OUTDIR}/debug.tgz" "${LAST_CHANGE}/debug.tgz" |
| 302 fi | 308 fi |
| 303 | 309 |
| 304 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ | 310 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ |
| 305 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] | 311 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then |
| 306 then | |
| 307 gsutil_archive "${FACTORY_ZIPFILE}" \ | 312 gsutil_archive "${FACTORY_ZIPFILE}" \ |
| 308 "${LAST_CHANGE}/factory_${FLAGS_zipname}" | 313 "${LAST_CHANGE}/factory_${FLAGS_zipname}" |
| 309 fi | 314 fi |
| 310 gsutil_archive "${FLAGS_to}/LATEST" "LATEST" | 315 gsutil_archive "${FLAGS_to}/LATEST" "LATEST" |
| 311 | 316 |
| 312 # Purge old builds if necessary | 317 # Purge old builds if necessary |
| 313 if [ $FLAGS_keep_max -gt 0 ] | 318 if [ $FLAGS_keep_max -gt 0 ]; then |
| 314 then | |
| 315 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." | 319 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." |
| 316 cd "$FLAGS_to" | 320 cd "$FLAGS_to" |
| 317 # +2 because line numbers start at 1 and need to skip LATEST file | 321 # +2 because line numbers start at 1 and need to skip LATEST file |
| 318 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` | 322 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` |
| 319 cd - | 323 cd - |
| 320 fi | 324 fi |
| 321 | 325 |
| 322 echo "Done." | 326 echo "Done." |
| OLD | NEW |