| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 "Use this as the chronos user passwd (defaults to \$CHRONOS_PASSWD)" | 56 "Use this as the chronos user passwd (defaults to \$CHRONOS_PASSWD)" |
| 57 DEFINE_string chroot "" "Chroot to build/use" | 57 DEFINE_string chroot "" "Chroot to build/use" |
| 58 DEFINE_boolean force_make_chroot ${FLAGS_FALSE} "Run make_chroot indep of sync" | 58 DEFINE_boolean force_make_chroot ${FLAGS_FALSE} "Run make_chroot indep of sync" |
| 59 DEFINE_string grab_buildbot "" \ | 59 DEFINE_string grab_buildbot "" \ |
| 60 "Instead of building, grab this full image.zip URI generated by the \ | 60 "Instead of building, grab this full image.zip URI generated by the \ |
| 61 buildbot" | 61 buildbot" |
| 62 DEFINE_boolean image_to_live ${FLAGS_FALSE} \ | 62 DEFINE_boolean image_to_live ${FLAGS_FALSE} \ |
| 63 "Put the resulting image on live instance (requires --remote)" | 63 "Put the resulting image on live instance (requires --remote)" |
| 64 DEFINE_string image_to_usb "" \ | 64 DEFINE_string image_to_usb "" \ |
| 65 "Treat this device as USB and put the image on it after build" | 65 "Treat this device as USB and put the image on it after build" |
| 66 # You can set jobs > 1 but then your build may break and you may need |
| 67 # to retry. Setting it to 1 is best for non-interactive sessions. |
| 66 DEFINE_boolean interactive ${FLAGS_FALSE} \ | 68 DEFINE_boolean interactive ${FLAGS_FALSE} \ |
| 67 "Tell user what we plan to do and wait for input to proceed" i | 69 "Tell user what we plan to do and wait for input to proceed" i |
| 68 DEFINE_integer jobs -1 "Concurrent build jobs" | 70 DEFINE_integer jobs -1 "Concurrent build jobs" |
| 69 DEFINE_boolean master ${FLAGS_TRUE} "Master an image from built code" | 71 DEFINE_boolean master ${FLAGS_TRUE} "Master an image from built code" |
| 70 DEFINE_boolean mod_image_for_test ${FLAGS_FALSE} "Modify the image for testing" | 72 DEFINE_boolean mod_image_for_test ${FLAGS_FALSE} "Modify the image for testing" |
| 71 DEFINE_string remote "" \ | 73 DEFINE_string remote "" \ |
| 72 "Use this hostname/IP for live updating and running tests" | 74 "Use this hostname/IP for live updating and running tests" |
| 73 DEFINE_string repo "${CHROMIUMOS_REPO}" "gclient repo for chromiumos" | 75 DEFINE_string repo "${CHROMIUMOS_REPO}" "gclient repo for chromiumos" |
| 74 DEFINE_boolean sync ${FLAGS_TRUE} "Sync the checkout" | 76 DEFINE_boolean sync ${FLAGS_TRUE} "Sync the checkout" |
| 75 DEFINE_string test "" \ | 77 DEFINE_string test "" \ |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 if [[ -z "${device}" ]]; then | 192 if [[ -z "${device}" ]]; then |
| 191 echo "Expected --image_to_usb option of /dev/* format" | 193 echo "Expected --image_to_usb option of /dev/* format" |
| 192 exit 1 | 194 exit 1 |
| 193 fi | 195 fi |
| 194 local is_removable=$(cat /sys/block/${device}/removable) | 196 local is_removable=$(cat /sys/block/${device}/removable) |
| 195 if [[ "${is_removable}" != "1" ]]; then | 197 if [[ "${is_removable}" != "1" ]]; then |
| 196 echo "Could not verify that ${device} for image_to_usb is removable" | 198 echo "Could not verify that ${device} for image_to_usb is removable" |
| 197 exit 1 | 199 exit 1 |
| 198 fi | 200 fi |
| 199 fi | 201 fi |
| 200 | |
| 201 if [[ ${FLAGS_jobs} -eq -1 ]]; then | |
| 202 FLAGS_jobs=$(cat /proc/cpuinfo | grep -c processor) | |
| 203 fi | |
| 204 } | 202 } |
| 205 | 203 |
| 206 | 204 |
| 207 function describe_jobs() { | |
| 208 local jobs=" single job (slow but no retries)" | |
| 209 if [[ ${FLAGS_jobs} -gt 1 ]]; then | |
| 210 jobs=" ${FLAGS_jobs} jobs" | |
| 211 fi | |
| 212 echo ${jobs} | |
| 213 } | |
| 214 | |
| 215 # Prints a description of what we are doing or did | 205 # Prints a description of what we are doing or did |
| 216 function describe_steps() { | 206 function describe_steps() { |
| 217 if [[ ${FLAGS_sync} -eq ${FLAGS_TRUE} ]]; then | 207 if [[ ${FLAGS_sync} -eq ${FLAGS_TRUE} ]]; then |
| 218 echo " * Sync client (gclient sync)" | 208 echo " * Sync client (gclient sync)" |
| 219 if is_google_environment; then | 209 if is_google_environment; then |
| 220 echo " * Create proper src/scripts/.chromeos_dev" | 210 echo " * Create proper src/scripts/.chromeos_dev" |
| 221 fi | 211 fi |
| 222 fi | 212 fi |
| 223 if [[ ${FLAGS_force_make_chroot} -eq ${FLAGS_TRUE} ]]; then | 213 if [[ ${FLAGS_force_make_chroot} -eq ${FLAGS_TRUE} ]]; then |
| 224 echo " * Rebuild chroot (make_chroot) in ${FLAGS_chroot}" | 214 echo " * Rebuild chroot (make_chroot) in ${FLAGS_chroot}" |
| 225 fi | 215 fi |
| 226 local set_passwd=${FLAGS_FALSE} | 216 local set_passwd=${FLAGS_FALSE} |
| 227 if [[ ${FLAGS_build} -eq ${FLAGS_TRUE} ]]; then | 217 if [[ ${FLAGS_build} -eq ${FLAGS_TRUE} ]]; then |
| 228 local withdev="" | 218 local withdev="" |
| 229 local jobs=$(describe_jobs) | 219 local jobs=" single job (slow but safe)" |
| 220 if [[ ${FLAGS_jobs} -gt 1 ]]; then |
| 221 jobs=" ${FLAGS_jobs} jobs (may cause build failure)" |
| 222 fi |
| 230 if [[ ${FLAGS_withdev} -eq ${FLAGS_TRUE} ]]; then | 223 if [[ ${FLAGS_withdev} -eq ${FLAGS_TRUE} ]]; then |
| 231 withdev=" with dev packages" | 224 withdev=" with dev packages" |
| 232 fi | 225 fi |
| 233 echo " * Build image${withdev} with ${jobs}" | 226 echo " * Build image${withdev}${jobs}" |
| 234 set_passwd=${FLAGS_TRUE} | 227 set_passwd=${FLAGS_TRUE} |
| 235 if [[ ${FLAGS_build_autotest} -eq ${FLAGS_TRUE} ]]; then | 228 if [[ ${FLAGS_build_autotest} -eq ${FLAGS_TRUE} ]]; then |
| 236 echo " * Cross-build autotest client tests (build_autotest)" | 229 echo " * Cross-build autotest client tests (build_autotest)" |
| 237 fi | 230 fi |
| 238 fi | 231 fi |
| 239 if [[ ${FLAGS_master} -eq ${FLAGS_TRUE} ]]; then | 232 if [[ ${FLAGS_master} -eq ${FLAGS_TRUE} ]]; then |
| 240 local jobs=$(describe_jobs) | 233 echo " * Master image (build_image)" |
| 241 echo " * Master image (build_image) with ${jobs}" | |
| 242 fi | 234 fi |
| 243 if [[ -n "${FLAGS_grab_buildbot}" ]]; then | 235 if [[ -n "${FLAGS_grab_buildbot}" ]]; then |
| 244 if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then | 236 if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then |
| 245 echo " * Grab latest buildbot image under ${FLAGS_buildbot_uri}" | 237 echo " * Grab latest buildbot image under ${FLAGS_buildbot_uri}" |
| 246 else | 238 else |
| 247 echo " * Grab buildbot image zip at URI ${FLAGS_grab_buildbot}" | 239 echo " * Grab buildbot image zip at URI ${FLAGS_grab_buildbot}" |
| 248 fi | 240 fi |
| 249 fi | 241 fi |
| 250 if [[ ${FLAGS_mod_image_for_test} -eq ${FLAGS_TRUE} ]]; then | 242 if [[ ${FLAGS_mod_image_for_test} -eq ${FLAGS_TRUE} ]]; then |
| 251 if [[ -n "${FLAGS_grab_buildbot}" ]]; then | 243 if [[ -n "${FLAGS_grab_buildbot}" ]]; then |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 fi | 584 fi |
| 593 | 585 |
| 594 trap - EXIT | 586 trap - EXIT |
| 595 echo "Successfully used ${FLAGS_top} to:" | 587 echo "Successfully used ${FLAGS_top} to:" |
| 596 describe_steps | 588 describe_steps |
| 597 show_duration | 589 show_duration |
| 598 } | 590 } |
| 599 | 591 |
| 600 | 592 |
| 601 main $@ | 593 main $@ |
| OLD | NEW |