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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 DEFINE_string chrome_root "" \ | 55 DEFINE_string chrome_root "" \ |
56 "The root of your chrome browser source. Should contain a 'src' subdir. \ | 56 "The root of your chrome browser source. Should contain a 'src' subdir. \ |
57 If this is set, chrome browser will be built from source." | 57 If this is set, chrome browser will be built from source." |
58 DEFINE_string chronos_passwd "${CHRONOS_PASSWD}" \ | 58 DEFINE_string chronos_passwd "${CHRONOS_PASSWD}" \ |
59 "Use this as the chronos user passwd (defaults to \$CHRONOS_PASSWD)" | 59 "Use this as the chronos user passwd (defaults to \$CHRONOS_PASSWD)" |
60 DEFINE_string chroot "" "Chroot to build/use" | 60 DEFINE_string chroot "" "Chroot to build/use" |
61 DEFINE_boolean force_make_chroot ${FLAGS_FALSE} "Run make_chroot indep of sync" | 61 DEFINE_boolean force_make_chroot ${FLAGS_FALSE} "Run make_chroot indep of sync" |
62 DEFINE_string grab_buildbot "" \ | 62 DEFINE_string grab_buildbot "" \ |
63 "Instead of building, grab this full image.zip URI generated by the \ | 63 "Instead of building, grab this full image.zip URI generated by the \ |
64 buildbot" | 64 buildbot" |
65 DEFINE_boolean ignore_remote_test_failures ${FLAGS_FALSE} \ | |
66 "Ignore any remote tests that failed and don't return failure" | |
65 DEFINE_boolean image_to_live ${FLAGS_FALSE} \ | 67 DEFINE_boolean image_to_live ${FLAGS_FALSE} \ |
66 "Put the resulting image on live instance (requires --remote)" | 68 "Put the resulting image on live instance (requires --remote)" |
67 DEFINE_string image_to_usb "" \ | 69 DEFINE_string image_to_usb "" \ |
68 "Treat this device as USB and put the image on it after build" | 70 "Treat this device as USB and put the image on it after build" |
69 # You can set jobs > 1 but then your build may break and you may need | 71 # You can set jobs > 1 but then your build may break and you may need |
70 # to retry. Setting it to 1 is best for non-interactive sessions. | 72 # to retry. Setting it to 1 is best for non-interactive sessions. |
71 DEFINE_boolean interactive ${FLAGS_FALSE} \ | 73 DEFINE_boolean interactive ${FLAGS_FALSE} \ |
72 "Tell user what we plan to do and wait for input to proceed" i | 74 "Tell user what we plan to do and wait for input to proceed" i |
73 DEFINE_integer jobs -1 "Concurrent build jobs" | 75 DEFINE_integer jobs -1 "Concurrent build jobs" |
74 DEFINE_boolean master ${FLAGS_TRUE} "Master an image from built code" | 76 DEFINE_boolean master ${FLAGS_TRUE} "Master an image from built code" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 if [[ -n "${FLAGS_grab_buildbot}" ]]; then | 178 if [[ -n "${FLAGS_grab_buildbot}" ]]; then |
177 if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then | 179 if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then |
178 if [[ -z "${FLAGS_buildbot_uri}" ]]; then | 180 if [[ -z "${FLAGS_buildbot_uri}" ]]; then |
179 echo "--grab_buildbot=LATEST requires --buildbot_uri or setting " | 181 echo "--grab_buildbot=LATEST requires --buildbot_uri or setting " |
180 echo "BUILDBOT_URI" | 182 echo "BUILDBOT_URI" |
181 exit 1 | 183 exit 1 |
182 fi | 184 fi |
183 fi | 185 fi |
184 FLAGS_sync=${FLAGS_FALSE} | 186 FLAGS_sync=${FLAGS_FALSE} |
185 FLAGS_build=${FLAGS_FALSE} | 187 FLAGS_build=${FLAGS_FALSE} |
188 FLAGS_unittest=${FLAGS_FALSE} | |
186 FLAGS_master=${FLAGS_FALSE} | 189 FLAGS_master=${FLAGS_FALSE} |
187 fi | 190 fi |
188 | 191 |
189 if [[ ${FLAGS_image_to_live} -eq ${FLAGS_TRUE} ]]; then | 192 if [[ ${FLAGS_image_to_live} -eq ${FLAGS_TRUE} ]]; then |
190 if [[ ${FLAGS_mod_image_for_test} -eq ${FLAGS_FALSE} ]]; then | 193 if [[ ${FLAGS_mod_image_for_test} -eq ${FLAGS_FALSE} ]]; then |
191 echo "WARNING: You have specified to live reimage a machine with" | 194 echo "WARNING: You have specified to live reimage a machine with" |
192 echo "an image that is not modified for test (so it cannot be" | 195 echo "an image that is not modified for test (so it cannot be" |
193 echo "later live reimaged)" | 196 echo "later live reimaged)" |
194 fi | 197 fi |
195 if [[ -n "${FLAGS_image_to_usb}" ]]; then | 198 if [[ -n "${FLAGS_image_to_usb}" ]]; then |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
443 echo <<EOF > src/scripts/.chromeos_dev | 446 echo <<EOF > src/scripts/.chromeos_dev |
444 # Assume Chrome is checked out nearby | 447 # Assume Chrome is checked out nearby |
445 CHROMEOS_CHROME_DIR="${base_dir}/chrome" | 448 CHROMEOS_CHROME_DIR="${base_dir}/chrome" |
446 EOF | 449 EOF |
447 fi | 450 fi |
448 } | 451 } |
449 | 452 |
450 | 453 |
451 # Downloads a buildbot image | 454 # Downloads a buildbot image |
452 function grab_buildbot() { | 455 function grab_buildbot() { |
456 read -p "Username [${LOGNAME}]: " GSDCURL_USERNAME | |
457 export GSDCURL_USERNAME | |
458 read -s -p "Password: " GSDCURL_PASSWORD | |
459 export GSDCURL_PASSWORD | |
460 CURL="$(dirname $0)/bin/cros_gsdcurl.py" | |
453 if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then | 461 if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then |
454 local latest=$(curl "${FLAGS_buildbot_uri}/LATEST") | 462 local latest=$(${CURL} "${FLAGS_buildbot_uri}/LATEST") |
455 if [[ -z "${latest}" ]]; then | 463 if [[ -z "${latest}" ]]; then |
456 echo "Error finding latest." | 464 echo "Error finding latest." |
457 exit 1 | 465 exit 1 |
458 fi | 466 fi |
459 FLAGS_grab_buildbot="${FLAGS_buildbot_uri}/${latest}/image.zip" | 467 FLAGS_grab_buildbot="${FLAGS_buildbot_uri}/${latest}/image.zip" |
460 fi | 468 fi |
461 local dl_dir=$(mktemp -d "/tmp/image.XXXX") | 469 local dl_dir=$(mktemp -d "/tmp/image.XXXX") |
470 | |
462 echo "Grabbing image from ${FLAGS_grab_buildbot} to ${dl_dir}" | 471 echo "Grabbing image from ${FLAGS_grab_buildbot} to ${dl_dir}" |
463 run_phase "Downloading image" curl "${FLAGS_grab_buildbot}" \ | 472 run_phase "Downloading image" ${CURL} "${FLAGS_grab_buildbot}" \ |
464 -o "${dl_dir}/image.zip" | 473 -o "${dl_dir}/image.zip" |
474 # Clear out the credentials so they can't be used later. | |
petkov
2010/09/24 21:35:37
You should probably do this in the failure() funct
| |
475 export GSDCURL_USERNAME="" | |
476 export GSDCURL_PASSWORD="" | |
477 | |
465 cd "${dl_dir}" | 478 cd "${dl_dir}" |
466 unzip image.zip | 479 unzip image.zip |
467 local image_basename=$(basename $(dirname "${FLAGS_grab_buildbot}")) | 480 local image_basename=$(basename $(dirname "${FLAGS_grab_buildbot}")) |
468 local image_base_dir="${FLAGS_top}/src/build/images/${FLAGS_board}" | 481 local image_base_dir="${FLAGS_top}/src/build/images/${FLAGS_board}" |
469 local image_dir="${image_base_dir}/${image_basename}" | 482 local image_dir="${image_base_dir}/${image_basename}" |
470 echo "Copying in build image to ${image_dir}" | 483 echo "Copying in build image to ${image_dir}" |
471 rm -rf "${image_dir}" | 484 rm -rf "${image_dir}" |
472 mkdir -p "${image_dir}" | 485 mkdir -p "${image_dir}" |
473 if [[ ${FLAGS_mod_image_for_test} -eq ${FLAGS_TRUE} ]]; then | 486 if [[ ${FLAGS_mod_image_for_test} -eq ${FLAGS_TRUE} ]]; then |
474 run_phase "Installing buildbot test modified image" \ | 487 run_phase "Installing buildbot test modified image" \ |
475 mv chromiumos_test_image.bin "${image_dir}/chromiumos_image.bin" | 488 mv chromiumos_test_image.bin "${image_dir}/chromiumos_image.bin" |
476 FLAGS_mod_image_for_test=${FLAGS_FALSE} | 489 FLAGS_mod_image_for_test=${FLAGS_FALSE} |
490 else | |
491 run_phase "Installing buildbot base image" \ | |
492 mv chromiumos_base_image.bin "${image_dir}/chromiumos_image.bin" | |
493 fi | |
494 | |
495 if [[ -n "${FLAGS_test}" ]]; then | |
496 if [[ ! -d "${FLAGS_top}/chroot/build/${FLAGS_board}" ]]; then | |
497 echo "To run tests on a buildbot image, run setup_board first." | |
petkov
2010/09/24 21:35:37
die?
| |
498 exit 1 | |
499 fi | |
477 if [[ -e "autotest.tgz" || -e "autotest.tar.bz2" ]]; then | 500 if [[ -e "autotest.tgz" || -e "autotest.tar.bz2" ]]; then |
478 # pull in autotest | 501 # pull in autotest |
479 local dir="${FLAGS_chroot}/build/${FLAGS_board}/usr/local" | 502 local dir="${FLAGS_chroot}/build/${FLAGS_board}/usr/local" |
480 local tar_args="xzf" | 503 local tar_args="xzf" |
481 local tar_name="${dl_dir}/autotest.tgz" | 504 local tar_name="${dl_dir}/autotest.tgz" |
482 if [[ -e "autotest.tar.bz2" ]]; then | 505 if [[ -e "autotest.tar.bz2" ]]; then |
483 tar_args="xjf" | 506 tar_args="xjf" |
484 tar_name="${dl_dir}/autotest.tar.bz2" | 507 tar_name="${dl_dir}/autotest.tar.bz2" |
485 fi | 508 fi |
486 sudo rm -rf "${dir}/autotest" | 509 sudo rm -rf "${dir}/autotest" |
487 # Expand in temp directory as current user, then move it as | 510 # Expand in temp directory as current user, then move it as |
488 # root to keep local user ownership | 511 # root to keep local user ownership |
489 run_phase "Unpacking buildbot autotest cross-compiled binaries" \ | 512 run_phase "Unpacking buildbot autotest cross-compiled binaries" \ |
490 tar ${tar_args} "${tar_name}" | 513 tar ${tar_args} "${tar_name}" |
491 run_phase "Installing buildbot autotest cross-compiled binaries" \ | 514 run_phase "Installing buildbot autotest cross-compiled binaries" \ |
492 sudo mv autotest ${dir} | 515 sudo mv autotest ${dir} |
493 fi | 516 fi |
494 else | |
495 mv chromiumos_image.bin "${image_dir}" | |
496 fi | 517 fi |
497 chdir_relative . | 518 chdir_relative . |
498 run_phase "Removing downloaded image" rm -rf "${dl_dir}" | 519 run_phase "Removing downloaded image" rm -rf "${dl_dir}" |
499 } | 520 } |
500 | 521 |
501 | 522 |
502 function main() { | 523 function main() { |
503 assert_outside_chroot | 524 assert_outside_chroot |
504 assert_not_root_user | 525 assert_not_root_user |
505 | 526 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
562 | 583 |
563 chdir_relative src/scripts | 584 chdir_relative src/scripts |
564 # Only setup board target if the directory does not exist | 585 # Only setup board target if the directory does not exist |
565 if [[ ! -d "${FLAGS_top}/chroot/build/${FLAGS_board}" ]]; then | 586 if [[ ! -d "${FLAGS_top}/chroot/build/${FLAGS_board}" ]]; then |
566 run_phase_in_chroot "Setting up board target" \ | 587 run_phase_in_chroot "Setting up board target" \ |
567 ./setup_board ${pkg_param} "${board_param}" | 588 ./setup_board ${pkg_param} "${board_param}" |
568 fi | 589 fi |
569 local build_autotest_param="" | 590 local build_autotest_param="" |
570 if [[ ${FLAGS_build_autotest} -eq ${FLAGS_TRUE} ]]; then | 591 if [[ ${FLAGS_build_autotest} -eq ${FLAGS_TRUE} ]]; then |
571 build_autotest_param="--withautotest" | 592 build_autotest_param="--withautotest" |
572 if [[ ${FLAGS_useworkon} -eq ${FLAGS_TRUE} ]]; then | |
573 # In workon flow, you must workon packages to run tests | |
574 run_phase_in_chroot "Setting workon for autotest" \ | |
575 ./cros_workon --board=${FLAGS_board} start autotest \ | |
576 autotest-tests autotest-deps | |
577 # In minilayout you may not yet have autotest. | |
578 if [[ ! -d "${FLAGS_top}/src/third_party/autotest/files" ]]; then | |
579 run_phase "Syncing autotest repo" repo sync autotest | |
580 fi | |
581 fi | |
582 fi | 593 fi |
583 | 594 |
584 run_phase_in_chroot "Building packages" \ | 595 run_phase_in_chroot "Building packages" \ |
585 ./build_packages "${board_param}" \ | 596 ./build_packages "${board_param}" \ |
586 ${jobs_param} ${withdev_param} ${build_autotest_param} \ | 597 ${jobs_param} ${withdev_param} ${build_autotest_param} \ |
587 ${pkg_param} | 598 ${pkg_param} |
588 fi | 599 fi |
589 | 600 |
590 if [[ ${FLAGS_chrome_root} ]]; then | 601 if [[ ${FLAGS_chrome_root} ]]; then |
591 run_phase_in_chroot "Building Chromium browser" \ | 602 run_phase_in_chroot "Building Chromium browser" \ |
592 BOARD="${FLAGS_board}" USE="build_tests" FEATURES="-usersandbox" \ | 603 BOARD="${FLAGS_board}" USE="build_tests" FEATURES="-usersandbox" \ |
593 CHROME_ORIGIN=LOCAL_SOURCE emerge-${FLAGS_board} chromeos-chrome | 604 CHROME_ORIGIN=LOCAL_SOURCE emerge-${FLAGS_board} chromeos-chrome |
594 fi | 605 fi |
595 | 606 |
596 if [[ ${FLAGS_unittest} -eq ${FLAGS_TRUE} ]] && [[ "${FLAGS_board}" == \ | 607 if [[ ${FLAGS_unittest} -eq ${FLAGS_TRUE} ]] && [[ "${FLAGS_board}" == \ |
597 "x86-generic" ]] ; then | 608 "x86-generic" ]] ; then |
609 chdir_relative src/scripts | |
598 run_phase_in_chroot "Running unit tests" ./cros_run_unit_tests \ | 610 run_phase_in_chroot "Running unit tests" ./cros_run_unit_tests \ |
599 ${board_param} | 611 ${board_param} |
600 fi | 612 fi |
601 | 613 |
602 if [[ ${FLAGS_master} -eq ${FLAGS_TRUE} ]]; then | 614 if [[ ${FLAGS_master} -eq ${FLAGS_TRUE} ]]; then |
603 chdir_relative src/scripts | 615 chdir_relative src/scripts |
604 if [[ -n "${FLAGS_chronos_passwd}" ]]; then | 616 if [[ -n "${FLAGS_chronos_passwd}" ]]; then |
605 run_phase_in_chroot "Setting default chronos password" \ | 617 run_phase_in_chroot "Setting default chronos password" \ |
606 ./enter_chroot.sh "echo '${FLAGS_chronos_passwd}' | \ | 618 ./enter_chroot.sh "echo '${FLAGS_chronos_passwd}' | \ |
607 ~/trunk/src/scripts/set_shared_user_password.sh" | 619 ~/trunk/src/scripts/set_shared_user_password.sh" |
(...skipping 18 matching lines...) Expand all Loading... | |
626 if [[ ${FLAGS_image_to_live} -eq ${FLAGS_TRUE} ]]; then | 638 if [[ ${FLAGS_image_to_live} -eq ${FLAGS_TRUE} ]]; then |
627 chdir_relative src/scripts | 639 chdir_relative src/scripts |
628 run_phase "Re-imaging live Chromium OS machine ${FLAGS_remote}" \ | 640 run_phase "Re-imaging live Chromium OS machine ${FLAGS_remote}" \ |
629 ./image_to_live.sh "--remote=${FLAGS_remote}" --update_known_hosts | 641 ./image_to_live.sh "--remote=${FLAGS_remote}" --update_known_hosts |
630 fi | 642 fi |
631 | 643 |
632 if [[ -n "${FLAGS_test}" ]]; then | 644 if [[ -n "${FLAGS_test}" ]]; then |
633 chdir_relative src/scripts | 645 chdir_relative src/scripts |
634 # We purposefully do not quote FLAGS_test below as we expect it may | 646 # We purposefully do not quote FLAGS_test below as we expect it may |
635 # have multiple parameters | 647 # have multiple parameters |
636 run_phase "Running tests on Chromium OS machine ${FLAGS_remote}" \ | 648 if ! run_phase "Running tests on Chromium OS machine ${FLAGS_remote}" \ |
637 ./run_remote_tests.sh "--remote=${FLAGS_remote}" ${FLAGS_test} \ | 649 ./run_remote_tests.sh "--remote=${FLAGS_remote}" ${FLAGS_test} \ |
638 "${board_param}" | 650 "${board_param}"; then |
651 if [[ ${FLAGS_ignore_remote_test_failures} -eq ${FLAGS_FALSE} ]]; then | |
652 echo "Remote tests failed and --ignore_remote_test_failures not passed" | |
653 false | |
654 fi | |
655 fi | |
639 fi | 656 fi |
640 | 657 |
641 trap - EXIT | 658 trap - EXIT |
642 echo "Successfully used ${FLAGS_top} to:" | 659 echo "Successfully used ${FLAGS_top} to:" |
643 describe_steps | 660 describe_steps |
644 show_duration | 661 show_duration |
645 } | 662 } |
646 | 663 |
647 | 664 |
648 main $@ | 665 main $@ |
OLD | NEW |