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