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 sync your checkout, build a Chromium OS image, and test it all | 7 # Script to sync your checkout, build a Chromium OS image, and test it all |
8 # with one command. Can also check out a new Chromium OS checkout and | 8 # with one command. Can also check out a new Chromium OS checkout and |
9 # perform a subset of the above operations. | 9 # perform a subset of the above operations. |
10 # | 10 # |
(...skipping 23 matching lines...) Expand all Loading... |
34 # sync_build_test.sh --grab_buildbot=LATEST --test Pam --remote=192.168.1.2 | 34 # sync_build_test.sh --grab_buildbot=LATEST --test Pam --remote=192.168.1.2 |
35 # grabs the latest build from the buildbot, properly modifies it, | 35 # grabs the latest build from the buildbot, properly modifies it, |
36 # reimages 192.168.1.2, and runs the given test on it. | 36 # reimages 192.168.1.2, and runs the given test on it. |
37 # | 37 # |
38 # Environment variables that may be useful: | 38 # Environment variables that may be useful: |
39 # BUILDBOT_URI - default value for --buildbot_uri | 39 # BUILDBOT_URI - default value for --buildbot_uri |
40 # CHROMIUM_REPO - default value for --repo | 40 # CHROMIUM_REPO - default value for --repo |
41 # CHRONOS_PASSWD - default value for --chronos_passwd | 41 # CHRONOS_PASSWD - default value for --chronos_passwd |
42 # | 42 # |
43 | 43 |
44 # Load common constants. This should be the first executable line. | 44 # --- BEGIN COMMON.SH BOILERPLATE --- |
45 # The path to common.sh should be relative to your script's location. | 45 # Load common CrOS utilities. Inside the chroot this file is installed in |
46 . "$(dirname "$0")/common.sh" | 46 # /usr/lib/crosutils. Outside the chroot we find it relative to the script's |
47 # Allow remote access (for learning board type) | 47 # location. |
48 . "$(dirname "$0")/remote_access.sh" | 48 find_common_sh() { |
| 49 local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) |
| 50 local path |
| 51 |
| 52 SCRIPT_ROOT= |
| 53 for path in "${common_paths[@]}"; do |
| 54 if [ -r "${path}/common.sh" ]; then |
| 55 SCRIPT_ROOT=${path} |
| 56 break |
| 57 fi |
| 58 done |
| 59 } |
| 60 |
| 61 find_common_sh |
| 62 . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) |
| 63 # --- END COMMON.SH BOILERPLATE --- |
| 64 |
| 65 . "${SCRIPT_ROOT}/remote_access.sh" |
49 | 66 |
50 DEFINE_string board "" "Board setting" | 67 DEFINE_string board "" "Board setting" |
51 DEFINE_boolean build ${FLAGS_TRUE} \ | 68 DEFINE_boolean build ${FLAGS_TRUE} \ |
52 "Build all code (but not necessarily master image)" | 69 "Build all code (but not necessarily master image)" |
53 DEFINE_boolean build_autotest ${FLAGS_FALSE} "Build autotest" | 70 DEFINE_boolean build_autotest ${FLAGS_FALSE} "Build autotest" |
54 DEFINE_string buildbot_uri "${BUILDBOT_URI}" \ | 71 DEFINE_string buildbot_uri "${BUILDBOT_URI}" \ |
55 "Base URI to buildbot build location which contains LATEST file" | 72 "Base URI to buildbot build location which contains LATEST file" |
56 DEFINE_string chrome_gold ${FLAGS_TRUE} \ | 73 DEFINE_string chrome_gold ${FLAGS_TRUE} \ |
57 "Build Chrome using gold if it is installed and supported." | 74 "Build Chrome using gold if it is installed and supported." |
58 DEFINE_string chrome_root "" \ | 75 DEFINE_string chrome_root "" \ |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 if [[ -d "${test_dir}/src/platform/dev" ]]; then | 132 if [[ -d "${test_dir}/src/platform/dev" ]]; then |
116 FLAGS_top="${test_dir}" | 133 FLAGS_top="${test_dir}" |
117 break | 134 break |
118 fi | 135 fi |
119 test_dir=$(dirname "${test_dir}") | 136 test_dir=$(dirname "${test_dir}") |
120 done | 137 done |
121 fi | 138 fi |
122 | 139 |
123 if [[ -z "${FLAGS_top}" ]]; then | 140 if [[ -z "${FLAGS_top}" ]]; then |
124 # Use the top directory based on where this script runs from | 141 # Use the top directory based on where this script runs from |
125 FLAGS_top=$(dirname $(dirname $(dirname $0))) | 142 FLAGS_top=${GCLIENT_ROOT} |
126 fi | 143 fi |
127 | 144 |
128 # Canonicalize any symlinks | 145 # Canonicalize any symlinks |
129 if [[ -d "${FLAGS_top}" ]]; then | 146 if [[ -d "${FLAGS_top}" ]]; then |
130 FLAGS_top=$(readlink -f "${FLAGS_top}") | 147 FLAGS_top=$(readlink -f "${FLAGS_top}") |
131 fi | 148 fi |
132 | 149 |
133 if [[ -z "${FLAGS_chroot}" ]]; then | 150 if [[ -z "${FLAGS_chroot}" ]]; then |
134 FLAGS_chroot="${FLAGS_top}/chroot" | 151 FLAGS_chroot="${FLAGS_top}/chroot" |
135 fi | 152 fi |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 chdir_relative . | 497 chdir_relative . |
481 } | 498 } |
482 | 499 |
483 | 500 |
484 # Downloads a buildbot image | 501 # Downloads a buildbot image |
485 function grab_buildbot() { | 502 function grab_buildbot() { |
486 read -p "Username [${LOGNAME}]: " GSDCURL_USERNAME | 503 read -p "Username [${LOGNAME}]: " GSDCURL_USERNAME |
487 export GSDCURL_USERNAME | 504 export GSDCURL_USERNAME |
488 read -s -p "Password: " GSDCURL_PASSWORD | 505 read -s -p "Password: " GSDCURL_PASSWORD |
489 export GSDCURL_PASSWORD | 506 export GSDCURL_PASSWORD |
490 CURL="$(dirname $0)/bin/cros_gsdcurl.py" | 507 CURL="${SCRIPTS_DIR}/bin/cros_gsdcurl.py" |
491 if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then | 508 if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then |
492 local latest=$(${CURL} "${FLAGS_buildbot_uri}/LATEST") | 509 local latest=$(${CURL} "${FLAGS_buildbot_uri}/LATEST") |
493 if [[ -z "${latest}" ]]; then | 510 if [[ -z "${latest}" ]]; then |
494 die "Error finding latest." | 511 die "Error finding latest." |
495 fi | 512 fi |
496 FLAGS_grab_buildbot="${FLAGS_buildbot_uri}/${latest}/image.zip" | 513 FLAGS_grab_buildbot="${FLAGS_buildbot_uri}/${latest}/image.zip" |
497 fi | 514 fi |
498 local dl_dir="${TMP}/image" | 515 local dl_dir="${TMP}/image" |
499 mkdir -p "${dl_dir}" | 516 mkdir -p "${dl_dir}" |
500 | 517 |
501 info "Grabbing image from ${FLAGS_grab_buildbot} to ${dl_dir}" | 518 info "Grabbing image from ${FLAGS_grab_buildbot} to ${dl_dir}" |
502 run_phase "Downloading image" ${CURL} "${FLAGS_grab_buildbot}" \ | 519 run_phase "Downloading image" ${CURL} "${FLAGS_grab_buildbot}" \ |
503 -o "${dl_dir}/image.zip" | 520 -o "${dl_dir}/image.zip" |
504 # Clear out the credentials so they can't be used later. | 521 # Clear out the credentials so they can't be used later. |
505 export GSDCURL_USERNAME="" | 522 export GSDCURL_USERNAME="" |
506 export GSDCURL_PASSWORD="" | 523 export GSDCURL_PASSWORD="" |
507 | 524 |
508 cd "${dl_dir}" | 525 cd "${dl_dir}" |
509 unzip image.zip | 526 unzip image.zip |
510 local image_basename=$(basename $(dirname "${FLAGS_grab_buildbot}")) | 527 local image_basename=$(basename "$(dirname "${FLAGS_grab_buildbot}")") |
511 local image_base_dir="${FLAGS_top}/src/build/images/${FLAGS_board}" | 528 local image_base_dir="${FLAGS_top}/src/build/images/${FLAGS_board}" |
512 local image_dir="${image_base_dir}/${image_basename}" | 529 local image_dir="${image_base_dir}/${image_basename}" |
513 info "Copying in build image to ${image_dir}" | 530 info "Copying in build image to ${image_dir}" |
514 rm -rf "${image_dir}" | 531 rm -rf "${image_dir}" |
515 mkdir -p "${image_dir}" | 532 mkdir -p "${image_dir}" |
516 if [[ ${FLAGS_mod_image_for_test} -eq ${FLAGS_TRUE} ]]; then | 533 if [[ ${FLAGS_mod_image_for_test} -eq ${FLAGS_TRUE} ]]; then |
517 run_phase "Installing buildbot test modified image" \ | 534 run_phase "Installing buildbot test modified image" \ |
518 mv chromiumos_test_image.bin "${image_dir}/chromiumos_image.bin" | 535 mv chromiumos_test_image.bin "${image_dir}/chromiumos_image.bin" |
519 FLAGS_mod_image_for_test=${FLAGS_FALSE} | 536 FLAGS_mod_image_for_test=${FLAGS_FALSE} |
520 else | 537 else |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 echo "" | 741 echo "" |
725 info_div | 742 info_div |
726 info "Successfully used ${FLAGS_top} to:" | 743 info "Successfully used ${FLAGS_top} to:" |
727 describe_steps | 744 describe_steps |
728 show_duration | 745 show_duration |
729 info_div | 746 info_div |
730 } | 747 } |
731 | 748 |
732 main "$@" | 749 main "$@" |
733 | 750 |
OLD | NEW |