| 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 CHROMEOS_EXT_MIRROR="http://chromeos-deb/ubuntu" | 394 CHROMEOS_EXT_MIRROR="http://chromeos-deb/ubuntu" |
| 395 CHROMEOS_EXT_SUITE="karmic" | 395 CHROMEOS_EXT_SUITE="karmic" |
| 396 | 396 |
| 397 # Assume Chrome is checked out nearby | 397 # Assume Chrome is checked out nearby |
| 398 CHROMEOS_CHROME_DIR="${base_dir}/chrome" | 398 CHROMEOS_CHROME_DIR="${base_dir}/chrome" |
| 399 EOF | 399 EOF |
| 400 fi | 400 fi |
| 401 } | 401 } |
| 402 | 402 |
| 403 | 403 |
| 404 function check_rootfs_validity() { | |
| 405 echo "Checking rootfs validity" | |
| 406 local device=$(sudo losetup -f) | |
| 407 local invalid=0 | |
| 408 sudo losetup "${device}" rootfs.image | |
| 409 sudo mount "${device}" rootfs | |
| 410 if [[ ! -e rootfs/boot/vmlinuz ]]; then | |
| 411 echo "This image has no kernel" | |
| 412 invalid=1 | |
| 413 fi | |
| 414 sudo umount rootfs | |
| 415 sudo losetup -d "${device}" | |
| 416 return ${invalid} | |
| 417 } | |
| 418 | |
| 419 | |
| 420 # Downloads a buildbot image | 404 # Downloads a buildbot image |
| 421 function grab_buildbot() { | 405 function grab_buildbot() { |
| 422 if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then | 406 if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then |
| 423 local latest=$(curl "${FLAGS_buildbot_uri}/LATEST") | 407 local latest=$(curl "${FLAGS_buildbot_uri}/LATEST") |
| 424 if [[ -z "${latest}" ]]; then | 408 if [[ -z "${latest}" ]]; then |
| 425 echo "Error finding latest." | 409 echo "Error finding latest." |
| 426 exit 1 | 410 exit 1 |
| 427 fi | 411 fi |
| 428 FLAGS_grab_buildbot="${FLAGS_buildbot_uri}/${latest}/image.zip" | 412 FLAGS_grab_buildbot="${FLAGS_buildbot_uri}/${latest}/image.zip" |
| 429 fi | 413 fi |
| 430 local dl_dir=$(mktemp -d "/tmp/image.XXXX") | 414 local dl_dir=$(mktemp -d "/tmp/image.XXXX") |
| 431 echo "Grabbing image from ${FLAGS_grab_buildbot} to ${dl_dir}" | 415 echo "Grabbing image from ${FLAGS_grab_buildbot} to ${dl_dir}" |
| 432 run_phase "Downloading image" curl "${FLAGS_grab_buildbot}" \ | 416 run_phase "Downloading image" curl "${FLAGS_grab_buildbot}" \ |
| 433 -o "${dl_dir}/image.zip" | 417 -o "${dl_dir}/image.zip" |
| 434 cd "${dl_dir}" | 418 cd "${dl_dir}" |
| 435 unzip image.zip | 419 unzip image.zip |
| 436 check_rootfs_validity | |
| 437 local image_basename=$(basename $(dirname "${FLAGS_grab_buildbot}")) | 420 local image_basename=$(basename $(dirname "${FLAGS_grab_buildbot}")) |
| 438 local image_base_dir="${FLAGS_top}/src/build/images/${FLAGS_board}" | 421 local image_base_dir="${FLAGS_top}/src/build/images/${FLAGS_board}" |
| 439 local image_dir="${image_base_dir}/${image_basename}" | 422 local image_dir="${image_base_dir}/${image_basename}" |
| 440 echo "Copying in build image to ${image_dir}" | 423 echo "Copying in build image to ${image_dir}" |
| 441 rm -rf "${image_dir}" | 424 rm -rf "${image_dir}" |
| 442 mkdir -p "${image_dir}" | 425 mkdir -p "${image_dir}" |
| 443 # Note that if mbr.image does not exist, this image was not successful. | |
| 444 mv mbr.image rootfs.image "${image_dir}" | |
| 445 if [[ ${FLAGS_mod_image_for_test} -eq ${FLAGS_TRUE} ]]; then | 426 if [[ ${FLAGS_mod_image_for_test} -eq ${FLAGS_TRUE} ]]; then |
| 446 run_phase "Installing buildbot test modified image" \ | 427 run_phase "Installing buildbot test modified image" \ |
| 447 mv rootfs_test.image "${image_dir}/rootfs.image" | 428 mv chromiumos_test_image.bin "${image_dir}/chromiumos_image.bin" |
| 448 FLAGS_mod_image_for_test=${FLAGS_FALSE} | 429 FLAGS_mod_image_for_test=${FLAGS_FALSE} |
| 449 if [[ -e "autotest.tgz" || -e "autotest.tar.bz2" ]]; then | 430 if [[ -e "autotest.tgz" || -e "autotest.tar.bz2" ]]; then |
| 450 # pull in autotest | 431 # pull in autotest |
| 451 local dir="${FLAGS_chroot}/build/${FLAGS_board}/usr/local" | 432 local dir="${FLAGS_chroot}/build/${FLAGS_board}/usr/local" |
| 452 local tar_args="xzf" | 433 local tar_args="xzf" |
| 453 local tar_name="${dl_dir}/autotest.tgz" | 434 local tar_name="${dl_dir}/autotest.tgz" |
| 454 if [[ -e "autotest.tar.bz2" ]]; then | 435 if [[ -e "autotest.tar.bz2" ]]; then |
| 455 tar_args="xjf" | 436 tar_args="xjf" |
| 456 tar_name="${dl_dir}/autotest.tar.bz2" | 437 tar_name="${dl_dir}/autotest.tar.bz2" |
| 457 fi | 438 fi |
| 458 sudo rm -rf "${dir}/autotest" | 439 sudo rm -rf "${dir}/autotest" |
| 459 # Expand in temp directory as current user, then move it as | 440 # Expand in temp directory as current user, then move it as |
| 460 # root to keep local user ownership | 441 # root to keep local user ownership |
| 461 run_phase "Unpacking buildbot autotest cross-compiled binaries" \ | 442 run_phase "Unpacking buildbot autotest cross-compiled binaries" \ |
| 462 tar ${tar_args} "${tar_name}" | 443 tar ${tar_args} "${tar_name}" |
| 463 run_phase "Installing buildbot autotest cross-compiled binaries" \ | 444 run_phase "Installing buildbot autotest cross-compiled binaries" \ |
| 464 sudo mv autotest ${dir} | 445 sudo mv autotest ${dir} |
| 465 fi | 446 fi |
| 447 else |
| 448 mv chromiumos_image.bin "${image_dir}" |
| 466 fi | 449 fi |
| 467 chdir_relative . | 450 chdir_relative . |
| 468 run_phase "Removing downloaded image" rm -rf "${dl_dir}" | 451 run_phase "Removing downloaded image" rm -rf "${dl_dir}" |
| 469 } | 452 } |
| 470 | 453 |
| 471 | 454 |
| 472 function main() { | 455 function main() { |
| 473 assert_outside_chroot | 456 assert_outside_chroot |
| 474 assert_not_root_user | 457 assert_not_root_user |
| 475 | 458 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 fi | 567 fi |
| 585 | 568 |
| 586 trap - EXIT | 569 trap - EXIT |
| 587 echo "Successfully used ${FLAGS_top} to:" | 570 echo "Successfully used ${FLAGS_top} to:" |
| 588 describe_steps | 571 describe_steps |
| 589 show_duration | 572 show_duration |
| 590 } | 573 } |
| 591 | 574 |
| 592 | 575 |
| 593 main $@ | 576 main $@ |
| OLD | NEW |