Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: archive_build.sh

Issue 6508011: Add tarball option and print out what gsutil would do to make it easier to debug. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: One more time Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 # --- BEGIN COMMON.SH BOILERPLATE --- 9 # --- BEGIN COMMON.SH BOILERPLATE ---
10 # Load common CrOS utilities. Inside the chroot this file is installed in 10 # Load common CrOS utilities. Inside the chroot this file is installed in
(...skipping 27 matching lines...) Expand all
38 38
39 # Flags 39 # Flags
40 DEFINE_boolean archive_debug $FLAGS_TRUE \ 40 DEFINE_boolean archive_debug $FLAGS_TRUE \
41 "Archive debug information for build" 41 "Archive debug information for build"
42 DEFINE_string board "$DEFAULT_BOARD" \ 42 DEFINE_string board "$DEFAULT_BOARD" \
43 "The board to build packages for." 43 "The board to build packages for."
44 DEFINE_string build_number "" \ 44 DEFINE_string build_number "" \
45 "The build-bot build number (when called by buildbot only)." "b" 45 "The build-bot build number (when called by buildbot only)." "b"
46 DEFINE_string chroot "$DEFAULT_CHROOT_DIR" \ 46 DEFINE_string chroot "$DEFAULT_CHROOT_DIR" \
47 "The chroot of the build to archive." 47 "The chroot of the build to archive."
48 DEFINE_boolean debug $FLAGS_FALSE "Run, but don't upload anything."
48 DEFINE_boolean factory_install_mod $FLAGS_FALSE \ 49 DEFINE_boolean factory_install_mod $FLAGS_FALSE \
49 "Modify image for factory install purposes" 50 "Modify image for factory install purposes"
50 DEFINE_boolean factory_test_mod $FLAGS_FALSE \ 51 DEFINE_boolean factory_test_mod $FLAGS_FALSE \
51 "Modify image for factory testing purposes" 52 "Modify image for factory testing purposes"
52 DEFINE_string from "$DEFAULT_FROM" \ 53 DEFINE_string from "$DEFAULT_FROM" \
53 "Directory to archive" 54 "Directory to archive"
54 DEFINE_string gsutil "gsutil" \ 55 DEFINE_string gsutil "gsutil" \
55 "Location of gsutil" 56 "Location of gsutil"
56 DEFINE_string gsd_gen_index "" \ 57 DEFINE_string gsd_gen_index "" \
57 "Location of gsd_generate_index.py" 58 "Location of gsd_generate_index.py"
58 DEFINE_string acl "private" \ 59 DEFINE_string acl "private" \
59 "ACL to set on GSD archives" 60 "ACL to set on GSD archives"
60 DEFINE_string gsutil_archive "" \ 61 DEFINE_string gsutil_archive "" \
61 "Optional datastore archive location" 62 "Optional datastore archive location"
62 DEFINE_integer keep_max 0 "Maximum builds to keep in archive (0=all)" 63 DEFINE_integer keep_max 0 "Maximum builds to keep in archive (0=all)"
63 DEFINE_boolean official_build $FLAGS_FALSE \ 64 DEFINE_boolean official_build $FLAGS_FALSE \
64 "Set CHROMEOS_OFFICIAL=1 for release builds." 65 "Set CHROMEOS_OFFICIAL=1 for release builds."
66 DEFINE_string test_tarball "" "Optional path to test tarball to archive"
65 DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes" 67 DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes"
66 DEFINE_boolean prebuilt_upload $FLAGS_FALSE "Upload prebuilt binary packages." 68 DEFINE_boolean prebuilt_upload $FLAGS_FALSE "Upload prebuilt binary packages."
67 DEFINE_string to "$DEFAULT_TO" "Directory of build archive" 69 DEFINE_string to "$DEFAULT_TO" "Directory of build archive"
68 DEFINE_string zipname "image.zip" "Name of zip file to create." 70 DEFINE_string zipname "image.zip" "Name of zip file to create."
69 71
70 # Parse command line 72 # Parse command line
71 FLAGS "$@" || exit 1 73 FLAGS "$@" || exit 1
72 eval set -- "${FLAGS_ARGV}" 74 eval set -- "${FLAGS_ARGV}"
73 75
74 # Set if default from path is used 76 # Set if default from path is used
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 243
242 # Make sure files are readable 244 # Make sure files are readable
243 chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST" 245 chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST"
244 chmod 755 "$OUTDIR" 246 chmod 755 "$OUTDIR"
245 cp -f "${FLAGS_from}/au-generator.zip" "${OUTDIR}/" 247 cp -f "${FLAGS_from}/au-generator.zip" "${OUTDIR}/"
246 248
247 249
248 function gsutil_archive() { 250 function gsutil_archive() {
249 IN_PATH="$1" 251 IN_PATH="$1"
250 OUT_PATH="$2" 252 OUT_PATH="$2"
251 if [ -n "$FLAGS_gsutil_archive" ] 253 echo "Using gsutil to archive to ${OUT_PATH}..."
252 then 254 if [ -n "$FLAGS_gsutil_archive" -a ${FLAGS_debug} -eq ${FLAGS_FALSE} ]; then
253 FULL_OUT_PATH="${FLAGS_gsutil_archive}/${OUT_PATH}" 255 FULL_OUT_PATH="${FLAGS_gsutil_archive}/${OUT_PATH}"
254 echo "Using gsutil to archive to ${OUT_PATH}..."
255 ${FLAGS_gsutil} cp ${IN_PATH} ${FULL_OUT_PATH} 256 ${FLAGS_gsutil} cp ${IN_PATH} ${FULL_OUT_PATH}
256 ${FLAGS_gsutil} setacl ${FLAGS_acl} ${FULL_OUT_PATH} 257 ${FLAGS_gsutil} setacl ${FLAGS_acl} ${FULL_OUT_PATH}
257 if [ -n "$FLAGS_gsd_gen_index" ] 258 if [ -n "$FLAGS_gsd_gen_index" ]
258 then 259 then
259 echo "Updating indexes..." 260 echo "Updating indexes..."
260 ${FLAGS_gsd_gen_index} \ 261 ${FLAGS_gsd_gen_index} \
261 --gsutil=${FLAGS_gsutil} \ 262 --gsutil=${FLAGS_gsutil} \
262 -a ${FLAGS_acl} \ 263 -a ${FLAGS_acl} \
263 -p ${FULL_OUT_PATH} ${FLAGS_gsutil_archive} 264 -p ${FULL_OUT_PATH} ${FLAGS_gsutil_archive}
264 fi 265 fi
266 else
267 echo -n "In debug mode. Would have run: "
268 echo "gsutil cp ${IN_PATH} <gsutil_archive>/${OUT_PATH}"
265 fi 269 fi
266 } 270 }
267 271
268 if [ $FLAGS_test_mod -eq $FLAGS_TRUE -a $FLAGS_official_build -eq $FLAGS_TRUE ] 272 if [ $FLAGS_test_mod -eq $FLAGS_TRUE -a $FLAGS_official_build -eq $FLAGS_TRUE ]
269 then 273 then
270 echo "Creating hwqual archive" 274 echo "Creating hwqual archive"
271 HWQUAL_NAME="chromeos-hwqual-${FLAGS_board}-${CHROMEOS_VERSION_STRING}" 275 HWQUAL_NAME="chromeos-hwqual-${FLAGS_board}-${CHROMEOS_VERSION_STRING}"
272 "${SCRIPTS_DIR}/archive_hwqual" --from "${OUTDIR}" \ 276 "${SCRIPTS_DIR}/archive_hwqual" --from "${OUTDIR}" \
273 --output_tag "${HWQUAL_NAME}" 277 --output_tag "${HWQUAL_NAME}"
274 gsutil_archive "${OUTDIR}/${HWQUAL_NAME}.tar.bz2" \ 278 gsutil_archive "${OUTDIR}/${HWQUAL_NAME}.tar.bz2" \
275 "${LAST_CHANGE}/${HWQUAL_NAME}.tar.bz2" 279 "${LAST_CHANGE}/${HWQUAL_NAME}.tar.bz2"
276 fi 280 fi
277 281
278 282
279 if [ $FLAGS_prebuilt_upload -eq $FLAGS_TRUE ]; then 283 if [ $FLAGS_prebuilt_upload -eq $FLAGS_TRUE ]; then
280 # Construct prebuilt upload command. 284 # Construct prebuilt upload command.
281 # This will upload prebuilt packages to Google Storage. 285 # This will upload prebuilt packages to Google Storage.
282 prebuilt_cmd="${GCLIENT_ROOT}/chromite/buildbot/prebuilt.py" 286 prebuilt_cmd="${GCLIENT_ROOT}/chromite/buildbot/prebuilt.py"
283 prebuilt_cmd="$prebuilt_cmd -u gs://chromeos-prebuilt --git-sync -V master" 287 prebuilt_cmd="$prebuilt_cmd -u gs://chromeos-prebuilt --git-sync -V master"
284 prebuilt_cmd="$prebuilt_cmd -p ${GCLIENT_ROOT} -b ${FLAGS_board}" 288 prebuilt_cmd="$prebuilt_cmd -p ${GCLIENT_ROOT} -b ${FLAGS_board}"
285 289
286 if [ "${FLAGS_board}" == "x86-generic" ] 290 if [ "${FLAGS_board}" == "x86-generic" ]
287 then 291 then
288 prebuilt_cmd="$prebuilt_cmd --sync-host" 292 prebuilt_cmd="$prebuilt_cmd --sync-host"
289 fi 293 fi
290 294
291 echo "Running $prebuilt_cmd" 295 if [ ${FLAGS_debug} -eq ${FLAGS_FALSE} ]; then
292 $prebuilt_cmd 296 echo "Running $prebuilt_cmd"
297 $prebuilt_cmd
298 else
299 echo "Would have run $prebuilt_cmd"
300 fi
293 fi 301 fi
294 302
295 gsutil_archive "${ZIPFILE}" "${LAST_CHANGE}/${FLAGS_zipname}" 303 gsutil_archive "${ZIPFILE}" "${LAST_CHANGE}/${FLAGS_zipname}"
296 304
297 if [ $FLAGS_archive_debug -eq $FLAGS_TRUE ]; then 305 if [ $FLAGS_archive_debug -eq $FLAGS_TRUE ]; then
298 echo "Generating Breakpad symbols" 306 echo "Generating Breakpad symbols"
299 ! ${SCRIPTS_DIR}/cros_generate_breakpad_symbols --board=${FLAGS_board} 307 ! ${SCRIPTS_DIR}/cros_generate_breakpad_symbols --board=${FLAGS_board}
300 echo "Creating debug archive" 308 echo "Creating debug archive"
301 pushd "${FLAGS_chroot}/build/${FLAGS_board}/usr/lib" 309 pushd "${FLAGS_chroot}/build/${FLAGS_board}/usr/lib"
302 sudo tar czf "${OUTDIR}/debug.tgz" --checkpoint=1000 --exclude\ 310 sudo tar czf "${OUTDIR}/debug.tgz" --checkpoint=1000 --exclude\
303 debug/usr/local/autotest --exclude debug/tests debug 311 debug/usr/local/autotest --exclude debug/tests debug
304 CMD="chown \${SUDO_UID}:\${SUDO_GID} ${OUTDIR}/debug.tgz" 312 CMD="chown \${SUDO_UID}:\${SUDO_GID} ${OUTDIR}/debug.tgz"
305 sudo sh -c "${CMD}" 313 sudo sh -c "${CMD}"
306 popd 314 popd
307 gsutil_archive "${OUTDIR}/debug.tgz" "${LAST_CHANGE}/debug.tgz" 315 gsutil_archive "${OUTDIR}/debug.tgz" "${LAST_CHANGE}/debug.tgz"
308 fi 316 fi
309 317
310 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ 318 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \
311 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then 319 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then
312 gsutil_archive "${FACTORY_ZIPFILE}" \ 320 gsutil_archive "${FACTORY_ZIPFILE}" \
313 "${LAST_CHANGE}/factory_${FLAGS_zipname}" 321 "${LAST_CHANGE}/factory_${FLAGS_zipname}"
314 fi 322 fi
323
315 gsutil_archive "${FLAGS_to}/LATEST" "LATEST" 324 gsutil_archive "${FLAGS_to}/LATEST" "LATEST"
316 325
317 if [ -n "${FLAGS_gsutil_archive}" ]; then 326 if [ -n "${FLAGS_gsutil_archive}" ]; then
318 FULL_INDEX_PATH="${FLAGS_gsutil_archive}/${LAST_CHANGE}/_index.html" 327 FULL_INDEX_PATH="${FLAGS_gsutil_archive}/${LAST_CHANGE}/_index.html"
319 RELATIVE_ARCHIVE_URL_PATH="${FULL_INDEX_PATH#gs://}" 328 RELATIVE_ARCHIVE_URL_PATH="${FULL_INDEX_PATH#gs://}"
320 echo "CROS_ARCHIVE_URL=\ 329 echo "CROS_ARCHIVE_URL=\
321 https://sandbox.google.com/storage/${RELATIVE_ARCHIVE_URL_PATH}" 330 https://sandbox.google.com/storage/${RELATIVE_ARCHIVE_URL_PATH}"
322 fi 331 fi
323 332
333 if [ -n "${FLAGS_test_tarball}" ]; then
334 gsutil_archive "${FLAGS_test_tarball}" "${LAST_CHANGE}/test_results.tgz"
335 fi
336
324 # Purge old builds if necessary 337 # Purge old builds if necessary
325 if [ $FLAGS_keep_max -gt 0 ]; then 338 if [ $FLAGS_keep_max -gt 0 ]; then
326 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." 339 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..."
327 cd "$FLAGS_to" 340 cd "$FLAGS_to"
328 # +2 because line numbers start at 1 and need to skip LATEST file 341 # +2 because line numbers start at 1 and need to skip LATEST file
329 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` 342 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))`
330 cd - 343 cd -
331 fi 344 fi
332 345
333 echo "Done." 346 echo "Done."
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698