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

Side by Side Diff: archive_build.sh

Issue 6749018: Add in a gsutil_append_latest bool option to avoid appending ChromeOS-Hash-B# (Closed) Base URL: ssh://gitrw.chromium.org:9222/crosutils@master
Patch Set: fix a typo Created 9 years, 9 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
« 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 DEFINE_string from "$DEFAULT_FROM" \ 53 DEFINE_string from "$DEFAULT_FROM" \
54 "Directory to archive" 54 "Directory to archive"
55 DEFINE_string gsutil "gsutil" \ 55 DEFINE_string gsutil "gsutil" \
56 "Location of gsutil" 56 "Location of gsutil"
57 DEFINE_string gsd_gen_index "" \ 57 DEFINE_string gsd_gen_index "" \
58 "Location of gsd_generate_index.py" 58 "Location of gsd_generate_index.py"
59 DEFINE_string acl "private" \ 59 DEFINE_string acl "private" \
60 "ACL to set on GSD archives" 60 "ACL to set on GSD archives"
61 DEFINE_string gsutil_archive "" \ 61 DEFINE_string gsutil_archive "" \
62 "Optional datastore archive location" 62 "Optional datastore archive location"
63 DEFINE_boolean gsutil_append_last_change $FLAGS_TRUE \
64 "Optional Whether to append build # and chrome os hash to GS uploads"
63 DEFINE_integer keep_max 0 "Maximum builds to keep in archive (0=all)" 65 DEFINE_integer keep_max 0 "Maximum builds to keep in archive (0=all)"
64 DEFINE_boolean official_build $FLAGS_FALSE \ 66 DEFINE_boolean official_build $FLAGS_FALSE \
65 "Set CHROMEOS_OFFICIAL=1 for release builds." 67 "Set CHROMEOS_OFFICIAL=1 for release builds."
66 DEFINE_string test_tarball "" "Optional path to test tarball to archive" 68 DEFINE_string test_tarball "" "Optional path to test tarball to archive"
67 DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes" 69 DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes"
68 DEFINE_boolean prebuilt_upload $FLAGS_FALSE "Upload prebuilt binary packages." 70 DEFINE_boolean prebuilt_upload $FLAGS_FALSE "Upload prebuilt binary packages."
69 DEFINE_boolean remove_dev $FLAGS_TRUE "Remove the de image during archive." 71 DEFINE_boolean remove_dev $FLAGS_TRUE "Remove the de image during archive."
70 DEFINE_string to "$DEFAULT_TO" "Directory of build archive" 72 DEFINE_string to "$DEFAULT_TO" "Directory of build archive"
71 DEFINE_string zipname "image.zip" "Name of zip file to create." 73 DEFINE_string zipname "image.zip" "Name of zip file to create."
72 74
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 249
248 # Make sure files are readable 250 # Make sure files are readable
249 chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST" 251 chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST"
250 chmod 755 "$OUTDIR" 252 chmod 755 "$OUTDIR"
251 cp -f "${FLAGS_from}/au-generator.zip" "${OUTDIR}/" 253 cp -f "${FLAGS_from}/au-generator.zip" "${OUTDIR}/"
252 254
253 255
254 function gsutil_archive() { 256 function gsutil_archive() {
255 IN_PATH="$1" 257 IN_PATH="$1"
256 OUT_PATH="$2" 258 OUT_PATH="$2"
259 if [ ${FLAGS_gsutil_append_last_change} -eq ${FLAGS_TRUE} ]; then
260 OUT_PATH="${LAST_CHANGE}/${OUT_PATH}"
261 fi
262
257 echo "Using gsutil to archive to ${OUT_PATH}..." 263 echo "Using gsutil to archive to ${OUT_PATH}..."
258 if [ -z "$FLAGS_gsutil_archive" -o ${FLAGS_debug} -eq ${FLAGS_TRUE} ]; then 264 if [ -z "$FLAGS_gsutil_archive" -o ${FLAGS_debug} -eq ${FLAGS_TRUE} ]; then
259 echo -n "In debug mode. Would have run: " 265 echo -n "In debug mode. Would have run: "
260 echo "gsutil cp ${IN_PATH} <gsutil_archive>/${OUT_PATH}" 266 echo "gsutil cp ${IN_PATH} <gsutil_archive>/${OUT_PATH}"
261 return 267 return
262 fi 268 fi
263 269
264 FULL_OUT_PATH="${FLAGS_gsutil_archive}/${OUT_PATH}" 270 FULL_OUT_PATH="${FLAGS_gsutil_archive}/${OUT_PATH}"
265 ${FLAGS_gsutil} cp ${IN_PATH} ${FULL_OUT_PATH} 271 ${FLAGS_gsutil} cp ${IN_PATH} ${FULL_OUT_PATH}
266 ${FLAGS_gsutil} setacl ${FLAGS_acl} ${FULL_OUT_PATH} 272 ${FLAGS_gsutil} setacl ${FLAGS_acl} ${FULL_OUT_PATH}
267 if [ -n "$FLAGS_gsd_gen_index" ]; then 273 if [ -n "$FLAGS_gsd_gen_index" ]; then
268 echo "Updating indexes..." 274 echo "Updating indexes..."
269 ${FLAGS_gsd_gen_index} \ 275 ${FLAGS_gsd_gen_index} \
270 --gsutil=${FLAGS_gsutil} \ 276 --gsutil=${FLAGS_gsutil} \
271 -a ${FLAGS_acl} \ 277 -a ${FLAGS_acl} \
272 -p ${FULL_OUT_PATH} ${FLAGS_gsutil_archive} 278 -p ${FULL_OUT_PATH} ${FLAGS_gsutil_archive}
273 fi 279 fi
274 } 280 }
275 281
276 if [ $FLAGS_test_mod -eq $FLAGS_TRUE -a $FLAGS_official_build -eq $FLAGS_TRUE ] 282 if [ $FLAGS_test_mod -eq $FLAGS_TRUE -a $FLAGS_official_build -eq $FLAGS_TRUE ]
277 then 283 then
278 echo "Creating hwqual archive" 284 echo "Creating hwqual archive"
279 HWQUAL_NAME="chromeos-hwqual-${FLAGS_board}-${CHROMEOS_VERSION_STRING}" 285 HWQUAL_NAME="chromeos-hwqual-${FLAGS_board}-${CHROMEOS_VERSION_STRING}"
280 "${SCRIPTS_DIR}/archive_hwqual" --from "${OUTDIR}" \ 286 "${SCRIPTS_DIR}/archive_hwqual" --from "${OUTDIR}" \
281 --output_tag "${HWQUAL_NAME}" 287 --output_tag "${HWQUAL_NAME}"
282 gsutil_archive "${OUTDIR}/${HWQUAL_NAME}.tar.bz2" \ 288 gsutil_archive "${OUTDIR}/${HWQUAL_NAME}.tar.bz2" \
283 "${LAST_CHANGE}/${HWQUAL_NAME}.tar.bz2" 289 "${HWQUAL_NAME}.tar.bz2"
284 fi 290 fi
285 291
286 292
287 if [ $FLAGS_prebuilt_upload -eq $FLAGS_TRUE ]; then 293 if [ $FLAGS_prebuilt_upload -eq $FLAGS_TRUE ]; then
288 # Construct prebuilt upload command. 294 # Construct prebuilt upload command.
289 # This will upload prebuilt packages to Google Storage. 295 # This will upload prebuilt packages to Google Storage.
290 prebuilt_cmd="${GCLIENT_ROOT}/chromite/buildbot/prebuilt.py" 296 prebuilt_cmd="${GCLIENT_ROOT}/chromite/buildbot/prebuilt.py"
291 prebuilt_cmd="$prebuilt_cmd -u gs://chromeos-prebuilt --git-sync -V master" 297 prebuilt_cmd="$prebuilt_cmd -u gs://chromeos-prebuilt --git-sync -V master"
292 prebuilt_cmd="$prebuilt_cmd -p ${GCLIENT_ROOT} -b ${FLAGS_board}" 298 prebuilt_cmd="$prebuilt_cmd -p ${GCLIENT_ROOT} -b ${FLAGS_board}"
293 299
294 if [ "${FLAGS_board}" == "x86-generic" ] 300 if [ "${FLAGS_board}" == "x86-generic" ]
295 then 301 then
296 prebuilt_cmd="$prebuilt_cmd --sync-host" 302 prebuilt_cmd="$prebuilt_cmd --sync-host"
297 fi 303 fi
298 304
299 if [ ${FLAGS_debug} -eq ${FLAGS_FALSE} ]; then 305 if [ ${FLAGS_debug} -eq ${FLAGS_FALSE} ]; then
300 echo "Running $prebuilt_cmd" 306 echo "Running $prebuilt_cmd"
301 $prebuilt_cmd 307 $prebuilt_cmd
302 else 308 else
303 echo "Would have run $prebuilt_cmd" 309 echo "Would have run $prebuilt_cmd"
304 fi 310 fi
305 fi 311 fi
306 312
307 gsutil_archive "${ZIPFILE}" "${LAST_CHANGE}/${FLAGS_zipname}" 313 gsutil_archive "${ZIPFILE}" "${FLAGS_zipname}"
308 314
309 if [ $FLAGS_archive_debug -eq $FLAGS_TRUE ]; then 315 if [ $FLAGS_archive_debug -eq $FLAGS_TRUE ]; then
310 echo "Generating Breakpad symbols" 316 echo "Generating Breakpad symbols"
311 ! ${SCRIPTS_DIR}/cros_generate_breakpad_symbols --board=${FLAGS_board} 317 ! ${SCRIPTS_DIR}/cros_generate_breakpad_symbols --board=${FLAGS_board}
312 echo "Creating debug archive" 318 echo "Creating debug archive"
313 pushd "${FLAGS_chroot}/build/${FLAGS_board}/usr/lib" 319 pushd "${FLAGS_chroot}/build/${FLAGS_board}/usr/lib"
314 sudo tar czf "${OUTDIR}/debug.tgz" --checkpoint=1000 --exclude\ 320 sudo tar czf "${OUTDIR}/debug.tgz" --checkpoint=1000 --exclude\
315 debug/usr/local/autotest --exclude debug/tests debug 321 debug/usr/local/autotest --exclude debug/tests debug
316 CMD="chown \${SUDO_UID}:\${SUDO_GID} ${OUTDIR}/debug.tgz" 322 CMD="chown \${SUDO_UID}:\${SUDO_GID} ${OUTDIR}/debug.tgz"
317 sudo sh -c "${CMD}" 323 sudo sh -c "${CMD}"
318 popd 324 popd
319 gsutil_archive "${OUTDIR}/debug.tgz" "${LAST_CHANGE}/debug.tgz" 325 gsutil_archive "${OUTDIR}/debug.tgz" "debug.tgz"
320 fi 326 fi
321 327
322 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ 328 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \
323 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then 329 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then
324 gsutil_archive "${FACTORY_ZIPFILE}" \ 330 gsutil_archive "${FACTORY_ZIPFILE}" \
325 "${LAST_CHANGE}/factory_${FLAGS_zipname}" 331 "factory_${FLAGS_zipname}"
326 fi 332 fi
327 333
328 gsutil_archive "${FLAGS_to}/LATEST" "LATEST" 334 gsutil_archive "${FLAGS_to}/LATEST" "LATEST"
329 335
330 if [ -n "${FLAGS_gsutil_archive}" ]; then 336 if [ -n "${FLAGS_gsutil_archive}" ]; then
331 FULL_INDEX_PATH="${FLAGS_gsutil_archive}/${LAST_CHANGE}/_index.html" 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
332 RELATIVE_ARCHIVE_URL_PATH="${FULL_INDEX_PATH#gs://}" 342 RELATIVE_ARCHIVE_URL_PATH="${FULL_INDEX_PATH#gs://}"
333 echo "CROS_ARCHIVE_URL=\ 343 echo "CROS_ARCHIVE_URL=\
334 https://sandbox.google.com/storage/${RELATIVE_ARCHIVE_URL_PATH}" 344 https://sandbox.google.com/storage/${RELATIVE_ARCHIVE_URL_PATH}"
335 fi 345 fi
336 346
337 if [ -n "${FLAGS_test_tarball}" ]; then 347 if [ -n "${FLAGS_test_tarball}" ]; then
338 gsutil_archive "${FLAGS_test_tarball}" "${LAST_CHANGE}/test_results.tgz" 348 gsutil_archive "${FLAGS_test_tarball}" "test_results.tgz"
339 fi 349 fi
340 350
341 # Purge old builds if necessary 351 # Purge old builds if necessary
342 if [ $FLAGS_keep_max -gt 0 ]; then 352 if [ $FLAGS_keep_max -gt 0 ]; then
343 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." 353 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..."
344 cd "$FLAGS_to" 354 cd "$FLAGS_to"
345 # +2 because line numbers start at 1 and need to skip LATEST file 355 # +2 because line numbers start at 1 and need to skip LATEST file
346 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` 356 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))`
347 cd - 357 cd -
348 fi 358 fi
349 359
350 echo "Done." 360 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