rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
David McMahon | 4930294 | 2010-02-18 16:55:35 -0800 | [diff] [blame] | 3 | # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 4 | # 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 Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 9 | # --- 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. |
| 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 --- |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 29 | |
| 30 | # Script must be run outside the chroot |
| 31 | assert_outside_chroot |
| 32 | |
| 33 | IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images" |
| 34 | # Default to the most recent image |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 35 | DEFAULT_TO="${GCLIENT_ROOT}/archive" |
David McMahon | 7c86716 | 2010-02-19 15:59:39 -0800 | [diff] [blame] | 36 | DEFAULT_FROM="${IMAGES_DIR}/$DEFAULT_BOARD/$(ls -t1 \ |
| 37 | $IMAGES_DIR/$DEFAULT_BOARD 2>&-| head -1)" |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 38 | |
| 39 | # Flags |
Ken Mixter | aba0429 | 2010-06-30 12:38:53 -0700 | [diff] [blame] | 40 | DEFINE_boolean archive_debug $FLAGS_TRUE \ |
| 41 | "Archive debug information for build" |
David McMahon | 4930294 | 2010-02-18 16:55:35 -0800 | [diff] [blame] | 42 | DEFINE_string board "$DEFAULT_BOARD" \ |
Nick Sanders | 5fa0950 | 2010-05-20 20:37:14 -0700 | [diff] [blame] | 43 | "The board to build packages for." |
robotboy | b49136d | 2010-06-29 15:03:37 -0700 | [diff] [blame] | 44 | DEFINE_string build_number "" \ |
| 45 | "The build-bot build number (when called by buildbot only)." "b" |
Ken Mixter | aba0429 | 2010-06-30 12:38:53 -0700 | [diff] [blame] | 46 | DEFINE_string chroot "$DEFAULT_CHROOT_DIR" \ |
| 47 | "The chroot of the build to archive." |
Chris Sosa | c04833c | 2011-02-14 11:31:14 -0800 | [diff] [blame] | 48 | DEFINE_boolean debug $FLAGS_FALSE "Run, but don't upload anything." |
robotboy | b49136d | 2010-06-29 15:03:37 -0700 | [diff] [blame] | 49 | DEFINE_boolean factory_install_mod $FLAGS_FALSE \ |
| 50 | "Modify image for factory install purposes" |
Ken Mixter | aba0429 | 2010-06-30 12:38:53 -0700 | [diff] [blame] | 51 | DEFINE_boolean factory_test_mod $FLAGS_FALSE \ |
| 52 | "Modify image for factory testing purposes" |
| 53 | DEFINE_string from "$DEFAULT_FROM" \ |
| 54 | "Directory to archive" |
bradnelson | 7fcb192 | 2010-06-22 20:37:01 -0700 | [diff] [blame] | 55 | DEFINE_string gsutil "gsutil" \ |
| 56 | "Location of gsutil" |
bradnelson | 8046594 | 2010-06-29 18:12:08 -0700 | [diff] [blame] | 57 | DEFINE_string gsd_gen_index "" \ |
| 58 | "Location of gsd_generate_index.py" |
| 59 | DEFINE_string acl "private" \ |
| 60 | "ACL to set on GSD archives" |
bradnelson | 7fcb192 | 2010-06-22 20:37:01 -0700 | [diff] [blame] | 61 | DEFINE_string gsutil_archive "" \ |
| 62 | "Optional datastore archive location" |
Scott Zawalski | c1bb3c8 | 2011-03-25 16:56:32 -0700 | [diff] [blame] | 63 | DEFINE_boolean gsutil_append_last_change $FLAGS_TRUE \ |
| 64 | "Optional Whether to append build # and chrome os hash to GS uploads" |
Ken Mixter | aba0429 | 2010-06-30 12:38:53 -0700 | [diff] [blame] | 65 | DEFINE_integer keep_max 0 "Maximum builds to keep in archive (0=all)" |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 66 | DEFINE_boolean official_build $FLAGS_FALSE \ |
| 67 | "Set CHROMEOS_OFFICIAL=1 for release builds." |
Chris Sosa | c04833c | 2011-02-14 11:31:14 -0800 | [diff] [blame] | 68 | DEFINE_string test_tarball "" "Optional path to test tarball to archive" |
Ken Mixter | aba0429 | 2010-06-30 12:38:53 -0700 | [diff] [blame] | 69 | DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes" |
Scott Zawalski | 3b0c6d8 | 2010-10-29 11:07:42 -0700 | [diff] [blame] | 70 | DEFINE_boolean prebuilt_upload $FLAGS_FALSE "Upload prebuilt binary packages." |
Chris Sosa | b885b80 | 2011-02-16 15:33:11 -0800 | [diff] [blame] | 71 | DEFINE_boolean remove_dev $FLAGS_TRUE "Remove the de image during archive." |
Ken Mixter | aba0429 | 2010-06-30 12:38:53 -0700 | [diff] [blame] | 72 | DEFINE_string to "$DEFAULT_TO" "Directory of build archive" |
| 73 | DEFINE_string zipname "image.zip" "Name of zip file to create." |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 74 | |
| 75 | # Parse command line |
| 76 | FLAGS "$@" || exit 1 |
| 77 | eval set -- "${FLAGS_ARGV}" |
| 78 | |
Chris Sosa | 3adaa54 | 2010-05-06 17:52:32 -0700 | [diff] [blame] | 79 | # Set if default from path is used |
| 80 | DEFAULT_USED= |
| 81 | |
David McMahon | 7c86716 | 2010-02-19 15:59:39 -0800 | [diff] [blame] | 82 | # Reset "default" FLAGS_from based on passed-in board if not set on cmd-line |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 83 | if [ "$FLAGS_from" = "$DEFAULT_FROM" ]; then |
Nick Sanders | ad0599f | 2010-10-22 21:15:02 -0700 | [diff] [blame] | 84 | # 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 Sosa | 3adaa54 | 2010-05-06 17:52:32 -0700 | [diff] [blame] | 87 | DEFAULT_USED=1 |
David McMahon | 7c86716 | 2010-02-19 15:59:39 -0800 | [diff] [blame] | 88 | fi |
| 89 | |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 90 | # Die on any errors. |
| 91 | set -e |
| 92 | |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 93 | if [ -z "$DEFAULT_USED" ]; then |
Nick Sanders | ad0599f | 2010-10-22 21:15:02 -0700 | [diff] [blame] | 94 | 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 Sosa | 3adaa54 | 2010-05-06 17:52:32 -0700 | [diff] [blame] | 103 | fi |
| 104 | |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 105 | if [ ! -d "$FLAGS_from" ]; then |
David McMahon | 7c86716 | 2010-02-19 15:59:39 -0800 | [diff] [blame] | 106 | echo "$FLAGS_from does not exist. Exiting..." |
| 107 | exit 1 |
| 108 | fi |
| 109 | |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 110 | if [ $FLAGS_official_build -eq $FLAGS_TRUE ]; then |
djmm@google.com | 72cfa11 | 2009-11-17 00:26:20 +0000 | [diff] [blame] | 111 | CHROMEOS_OFFICIAL=1 |
| 112 | fi |
| 113 | |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 114 | # Get version information |
Yasuhiro Matsuda | 27c473d | 2010-12-15 17:35:54 +0900 | [diff] [blame] | 115 | . ${SRC_ROOT}/third_party/chromiumos-overlay/chromeos/config/chromeos_version.sh |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 116 | |
David McMahon | 03aeb20 | 2009-12-08 12:47:08 -0800 | [diff] [blame] | 117 | # Get git hash |
| 118 | # Use git:8 chars of sha1 |
| 119 | REVISION=$(git rev-parse HEAD) |
| 120 | REVISION=${REVISION:0:8} |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 121 | |
| 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 McMahon | b059e34 | 2009-12-08 18:10:45 -0800 | [diff] [blame] | 124 | LAST_CHANGE="${CHROMEOS_VERSION_STRING}-r${REVISION}" |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 125 | if [ -n "$FLAGS_build_number" ]; then |
David McMahon | b059e34 | 2009-12-08 18:10:45 -0800 | [diff] [blame] | 126 | LAST_CHANGE="$LAST_CHANGE-b${FLAGS_build_number}" |
| 127 | fi |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 128 | |
| 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 |
| 131 | echo "last change: $LAST_CHANGE" |
| 132 | echo "archive from: $FLAGS_from" |
| 133 | |
| 134 | # Create the output directory |
| 135 | OUTDIR="${FLAGS_to}/${LAST_CHANGE}" |
| 136 | ZIPFILE="${OUTDIR}/${FLAGS_zipname}" |
Nick Sanders | 5fa0950 | 2010-05-20 20:37:14 -0700 | [diff] [blame] | 137 | FACTORY_ZIPFILE="${OUTDIR}/factory_${FLAGS_zipname}" |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 138 | echo "archive to dir: $OUTDIR" |
| 139 | echo "archive to file: $ZIPFILE" |
| 140 | |
| 141 | rm -rf "$OUTDIR" |
| 142 | mkdir -p "$OUTDIR" |
| 143 | |
Chris Sosa | 8a09a05 | 2010-01-19 16:05:36 -0800 | [diff] [blame] | 144 | # Modify image for test if flag set. |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 145 | if [ $FLAGS_test_mod -eq $FLAGS_TRUE ]; then |
Chris Sosa | 8a09a05 | 2010-01-19 16:05:36 -0800 | [diff] [blame] | 146 | echo "Modifying image for test" |
Chris Sosa | b885b80 | 2011-02-16 15:33:11 -0800 | [diff] [blame] | 147 | ./enter_chroot.sh -- ./mod_image_for_test.sh --board $FLAGS_board \ |
| 148 | --noinplace --yes |
Nick Sanders | 5fa0950 | 2010-05-20 20:37:14 -0700 | [diff] [blame] | 149 | |
| 150 | pushd "${FLAGS_chroot}/build/${FLAGS_board}/usr/local" |
Ken Mixter | eb31903 | 2010-02-26 17:33:51 -0800 | [diff] [blame] | 151 | echo "Archiving autotest build artifacts" |
Zelidrag Hornung | 151112c | 2010-07-29 10:32:26 -0700 | [diff] [blame] | 152 | tar cjf "${FLAGS_from}/autotest.tar.bz2" --checkpoint=1000 autotest |
Nick Sanders | 5fa0950 | 2010-05-20 20:37:14 -0700 | [diff] [blame] | 153 | popd |
Chris Sosa | 8a09a05 | 2010-01-19 16:05:36 -0800 | [diff] [blame] | 154 | fi |
| 155 | |
David McMahon | 7f2951d | 2010-07-29 14:37:06 -0700 | [diff] [blame] | 156 | # Modify for recovery |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 157 | if [ $FLAGS_official_build -eq $FLAGS_TRUE ]; then |
Nick Sanders | ad0599f | 2010-10-22 21:15:02 -0700 | [diff] [blame] | 158 | 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 Zawalski | ec6421c | 2010-08-02 12:31:35 -0700 | [diff] [blame] | 161 | --image $CHROOT_IMAGE_DIR/chromiumos_base_image.bin |
David McMahon | 7f2951d | 2010-07-29 14:37:06 -0700 | [diff] [blame] | 162 | fi |
| 163 | |
Chris Sosa | bfabd93 | 2010-05-21 09:54:46 -0700 | [diff] [blame] | 164 | # Remove the developer build if test image is also built. |
Chris Sosa | b885b80 | 2011-02-16 15:33:11 -0800 | [diff] [blame] | 165 | if [ $FLAGS_remove_dev -eq $FLAGS_TRUE ]; then |
| 166 | rm -f "${FLAGS_from}/${CHROMEOS_IMAGE_NAME}" |
Chris Sosa | bfabd93 | 2010-05-21 09:54:46 -0700 | [diff] [blame] | 167 | fi |
Nick Sanders | 5fa0950 | 2010-05-20 20:37:14 -0700 | [diff] [blame] | 168 | |
Nick Sanders | 4ed0b86 | 2011-03-06 15:21:42 -0800 | [diff] [blame] | 169 | if [ $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}" |
| 191 | fi |
| 192 | |
Nick Sanders | ad0599f | 2010-10-22 21:15:02 -0700 | [diff] [blame] | 193 | # Build differently sized shims. Currently only factory install shim is |
| 194 | # supported, TODO(tgao): Add developer shim. |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 195 | if [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then |
Nick Sanders | ad0599f | 2010-10-22 21:15:02 -0700 | [diff] [blame] | 196 | echo "Building factory install shim." |
| 197 | # HACK: The build system can't currently handle more than one image size |
Nick Sanders | 4ed0b86 | 2011-03-06 15:21:42 -0800 | [diff] [blame] | 198 | # at a time. Therefore it's necessary to do another round of build after |
Nick Sanders | ad0599f | 2010-10-22 21:15:02 -0700 | [diff] [blame] | 199 | # 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 Sanders | ad0599f | 2010-10-22 21:15:02 -0700 | [diff] [blame] | 213 | echo "Factory install shim dir: ${SHIM_DIR}" |
| 214 | fi |
| 215 | |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 216 | # Zip the build |
| 217 | echo "Compressing and archiving build..." |
David McMahon | 7c86716 | 2010-02-19 15:59:39 -0800 | [diff] [blame] | 218 | cd "$FLAGS_from" |
Nick Sanders | 5fa0950 | 2010-05-20 20:37:14 -0700 | [diff] [blame] | 219 | MANIFEST=`ls | grep -v factory` |
| 220 | zip -r "${ZIPFILE}" ${MANIFEST} |
| 221 | |
| 222 | if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 223 | [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then |
Nick Sanders | ad0599f | 2010-10-22 21:15:02 -0700 | [diff] [blame] | 224 | # 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 Sanders | 4ed0b86 | 2011-03-06 15:21:42 -0800 | [diff] [blame] | 228 | [ -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 Sanders | ad0599f | 2010-10-22 21:15:02 -0700 | [diff] [blame] | 232 | |
| 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 Sanders | 07eac9e | 2010-06-16 04:19:39 -0700 | [diff] [blame] | 243 | chmod 644 "${FACTORY_ZIPFILE}" |
Nick Sanders | 5fa0950 | 2010-05-20 20:37:14 -0700 | [diff] [blame] | 244 | fi |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 245 | cd - |
| 246 | |
| 247 | # Update LATEST file |
| 248 | echo "$LAST_CHANGE" > "${FLAGS_to}/LATEST" |
| 249 | |
| 250 | # Make sure files are readable |
| 251 | chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST" |
| 252 | chmod 755 "$OUTDIR" |
Raja Aluri | aeb1048 | 2010-12-10 13:03:09 -0800 | [diff] [blame] | 253 | cp -f "${FLAGS_from}/au-generator.zip" "${OUTDIR}/" |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 254 | |
bradnelson | 8046594 | 2010-06-29 18:12:08 -0700 | [diff] [blame] | 255 | |
bradnelson | 8046594 | 2010-06-29 18:12:08 -0700 | [diff] [blame] | 256 | function gsutil_archive() { |
| 257 | IN_PATH="$1" |
| 258 | OUT_PATH="$2" |
Scott Zawalski | c1bb3c8 | 2011-03-25 16:56:32 -0700 | [diff] [blame] | 259 | if [ ${FLAGS_gsutil_append_last_change} -eq ${FLAGS_TRUE} ]; then |
| 260 | OUT_PATH="${LAST_CHANGE}/${OUT_PATH}" |
| 261 | fi |
| 262 | |
Chris Sosa | c04833c | 2011-02-14 11:31:14 -0800 | [diff] [blame] | 263 | 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} |
bradnelson | 8046594 | 2010-06-29 18:12:08 -0700 | [diff] [blame] | 279 | fi |
| 280 | } |
| 281 | |
David McMahon | ad9c203 | 2010-04-12 12:21:35 -0700 | [diff] [blame] | 282 | if [ $FLAGS_test_mod -eq $FLAGS_TRUE -a $FLAGS_official_build -eq $FLAGS_TRUE ] |
Ken Mixter | 54a3e83 | 2010-03-12 14:52:51 -0800 | [diff] [blame] | 283 | then |
| 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}" |
bradnelson | 8046594 | 2010-06-29 18:12:08 -0700 | [diff] [blame] | 288 | gsutil_archive "${OUTDIR}/${HWQUAL_NAME}.tar.bz2" \ |
Scott Zawalski | c1bb3c8 | 2011-03-25 16:56:32 -0700 | [diff] [blame] | 289 | "${HWQUAL_NAME}.tar.bz2" |
bradnelson | 7fcb192 | 2010-06-22 20:37:01 -0700 | [diff] [blame] | 290 | fi |
| 291 | |
Scott Zawalski | 695adf1 | 2010-10-28 16:56:00 -0700 | [diff] [blame] | 292 | |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 293 | if [ $FLAGS_prebuilt_upload -eq $FLAGS_TRUE ]; then |
Scott Zawalski | 3b0c6d8 | 2010-10-29 11:07:42 -0700 | [diff] [blame] | 294 | # Construct prebuilt upload command. |
| 295 | # This will upload prebuilt packages to Google Storage. |
David James | 2b2f19f | 2011-02-02 10:35:42 -0800 | [diff] [blame] | 296 | prebuilt_cmd="${GCLIENT_ROOT}/chromite/buildbot/prebuilt.py" |
Scott Zawalski | 3b0c6d8 | 2010-10-29 11:07:42 -0700 | [diff] [blame] | 297 | prebuilt_cmd="$prebuilt_cmd -u gs://chromeos-prebuilt --git-sync -V master" |
Scott Zawalski | 7333e2b | 2010-11-02 18:01:14 -0700 | [diff] [blame] | 298 | prebuilt_cmd="$prebuilt_cmd -p ${GCLIENT_ROOT} -b ${FLAGS_board}" |
Scott Zawalski | 695adf1 | 2010-10-28 16:56:00 -0700 | [diff] [blame] | 299 | |
David James | 3146eaa | 2010-12-09 09:37:14 -0800 | [diff] [blame] | 300 | if [ "${FLAGS_board}" == "x86-generic" ] |
Scott Zawalski | 3b0c6d8 | 2010-10-29 11:07:42 -0700 | [diff] [blame] | 301 | then |
| 302 | prebuilt_cmd="$prebuilt_cmd --sync-host" |
| 303 | fi |
| 304 | |
Chris Sosa | c04833c | 2011-02-14 11:31:14 -0800 | [diff] [blame] | 305 | 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 Zawalski | 3b0c6d8 | 2010-10-29 11:07:42 -0700 | [diff] [blame] | 311 | fi |
Scott Zawalski | 695adf1 | 2010-10-28 16:56:00 -0700 | [diff] [blame] | 312 | |
Scott Zawalski | c1bb3c8 | 2011-03-25 16:56:32 -0700 | [diff] [blame] | 313 | gsutil_archive "${ZIPFILE}" "${FLAGS_zipname}" |
Ken Mixter | 25d48c4 | 2010-07-01 11:20:42 -0700 | [diff] [blame] | 314 | |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 315 | if [ $FLAGS_archive_debug -eq $FLAGS_TRUE ]; then |
Ken Mixter | 8899d5a | 2010-08-25 09:17:38 -0700 | [diff] [blame] | 316 | echo "Generating Breakpad symbols" |
| 317 | ! ${SCRIPTS_DIR}/cros_generate_breakpad_symbols --board=${FLAGS_board} |
Ken Mixter | aba0429 | 2010-06-30 12:38:53 -0700 | [diff] [blame] | 318 | echo "Creating debug archive" |
| 319 | pushd "${FLAGS_chroot}/build/${FLAGS_board}/usr/lib" |
Zelidrag Hornung | 151112c | 2010-07-29 10:32:26 -0700 | [diff] [blame] | 320 | sudo tar czf "${OUTDIR}/debug.tgz" --checkpoint=1000 --exclude\ |
| 321 | debug/usr/local/autotest --exclude debug/tests debug |
Ken Mixter | aba0429 | 2010-06-30 12:38:53 -0700 | [diff] [blame] | 322 | CMD="chown \${SUDO_UID}:\${SUDO_GID} ${OUTDIR}/debug.tgz" |
| 323 | sudo sh -c "${CMD}" |
| 324 | popd |
Scott Zawalski | c1bb3c8 | 2011-03-25 16:56:32 -0700 | [diff] [blame] | 325 | gsutil_archive "${OUTDIR}/debug.tgz" "debug.tgz" |
Ken Mixter | aba0429 | 2010-06-30 12:38:53 -0700 | [diff] [blame] | 326 | fi |
| 327 | |
bradnelson | 8046594 | 2010-06-29 18:12:08 -0700 | [diff] [blame] | 328 | if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 329 | [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then |
bradnelson | 8046594 | 2010-06-29 18:12:08 -0700 | [diff] [blame] | 330 | gsutil_archive "${FACTORY_ZIPFILE}" \ |
Scott Zawalski | c1bb3c8 | 2011-03-25 16:56:32 -0700 | [diff] [blame] | 331 | "factory_${FLAGS_zipname}" |
Ken Mixter | 54a3e83 | 2010-03-12 14:52:51 -0800 | [diff] [blame] | 332 | fi |
Chris Sosa | c04833c | 2011-02-14 11:31:14 -0800 | [diff] [blame] | 333 | |
bradnelson | 8046594 | 2010-06-29 18:12:08 -0700 | [diff] [blame] | 334 | gsutil_archive "${FLAGS_to}/LATEST" "LATEST" |
Ken Mixter | 54a3e83 | 2010-03-12 14:52:51 -0800 | [diff] [blame] | 335 | |
Chris Sosa | 89e9244 | 2011-02-11 17:42:55 -0800 | [diff] [blame] | 336 | if [ -n "${FLAGS_gsutil_archive}" ]; then |
Scott Zawalski | c1bb3c8 | 2011-03-25 16:56:32 -0700 | [diff] [blame] | 337 | 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 Sosa | 89e9244 | 2011-02-11 17:42:55 -0800 | [diff] [blame] | 342 | RELATIVE_ARCHIVE_URL_PATH="${FULL_INDEX_PATH#gs://}" |
| 343 | echo "CROS_ARCHIVE_URL=\ |
| 344 | https://sandbox.google.com/storage/${RELATIVE_ARCHIVE_URL_PATH}" |
| 345 | fi |
| 346 | |
Chris Sosa | c04833c | 2011-02-14 11:31:14 -0800 | [diff] [blame] | 347 | if [ -n "${FLAGS_test_tarball}" ]; then |
Scott Zawalski | c1bb3c8 | 2011-03-25 16:56:32 -0700 | [diff] [blame] | 348 | gsutil_archive "${FLAGS_test_tarball}" "test_results.tgz" |
Chris Sosa | c04833c | 2011-02-14 11:31:14 -0800 | [diff] [blame] | 349 | fi |
| 350 | |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 351 | # Purge old builds if necessary |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 352 | if [ $FLAGS_keep_max -gt 0 ]; then |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 353 | 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 - |
| 358 | fi |
| 359 | |
| 360 | echo "Done." |