blob: 63224a6378729a6681f393802d58fb7ee63271b1 [file] [log] [blame]
rspangler@google.comd74220d2009-10-09 20:56:14 +00001#!/bin/bash
2
David McMahon49302942010-02-18 16:55:35 -08003# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
rspangler@google.comd74220d2009-10-09 20:56:14 +00004# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# Script to archive build results. Used by the buildbots.
8
Greg Spencer798d75f2011-02-01 22:04:49 -08009# --- BEGIN COMMON.SH BOILERPLATE ---
10# Load common CrOS utilities. Inside the chroot this file is installed in
11# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
12# location.
13find_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
26find_common_sh
27. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
28# --- END COMMON.SH BOILERPLATE ---
rspangler@google.comd74220d2009-10-09 20:56:14 +000029
30# Script must be run outside the chroot
31assert_outside_chroot
32
33IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images"
34# Default to the most recent image
rspangler@google.comd74220d2009-10-09 20:56:14 +000035DEFAULT_TO="${GCLIENT_ROOT}/archive"
David McMahon7c867162010-02-19 15:59:39 -080036DEFAULT_FROM="${IMAGES_DIR}/$DEFAULT_BOARD/$(ls -t1 \
37 $IMAGES_DIR/$DEFAULT_BOARD 2>&-| head -1)"
rspangler@google.comd74220d2009-10-09 20:56:14 +000038
39# Flags
Ken Mixteraba04292010-06-30 12:38:53 -070040DEFINE_boolean archive_debug $FLAGS_TRUE \
41 "Archive debug information for build"
David McMahon49302942010-02-18 16:55:35 -080042DEFINE_string board "$DEFAULT_BOARD" \
Nick Sanders5fa09502010-05-20 20:37:14 -070043 "The board to build packages for."
robotboyb49136d2010-06-29 15:03:37 -070044DEFINE_string build_number "" \
45 "The build-bot build number (when called by buildbot only)." "b"
Ken Mixteraba04292010-06-30 12:38:53 -070046DEFINE_string chroot "$DEFAULT_CHROOT_DIR" \
47 "The chroot of the build to archive."
Chris Sosac04833c2011-02-14 11:31:14 -080048DEFINE_boolean debug $FLAGS_FALSE "Run, but don't upload anything."
robotboyb49136d2010-06-29 15:03:37 -070049DEFINE_boolean factory_install_mod $FLAGS_FALSE \
50 "Modify image for factory install purposes"
Ken Mixteraba04292010-06-30 12:38:53 -070051DEFINE_boolean factory_test_mod $FLAGS_FALSE \
52 "Modify image for factory testing purposes"
53DEFINE_string from "$DEFAULT_FROM" \
54 "Directory to archive"
bradnelson7fcb1922010-06-22 20:37:01 -070055DEFINE_string gsutil "gsutil" \
56 "Location of gsutil"
bradnelson80465942010-06-29 18:12:08 -070057DEFINE_string gsd_gen_index "" \
58 "Location of gsd_generate_index.py"
59DEFINE_string acl "private" \
60 "ACL to set on GSD archives"
bradnelson7fcb1922010-06-22 20:37:01 -070061DEFINE_string gsutil_archive "" \
62 "Optional datastore archive location"
Scott Zawalskic1bb3c82011-03-25 16:56:32 -070063DEFINE_boolean gsutil_append_last_change $FLAGS_TRUE \
64 "Optional Whether to append build # and chrome os hash to GS uploads"
Ken Mixteraba04292010-06-30 12:38:53 -070065DEFINE_integer keep_max 0 "Maximum builds to keep in archive (0=all)"
Greg Spencer798d75f2011-02-01 22:04:49 -080066DEFINE_boolean official_build $FLAGS_FALSE \
67 "Set CHROMEOS_OFFICIAL=1 for release builds."
Chris Sosac04833c2011-02-14 11:31:14 -080068DEFINE_string test_tarball "" "Optional path to test tarball to archive"
Ken Mixteraba04292010-06-30 12:38:53 -070069DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes"
Scott Zawalski3b0c6d82010-10-29 11:07:42 -070070DEFINE_boolean prebuilt_upload $FLAGS_FALSE "Upload prebuilt binary packages."
Chris Sosab885b802011-02-16 15:33:11 -080071DEFINE_boolean remove_dev $FLAGS_TRUE "Remove the de image during archive."
Ken Mixteraba04292010-06-30 12:38:53 -070072DEFINE_string to "$DEFAULT_TO" "Directory of build archive"
73DEFINE_string zipname "image.zip" "Name of zip file to create."
rspangler@google.comd74220d2009-10-09 20:56:14 +000074
75# Parse command line
76FLAGS "$@" || exit 1
77eval set -- "${FLAGS_ARGV}"
78
Chris Sosa3adaa542010-05-06 17:52:32 -070079# Set if default from path is used
80DEFAULT_USED=
81
David McMahon7c867162010-02-19 15:59:39 -080082# Reset "default" FLAGS_from based on passed-in board if not set on cmd-line
Greg Spencer798d75f2011-02-01 22:04:49 -080083if [ "$FLAGS_from" = "$DEFAULT_FROM" ]; then
Nick Sandersad0599f2010-10-22 21:15:02 -070084 # Keep the directory name of the current image set (*.bin).
85 IMG_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)"
86 FLAGS_from="${IMAGES_DIR}/${FLAGS_board}/${IMG_DIR}"
Chris Sosa3adaa542010-05-06 17:52:32 -070087 DEFAULT_USED=1
David McMahon7c867162010-02-19 15:59:39 -080088fi
89
rspangler@google.comd74220d2009-10-09 20:56:14 +000090# Die on any errors.
91set -e
92
Greg Spencer798d75f2011-02-01 22:04:49 -080093if [ -z "$DEFAULT_USED" ]; then
Nick Sandersad0599f2010-10-22 21:15:02 -070094 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] || \
95 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] || \
96 [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ]
97 then
98 echo "test_mod requires that the default from path be used."
99 echo "If non default behavior is desired, run mod_image_for_test manually"
100 echo "re-run archive build without test_mod"
101 exit 1
102 fi
Chris Sosa3adaa542010-05-06 17:52:32 -0700103fi
104
Greg Spencer798d75f2011-02-01 22:04:49 -0800105if [ ! -d "$FLAGS_from" ]; then
David McMahon7c867162010-02-19 15:59:39 -0800106 echo "$FLAGS_from does not exist. Exiting..."
107 exit 1
108fi
109
Greg Spencer798d75f2011-02-01 22:04:49 -0800110if [ $FLAGS_official_build -eq $FLAGS_TRUE ]; then
djmm@google.com72cfa112009-11-17 00:26:20 +0000111 CHROMEOS_OFFICIAL=1
112fi
113
rspangler@google.comd74220d2009-10-09 20:56:14 +0000114# Get version information
Yasuhiro Matsuda27c473d2010-12-15 17:35:54 +0900115. ${SRC_ROOT}/third_party/chromiumos-overlay/chromeos/config/chromeos_version.sh
rspangler@google.comd74220d2009-10-09 20:56:14 +0000116
David McMahon03aeb202009-12-08 12:47:08 -0800117# Get git hash
118# Use git:8 chars of sha1
119REVISION=$(git rev-parse HEAD)
120REVISION=${REVISION:0:8}
rspangler@google.comd74220d2009-10-09 20:56:14 +0000121
122# Use the version number plus revision as the last change. (Need both, since
123# trunk builds multiple times with the same version string.)
David McMahonb059e342009-12-08 18:10:45 -0800124LAST_CHANGE="${CHROMEOS_VERSION_STRING}-r${REVISION}"
Greg Spencer798d75f2011-02-01 22:04:49 -0800125if [ -n "$FLAGS_build_number" ]; then
David McMahonb059e342009-12-08 18:10:45 -0800126 LAST_CHANGE="$LAST_CHANGE-b${FLAGS_build_number}"
127fi
rspangler@google.comd74220d2009-10-09 20:56:14 +0000128
129# The Chromium buildbot scripts only create a clickable link to the archive
130# if an output line of the form "last change: XXX" exists
131echo "last change: $LAST_CHANGE"
132echo "archive from: $FLAGS_from"
133
134# Create the output directory
135OUTDIR="${FLAGS_to}/${LAST_CHANGE}"
136ZIPFILE="${OUTDIR}/${FLAGS_zipname}"
Nick Sanders5fa09502010-05-20 20:37:14 -0700137FACTORY_ZIPFILE="${OUTDIR}/factory_${FLAGS_zipname}"
rspangler@google.comd74220d2009-10-09 20:56:14 +0000138echo "archive to dir: $OUTDIR"
139echo "archive to file: $ZIPFILE"
140
141rm -rf "$OUTDIR"
142mkdir -p "$OUTDIR"
143
Chris Sosa8a09a052010-01-19 16:05:36 -0800144# Modify image for test if flag set.
Greg Spencer798d75f2011-02-01 22:04:49 -0800145if [ $FLAGS_test_mod -eq $FLAGS_TRUE ]; then
Chris Sosa8a09a052010-01-19 16:05:36 -0800146 echo "Modifying image for test"
Chris Sosab885b802011-02-16 15:33:11 -0800147 ./enter_chroot.sh -- ./mod_image_for_test.sh --board $FLAGS_board \
148 --noinplace --yes
Nick Sanders5fa09502010-05-20 20:37:14 -0700149
150 pushd "${FLAGS_chroot}/build/${FLAGS_board}/usr/local"
Ken Mixtereb319032010-02-26 17:33:51 -0800151 echo "Archiving autotest build artifacts"
Zelidrag Hornung151112c2010-07-29 10:32:26 -0700152 tar cjf "${FLAGS_from}/autotest.tar.bz2" --checkpoint=1000 autotest
Nick Sanders5fa09502010-05-20 20:37:14 -0700153 popd
Chris Sosa8a09a052010-01-19 16:05:36 -0800154fi
155
David McMahon7f2951d2010-07-29 14:37:06 -0700156# Modify for recovery
Greg Spencer798d75f2011-02-01 22:04:49 -0800157if [ $FLAGS_official_build -eq $FLAGS_TRUE ]; then
Nick Sandersad0599f2010-10-22 21:15:02 -0700158 BUILDVER="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)"
159 CHROOT_IMAGE_DIR=/home/$USER/trunk/src/build/images/$FLAGS_board/$BUILDVER
160 ./enter_chroot.sh -- ./mod_image_for_recovery.sh --board $FLAGS_board \
Scott Zawalskiec6421c2010-08-02 12:31:35 -0700161 --image $CHROOT_IMAGE_DIR/chromiumos_base_image.bin
David McMahon7f2951d2010-07-29 14:37:06 -0700162fi
163
Chris Sosabfabd932010-05-21 09:54:46 -0700164# Remove the developer build if test image is also built.
Chris Sosab885b802011-02-16 15:33:11 -0800165if [ $FLAGS_remove_dev -eq $FLAGS_TRUE ]; then
166 rm -f "${FLAGS_from}/${CHROMEOS_IMAGE_NAME}"
Chris Sosabfabd932010-05-21 09:54:46 -0700167fi
Nick Sanders5fa09502010-05-20 20:37:14 -0700168
Nick Sanders4ed0b862011-03-06 15:21:42 -0800169if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ]; then
170 echo "Generating image for factory test"
171 # HACK: The build system can't currently handle more than one image size
172 # at a time. Therefore it's necessary to do another round of build after
173 # archiving the original build. This should be fixed in Chromite.
174
175 # HACK: cbuild has a special case when running on chrome-bot that
176 # zeroes out the current revision, which makes calling build_image directly
177 # fail. You must explictly call replace and specify a unique name numerically
178 # using build_attempt.
179 ./enter_chroot.sh -- ./build_image --board $FLAGS_board \
180 --replace --noenable_rootfs_verification --build_attempt 4
181
182 ./enter_chroot.sh -- ./mod_image_for_test.sh --board $FLAGS_board \
183 --yes --noinplace --factory
184
185 # Get the factory test dir: It is the newest build.
186 # This is the output dir for the factory shim, the factory test and
187 # release images will remain in IMG_DIR, defined previously.
188 FACTORY_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)"
189
190 echo "Factory image dir: ${FACTORY_DIR}"
191fi
192
Nick Sandersad0599f2010-10-22 21:15:02 -0700193# Build differently sized shims. Currently only factory install shim is
194# supported, TODO(tgao): Add developer shim.
Greg Spencer798d75f2011-02-01 22:04:49 -0800195if [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then
Nick Sandersad0599f2010-10-22 21:15:02 -0700196 echo "Building factory install shim."
197 # HACK: The build system can't currently handle more than one image size
Nick Sanders4ed0b862011-03-06 15:21:42 -0800198 # at a time. Therefore it's necessary to do another round of build after
Nick Sandersad0599f2010-10-22 21:15:02 -0700199 # archiving the original build. This should be fixed in Chromite.
200
201 # HACK: cbuild has a special case when running on chrome-bot that
202 # zeroes out the current revision, which makes calling build_image directly
203 # fail. You must explictly call replace and specify a unique name numerically
204 # using build_attempt.
205 ./enter_chroot.sh -- ./build_image --board $FLAGS_board --factory_install \
206 --replace --build_attempt 7
207
208 # Get the install shim dir: It is the newest build.
209 # This is the output dir for the factory shim, the factory test and
210 # release images will remain in IMG_DIR, defined previously.
211 SHIM_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)"
212
Nick Sandersad0599f2010-10-22 21:15:02 -0700213 echo "Factory install shim dir: ${SHIM_DIR}"
214fi
215
rspangler@google.comd74220d2009-10-09 20:56:14 +0000216# Zip the build
217echo "Compressing and archiving build..."
David McMahon7c867162010-02-19 15:59:39 -0800218cd "$FLAGS_from"
Nick Sanders5fa09502010-05-20 20:37:14 -0700219MANIFEST=`ls | grep -v factory`
220zip -r "${ZIPFILE}" ${MANIFEST}
221
222if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \
Greg Spencer798d75f2011-02-01 22:04:49 -0800223 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then
Nick Sandersad0599f2010-10-22 21:15:02 -0700224 # We need to have directory structure for factory package, as
225 # signing and packaging utilities need unpack_partitions.sh.
226 echo "Compressing factory software"
227 pushd ..
Nick Sanders4ed0b862011-03-06 15:21:42 -0800228 [ -n "${SHIM_DIR}" ] && rm -f factory_shim && \
229 ln -s "${SHIM_DIR}" factory_shim
230 [ -n "${FACTORY_DIR}" ] && rm -f factory_test && \
231 ln -s "${FACTORY_DIR}" factory_test
Nick Sandersad0599f2010-10-22 21:15:02 -0700232
233 # Restore "latest" status to the original image.
234 # The "latest" symlink and latest timestamp are used extensively
235 # throughout the build scripts rather than explicitly specifying an image.
236 touch "${IMG_DIR}"
237 [ -n "${IMG_DIR}" ] && rm -f latest && ln -s "${IMG_DIR}" latest
238 FACTORY_MANIFEST=`find factory_shim factory_test -follow \
239 -type f | grep -E "(factory_image|factory_install|partition)"`
240 zip "${FACTORY_ZIPFILE}" ${FACTORY_MANIFEST}
241 echo "Zipped"
242 popd
Nick Sanders07eac9e2010-06-16 04:19:39 -0700243 chmod 644 "${FACTORY_ZIPFILE}"
Nick Sanders5fa09502010-05-20 20:37:14 -0700244fi
rspangler@google.comd74220d2009-10-09 20:56:14 +0000245cd -
246
247# Update LATEST file
248echo "$LAST_CHANGE" > "${FLAGS_to}/LATEST"
249
250# Make sure files are readable
251chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST"
252chmod 755 "$OUTDIR"
Raja Aluriaeb10482010-12-10 13:03:09 -0800253cp -f "${FLAGS_from}/au-generator.zip" "${OUTDIR}/"
rspangler@google.comd74220d2009-10-09 20:56:14 +0000254
bradnelson80465942010-06-29 18:12:08 -0700255
bradnelson80465942010-06-29 18:12:08 -0700256function gsutil_archive() {
257 IN_PATH="$1"
258 OUT_PATH="$2"
Scott Zawalskic1bb3c82011-03-25 16:56:32 -0700259 if [ ${FLAGS_gsutil_append_last_change} -eq ${FLAGS_TRUE} ]; then
260 OUT_PATH="${LAST_CHANGE}/${OUT_PATH}"
261 fi
262
Chris Sosac04833c2011-02-14 11:31:14 -0800263 echo "Using gsutil to archive to ${OUT_PATH}..."
264 if [ -z "$FLAGS_gsutil_archive" -o ${FLAGS_debug} -eq ${FLAGS_TRUE} ]; then
265 echo -n "In debug mode. Would have run: "
266 echo "gsutil cp ${IN_PATH} <gsutil_archive>/${OUT_PATH}"
267 return
268 fi
269
270 FULL_OUT_PATH="${FLAGS_gsutil_archive}/${OUT_PATH}"
271 ${FLAGS_gsutil} cp ${IN_PATH} ${FULL_OUT_PATH}
272 ${FLAGS_gsutil} setacl ${FLAGS_acl} ${FULL_OUT_PATH}
273 if [ -n "$FLAGS_gsd_gen_index" ]; then
274 echo "Updating indexes..."
275 ${FLAGS_gsd_gen_index} \
276 --gsutil=${FLAGS_gsutil} \
277 -a ${FLAGS_acl} \
278 -p ${FULL_OUT_PATH} ${FLAGS_gsutil_archive}
bradnelson80465942010-06-29 18:12:08 -0700279 fi
280}
281
David McMahonad9c2032010-04-12 12:21:35 -0700282if [ $FLAGS_test_mod -eq $FLAGS_TRUE -a $FLAGS_official_build -eq $FLAGS_TRUE ]
Ken Mixter54a3e832010-03-12 14:52:51 -0800283then
284 echo "Creating hwqual archive"
285 HWQUAL_NAME="chromeos-hwqual-${FLAGS_board}-${CHROMEOS_VERSION_STRING}"
286 "${SCRIPTS_DIR}/archive_hwqual" --from "${OUTDIR}" \
287 --output_tag "${HWQUAL_NAME}"
bradnelson80465942010-06-29 18:12:08 -0700288 gsutil_archive "${OUTDIR}/${HWQUAL_NAME}.tar.bz2" \
Scott Zawalskic1bb3c82011-03-25 16:56:32 -0700289 "${HWQUAL_NAME}.tar.bz2"
bradnelson7fcb1922010-06-22 20:37:01 -0700290fi
291
Scott Zawalski695adf12010-10-28 16:56:00 -0700292
Greg Spencer798d75f2011-02-01 22:04:49 -0800293if [ $FLAGS_prebuilt_upload -eq $FLAGS_TRUE ]; then
Scott Zawalski3b0c6d82010-10-29 11:07:42 -0700294 # Construct prebuilt upload command.
295 # This will upload prebuilt packages to Google Storage.
David James2b2f19f2011-02-02 10:35:42 -0800296 prebuilt_cmd="${GCLIENT_ROOT}/chromite/buildbot/prebuilt.py"
Scott Zawalski3b0c6d82010-10-29 11:07:42 -0700297 prebuilt_cmd="$prebuilt_cmd -u gs://chromeos-prebuilt --git-sync -V master"
Scott Zawalski7333e2b2010-11-02 18:01:14 -0700298 prebuilt_cmd="$prebuilt_cmd -p ${GCLIENT_ROOT} -b ${FLAGS_board}"
Scott Zawalski695adf12010-10-28 16:56:00 -0700299
David James3146eaa2010-12-09 09:37:14 -0800300 if [ "${FLAGS_board}" == "x86-generic" ]
Scott Zawalski3b0c6d82010-10-29 11:07:42 -0700301 then
302 prebuilt_cmd="$prebuilt_cmd --sync-host"
303 fi
304
Chris Sosac04833c2011-02-14 11:31:14 -0800305 if [ ${FLAGS_debug} -eq ${FLAGS_FALSE} ]; then
306 echo "Running $prebuilt_cmd"
307 $prebuilt_cmd
308 else
309 echo "Would have run $prebuilt_cmd"
310 fi
Scott Zawalski3b0c6d82010-10-29 11:07:42 -0700311fi
Scott Zawalski695adf12010-10-28 16:56:00 -0700312
Scott Zawalskic1bb3c82011-03-25 16:56:32 -0700313gsutil_archive "${ZIPFILE}" "${FLAGS_zipname}"
Ken Mixter25d48c42010-07-01 11:20:42 -0700314
Greg Spencer798d75f2011-02-01 22:04:49 -0800315if [ $FLAGS_archive_debug -eq $FLAGS_TRUE ]; then
Ken Mixter8899d5a2010-08-25 09:17:38 -0700316 echo "Generating Breakpad symbols"
317 ! ${SCRIPTS_DIR}/cros_generate_breakpad_symbols --board=${FLAGS_board}
Ken Mixteraba04292010-06-30 12:38:53 -0700318 echo "Creating debug archive"
319 pushd "${FLAGS_chroot}/build/${FLAGS_board}/usr/lib"
Zelidrag Hornung151112c2010-07-29 10:32:26 -0700320 sudo tar czf "${OUTDIR}/debug.tgz" --checkpoint=1000 --exclude\
321 debug/usr/local/autotest --exclude debug/tests debug
Ken Mixteraba04292010-06-30 12:38:53 -0700322 CMD="chown \${SUDO_UID}:\${SUDO_GID} ${OUTDIR}/debug.tgz"
323 sudo sh -c "${CMD}"
324 popd
Scott Zawalskic1bb3c82011-03-25 16:56:32 -0700325 gsutil_archive "${OUTDIR}/debug.tgz" "debug.tgz"
Ken Mixteraba04292010-06-30 12:38:53 -0700326fi
327
bradnelson80465942010-06-29 18:12:08 -0700328if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \
Greg Spencer798d75f2011-02-01 22:04:49 -0800329 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then
bradnelson80465942010-06-29 18:12:08 -0700330 gsutil_archive "${FACTORY_ZIPFILE}" \
Scott Zawalskic1bb3c82011-03-25 16:56:32 -0700331 "factory_${FLAGS_zipname}"
Ken Mixter54a3e832010-03-12 14:52:51 -0800332fi
Chris Sosac04833c2011-02-14 11:31:14 -0800333
bradnelson80465942010-06-29 18:12:08 -0700334gsutil_archive "${FLAGS_to}/LATEST" "LATEST"
Ken Mixter54a3e832010-03-12 14:52:51 -0800335
Chris Sosa89e92442011-02-11 17:42:55 -0800336if [ -n "${FLAGS_gsutil_archive}" ]; then
Scott Zawalskic1bb3c82011-03-25 16:56:32 -0700337 if [ ${FLAGS_gsutil_append_last_change} -eq ${FLAGS_TRUE} ]; then
338 FULL_INDEX_PATH="${FLAGS_gsutil_archive}/${LAST_CHANGE}/_index.html"
339 else
340 FULL_INDEX_PATH="${FLAGS_gsutil_archive}/_index.html"
341 fi
Chris Sosa89e92442011-02-11 17:42:55 -0800342 RELATIVE_ARCHIVE_URL_PATH="${FULL_INDEX_PATH#gs://}"
343 echo "CROS_ARCHIVE_URL=\
344https://sandbox.google.com/storage/${RELATIVE_ARCHIVE_URL_PATH}"
345fi
346
Chris Sosac04833c2011-02-14 11:31:14 -0800347if [ -n "${FLAGS_test_tarball}" ]; then
Scott Zawalskic1bb3c82011-03-25 16:56:32 -0700348 gsutil_archive "${FLAGS_test_tarball}" "test_results.tgz"
Chris Sosac04833c2011-02-14 11:31:14 -0800349fi
350
rspangler@google.comd74220d2009-10-09 20:56:14 +0000351# Purge old builds if necessary
Greg Spencer798d75f2011-02-01 22:04:49 -0800352if [ $FLAGS_keep_max -gt 0 ]; then
rspangler@google.comd74220d2009-10-09 20:56:14 +0000353 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..."
354 cd "$FLAGS_to"
355 # +2 because line numbers start at 1 and need to skip LATEST file
356 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))`
357 cd -
358fi
359
360echo "Done."