update_chroot: only update toolchains for specific requested board

When we're run via build_packages for a board, don't bother trying to
install every single cross-compiler.  Only pull in the ones this board
actually needs.

BUG=chromium:342199
TEST=`./setup_board --board=x86-generic` only installs two toolchains
CQ-DEPEND=CL:229821

Change-Id: Id20d78987c5fb5b3c9ad024d4f1142273347a6fc
Reviewed-on: https://chromium-review.googlesource.com/229504
Reviewed-by: Bertrand Simonnet <bsimonnet@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
diff --git a/update_chroot b/update_chroot
index f522ff0..86ba865 100755
--- a/update_chroot
+++ b/update_chroot
@@ -85,13 +85,20 @@
   EMERGE_CMD="${CHROMITE_BIN}/parallel_emerge"
 fi
 
-# In first pass, update portage and toolchains. Lagged updates of both
-# can cause serious issues later.
+# First make sure the cross-compilers have the right config settings.
+# We don't actually build them yet though as we want to wait for the
+# sdk to have all up-to-date packages.
 if [ "${FLAGS_skip_toolchain_update}" -eq "${FLAGS_FALSE}" ]; then
-  # First update crossdev.
-  sudo -E ${EMERGE_CMD} ${EMERGE_FLAGS} crossdev
+  info "Updating cross-compilers"
+  TOOLCHAIN_FLAGS=()
 
-  TOOLCHAIN_FLAGS=( "--include-boards=${FLAGS_toolchain_boards}" )
+  if [[ -n ${FLAGS_toolchain_boards} ]]; then
+    TOOLCHAIN_FLAGS+=(
+      "--targets=boards"
+      "--include-boards=${FLAGS_toolchain_boards}"
+    )
+  fi
+
   # This should really only be skipped while bootstrapping.
   if [ "${FLAGS_usepkg}" -eq "${FLAGS_FALSE}" ]; then
     TOOLCHAIN_FLAGS+=( --nousepkg )
@@ -100,6 +107,8 @@
   sudo -E $(type -p cros_setup_toolchains) "${TOOLCHAIN_FLAGS[@]}"
 fi
 
+info "Updating the SDK"
+
 # Build cros_workon packages when they are changed.
 for pkg in $("${CHROMITE_BIN}/cros_list_modified_packages" --host); do
   EMERGE_FLAGS+=" --reinstall-atoms=${pkg} --usepkg-exclude=${pkg}"