From cc48864bcedaf4b4dfa0b1bc404e902eb4c7c60a Mon Sep 17 00:00:00 2001 From: Ken Mixter Date: Wed, 24 Feb 2010 15:27:30 -0800 Subject: [PATCH] Support renamed commands, remove non-portage build support, fix a minor mod_image_for_test bug. Tested with build_autotest, mift, image_to_usb, and image_to_live. Also not recreating the chroot unless it's missing or you pass --force_make_chroot as folks say that added dependencies in the chroot are handled currently during build_packages. Review URL: http://codereview.chromium.org/650123 --- mod_image_for_test.sh | 2 +- sync_build_test.sh | 159 +++++++++++++++++++++--------------------- 2 files changed, 82 insertions(+), 79 deletions(-) diff --git a/mod_image_for_test.sh b/mod_image_for_test.sh index e6982a1fc1..98706d92d2 100755 --- a/mod_image_for_test.sh +++ b/mod_image_for_test.sh @@ -21,7 +21,7 @@ FLAGS "$@" || exit 1 eval set -- "${FLAGS_ARGV}" # No board, no default and no image set then we can't find the image -if [ -z $FLAGS_IMAGE ] && [ -z $FLAGS_board ] ; then +if [ -z $FLAGS_IMAGE ] && [ -z $FLAGS_board ] ; then setup_board_warning echo "*** mod_image_for_test failed. No board set and no image set" exit 1 diff --git a/sync_build_test.sh b/sync_build_test.sh index b8474b6dfa..5dfe7cf10f 100755 --- a/sync_build_test.sh +++ b/sync_build_test.sh @@ -46,40 +46,41 @@ . "$(dirname "$0")/common.sh" -DEFINE_string top "" \ - "Root directory of your checkout (defaults to determining from your cwd)" -DEFINE_string repo "${CHROMIUMOS_REPO}" "gclient repo for chromiumos" -DEFINE_boolean sync ${FLAGS_TRUE} "Sync the checkout" -DEFINE_boolean force_make_chroot ${FLAGS_FALSE} "Run make_chroot indep of sync" +DEFINE_string board "x86-generic" "Board setting" DEFINE_boolean build ${FLAGS_TRUE} \ "Build all code (but not necessarily master image)" -DEFINE_boolean master ${FLAGS_TRUE} "Master an image from built code" +DEFINE_boolean build_autotest ${FLAGS_FALSE} "Build autotest" +DEFINE_string buildbot_uri "${BUILDBOT_URI}" \ + "Base URI to buildbot build location which contains LATEST file" +DEFINE_string chronos_passwd "${CHRONOS_PASSWD}" \ + "Use this as the chronos user passwd (defaults to \$CHRONOS_PASSWD)" +DEFINE_string chroot "" "Chroot to build/use" +DEFINE_boolean force_make_chroot ${FLAGS_FALSE} "Run make_chroot indep of sync" DEFINE_string grab_buildbot "" \ "Instead of building, grab this full image.zip URI generated by the \ buildbot" -DEFINE_string chronos_passwd "${CHRONOS_PASSWD}" \ - "Use this as the chronos user passwd (defaults to \$CHRONOS_PASSWD)" -DEFINE_boolean mod_image_for_test ${FLAGS_FALSE} "Modify the image for testing" -DEFINE_boolean build_autotest ${FLAGS_FALSE} "Build autotest" DEFINE_boolean image_to_live ${FLAGS_FALSE} \ "Put the resulting image on live instance (requires --remote)" -DEFINE_string remote "" \ - "Use this hostname/IP for live updating and running tests" DEFINE_string image_to_usb "" \ "Treat this device as USB and put the image on it after build" -DEFINE_string test "" \ - "Test the built image with the given params to run_remote_tests" -DEFINE_string buildbot_uri "${BUILDBOT_URI}" \ - "Base URI to buildbot build location which contains LATEST file" -DEFINE_boolean unittest ${FLAGS_TRUE} "Run unit tests" +# You can set jobs > 1 but then your build may break and you may need +# to retry. Setting it to 1 is best for non-interactive sessions. DEFINE_boolean interactive ${FLAGS_FALSE} \ "Tell user what we plan to do and wait for input to proceed" i -DEFINE_boolean portage ${FLAGS_TRUE} "Use portage-based build" -DEFINE_string board "x86-generic" "Board setting (portage)" -DEFINE_string toolchain "i686-pc-linux-gnu" "Toolchain setting (portage)" -# You can set build_jobs > 1 but then your build may break and you may need -# to retry. Setting it to 1 is best for non-interactive sessions. -DEFINE_integer build_jobs 1 "Concurrent build jobs (portage)" +DEFINE_integer jobs -1 "Concurrent build jobs" +DEFINE_boolean master ${FLAGS_TRUE} "Master an image from built code" +DEFINE_boolean mod_image_for_test ${FLAGS_FALSE} "Modify the image for testing" +DEFINE_string remote "" \ + "Use this hostname/IP for live updating and running tests" +DEFINE_string repo "${CHROMIUMOS_REPO}" "gclient repo for chromiumos" +DEFINE_boolean sync ${FLAGS_TRUE} "Sync the checkout" +DEFINE_string test "" \ + "Test the built image with the given params to run_remote_tests" +DEFINE_string top "" \ + "Root directory of your checkout (defaults to determining from your cwd)" +DEFINE_boolean withdev ${FLAGS_TRUE} "Build development packages" +DEFINE_boolean unittest ${FLAGS_TRUE} "Run unit tests" + # Returns a heuristic indicating if we believe this to be a google internal # development environment. @@ -111,7 +112,18 @@ function validate_and_set_param_defaults() { fi # Canonicalize any symlinks - FLAGS_top=$(readlink -f "${FLAGS_top}") + if [[ -d "${FLAGS_top}" ]]; then + FLAGS_top=$(readlink -f "${FLAGS_top}") + fi + + if [[ -z "${FLAGS_chroot}" ]]; then + FLAGS_chroot="${FLAGS_top}/chroot" + fi + + # If chroot does not exist, force making it + if [[ ! -d "${FLAGS_chroot}" ]]; then + FLAGS_force_make_chroot=${FLAGS_TRUE} + fi if [[ -z "${FLAGS_repo}" ]]; then if is_google_environment; then @@ -170,13 +182,8 @@ function validate_and_set_param_defaults() { # TODO(kmixter): Make this more efficient by either doing incremental # building, or only building if the tests we're running needs to be. FLAGS_build_autotest=${FLAGS_TRUE} - fi - - if [[ -e "${FLAGS_top}/src/scripts/new_make_env.sh" ]]; then - if [[ ${FLAGS_portage} -ne ${FLAGS_TRUE} ]]; then - echo "WARNING: It looks like you wanted to pass --portage to " - echo "build with the portage method" - fi + # If you're modding for test, you also want developer packages. + FLAGS_withdev=${FLAGS_TRUE} fi if [[ -n "${FLAGS_image_to_usb}" ]]; then @@ -203,15 +210,23 @@ function describe_steps() { fi fi if [[ ${FLAGS_force_make_chroot} -eq ${FLAGS_TRUE} ]]; then - echo " * (Re-)create development chroot (make_chroot.sh)" + echo " * Rebuild chroot (make_chroot) in ${FLAGS_chroot}" fi local set_passwd=${FLAGS_FALSE} if [[ ${FLAGS_build} -eq ${FLAGS_TRUE} ]]; then - echo " * Build image (build_platform_packages.sh, build_kernel.sh)" + local withdev="" + local jobs=" single job (slow but safe)" + if [[ ${FLAGS_jobs} -gt 1 ]]; then + jobs=" ${FLAGS_jobs} jobs (may cause build failure)" + fi + if [[ ${FLAGS_withdev} -eq ${FLAGS_TRUE} ]]; then + withdev=" with dev packages" + fi + echo " * Build image${withdev}${jobs}" set_passwd=${FLAGS_TRUE} fi if [[ ${FLAGS_master} -eq ${FLAGS_TRUE} ]]; then - echo " * Master image (build_image.sh)" + echo " * Master image (build_image)" fi if [[ -n "${FLAGS_grab_buildbot}" ]]; then if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then @@ -232,7 +247,7 @@ function describe_steps() { fi fi if [[ ${FLAGS_build_autotest} -eq ${FLAGS_TRUE} ]]; then - echo " * Build autotest" + echo " * Cross-build autotest client tests (build_autotest)" fi if [[ -n "${FLAGS_image_to_usb}" ]]; then echo " * Write the image to USB device ${FLAGS_image_to_usb}" @@ -329,7 +344,7 @@ function run_phase() { function run_phase_in_chroot() { local desc="$1" shift - run_phase "${desc}" ./enter_chroot.sh -- "$@" + run_phase "${desc}" ./enter_chroot.sh "--chroot=${FLAGS_chroot}" -- "$@" } @@ -368,10 +383,6 @@ CHROMEOS_EXT_SUITE="karmic" CHROMEOS_CHROME_DIR="${base_dir}/chrome" EOF fi - if [[ ${FLAGS_portage} -eq ${FLAGS_TRUE} ]]; then - chdir_relative src/third_party - chromiumos-overlay/chromeos/scripts/setup_source_tree.sh - fi } @@ -444,16 +455,24 @@ function main() { set_start_time + local withdev_param="" + if [[ ${FLAGS_withdev} -eq ${FLAGS_TRUE} ]]; then + withdev_param="--withdev" + fi + + local jobs_param="" + if [[ ${FLAGS_jobs} -gt 1 ]]; then + jobs_param="--jobs=${FLAGS_jobs}" + fi + + local board_param="--board=${FLAGS_board}" + if [[ ! -e "${FLAGS_top}" ]]; then config_new_checkout fi if [[ ${FLAGS_sync} -eq ${FLAGS_TRUE} ]]; then sync - # The package repository is now potentially out of date, so - # reflect that. - run_phase "Removing existing package repo" sudo rm -rf repo - FLAGS_force_make_chroot=${FLAGS_TRUE} fi if [[ -n "${FLAGS_grab_buildbot}" ]]; then @@ -462,33 +481,24 @@ function main() { if [[ ${FLAGS_force_make_chroot} -eq ${FLAGS_TRUE} ]]; then chdir_relative src/scripts - if [[ ${FLAGS_portage} -eq ${FLAGS_TRUE} ]]; then - run_phase "Replacing chroot" ./new_make_env.sh --replace - else - run_phase "Replacing chroot" ./make_chroot.sh --replace - fi + run_phase "Replacing chroot" ./make_chroot --replace \ + "--chroot=${FLAGS_chroot}" ${jobs_param} fi if [[ ${FLAGS_build} -eq ${FLAGS_TRUE} ]]; then chdir_relative src/scripts - if [[ ${FLAGS_portage} -eq ${FLAGS_TRUE} ]]; then - # Only setup board target if the directory does not exist - if [[ ! -d "${DEFAULT_CHROOT_DIR}/build/${FLAGS_board}" ]]; then - run_phase_in_chroot "Setting up board target" \ - ./setup_board "--board=${FLAGS_board}" \ - "--toolchain=${FLAGS_toolchain}" - fi - run_phase_in_chroot "Building packages" \ - ./new_build_pkgs.sh "--board=${FLAGS_board}" \ - "--jobs=${FLAGS_build_jobs}" - else - run_phase_in_chroot "Building platform packages and kernel" \ - "./build_platform_packages.sh && ./build_kernel.sh" + # Only setup board target if the directory does not exist + if [[ ! -d "${FLAGS_top}/chroot/build/${FLAGS_board}" ]]; then + run_phase_in_chroot "Setting up board target" \ + ./setup_board "${board_param}" fi + run_phase_in_chroot "Building packages" \ + ./build_packages "${board_param}" \ + ${jobs_param} ${withdev_param} # TODO(kmixter): Enable this once build_tests works, but even # then only do it when not cross compiling. - if [[ ${FLAGS_portage} -eq ${FLAGS_FALSE} ]]; then + if [[ '' ]]; then run_phase_in_chroot "Building and running unit tests" \ "./build_tests.sh && ./run_tests.sh" fi @@ -501,29 +511,21 @@ function main() { ./enter_chroot.sh "echo '${FLAGS_chronos_passwd}' | \ ~/trunk/src/scripts/set_shared_user_password.sh" fi - if [[ ${FLAGS_portage} -eq ${FLAGS_TRUE} ]]; then - run_phase_in_chroot "Mastering image" ./new_build_image.sh \ - "--board=${FLAGS_board}" --replace - else - run_phase_in_chroot "Mastering image" ./build_image.sh --replace - fi - fi - - local board_param="" - if [[ ${FLAGS_portage} -eq ${FLAGS_TRUE} ]]; then - board_param="--board=${FLAGS_board}" + run_phase_in_chroot "Mastering image" ./build_image \ + "${board_param}" --replace ${withdev_param} \ + ${jobs_param} fi if [[ ${FLAGS_mod_image_for_test} -eq ${FLAGS_TRUE} ]]; then chdir_relative src/scripts run_phase_in_chroot "Modifying image for test" \ - "./mod_image_for_test.sh" ${board_param} + "./mod_image_for_test.sh" "${board_param}" --yes fi if [[ -n "${FLAGS_image_to_usb}" ]]; then chdir_relative src/scripts run_phase "Installing image to USB" \ - ./image_to_usb.sh --yes "--to=${FLAGS_image_to_usb}" ${board_param} + ./image_to_usb.sh --yes "--to=${FLAGS_image_to_usb}" "${board_param}" fi if [[ ${FLAGS_image_to_live} -eq ${FLAGS_TRUE} ]]; then @@ -534,7 +536,8 @@ function main() { if [[ ${FLAGS_build_autotest} -eq ${FLAGS_TRUE} ]]; then chdir_relative src/scripts - run_phase_in_chroot "Building autotest" "./build_autotest.sh" ${board_param} + run_phase_in_chroot "Building autotest" "./build_autotest.sh" \ + --noprompt "${board_param}" fi if [[ -n "${FLAGS_test}" ]]; then @@ -543,7 +546,7 @@ function main() { # have multiple parameters run_phase "Running tests on Chromium OS machine ${FLAGS_remote}" \ ./run_remote_tests.sh "--remote=${FLAGS_remote}" ${FLAGS_test} \ - ${board_param} + "${board_param}" fi echo "Successfully used ${FLAGS_top} to:"