From 17c622a38021500f22872648aba8c43cf18bb05d Mon Sep 17 00:00:00 2001 From: David James Date: Wed, 7 Mar 2012 09:34:08 -0800 Subject: [PATCH] Add support for using local binary packages. This CL adds the --reuse_pkgs_from_local_boards flag to setup_board and build_packages. With this flag, binary packages are shared between boards that are built locally, so that the total time required to build several boards is reduced. This flag is only useful when you are not able to use remote binary packages, since remote binary packages are usually more up to date than anything you have locally. For this reason it is typically only used by buildbots which build multiple similar full builds on the same machine. BUG=chromium-os:26232 TEST=Test build using only local binary packages from a different board. CQ-DEPEND=I0353dd34f63f1b5c9c1a08882322279c6c4d82f5 Change-Id: I8a1d2687bd0d177de4464a80703b8b5a0b6c9f52 Reviewed-on: https://gerrit.chromium.org/gerrit/15775 Commit-Ready: David James Reviewed-by: David James Tested-by: David James --- build_packages | 14 +++++++++++++- setup_board | 48 ++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/build_packages b/build_packages index 631ef0522f..e8a8ccb71a 100755 --- a/build_packages +++ b/build_packages @@ -73,6 +73,14 @@ DEFINE_boolean oldchromebinary "${FLAGS_FALSE}" \ DEFINE_boolean skip_toolchain_update "${FLAGS_FALSE}" \ "Don't update toolchain automatically." +# The --reuse_pkgs_from_local_boards flag tells Portage to share binary +# packages between boards that are built locally, so that the total time +# required to build several boards is reduced. This flag is only useful +# when you are not able to use remote binary packages, since remote binary +# packages are usually more up to date than anything you have locally. +DEFINE_boolean reuse_pkgs_from_local_boards $FLAGS_FALSE \ + "Bootstrap from local packages instead of remote packages." + # Parse command line FLAGS_HELP="usage: $0 [flags]" @@ -103,7 +111,8 @@ if [[ -n "${EXTRA_BOARD_FLAGS}" ]]; then EMERGE_BOARD_CMD="${EMERGE_BOARD_CMD} ${EXTRA_BOARD_FLAGS}" fi -if [[ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]]; then +if [[ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" || + "${FLAGS_reuse_pkgs_from_local_boards}" -eq "${FLAGS_TRUE}" ]]; then # Use binary packages. Include all build-time dependencies, # so as to avoid unnecessary differences between source # and binary builds. @@ -135,6 +144,9 @@ fi if [[ "${FLAGS_jobs}" -ne -1 ]]; then UPDATE_ARGS+=" --jobs=${FLAGS_jobs}" fi +if [ "${FLAGS_reuse_pkgs_from_local_boards}" -eq "${FLAGS_TRUE}" ]; then + UPDATE_ARGS+=" --reuse_pkgs_from_local_boards" +fi if [ "${FLAGS_skip_toolchain_update}" -eq "${FLAGS_TRUE}" ]; then UPDATE_ARGS+=" --skip_toolchain_update" fi diff --git a/setup_board b/setup_board index a3437888a2..406e23115b 100755 --- a/setup_board +++ b/setup_board @@ -74,6 +74,15 @@ DEFINE_boolean skip_chroot_upgrade $FLAGS_FALSE \ This should only be called by version hook scripts that need to call \ setup_board." +# The --reuse_pkgs_from_local_boards flag tells Portage to share binary +# packages between boards that are built locally, so that the total time +# required to build several boards is reduced. This flag is only useful +# when you are not able to use remote binary packages, since remote binary +# packages are usually more up to date than anything you have locally. +DEFINE_boolean reuse_pkgs_from_local_boards $FLAGS_FALSE \ + "Bootstrap from local packages instead of remote packages." + + # builds wrappers like equery-arm-generic. # args: # $1: command to wrap @@ -394,7 +403,15 @@ print_board_make_conf() { echo } -print_board_binhost_config() { +print_binhost_config() { + if [ "$1" == "--local" ]; then + cros_generate_local_binhosts --board "${BOARD_VARIANT}" + echo 'PORTAGE_BINHOST="$LOCAL_BINHOST"' + return 0 + elif [ $# -ne 0 ]; then + die "Invalid arguments for print_binhost_config: $@" + fi + local binhost_dir="$CHROMIUMOS_OVERLAY/chromeos/binhost/target" local preflight_binhost="$binhost_dir/$BOARD-PREFLIGHT_BINHOST.conf" local chrome_binhost_suffix="LATEST_RELEASE_CHROME_BINHOST.conf" @@ -452,6 +469,14 @@ EOF fi } +print_board_binhost_config() { + if [ "${FLAGS_reuse_pkgs_from_local_boards}" -eq "${FLAGS_TRUE}" ]; then + print_binhost_config --local + else + print_binhost_config + fi +} + # Parse command line flags FLAGS "$@" || exit 1 eval set -- "${FLAGS_ARGV}" @@ -571,8 +596,8 @@ if [ -d "$BOARD_ROOT" ] ; then sudo rm -rf $TEMP_DIR & else if ! $HOST_BOARD; then - print_board_make_conf | sudo_clobber $BOARD_ETC/make.conf.board - print_board_binhost_config | sudo_append $BOARD_ETC/make.conf.board + { print_board_make_conf; print_board_binhost_config; } | \ + sudo_clobber $BOARD_ETC/make.conf.board fi if [[ $FLAGS_quiet -eq $FLAGS_FALSE ]]; then warn "Board output directory '$BOARD_ROOT' already exists." @@ -631,7 +656,6 @@ if ! ${HOST_BOARD}; then sudo ln -sf "${CHROMIUMOS_CONFIG}/make.conf.${ARCH}-target" \ "${BOARD_ETC}/make.conf" print_board_make_conf | sudo_clobber $BOARD_ETC/make.conf.board - print_board_binhost_config | sudo_append $BOARD_ETC/make.conf.board # We install the toolchain related bits after the BOARD_ROOT, BOARD_PROFILE # and BOARD_ETC directories have been created. @@ -728,15 +752,23 @@ if ${HOST_BOARD}; then sudo find $BOARD_ROOT -type f -name '*.la' | xargs sudo \ sed -i -e "s|$BOARD_ROOT/|/|g" else + # Now that the portageq-* wrappers have been created, we can add the binhost + # config to make.conf.board. + print_board_binhost_config | sudo_append $BOARD_ETC/make.conf.board + # # Emerge the kernel headers into the board build root. # - EMERGE_FLAGS="--select --quiet" - if [[ $FLAGS_usepkg -eq $FLAGS_TRUE ]]; then - EMERGE_FLAGS+=" --getbinpkg --usepkg" + KERNEL_EMERGE_FLAGS="--select --quiet" + if [[ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" || + "${FLAGS_reuse_pkgs_from_local_boards}" -eq "${FLAGS_TRUE}" ]]; then + KERNEL_EMERGE_FLAGS+=" --getbinpkg --usepkg" fi - sudo -E "${EMERGE_WRAPPER}" ${EMERGE_FLAGS} chromeos-base/kernel-headers + sudo -E "${EMERGE_WRAPPER}" ${KERNEL_EMERGE_FLAGS} \ + chromeos-base/kernel-headers + + unset KERNEL_EMERGE_FLAGS fi if [ $FLAGS_default -eq $FLAGS_TRUE ] ; then