Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 1 | #!/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 James | 0b1baf6 | 2012-03-15 09:26:23 -0700 | [diff] [blame] | 7 | . "$(dirname "$0")/common.sh" || exit 1 |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 8 | |
| 9 | # Script must run inside the chroot |
| 10 | restart_in_chroot_if_needed "$@" |
| 11 | |
Zdenek Behan | 0578078 | 2012-05-18 03:07:28 +0200 | [diff] [blame] | 12 | assert_not_root_user |
| 13 | |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 14 | # Developer-visible flags. |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 15 | DEFINE_string board "${DEFAULT_BOARD}" \ |
| 16 | "The board to build packages for." |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 17 | DEFINE_boolean usepkg "${FLAGS_TRUE}" \ |
| 18 | "Use binary packages to bootstrap when possible." |
Thiago Goncales | 5ad4ca0 | 2013-07-12 10:55:11 -0700 | [diff] [blame] | 19 | DEFINE_boolean usepkgonly "${FLAGS_FALSE}" \ |
| 20 | "Only use binary packages to bootstrap; abort if any are missing." |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 21 | DEFINE_boolean noworkon "${FLAGS_FALSE}" \ |
| 22 | "Don't force-build workon packages." |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 23 | DEFINE_boolean showoutput "${FLAGS_FALSE}" \ |
| 24 | "Show all output from parallel_emerge." |
| 25 | DEFINE_boolean withautotest "${FLAGS_TRUE}" \ |
| 26 | "Build autotest client code." |
Brian Harring | 17c1fe8 | 2012-12-05 21:12:31 -0800 | [diff] [blame] | 27 | DEFINE_boolean fetchonly "${FLAGS_FALSE}" \ |
| 28 | "Don't build anything, instead only fetch what is needed." |
Thiago Goncales | 5ad4ca0 | 2013-07-12 10:55:11 -0700 | [diff] [blame] | 29 | DEFINE_boolean unpackonly "${FLAGS_FALSE}" \ |
| 30 | "Don't build anything; instead only fetch and unpack what is needed." |
Bertrand SIMONNET | 2f6aaf2 | 2015-02-09 15:49:05 -0800 | [diff] [blame] | 31 | DEFINE_boolean withdebugsymbols "${FLAGS_FALSE}" \ |
Bertrand SIMONNET | c7a46e2 | 2014-12-11 15:58:11 -0800 | [diff] [blame] | 32 | "Install the debug symbols for all packages" |
Thiago Goncales | 5ad4ca0 | 2013-07-12 10:55:11 -0700 | [diff] [blame] | 33 | |
| 34 | # The --board_root flag specifies the environment variables ROOT and PKGDIR. |
| 35 | # This allows fetching and emerging of all packages to specified board_root. |
| 36 | # Note that --board_root will setup the board normally in /build/$BOARD, if it's |
| 37 | # not setup yet. It also expects the toolchain to already be installed in the |
| 38 | # board_root. --usepkgonly and --norebuild are required, because building is not |
| 39 | # supported when board_root is set. |
| 40 | # enforce this)." |
| 41 | DEFINE_string board_root "" \ |
| 42 | "Emerge packages to board_root." |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 43 | |
Mike Frysinger | 76452ba | 2012-09-13 22:45:34 -0400 | [diff] [blame] | 44 | FLAGS_HELP="usage: $(basename $0) [flags] [packages] |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 45 | |
| 46 | build_packages updates the set of binary packages needed by Chrome OS. It will |
| 47 | cross compile all packages that have been updated into the given target's root |
| 48 | and build binary packages as a side-effect. The output packages will be picked |
| 49 | up by the build_image script to put together a bootable Chrome OS image. |
| 50 | |
Mike Frysinger | 76452ba | 2012-09-13 22:45:34 -0400 | [diff] [blame] | 51 | If [packages] are specified, only build those specific packages (and any |
| 52 | dependencies they might need). |
| 53 | |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 54 | For the fastest builds, use --nowithautotest --noworkon. |
| 55 | " |
| 56 | show_help_if_requested "$@" |
| 57 | |
| 58 | # The following options are advanced options, only available to those willing |
| 59 | # to read the source code. They are not shown in help output, since they are |
| 60 | # not needed for the typical developer workflow. |
Ryan Cui | eb4595f | 2012-12-17 14:28:42 -0800 | [diff] [blame] | 61 | DEFINE_string accept_licenses "" \ |
| 62 | "Licenses to append to the accept list." |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 63 | DEFINE_integer jobs -1 \ |
| 64 | "How many packages to build in parallel at maximum." |
| 65 | DEFINE_boolean norebuild "${FLAGS_FALSE}" \ |
| 66 | "Don't automatically rebuild dependencies." |
Mike Frysinger | 839e82a | 2012-03-01 14:22:10 -0500 | [diff] [blame] | 67 | DEFINE_boolean skip_chroot_upgrade "${FLAGS_FALSE}" \ |
| 68 | "Don't run the chroot upgrade automatically; use with care." |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 69 | DEFINE_boolean skip_toolchain_update "${FLAGS_FALSE}" \ |
| 70 | "Don't update toolchain automatically." |
| 71 | DEFINE_boolean withdev "${FLAGS_TRUE}" \ |
| 72 | "Build useful developer friendly utilities." |
| 73 | DEFINE_boolean withdebug "${FLAGS_TRUE}" \ |
| 74 | "Build debug versions of Chromium-OS-specific packages." |
| 75 | DEFINE_boolean withfactory "${FLAGS_TRUE}" \ |
| 76 | "Build factory installer." |
| 77 | DEFINE_boolean withtest "${FLAGS_TRUE}" \ |
| 78 | "Build packages required for testing." |
David James | 0ae653d | 2013-07-03 15:59:29 -0700 | [diff] [blame] | 79 | DEFINE_boolean chrome_binhost_only $FLAGS_FALSE \ |
| 80 | "Only fetch packages from the Chrome binhost." |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 81 | |
David James | 17c622a | 2012-03-07 09:34:08 -0800 | [diff] [blame] | 82 | # The --reuse_pkgs_from_local_boards flag tells Portage to share binary |
| 83 | # packages between boards that are built locally, so that the total time |
| 84 | # required to build several boards is reduced. This flag is only useful |
| 85 | # when you are not able to use remote binary packages, since remote binary |
| 86 | # packages are usually more up to date than anything you have locally. |
| 87 | DEFINE_boolean reuse_pkgs_from_local_boards $FLAGS_FALSE \ |
| 88 | "Bootstrap from local packages instead of remote packages." |
| 89 | |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 90 | # Parse command line |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 91 | FLAGS "$@" || exit 1 |
| 92 | eval set -- "${FLAGS_ARGV}" |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 93 | |
| 94 | # Die on any errors. |
Brian Harring | 7f175a5 | 2012-03-02 05:37:00 -0800 | [diff] [blame] | 95 | switch_to_strict_mode |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 96 | |
| 97 | # Right now build_packages has to be run from scripts/ |
| 98 | . ${SRC_ROOT}/third_party/chromiumos-overlay/chromeos/config/chromeos_version.sh |
| 99 | |
| 100 | if [[ -z "${FLAGS_board}" ]]; then |
| 101 | echo "Error: --board is required." |
| 102 | exit 1 |
| 103 | fi |
| 104 | |
David James | 4c29c24 | 2012-06-06 20:45:18 -0700 | [diff] [blame] | 105 | CHROMITE_BIN="${GCLIENT_ROOT}/chromite/bin" |
Mike Frysinger | 4114c79 | 2012-09-13 22:33:12 -0400 | [diff] [blame] | 106 | |
| 107 | # Before we can run any tools, we need to update chroot or setup_board. |
| 108 | UPDATE_ARGS=() |
Ryan Cui | eb4595f | 2012-12-17 14:28:42 -0800 | [diff] [blame] | 109 | if [[ -n ${FLAGS_accept_licenses} ]]; then |
| 110 | UPDATE_ARGS+=( --accept_licenses "${FLAGS_accept_licenses}" ) |
| 111 | fi |
Mike Frysinger | 4114c79 | 2012-09-13 22:33:12 -0400 | [diff] [blame] | 112 | if [ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]; then |
| 113 | UPDATE_ARGS+=( --usepkg ) |
| 114 | else |
| 115 | UPDATE_ARGS+=( --nousepkg ) |
| 116 | fi |
| 117 | if [[ "${FLAGS_jobs}" -ne -1 ]]; then |
| 118 | UPDATE_ARGS+=( --jobs=${FLAGS_jobs} ) |
| 119 | fi |
David James | 0ae653d | 2013-07-03 15:59:29 -0700 | [diff] [blame] | 120 | if [ "${FLAGS_chrome_binhost_only}" -eq "${FLAGS_TRUE}" ]; then |
| 121 | UPDATE_ARGS+=( --chrome_binhost_only ) |
| 122 | fi |
Mike Frysinger | 4114c79 | 2012-09-13 22:33:12 -0400 | [diff] [blame] | 123 | if [ "${FLAGS_reuse_pkgs_from_local_boards}" -eq "${FLAGS_TRUE}" ]; then |
| 124 | UPDATE_ARGS+=( --reuse_pkgs_from_local_boards ) |
| 125 | fi |
| 126 | if [ "${FLAGS_skip_toolchain_update}" -eq "${FLAGS_TRUE}" ]; then |
| 127 | UPDATE_ARGS+=( --skip_toolchain_update ) |
| 128 | fi |
| 129 | if [ "${FLAGS_skip_chroot_upgrade}" -eq "${FLAGS_TRUE}" ]; then |
| 130 | UPDATE_ARGS+=( --skip_chroot_upgrade ) |
| 131 | fi |
Thiago Goncales | 5ad4ca0 | 2013-07-12 10:55:11 -0700 | [diff] [blame] | 132 | if [[ ${FLAGS_unpackonly} -eq ${FLAGS_TRUE} ]]; then |
| 133 | UPDATE_ARGS+=( --skip_board_pkg_init ) |
| 134 | fi |
Bertrand SIMONNET | 10ede91 | 2014-10-09 16:21:13 -0700 | [diff] [blame] | 135 | if [[ -n ${FLAGS_board_root} ]]; then |
| 136 | UPDATE_ARGS+=( --board_root "${FLAGS_board_root}" ) |
| 137 | fi |
Mike Frysinger | 4114c79 | 2012-09-13 22:33:12 -0400 | [diff] [blame] | 138 | |
| 139 | "${SCRIPTS_DIR}"/setup_board --quiet --board=${FLAGS_board} "${UPDATE_ARGS[@]}" |
| 140 | |
Chris Masone | bbccc24 | 2014-02-08 16:23:53 -0800 | [diff] [blame] | 141 | sudo_clear_shadow_locks "/build/${FLAGS_board}" |
| 142 | |
Mike Frysinger | 4114c79 | 2012-09-13 22:33:12 -0400 | [diff] [blame] | 143 | # Setup all the emerge command/flags. |
David James | 886f2c3 | 2014-02-26 20:38:04 -0800 | [diff] [blame] | 144 | EMERGE_FLAGS=( -uDNv --backtrack=30 --select --newrepo ) |
Mike Frysinger | 4114c79 | 2012-09-13 22:33:12 -0400 | [diff] [blame] | 145 | |
Bertrand SIMONNET | 4dda4f5 | 2015-03-19 13:40:58 -0700 | [diff] [blame] | 146 | EMERGE_CMD=( |
| 147 | "${CHROMITE_BIN}/parallel_emerge" |
| 148 | --board=${FLAGS_board} |
| 149 | ) |
| 150 | |
Brian Harring | 3d01db2 | 2012-12-15 21:09:03 -0800 | [diff] [blame] | 151 | if [[ "${FLAGS_fetchonly}" -eq "${FLAGS_TRUE}" ]]; then |
Brian Harring | 17c1fe8 | 2012-12-05 21:12:31 -0800 | [diff] [blame] | 152 | EMERGE_CMD+=( --fetchonly ) |
| 153 | fi |
Thiago Goncales | 5ad4ca0 | 2013-07-12 10:55:11 -0700 | [diff] [blame] | 154 | if [[ ${FLAGS_unpackonly} -eq ${FLAGS_TRUE} ]]; then |
| 155 | EMERGE_CMD+=( --unpackonly ) |
| 156 | fi |
Brian Harring | 17c1fe8 | 2012-12-05 21:12:31 -0800 | [diff] [blame] | 157 | |
Mike Frysinger | 4114c79 | 2012-09-13 22:33:12 -0400 | [diff] [blame] | 158 | EMERGE_CMD+=( ${EXTRA_BOARD_FLAGS} ) |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 159 | |
David James | 17c622a | 2012-03-07 09:34:08 -0800 | [diff] [blame] | 160 | if [[ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" || |
Thiago Goncales | 5ad4ca0 | 2013-07-12 10:55:11 -0700 | [diff] [blame] | 161 | "${FLAGS_reuse_pkgs_from_local_boards}" -eq "${FLAGS_TRUE}" || |
| 162 | "${FLAGS_usepkgonly}" -eq "${FLAGS_TRUE}" ]]; then |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 163 | # Use binary packages. Include all build-time dependencies, |
| 164 | # so as to avoid unnecessary differences between source |
| 165 | # and binary builds. |
Thiago Goncales | 5ad4ca0 | 2013-07-12 10:55:11 -0700 | [diff] [blame] | 166 | EMERGE_FLAGS+=( --getbinpkg --with-bdeps y ) |
| 167 | if [[ ${FLAGS_usepkgonly} -eq ${FLAGS_TRUE} ]]; then |
| 168 | EMERGE_FLAGS+=( --usepkgonly ) |
| 169 | else |
| 170 | EMERGE_FLAGS+=( --usepkg ) |
| 171 | fi |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 172 | fi |
| 173 | |
| 174 | if [[ "${FLAGS_jobs}" -ne -1 ]]; then |
Mike Frysinger | 4114c79 | 2012-09-13 22:33:12 -0400 | [diff] [blame] | 175 | EMERGE_FLAGS+=( --jobs=${FLAGS_jobs} ) |
| 176 | fi |
| 177 | |
| 178 | if [[ "${FLAGS_norebuild}" -eq "${FLAGS_FALSE}" ]]; then |
| 179 | EMERGE_FLAGS+=( --rebuild-if-unbuilt ) |
| 180 | fi |
Bertrand SIMONNET | 4dda4f5 | 2015-03-19 13:40:58 -0700 | [diff] [blame] | 181 | if [[ "${FLAGS_showoutput}" -eq "${FLAGS_TRUE}" ]]; then |
Mike Frysinger | 4114c79 | 2012-09-13 22:33:12 -0400 | [diff] [blame] | 182 | EMERGE_FLAGS+=( --show-output ) |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 183 | fi |
| 184 | |
| 185 | if [[ "${FLAGS_withdebug}" -eq "${FLAGS_FALSE}" ]]; then |
| 186 | export USE="${USE} -cros-debug" |
| 187 | fi |
| 188 | |
Mike Frysinger | 4114c79 | 2012-09-13 22:33:12 -0400 | [diff] [blame] | 189 | # Figure out which packages we should be building. |
Mike Frysinger | 76452ba | 2012-09-13 22:45:34 -0400 | [diff] [blame] | 190 | PACKAGES=( "$@" ) |
Daniel Wang | af4d001 | 2015-07-17 11:52:05 -0700 | [diff] [blame] | 191 | FORCE_LOCAL_BUILD_PKGS=() |
Mike Frysinger | 76452ba | 2012-09-13 22:45:34 -0400 | [diff] [blame] | 192 | if [[ $# -eq 0 ]]; then |
Mike Frysinger | 2262195 | 2014-04-01 17:41:20 -0400 | [diff] [blame] | 193 | PACKAGES=( virtual/target-os ) |
Mike Frysinger | 76452ba | 2012-09-13 22:45:34 -0400 | [diff] [blame] | 194 | if [[ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]]; then |
Mike Frysinger | de39928 | 2014-04-15 18:26:04 -0400 | [diff] [blame] | 195 | PACKAGES+=( virtual/target-os-dev ) |
Mike Frysinger | 76452ba | 2012-09-13 22:45:34 -0400 | [diff] [blame] | 196 | fi |
| 197 | if [[ "${FLAGS_withfactory}" -eq "${FLAGS_TRUE}" ]]; then |
Hung-Te Lin | 9b43ced | 2016-01-14 20:29:47 +0800 | [diff] [blame^] | 198 | PACKAGES+=( virtual/target-os-factory ) |
| 199 | PACKAGES+=( virtual/target-os-factory-shim ) |
Mike Frysinger | 76452ba | 2012-09-13 22:45:34 -0400 | [diff] [blame] | 200 | fi |
| 201 | if [[ "${FLAGS_withtest}" -eq "${FLAGS_TRUE}" ]]; then |
Mike Frysinger | 5266943 | 2014-05-05 14:34:09 -0400 | [diff] [blame] | 202 | PACKAGES+=( virtual/target-os-test ) |
Daniel Wang | af4d001 | 2015-07-17 11:52:05 -0700 | [diff] [blame] | 203 | # chromeos-ssh-testkeys may generate ssh keys if the right USE flag is set. |
| 204 | # We force rebuilding this package from source every time, so that |
| 205 | # consecutive builds don't share ssh keys. |
| 206 | FORCE_LOCAL_BUILD_PKGS+=( chromeos-base/chromeos-ssh-testkeys ) |
Mike Frysinger | 76452ba | 2012-09-13 22:45:34 -0400 | [diff] [blame] | 207 | fi |
| 208 | if [[ "${FLAGS_withautotest}" -eq "${FLAGS_TRUE}" ]]; then |
| 209 | PACKAGES+=( chromeos-base/autotest-all ) |
| 210 | fi |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 211 | fi |
| 212 | |
| 213 | # Verify that all packages can be emerged from scratch, without any |
| 214 | # backtracking. Only print the output if this step fails. |
Mike Frysinger | 76452ba | 2012-09-13 22:45:34 -0400 | [diff] [blame] | 215 | info "Checking package dependencies are correct: ${PACKAGES[*]}" |
David James | ab9ca21 | 2012-11-06 11:06:07 -0800 | [diff] [blame] | 216 | if ! OUTPUT=$(emerge-${FLAGS_board} -pe --backtrack=0 \ |
| 217 | "${PACKAGES[@]}" 2>&1); then |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 218 | printf "%s\n" "${OUTPUT}" |
Brian Harring | 7f175a5 | 2012-03-02 05:37:00 -0800 | [diff] [blame] | 219 | die_notrace "emerge detected broken ebuilds. See error message above." |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 220 | fi |
| 221 | |
Mike Frysinger | 4114c79 | 2012-09-13 22:33:12 -0400 | [diff] [blame] | 222 | # Build cros_workon packages when they are changed. |
| 223 | CROS_WORKON_PKGS=() |
| 224 | if [ "${FLAGS_noworkon}" -eq "${FLAGS_FALSE}" ]; then |
| 225 | LIST_MODIFIED_PACKAGES="${CHROMITE_BIN}/cros_list_modified_packages" |
| 226 | CROS_WORKON_PKGS+=( $("${LIST_MODIFIED_PACKAGES}" --board=${FLAGS_board}) ) |
Mike Frysinger | 4114c79 | 2012-09-13 22:33:12 -0400 | [diff] [blame] | 227 | |
David James | 4941c6b | 2014-02-03 16:24:59 -0800 | [diff] [blame] | 228 | # TODO(anush): Make chrome a fake cros-workon package. |
| 229 | if [[ -n "${CHROME_ORIGIN}" ]]; then |
| 230 | CROS_WORKON_PKGS+=( chromeos-base/chromeos-chrome ) |
| 231 | fi |
Mike Frysinger | 4114c79 | 2012-09-13 22:33:12 -0400 | [diff] [blame] | 232 | fi |
| 233 | |
Daniel Wang | af4d001 | 2015-07-17 11:52:05 -0700 | [diff] [blame] | 234 | # cros_workon packages always have to be rebuilt. |
Daniel Wang | 491f42a | 2015-08-20 12:29:59 -0700 | [diff] [blame] | 235 | FORCE_LOCAL_BUILD_PKGS+=( "${CROS_WORKON_PKGS[@]}" ) |
Daniel Wang | af4d001 | 2015-07-17 11:52:05 -0700 | [diff] [blame] | 236 | |
| 237 | if [[ ${#FORCE_LOCAL_BUILD_PKGS[@]} -gt 0 ]]; then |
Mike Frysinger | 4114c79 | 2012-09-13 22:33:12 -0400 | [diff] [blame] | 238 | EMERGE_FLAGS+=( |
Daniel Wang | af4d001 | 2015-07-17 11:52:05 -0700 | [diff] [blame] | 239 | --reinstall-atoms="${FORCE_LOCAL_BUILD_PKGS[*]}" |
| 240 | --usepkg-exclude="${FORCE_LOCAL_BUILD_PKGS[*]}" |
Mike Frysinger | 4114c79 | 2012-09-13 22:33:12 -0400 | [diff] [blame] | 241 | ) |
David James | 710a7d1 | 2011-12-21 15:57:02 -0800 | [diff] [blame] | 242 | fi |
Matt Tennant | 298f61a | 2012-06-25 21:54:33 -0700 | [diff] [blame] | 243 | |
| 244 | # Prepare tmp file to capture emerge output from tee. |
| 245 | tmpfile=$(mktemp -t tmp.build_packages-emerge.XXXXXX) |
| 246 | trap "rm -f '${tmpfile}'" EXIT |
| 247 | |
Thiago Goncales | 5ad4ca0 | 2013-07-12 10:55:11 -0700 | [diff] [blame] | 248 | if [[ -n "${FLAGS_board_root}" ]]; then |
| 249 | export ROOT="${FLAGS_board_root}" |
Bertrand SIMONNET | 10ede91 | 2014-10-09 16:21:13 -0700 | [diff] [blame] | 250 | export PORTAGE_CONFIGROOT="${ROOT}" |
| 251 | export SYSROOT="${ROOT}" |
Thiago Goncales | 5ad4ca0 | 2013-07-12 10:55:11 -0700 | [diff] [blame] | 252 | export PKGDIR="${ROOT}"/packages |
| 253 | fi |
| 254 | |
Mike Frysinger | 76452ba | 2012-09-13 22:45:34 -0400 | [diff] [blame] | 255 | info "Merging board packages now" |
Matt Tennant | 298f61a | 2012-06-25 21:54:33 -0700 | [diff] [blame] | 256 | ( |
| 257 | set -o pipefail |
Mike Frysinger | 4114c79 | 2012-09-13 22:33:12 -0400 | [diff] [blame] | 258 | sudo -E "${EMERGE_CMD[@]}" "${EMERGE_FLAGS[@]}" "${PACKAGES[@]}" | \ |
Matt Tennant | 298f61a | 2012-06-25 21:54:33 -0700 | [diff] [blame] | 259 | tee "${tmpfile}" |
| 260 | ) |
| 261 | |
| 262 | # Extract total package count from emerge output. |
| 263 | package_count=$(awk '$0 ~ /^Total: [0-9]+ packages/ { print $2 }' "${tmpfile}") |
| 264 | rm "${tmpfile}" |
| 265 | trap - EXIT |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 266 | |
| 267 | echo "Builds complete" |
Bertrand SIMONNET | c7a46e2 | 2014-12-11 15:58:11 -0800 | [diff] [blame] | 268 | |
| 269 | if [[ ${FLAGS_withdebugsymbols} -eq ${FLAGS_TRUE} ]]; then |
| 270 | info "fetching the debug symbols" |
| 271 | sudo -E "${GCLIENT_ROOT}/chromite/bin/cros_install_debug_syms" \ |
| 272 | "--board=${FLAGS_board}" "--all" |
| 273 | fi |
| 274 | |
Matt Tennant | 298f61a | 2012-06-25 21:54:33 -0700 | [diff] [blame] | 275 | EXTRA_COMMAND_STATS[package_count]=${package_count} |
| 276 | command_completed |
Brian Harring | cb78224 | 2011-12-13 19:48:44 -0800 | [diff] [blame] | 277 | echo "Done" |