blob: fd411bc53fdb10f5023b47e843e88bef36b4b1ec [file] [log] [blame]
Brian Harringcb782242011-12-13 19:48:44 -08001#!/bin/bash
2
3# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
David James0b1baf62012-03-15 09:26:23 -07007. "$(dirname "$0")/common.sh" || exit 1
Brian Harringcb782242011-12-13 19:48:44 -08008
9# Script must run inside the chroot
10restart_in_chroot_if_needed "$@"
11
Zdenek Behan05780782012-05-18 03:07:28 +020012assert_not_root_user
13
David James855afb72012-03-14 20:04:59 -070014# Developer-visible flags.
Brian Harringcb782242011-12-13 19:48:44 -080015DEFINE_string board "${DEFAULT_BOARD}" \
16 "The board to build packages for."
Brian Harringcb782242011-12-13 19:48:44 -080017DEFINE_boolean usepkg "${FLAGS_TRUE}" \
18 "Use binary packages to bootstrap when possible."
Thiago Goncales5ad4ca02013-07-12 10:55:11 -070019DEFINE_boolean usepkgonly "${FLAGS_FALSE}" \
20 "Only use binary packages to bootstrap; abort if any are missing."
Brian Harringcb782242011-12-13 19:48:44 -080021DEFINE_boolean noworkon "${FLAGS_FALSE}" \
22 "Don't force-build workon packages."
David James855afb72012-03-14 20:04:59 -070023DEFINE_boolean showoutput "${FLAGS_FALSE}" \
24 "Show all output from parallel_emerge."
25DEFINE_boolean withautotest "${FLAGS_TRUE}" \
26 "Build autotest client code."
Bertrand SIMONNET2f6aaf22015-02-09 15:49:05 -080027DEFINE_boolean withdebugsymbols "${FLAGS_FALSE}" \
Bertrand SIMONNETc7a46e22014-12-11 15:58:11 -080028 "Install the debug symbols for all packages"
Chris Ching4bc95a12016-11-22 13:44:13 -070029DEFINE_boolean withevents "${FLAGS_FALSE}" \
30 "Generate events during parallel_emerge step"
31DEFINE_string eventfile "${DEFAULT_EVENT_FILE}" \
32 "Define the file that event logs will be written."
Gregory Meinkeb0f0adc2018-04-17 12:02:28 -060033DEFINE_boolean withrevdeps "${FLAGS_TRUE}" \
Gregory Meinke0766df42018-08-23 11:36:12 -060034 "Calculate reverse dependencies on changed ebuilds."
Thiago Goncales5ad4ca02013-07-12 10:55:11 -070035
36# The --board_root flag specifies the environment variables ROOT and PKGDIR.
37# This allows fetching and emerging of all packages to specified board_root.
38# Note that --board_root will setup the board normally in /build/$BOARD, if it's
39# not setup yet. It also expects the toolchain to already be installed in the
40# board_root. --usepkgonly and --norebuild are required, because building is not
41# supported when board_root is set.
42# enforce this)."
43DEFINE_string board_root "" \
44 "Emerge packages to board_root."
David James855afb72012-03-14 20:04:59 -070045
Mike Frysinger76452ba2012-09-13 22:45:34 -040046FLAGS_HELP="usage: $(basename $0) [flags] [packages]
David James855afb72012-03-14 20:04:59 -070047
48build_packages updates the set of binary packages needed by Chrome OS. It will
49cross compile all packages that have been updated into the given target's root
50and build binary packages as a side-effect. The output packages will be picked
51up by the build_image script to put together a bootable Chrome OS image.
52
Mike Frysinger76452ba2012-09-13 22:45:34 -040053If [packages] are specified, only build those specific packages (and any
54dependencies they might need).
55
David James855afb72012-03-14 20:04:59 -070056For the fastest builds, use --nowithautotest --noworkon.
57"
58show_help_if_requested "$@"
59
60# The following options are advanced options, only available to those willing
61# to read the source code. They are not shown in help output, since they are
62# not needed for the typical developer workflow.
Ryan Cuieb4595f2012-12-17 14:28:42 -080063DEFINE_string accept_licenses "" \
64 "Licenses to append to the accept list."
David James855afb72012-03-14 20:04:59 -070065DEFINE_integer jobs -1 \
66 "How many packages to build in parallel at maximum."
67DEFINE_boolean norebuild "${FLAGS_FALSE}" \
68 "Don't automatically rebuild dependencies."
Mike Frysinger839e82a2012-03-01 14:22:10 -050069DEFINE_boolean skip_chroot_upgrade "${FLAGS_FALSE}" \
70 "Don't run the chroot upgrade automatically; use with care."
David James855afb72012-03-14 20:04:59 -070071DEFINE_boolean skip_toolchain_update "${FLAGS_FALSE}" \
72 "Don't update toolchain automatically."
73DEFINE_boolean withdev "${FLAGS_TRUE}" \
74 "Build useful developer friendly utilities."
75DEFINE_boolean withdebug "${FLAGS_TRUE}" \
76 "Build debug versions of Chromium-OS-specific packages."
77DEFINE_boolean withfactory "${FLAGS_TRUE}" \
78 "Build factory installer."
79DEFINE_boolean withtest "${FLAGS_TRUE}" \
80 "Build packages required for testing."
Aviv Keshet8aa379b2016-02-29 10:00:05 -080081DEFINE_boolean buildretry "${FLAGS_TRUE}" \
82 "Retry failed packages."
Brian Harringcb782242011-12-13 19:48:44 -080083
David James17c622a2012-03-07 09:34:08 -080084# The --reuse_pkgs_from_local_boards flag tells Portage to share binary
85# packages between boards that are built locally, so that the total time
86# required to build several boards is reduced. This flag is only useful
87# when you are not able to use remote binary packages, since remote binary
88# packages are usually more up to date than anything you have locally.
Hidehiko Abe7a41d342017-03-29 21:19:16 +090089DEFINE_boolean reuse_pkgs_from_local_boards "${FLAGS_FALSE}" \
David James17c622a2012-03-07 09:34:08 -080090 "Bootstrap from local packages instead of remote packages."
91
Hidehiko Abe7a41d342017-03-29 21:19:16 +090092# --run_goma option is designed to be used on bots.
93# If you're trying to build pacakges with goma in your local dev env, this is
94# *not* the option you're looking for. Please see comments below.
95# This option; 1) starts goma, 2) builds packages (expecting that goma is
96# used), then 3) stops goma explicitly.
97# 3) is a request from the goma team, so that stats/logs can be taken.
98# Note: GOMA_DIR and GOMA_SERVICE_ACCOUNT_JSON_FILE are expected to be passed
99# via env var.
100#
101# In local dev env cases, compiler_proxy is expected to keep running.
102# In such a case;
103# $ python ${GOMA_DIR}/goma_ctl.py ensure_start
104# $ ./build_packages (... and options without --run_goma ...)
105# is an expected commandline sequence. If you set --run_goma flag while
106# compiler_proxy is already running, the existing compiler_proxy will be
107# stopped.
108DEFINE_boolean run_goma "${FLAGS_FALSE}" \
109 "If set to true, (re)starts goma, builds packages, and then stops goma."
110
Chris McDonaldf75a0352019-01-24 16:23:18 -0700111# The above --run_goma option is a configuration flag meant for build bots. It
112# only ensures that goma is running and stops goma when build_packages
113# completes. This step is to ensure that goma is functional for Chrome's build
114# and does *not* cause all packages to be built using goma.
115# If you are trying to build packages locally with goma, the option below is
116# what you want to use. You must either ensure that goma is running before you
117# invoke build_packages with this option by running:
118# $ python ${GOMA_DIR}/goma_ctl.py ensure_start
119# OR you may run build_packages with --run_goma in addition to this option.
120# Please see the following link for instructions on how to install goma in your
121# local dev environment:
122# https://g3doc.corp.google.com/devtools/goma/g3doc/how-to-use-goma/how-to-use-goma-chromeos.md#how-to-install-goma-in-host-environment-recommended
123
124DEFINE_boolean build_all_with_goma "${FLAGS_FALSE}" \
125 "If set to true, tries to use goma to build all packages. (experimental)"
126
Brian Harringcb782242011-12-13 19:48:44 -0800127# Parse command line
Brian Harringcb782242011-12-13 19:48:44 -0800128FLAGS "$@" || exit 1
129eval set -- "${FLAGS_ARGV}"
Brian Harringcb782242011-12-13 19:48:44 -0800130
131# Die on any errors.
Brian Harring7f175a52012-03-02 05:37:00 -0800132switch_to_strict_mode
Brian Harringcb782242011-12-13 19:48:44 -0800133
134# Right now build_packages has to be run from scripts/
135. ${SRC_ROOT}/third_party/chromiumos-overlay/chromeos/config/chromeos_version.sh
136
137if [[ -z "${FLAGS_board}" ]]; then
138 echo "Error: --board is required."
139 exit 1
140fi
141
Mike Frysinger4114c792012-09-13 22:33:12 -0400142# Before we can run any tools, we need to update chroot or setup_board.
143UPDATE_ARGS=()
Ryan Cuieb4595f2012-12-17 14:28:42 -0800144if [[ -n ${FLAGS_accept_licenses} ]]; then
145 UPDATE_ARGS+=( --accept_licenses "${FLAGS_accept_licenses}" )
146fi
Mike Frysinger4114c792012-09-13 22:33:12 -0400147if [ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]; then
148 UPDATE_ARGS+=( --usepkg )
149else
150 UPDATE_ARGS+=( --nousepkg )
151fi
152if [[ "${FLAGS_jobs}" -ne -1 ]]; then
153 UPDATE_ARGS+=( --jobs=${FLAGS_jobs} )
154fi
155if [ "${FLAGS_reuse_pkgs_from_local_boards}" -eq "${FLAGS_TRUE}" ]; then
156 UPDATE_ARGS+=( --reuse_pkgs_from_local_boards )
157fi
158if [ "${FLAGS_skip_toolchain_update}" -eq "${FLAGS_TRUE}" ]; then
159 UPDATE_ARGS+=( --skip_toolchain_update )
160fi
161if [ "${FLAGS_skip_chroot_upgrade}" -eq "${FLAGS_TRUE}" ]; then
162 UPDATE_ARGS+=( --skip_chroot_upgrade )
163fi
Bertrand SIMONNET10ede912014-10-09 16:21:13 -0700164if [[ -n ${FLAGS_board_root} ]]; then
165 UPDATE_ARGS+=( --board_root "${FLAGS_board_root}" )
166fi
Mike Frysinger4114c792012-09-13 22:33:12 -0400167
168"${SCRIPTS_DIR}"/setup_board --quiet --board=${FLAGS_board} "${UPDATE_ARGS[@]}"
169
Chris Masonebbccc242014-02-08 16:23:53 -0800170sudo_clear_shadow_locks "/build/${FLAGS_board}"
171
Mike Frysinger4114c792012-09-13 22:33:12 -0400172# Setup all the emerge command/flags.
David James886f2c32014-02-26 20:38:04 -0800173EMERGE_FLAGS=( -uDNv --backtrack=30 --select --newrepo )
Mike Frysinger4114c792012-09-13 22:33:12 -0400174
Bertrand SIMONNET4dda4f52015-03-19 13:40:58 -0700175EMERGE_CMD=(
176 "${CHROMITE_BIN}/parallel_emerge"
177 --board=${FLAGS_board}
178)
179
Aviv Keshet8aa379b2016-02-29 10:00:05 -0800180if [[ "${FLAGS_buildretry}" -eq "${FLAGS_FALSE}" ]]; then
181 EMERGE_CMD+=( --retries=0 )
182fi
Brian Harring17c1fe82012-12-05 21:12:31 -0800183
Mike Frysinger4114c792012-09-13 22:33:12 -0400184EMERGE_CMD+=( ${EXTRA_BOARD_FLAGS} )
Brian Harringcb782242011-12-13 19:48:44 -0800185
David James17c622a2012-03-07 09:34:08 -0800186if [[ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ||
Thiago Goncales5ad4ca02013-07-12 10:55:11 -0700187 "${FLAGS_reuse_pkgs_from_local_boards}" -eq "${FLAGS_TRUE}" ||
188 "${FLAGS_usepkgonly}" -eq "${FLAGS_TRUE}" ]]; then
Brian Harringcb782242011-12-13 19:48:44 -0800189 # Use binary packages. Include all build-time dependencies,
190 # so as to avoid unnecessary differences between source
191 # and binary builds.
Thiago Goncales5ad4ca02013-07-12 10:55:11 -0700192 EMERGE_FLAGS+=( --getbinpkg --with-bdeps y )
193 if [[ ${FLAGS_usepkgonly} -eq ${FLAGS_TRUE} ]]; then
194 EMERGE_FLAGS+=( --usepkgonly )
195 else
196 EMERGE_FLAGS+=( --usepkg )
197 fi
Brian Harringcb782242011-12-13 19:48:44 -0800198fi
199
200if [[ "${FLAGS_jobs}" -ne -1 ]]; then
Mike Frysinger4114c792012-09-13 22:33:12 -0400201 EMERGE_FLAGS+=( --jobs=${FLAGS_jobs} )
202fi
203
204if [[ "${FLAGS_norebuild}" -eq "${FLAGS_FALSE}" ]]; then
205 EMERGE_FLAGS+=( --rebuild-if-unbuilt )
206fi
Bertrand SIMONNET4dda4f52015-03-19 13:40:58 -0700207if [[ "${FLAGS_showoutput}" -eq "${FLAGS_TRUE}" ]]; then
Mike Frysinger4114c792012-09-13 22:33:12 -0400208 EMERGE_FLAGS+=( --show-output )
Brian Harringcb782242011-12-13 19:48:44 -0800209fi
210
211if [[ "${FLAGS_withdebug}" -eq "${FLAGS_FALSE}" ]]; then
212 export USE="${USE} -cros-debug"
213fi
214
Chris Ching4bc95a12016-11-22 13:44:13 -0700215# TODO Handle case where passed default value, but events not enabled
216if [[ "${FLAGS_eventfile}" != "${DEFAULT_EVENT_FILE}" ]]; then
217 FLAGS_withevents="${FLAGS_TRUE}"
218fi
219
220if [[ "${FLAGS_withevents}" -eq "${FLAGS_TRUE}" ]]; then
221 mkdir -p "$(dirname $FLAGS_eventfile)"
222 EMERGE_FLAGS+=( "--eventlogfile=${FLAGS_eventfile}" )
223fi
224
Mike Frysinger4114c792012-09-13 22:33:12 -0400225# Figure out which packages we should be building.
Mike Frysinger76452ba2012-09-13 22:45:34 -0400226PACKAGES=( "$@" )
Daniel Wangaf4d0012015-07-17 11:52:05 -0700227FORCE_LOCAL_BUILD_PKGS=()
Mike Frysinger76452ba2012-09-13 22:45:34 -0400228if [[ $# -eq 0 ]]; then
Mike Frysinger22621952014-04-01 17:41:20 -0400229 PACKAGES=( virtual/target-os )
Mike Frysinger76452ba2012-09-13 22:45:34 -0400230 if [[ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]]; then
Mike Frysingerde399282014-04-15 18:26:04 -0400231 PACKAGES+=( virtual/target-os-dev )
Mike Frysinger76452ba2012-09-13 22:45:34 -0400232 fi
233 if [[ "${FLAGS_withfactory}" -eq "${FLAGS_TRUE}" ]]; then
Hung-Te Lin9b43ced2016-01-14 20:29:47 +0800234 PACKAGES+=( virtual/target-os-factory )
235 PACKAGES+=( virtual/target-os-factory-shim )
Mike Frysinger76452ba2012-09-13 22:45:34 -0400236 fi
237 if [[ "${FLAGS_withtest}" -eq "${FLAGS_TRUE}" ]]; then
Mike Frysinger52669432014-05-05 14:34:09 -0400238 PACKAGES+=( virtual/target-os-test )
Daniel Wangaf4d0012015-07-17 11:52:05 -0700239 # chromeos-ssh-testkeys may generate ssh keys if the right USE flag is set.
240 # We force rebuilding this package from source every time, so that
241 # consecutive builds don't share ssh keys.
242 FORCE_LOCAL_BUILD_PKGS+=( chromeos-base/chromeos-ssh-testkeys )
Mike Frysinger76452ba2012-09-13 22:45:34 -0400243 fi
244 if [[ "${FLAGS_withautotest}" -eq "${FLAGS_TRUE}" ]]; then
245 PACKAGES+=( chromeos-base/autotest-all )
246 fi
Brian Harringcb782242011-12-13 19:48:44 -0800247fi
248
249# Verify that all packages can be emerged from scratch, without any
250# backtracking. Only print the output if this step fails.
Mike Frysinger76452ba2012-09-13 22:45:34 -0400251info "Checking package dependencies are correct: ${PACKAGES[*]}"
David Jamesab9ca212012-11-06 11:06:07 -0800252if ! OUTPUT=$(emerge-${FLAGS_board} -pe --backtrack=0 \
253 "${PACKAGES[@]}" 2>&1); then
Brian Harringcb782242011-12-13 19:48:44 -0800254 printf "%s\n" "${OUTPUT}"
Brian Harring7f175a52012-03-02 05:37:00 -0800255 die_notrace "emerge detected broken ebuilds. See error message above."
Brian Harringcb782242011-12-13 19:48:44 -0800256fi
257
Mike Frysinger4114c792012-09-13 22:33:12 -0400258# Build cros_workon packages when they are changed.
259CROS_WORKON_PKGS=()
260if [ "${FLAGS_noworkon}" -eq "${FLAGS_FALSE}" ]; then
261 LIST_MODIFIED_PACKAGES="${CHROMITE_BIN}/cros_list_modified_packages"
Jason D. Clinton321e2f82017-08-09 16:21:23 -0600262 MODIFIED_PACKAGES=( $("${LIST_MODIFIED_PACKAGES}" --board=${FLAGS_board}) )
Gregory Meinke7851ece2018-05-09 13:34:06 -0600263 info "cros_workon modified packages '${MODIFIED_PACKAGES[*]}' detected"
Jason D. Clinton321e2f82017-08-09 16:21:23 -0600264 CROS_WORKON_PKGS+=( "${MODIFIED_PACKAGES[@]}" )
Mike Frysinger4114c792012-09-13 22:33:12 -0400265
David James4941c6b2014-02-03 16:24:59 -0800266 # TODO(anush): Make chrome a fake cros-workon package.
267 if [[ -n "${CHROME_ORIGIN}" ]]; then
268 CROS_WORKON_PKGS+=( chromeos-base/chromeos-chrome )
269 fi
Mike Frysinger4114c792012-09-13 22:33:12 -0400270fi
271
Daniel Wangaf4d0012015-07-17 11:52:05 -0700272# cros_workon packages always have to be rebuilt.
Daniel Wang491f42a2015-08-20 12:29:59 -0700273FORCE_LOCAL_BUILD_PKGS+=( "${CROS_WORKON_PKGS[@]}" )
Daniel Wangaf4d0012015-07-17 11:52:05 -0700274
Gregory Meinkeb0f0adc2018-04-17 12:02:28 -0600275if [[ -n "${FLAGS_board_root}" ]]; then
276 export ROOT="${FLAGS_board_root}"
277 export PORTAGE_CONFIGROOT="${ROOT}"
278 export SYSROOT="${ROOT}"
279 export PKGDIR="${ROOT}"/packages
280fi
281
282# Temporarily modify the emerge flags so we can calculate the revdeps
283# on the modified packages.
Gregory Meinke0766df42018-08-23 11:36:12 -0600284if [[ "${FLAGS_withrevdeps}" -eq "${FLAGS_TRUE}" ]]; then
Yves Arrouyec16e45e2018-08-31 08:37:15 -0700285 info "starting reverse dependency calculations ..."
Gregory Meinke0766df42018-08-23 11:36:12 -0600286 SIM_EMERGE_FLAGS=( "${EMERGE_FLAGS[@]}" --pretend --columns )
Gregory Meinkeee71dd12018-07-09 12:42:25 -0600287
Gregory Meinke0766df42018-08-23 11:36:12 -0600288 if [[ ${#PACKAGES[@]} -gt 0 ]]; then
289 SIM_EMERGE_FLAGS+=(
290 --reinstall-atoms="${PACKAGES[*]}"
291 --usepkg-exclude="${PACKAGES[*]}"
292 )
293 fi
Gregory Meinkeb0f0adc2018-04-17 12:02:28 -0600294
Gregory Meinke0766df42018-08-23 11:36:12 -0600295 # Calculate only the ebuild changes from the emerge simulation ignoring
296 # the virtual packages and the forced rebuild of autotest-all package.
297 BASE_INSTALL_PKGS=( $( \
298 sudo -E "${EMERGE_CMD[@]}" "${SIM_EMERGE_FLAGS[@]}" "${PACKAGES[@]}" | \
299 sed -n -E '/^\[ebuild /{s:^[^]]+\] +::;s: .*::;p}' | \
300 grep -v -e '^virtual/' -e '^chromeos-base/autotest-all' | sort -u ) )
Gregory Meinkeb0f0adc2018-04-17 12:02:28 -0600301
Gregory Meinke0766df42018-08-23 11:36:12 -0600302 MOD_PKGS=()
303 if [[ "${#BASE_INSTALL_PKGS[@]}" -gt 0 ]]; then
304 info "New packages being installed: ${BASE_INSTALL_PKGS[*]}."
Gregory Meinkeb0f0adc2018-04-17 12:02:28 -0600305 # Convert specific versions into base package names
306 MOD_PKGS+=( $(\
Gregory Meinke0766df42018-08-23 11:36:12 -0600307 equery-${FLAGS_board} list -p -o --format='$category/$name' \
308 "${BASE_INSTALL_PKGS[@]}" | sort -u ) )
Mike Frysinger5a11e872018-09-05 16:29:02 -0400309 # Remove Chrome as rebuilding it is expensive and almost never makes sense.
310 # Ignore grep exit status in case chromeos-chrome is the only package.
Gregory Meinke0766df42018-08-23 11:36:12 -0600311 MOD_PKGS=( $(printf '%s\n' "${MOD_PKGS[@]}" | \
Mike Frysinger5a11e872018-09-05 16:29:02 -0400312 grep -v 'chromeos-base/chromeos-chrome' || :) )
Gregory Meinkeb0f0adc2018-04-17 12:02:28 -0600313 fi
Gregory Meinkeb0f0adc2018-04-17 12:02:28 -0600314
Gregory Meinke0766df42018-08-23 11:36:12 -0600315 FORCE_LOCAL_BUILD_PKGS+=( "${MOD_PKGS[@]}" )
316
317 if [[ "${#MOD_PKGS[@]}" -gt 0 ]]; then
318 info "calculating reverse dependencies on packages: ${MOD_PKGS[*]}"
319 REV_DEPS=( $(\
320 equery-${FLAGS_board} -q depends --indirect "${MOD_PKGS[@]}" |\
321 awk '{print $1}' | grep -v ^virtual/ | sort -u) )
322 if [[ "${#REV_DEPS[@]}" -gt 0 ]]; then
323 # Convert specific versions into base package names
324 RMOD_PKGS=( $(\
Gregory Meinkeb0f0adc2018-04-17 12:02:28 -0600325 equery-${FLAGS_board} -q list -p -o --format='$category/$name' \
Gregory Meinke0766df42018-08-23 11:36:12 -0600326 "${REV_DEPS[@]}" | sort -u ) )
Mike Frysinger5a11e872018-09-05 16:29:02 -0400327 # Remove Chrome as rebuilding it is expensive and almost never makes
328 # sense. Ignore grep exit status in case chromeos-chrome is the only
329 # package.
Gregory Meinke0766df42018-08-23 11:36:12 -0600330 RMOD_PKGS=( $(printf '%s\n' "${RMOD_PKGS[@]}" | \
Mike Frysinger5a11e872018-09-05 16:29:02 -0400331 grep -v 'chromeos-base/chromeos-chrome' || :) )
Gregory Meinke0766df42018-08-23 11:36:12 -0600332 info "final reverse dependencies that will be rebuilt: ${RMOD_PKGS[*]}"
333 FORCE_LOCAL_BUILD_PKGS+=( "${RMOD_PKGS[@]}" )
334 fi
Gregory Meinkeb0f0adc2018-04-17 12:02:28 -0600335 fi
Gregory Meinke0766df42018-08-23 11:36:12 -0600336fi # end FLAGS_withrevdeps
Gregory Meinkeb0f0adc2018-04-17 12:02:28 -0600337
Daniel Wangaf4d0012015-07-17 11:52:05 -0700338if [[ ${#FORCE_LOCAL_BUILD_PKGS[@]} -gt 0 ]]; then
Mike Frysinger4114c792012-09-13 22:33:12 -0400339 EMERGE_FLAGS+=(
Daniel Wangaf4d0012015-07-17 11:52:05 -0700340 --reinstall-atoms="${FORCE_LOCAL_BUILD_PKGS[*]}"
341 --usepkg-exclude="${FORCE_LOCAL_BUILD_PKGS[*]}"
Mike Frysinger4114c792012-09-13 22:33:12 -0400342 )
David James710a7d12011-12-21 15:57:02 -0800343fi
Matt Tennant298f61a2012-06-25 21:54:33 -0700344
Mike Frysinger76452ba2012-09-13 22:45:34 -0400345info "Merging board packages now"
Matt Tennant298f61a2012-06-25 21:54:33 -0700346(
Hidehiko Abe7a41d342017-03-29 21:19:16 +0900347 # Support goma on bots. This has to run in subshell, otherwise EXIT trap
348 # handler is overwritten.
349 if [[ "${FLAGS_run_goma}" -eq "${FLAGS_TRUE}" ]]; then
350 info "Starting goma compiler_proxy."
351 goma_ctl="${GOMA_DIR:-${HOME}/goma}/goma_ctl.py"
352 "${goma_ctl}" restart
Hidehiko Abe2aa41ae2017-05-16 18:31:00 +0900353 trap "'${goma_ctl}' stop" EXIT
Hidehiko Abe7a41d342017-03-29 21:19:16 +0900354 fi
355
Chris McDonaldf75a0352019-01-24 16:23:18 -0700356 GOMA_WRAPPER=()
357 if [[ "${FLAGS_build_all_with_goma}" -eq "${FLAGS_TRUE}" ]]; then
358 warn "The build_all_with_goma feature is still under development."
359 warn "This feature is experimental and may potentially break your build."
360 GOMA_WRAPPER=("${GOMA_DIR:-${HOME}/goma}/goma-wrapper" -j600 -l100)
361 fi
362
Chris McDonaldf75a0352019-01-24 16:23:18 -0700363 sudo -E "${GOMA_WRAPPER[@]}" "${EMERGE_CMD[@]}" \
Mike Frysinger3131d412019-03-02 14:09:37 -0500364 "${EMERGE_FLAGS[@]}" "${PACKAGES[@]}"
Matt Tennant298f61a2012-06-25 21:54:33 -0700365)
366
Brian Harringcb782242011-12-13 19:48:44 -0800367echo "Builds complete"
Bertrand SIMONNETc7a46e22014-12-11 15:58:11 -0800368
369if [[ ${FLAGS_withdebugsymbols} -eq ${FLAGS_TRUE} ]]; then
370 info "fetching the debug symbols"
Mike Frysinger66accd22017-09-13 03:50:30 -0400371 sudo -E "${CHROMITE_BIN}/cros_install_debug_syms" \
Bertrand SIMONNETc7a46e22014-12-11 15:58:11 -0800372 "--board=${FLAGS_board}" "--all"
373fi
374
Matt Tennant298f61a2012-06-25 21:54:33 -0700375command_completed
Brian Harringcb782242011-12-13 19:48:44 -0800376echo "Done"