From c17a493bcca1debfb423812d795228ef92de4666 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 12 Mar 2012 17:07:40 -0400 Subject: [PATCH] setup DEFAULT_BOARD by default Rather than forcing all consumers of DEFAULT_BOARD to remember to call get_default_board, just do it for them automatically. BUG=None TEST=`cbuildbot {arm,amd64,x86}-generic-full` works TEST=`./build_packages --help` shows correct default Change-Id: I8d6ccb83babb2764a50692318eb9193c45fb3b39 Reviewed-on: https://gerrit.chromium.org/gerrit/17868 Reviewed-by: David James Commit-Ready: Mike Frysinger Tested-by: Mike Frysinger --- bin/cros_download_latest_image | 2 -- bin/cros_package_to_live | 2 -- build_kernel_image.sh | 2 -- build_library/build_common.sh | 1 - build_packages | 2 -- clean_loopback_devices | 2 -- common.sh | 33 ++++++++++++++------------------- cros_generate_breakpad_symbols | 2 -- cros_show_stacks | 2 -- cros_workon | 1 - get_latest_image.sh | 2 -- get_package_list | 2 -- image_to_usb.sh | 2 -- image_to_vm.sh | 2 -- make_netboot.sh | 2 -- mod_test_image_for_pyauto.sh | 2 -- mount_gpt_image.sh | 2 -- setup_board | 2 -- update_bootloaders.sh | 2 -- upload_symbols | 2 -- 20 files changed, 14 insertions(+), 55 deletions(-) diff --git a/bin/cros_download_latest_image b/bin/cros_download_latest_image index e2cd0f4b4f..650e41f4aa 100755 --- a/bin/cros_download_latest_image +++ b/bin/cros_download_latest_image @@ -28,8 +28,6 @@ find_common_sh . "${SCRIPT_ROOT}/common.sh" || exit 1 # --- END COMMON.SH BOILERPLATE --- -get_default_board - DEFINE_string board "$DEFAULT_BOARD" \ "The name of the board to check for images." DEFINE_boolean incremental "$FLAGS_FALSE" "Download incremental build" diff --git a/bin/cros_package_to_live b/bin/cros_package_to_live index 09288f0b5d..b3d96e4ad8 100755 --- a/bin/cros_package_to_live +++ b/bin/cros_package_to_live @@ -30,8 +30,6 @@ find_common_sh . "${SCRIPT_ROOT}/remote_access.sh" || exit 1 -get_default_board - DEFINE_boolean verbose ${FLAGS_FALSE} \ "Whether to output verbose information for debugging." DEFINE_boolean build ${FLAGS_FALSE} "Build package before installing" diff --git a/build_kernel_image.sh b/build_kernel_image.sh index 061970acb9..11e59454ce 100755 --- a/build_kernel_image.sh +++ b/build_kernel_image.sh @@ -9,8 +9,6 @@ SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || exit 1 -get_default_board - # Flags. DEFINE_string arch "x86" \ "The boot architecture: arm, x86, or amd64. (Default: x86)" diff --git a/build_library/build_common.sh b/build_library/build_common.sh index b299e2ebc1..e3f217e257 100644 --- a/build_library/build_common.sh +++ b/build_library/build_common.sh @@ -19,4 +19,3 @@ INSTALLER_ROOT=/usr/lib/installer BUILD_LIBRARY_DIR=${SCRIPTS_DIR}/build_library locate_gpt -get_default_board diff --git a/build_packages b/build_packages index ccf81c6e03..9efcf289f5 100755 --- a/build_packages +++ b/build_packages @@ -9,8 +9,6 @@ # Script must run inside the chroot restart_in_chroot_if_needed "$@" -get_default_board - assert_not_root_user # Developer-visible flags. diff --git a/clean_loopback_devices b/clean_loopback_devices index 1e774cb23c..f5eda73706 100755 --- a/clean_loopback_devices +++ b/clean_loopback_devices @@ -14,8 +14,6 @@ SCRIPT_ROOT=$(dirname $(readlink -f "$0")) # Script must be run inside the chroot. assert_inside_chroot -get_default_board - DEFINE_string output_root "$DEFAULT_BUILD_ROOT/images" \ "Directory in which to place image result directories (named by version)" DEFINE_string board "$DEFAULT_BOARD" \ diff --git a/common.sh b/common.sh index 56f7f637ad..83c0c8909e 100644 --- a/common.sh +++ b/common.sh @@ -278,9 +278,20 @@ if [ -d "$SRC_ROOT/overlays" ]; then fi # Strip CR ALL_BOARDS=$(echo $ALL_BOARDS) -# Set a default BOARD -#DEFAULT_BOARD=x86-generic # or... -DEFAULT_BOARD=$(echo $ALL_BOARDS | awk '{print $NF}') + +# Sets the default board variable for calling script. +if [ -f "$GCLIENT_ROOT/src/scripts/.default_board" ] ; then + DEFAULT_BOARD=$(cat "$GCLIENT_ROOT/src/scripts/.default_board") + # Check for user typos like whitespace. + if [[ -n ${DEFAULT_BOARD//[a-zA-Z0-9-_]} ]] ; then + die ".default_board: invalid name detected; please fix:" \ + "'${DEFAULT_BOARD}'" + fi +fi +# Stub to get people to upgrade. +get_default_board() { + warn "please upgrade your script, and make sure to run build_packages" +} # Enable --fast by default. DEFAULT_FAST=${FLAGS_TRUE} @@ -394,22 +405,6 @@ setup_board_warning() { echo } - -# Sets the default board variable for calling script -get_default_board() { - DEFAULT_BOARD= - - if [ -f "$GCLIENT_ROOT/src/scripts/.default_board" ] ; then - DEFAULT_BOARD=$(cat "$GCLIENT_ROOT/src/scripts/.default_board") - # Check for user typos like whitespace. - if [[ -n ${DEFAULT_BOARD//[a-zA-Z0-9-_]} ]] ; then - die ".default_board: invalid name detected; please fix:" \ - "'${DEFAULT_BOARD}'" - fi - fi -} - - # Enter a chroot and restart the current script if needed restart_in_chroot_if_needed() { # NB: Pass in ARGV: restart_in_chroot_if_needed "$@" diff --git a/cros_generate_breakpad_symbols b/cros_generate_breakpad_symbols index 966d0a3bd2..444adff014 100755 --- a/cros_generate_breakpad_symbols +++ b/cros_generate_breakpad_symbols @@ -15,8 +15,6 @@ SCRIPT_ROOT=$(dirname $(readlink -f "$0")) # Script must be run inside the chroot restart_in_chroot_if_needed "$@" -get_default_board - # Flags DEFINE_string board "$DEFAULT_BOARD" "The board to build packages for." DEFINE_string minidump_symbol_root "" \ diff --git a/cros_show_stacks b/cros_show_stacks index 5a155dc4cb..b54cf9d68a 100755 --- a/cros_show_stacks +++ b/cros_show_stacks @@ -17,8 +17,6 @@ MINIDUMP_DUMP=/usr/bin/minidump_dump MINIDUMP_STACKWALK=/usr/bin/minidump_stackwalk USING_REMOTE=0 -get_default_board - DEFINE_string board "${DEFAULT_BOARD}" \ "The board for which you are building autotest" DEFINE_string breakpad_root "" \ diff --git a/cros_workon b/cros_workon index 46eb48b224..c575ca6189 100755 --- a/cros_workon +++ b/cros_workon @@ -15,7 +15,6 @@ assert_not_root_user # Script must be run inside the chroot -get_default_board DEFINE_string board "${DEFAULT_BOARD}" \ "The board to set package keywords for." diff --git a/get_latest_image.sh b/get_latest_image.sh index a7ddee57cc..882bae9007 100755 --- a/get_latest_image.sh +++ b/get_latest_image.sh @@ -9,8 +9,6 @@ SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || exit 1 -get_default_board - DEFINE_string board "$DEFAULT_BOARD" \ "The name of the board to check for images." diff --git a/get_package_list b/get_package_list index 84149bb81c..bbf4bad5aa 100755 --- a/get_package_list +++ b/get_package_list @@ -13,8 +13,6 @@ SCRIPT_ROOT=$(dirname $(readlink -f "$0")) # Script must be run inside the chroot. assert_inside_chroot -get_default_board - # Flags. DEFINE_string board "$DEFAULT_BOARD" \ "The board for which the image was built." b diff --git a/image_to_usb.sh b/image_to_usb.sh index 715db4ea66..f3547c3f1a 100755 --- a/image_to_usb.sh +++ b/image_to_usb.sh @@ -19,8 +19,6 @@ SCRIPT_ROOT=$(dirname $(readlink -f "$0")) # In case chromeos-common.sh doesn't support MMC yet declare -F list_mmc_disks >/dev/null || list_mmc_disks() { true; } -get_default_board - # Flags DEFINE_string board "${DEFAULT_BOARD}" \ "board for which the image was built" diff --git a/image_to_vm.sh b/image_to_vm.sh index 6ebc0aefa4..5fc512ea99 100755 --- a/image_to_vm.sh +++ b/image_to_vm.sh @@ -18,8 +18,6 @@ assert_inside_chroot . /usr/lib/installer/chromeos-common.sh || exit 1 . "${SCRIPT_ROOT}/lib/cros_vm_constants.sh" || exit 1 -get_default_board - # Flags DEFINE_string board "${DEFAULT_BOARD}" \ "Board for which the image was built" diff --git a/make_netboot.sh b/make_netboot.sh index 07e26237d2..5a4d9ff5c0 100755 --- a/make_netboot.sh +++ b/make_netboot.sh @@ -18,8 +18,6 @@ SCRIPT_ROOT=$(dirname $(readlink -f "$0")) # Script must be run inside the chroot. restart_in_chroot_if_needed "$@" -get_default_board - DEFINE_string board "${DEFAULT_BOARD}" \ "The board to build an image for." DEFINE_string image "" "Path to the image to use" diff --git a/mod_test_image_for_pyauto.sh b/mod_test_image_for_pyauto.sh index b30648bf2e..d3f517e2e1 100644 --- a/mod_test_image_for_pyauto.sh +++ b/mod_test_image_for_pyauto.sh @@ -17,8 +17,6 @@ cleanup() { # Need to be inside the chroot to load chromeos-common.sh assert_inside_chroot -get_default_board - DEFINE_string board "$DEFAULT_BOARD" "Board for which the image was built" b DEFINE_string image "$FLAGS_image" "Location of the test image file" i DEFINE_boolean scrub "$FLAGS_FALSE" "Don't include pyauto tests and data" s diff --git a/mount_gpt_image.sh b/mount_gpt_image.sh index 9cd8563161..acf62811b7 100755 --- a/mount_gpt_image.sh +++ b/mount_gpt_image.sh @@ -21,8 +21,6 @@ fi locate_gpt -get_default_board - # Flags. DEFINE_string board "$DEFAULT_BOARD" \ "The board for which the image was built." b diff --git a/setup_board b/setup_board index 9f5ce0ad4f..0f275828cf 100755 --- a/setup_board +++ b/setup_board @@ -10,8 +10,6 @@ # Script must run inside the chroot restart_in_chroot_if_needed "$@" -get_default_board - assert_not_root_user # Developer-visible flags. diff --git a/update_bootloaders.sh b/update_bootloaders.sh index 1bb5155713..6917432ef7 100755 --- a/update_bootloaders.sh +++ b/update_bootloaders.sh @@ -16,8 +16,6 @@ assert_inside_chroot # Load functions and constants for chromeos-install . /usr/lib/installer/chromeos-common.sh || exit 1 -get_default_board - # Flags. DEFINE_string arch "x86" \ "The boot architecture: arm or x86. (Default: x86)" diff --git a/upload_symbols b/upload_symbols index 982a3e8f0f..3c9035239c 100755 --- a/upload_symbols +++ b/upload_symbols @@ -16,8 +16,6 @@ if [[ "$1" != "--testing" ]]; then restart_in_chroot_if_needed "$@" fi -get_default_board - # Flags DEFINE_string board "$DEFAULT_BOARD" "The board to build packages for." DEFINE_string breakpad_root "" "Root directory for breakpad symbols."