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. |
11 . "$(dirname "$0")/common.sh" | 11 . "$(dirname "$0")/common.sh" |
12 | 12 |
13 # Script must be run outside the chroot | 13 # Script must be run outside the chroot |
14 assert_outside_chroot | 14 assert_outside_chroot |
15 | 15 |
16 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images" | 16 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images" |
17 # Default to the most recent image | 17 # Default to the most recent image |
18 DEFAULT_TO="${GCLIENT_ROOT}/archive" | 18 DEFAULT_TO="${GCLIENT_ROOT}/archive" |
19 DEFAULT_FROM="${IMAGES_DIR}/$DEFAULT_BOARD/$(ls -t1 \ | 19 DEFAULT_FROM="${IMAGES_DIR}/$DEFAULT_BOARD/$(ls -t1 \ |
20 $IMAGES_DIR/$DEFAULT_BOARD 2>&-| head -1)" | 20 $IMAGES_DIR/$DEFAULT_BOARD 2>&-| head -1)" |
21 | 21 |
22 # Flags | 22 # Flags |
| 23 DEFINE_boolean archive_debug $FLAGS_TRUE \ |
| 24 "Archive debug information for build" |
23 DEFINE_string board "$DEFAULT_BOARD" \ | 25 DEFINE_string board "$DEFAULT_BOARD" \ |
24 "The board to build packages for." | 26 "The board to build packages for." |
| 27 DEFINE_string build_number "" \ |
| 28 "The build-bot build number (when called by buildbot only)." "b" |
25 DEFINE_string chroot "$DEFAULT_CHROOT_DIR" \ | 29 DEFINE_string chroot "$DEFAULT_CHROOT_DIR" \ |
26 "The chroot of the build to archive." | 30 "The chroot of the build to archive." |
| 31 DEFINE_boolean factory_install_mod $FLAGS_FALSE \ |
| 32 "Modify image for factory install purposes" |
| 33 DEFINE_boolean factory_test_mod $FLAGS_FALSE \ |
| 34 "Modify image for factory testing purposes" |
27 DEFINE_string from "$DEFAULT_FROM" \ | 35 DEFINE_string from "$DEFAULT_FROM" \ |
28 "Directory to archive" | 36 "Directory to archive" |
29 DEFINE_string to "$DEFAULT_TO" "Directory of build archive" | |
30 DEFINE_integer keep_max 0 "Maximum builds to keep in archive (0=all)" | |
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." | |
33 DEFINE_string build_number "" \ | |
34 "The build-bot build number (when called by buildbot only)." "b" | |
35 DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes" | |
36 DEFINE_boolean factory_test_mod $FLAGS_FALSE \ | |
37 "Modify image for factory testing purposes" | |
38 DEFINE_boolean factory_install_mod $FLAGS_FALSE \ | |
39 "Modify image for factory install purposes" | |
40 DEFINE_string gsutil "gsutil" \ | 37 DEFINE_string gsutil "gsutil" \ |
41 "Location of gsutil" | 38 "Location of gsutil" |
42 DEFINE_string gsutil_archive "" \ | 39 DEFINE_string gsutil_archive "" \ |
43 "Optional datastore archive location" | 40 "Optional datastore archive location" |
| 41 DEFINE_integer keep_max 0 "Maximum builds to keep in archive (0=all)" |
| 42 DEFINE_boolean official_build $FLAGS_FALSE "Set CHROMEOS_OFFICIAL=1 for release
builds." |
| 43 DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes" |
| 44 DEFINE_string to "$DEFAULT_TO" "Directory of build archive" |
| 45 DEFINE_string zipname "image.zip" "Name of zip file to create." |
44 | 46 |
45 # Parse command line | 47 # Parse command line |
46 FLAGS "$@" || exit 1 | 48 FLAGS "$@" || exit 1 |
47 eval set -- "${FLAGS_ARGV}" | 49 eval set -- "${FLAGS_ARGV}" |
48 | 50 |
49 # Set if default from path is used | 51 # Set if default from path is used |
50 DEFAULT_USED= | 52 DEFAULT_USED= |
51 | 53 |
52 # Reset "default" FLAGS_from based on passed-in board if not set on cmd-line | 54 # Reset "default" FLAGS_from based on passed-in board if not set on cmd-line |
53 if [ "$FLAGS_from" = "$DEFAULT_FROM" ] | 55 if [ "$FLAGS_from" = "$DEFAULT_FROM" ] |
54 then | 56 then |
55 FLAGS_from="${IMAGES_DIR}/$FLAGS_board/$(ls -t1 \ | 57 FLAGS_from="${IMAGES_DIR}/$FLAGS_board/$(ls -t1 \ |
56 $IMAGES_DIR/$FLAGS_board 2>&-| head -1)" | 58 $IMAGES_DIR/$FLAGS_board 2>&-| head -1)" |
57 DEFAULT_USED=1 | 59 DEFAULT_USED=1 |
58 fi | 60 fi |
59 | 61 |
60 # Die on any errors. | 62 # Die on any errors. |
61 set -e | 63 set -e |
62 | 64 |
| 65 # Extend sudo timeout since we need it later. |
| 66 sudo -v |
| 67 |
63 if [ -z $DEFAULT_USED ] && [ $FLAGS_test_mod -eq $FLAGS_TRUE ] | 68 if [ -z $DEFAULT_USED ] && [ $FLAGS_test_mod -eq $FLAGS_TRUE ] |
64 then | 69 then |
65 echo "test_mod requires that the default from path be used." | 70 echo "test_mod requires that the default from path be used." |
66 echo "If non default behavior is desired, run mod_image_for_test manually" | 71 echo "If non default behavior is desired, run mod_image_for_test manually" |
67 echo "re-run archive build without test_mod" | 72 echo "re-run archive build without test_mod" |
68 exit 1 | 73 exit 1 |
69 fi | 74 fi |
70 | 75 |
71 if [ ! -d "$FLAGS_from" ] | 76 if [ ! -d "$FLAGS_from" ] |
72 then | 77 then |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST" | 185 chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST" |
181 chmod 755 "$OUTDIR" | 186 chmod 755 "$OUTDIR" |
182 | 187 |
183 if [ $FLAGS_test_mod -eq $FLAGS_TRUE -a $FLAGS_official_build -eq $FLAGS_TRUE ] | 188 if [ $FLAGS_test_mod -eq $FLAGS_TRUE -a $FLAGS_official_build -eq $FLAGS_TRUE ] |
184 then | 189 then |
185 echo "Creating hwqual archive" | 190 echo "Creating hwqual archive" |
186 HWQUAL_NAME="chromeos-hwqual-${FLAGS_board}-${CHROMEOS_VERSION_STRING}" | 191 HWQUAL_NAME="chromeos-hwqual-${FLAGS_board}-${CHROMEOS_VERSION_STRING}" |
187 "${SCRIPTS_DIR}/archive_hwqual" --from "${OUTDIR}" \ | 192 "${SCRIPTS_DIR}/archive_hwqual" --from "${OUTDIR}" \ |
188 --output_tag "${HWQUAL_NAME}" | 193 --output_tag "${HWQUAL_NAME}" |
189 # Optionally archive with gsutil hwqual. | 194 # Optionally archive with gsutil hwqual. |
190 if [ $FLAGS_gsutil_archive != "" ] | 195 if [ "$FLAGS_gsutil_archive" != "" ] |
191 then | 196 then |
192 GS_OUTDIR="${FLAGS_gsutil_archive}/${LAST_CHANGE}" | 197 GS_OUTDIR="${FLAGS_gsutil_archive}/${LAST_CHANGE}" |
193 GS_HWQUAL_IN="${OUTDIR}/${HWQUAL_NAME}.tar.bz2" | 198 GS_HWQUAL_IN="${OUTDIR}/${HWQUAL_NAME}.tar.bz2" |
194 GS_HWQUAL_OUT="${GS_OUTDIR}/${HWQUAL_NAME}.tar.bz2" | 199 GS_HWQUAL_OUT="${GS_OUTDIR}/${HWQUAL_NAME}.tar.bz2" |
195 echo "Using gsutil to archive to ${GS_HWQUAL_OUT}..." | 200 echo "Using gsutil to archive to ${GS_HWQUAL_OUT}..." |
196 ${FLAGS_gsutil} cp ${GS_HWQUAL_IN} ${GS_HWQUAL_OUT} | 201 ${FLAGS_gsutil} cp ${GS_HWQUAL_IN} ${GS_HWQUAL_OUT} |
197 fi | 202 fi |
198 fi | 203 fi |
199 | 204 |
| 205 if [ $FLAGS_archive_debug -eq $FLAGS_TRUE ] |
| 206 then |
| 207 echo "Creating debug archive" |
| 208 pushd "${FLAGS_chroot}/build/${FLAGS_board}/usr/lib" |
| 209 sudo tar czf "${OUTDIR}/debug.tgz" --exclude debug/usr/local/autotest \ |
| 210 --exclude debug/tests debug |
| 211 CMD="chown \${SUDO_UID}:\${SUDO_GID} ${OUTDIR}/debug.tgz" |
| 212 sudo sh -c "${CMD}" |
| 213 popd |
| 214 fi |
| 215 |
200 # Optionally archive to Google Storage for Developers. | 216 # Optionally archive to Google Storage for Developers. |
201 if [ $FLAGS_gsutil_archive != "" ] | 217 if [ "$FLAGS_gsutil_archive" != "" ] |
202 then | 218 then |
203 GS_OUTDIR="${FLAGS_gsutil_archive}/${LAST_CHANGE}" | 219 GS_OUTDIR="${FLAGS_gsutil_archive}/${LAST_CHANGE}" |
204 GS_ZIPFILE="${GS_OUTDIR}/${FLAGS_zipname}" | 220 GS_ZIPFILE="${GS_OUTDIR}/${FLAGS_zipname}" |
205 GS_FACTORY_ZIPFILE="${GS_OUTDIR}/factory_${FLAGS_zipname}" | 221 GS_FACTORY_ZIPFILE="${GS_OUTDIR}/factory_${FLAGS_zipname}" |
206 GS_LATEST="${FLAGS_gsutil_archive}/LATEST" | 222 GS_LATEST="${FLAGS_gsutil_archive}/LATEST" |
207 echo "Using gsutil to archive to ${GS_ZIPFILE}..." | 223 echo "Using gsutil to archive to ${GS_ZIPFILE}..." |
208 ${FLAGS_gsutil} cp ${ZIPFILE} ${GS_ZIPFILE} | 224 ${FLAGS_gsutil} cp ${ZIPFILE} ${GS_ZIPFILE} |
209 | 225 |
210 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ | 226 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ |
211 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] | 227 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] |
(...skipping 10 matching lines...) Expand all Loading... |
222 if [ $FLAGS_keep_max -gt 0 ] | 238 if [ $FLAGS_keep_max -gt 0 ] |
223 then | 239 then |
224 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." | 240 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." |
225 cd "$FLAGS_to" | 241 cd "$FLAGS_to" |
226 # +2 because line numbers start at 1 and need to skip LATEST file | 242 # +2 because line numbers start at 1 and need to skip LATEST file |
227 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` | 243 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` |
228 cd - | 244 cd - |
229 fi | 245 fi |
230 | 246 |
231 echo "Done." | 247 echo "Done." |
OLD | NEW |