From 2fbd5af6a808a8ab4f2ece5371c5255dc7cd7c2d Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Mon, 12 Mar 2012 19:38:50 +0100 Subject: [PATCH] Make use of cros_setup_toolchains, take 2 Resubmit of If62b4f3973f02fd8e1deed35864c824a02ab0c22 This will be safe to land after I2c4e21ec7e8c0c0cf58947e2b0a3a9edf7617a09 The breakage was a timing issue paired with people not always syncing the complete tree. No changes to the CL are needed. It is now used for: - make_chroot (cros_sdk --bootstrap) - update_chroot setup_board is stripped of redundant code which was deprecated by this. Also stripped is some usepkg logic in make_chroot, as that is now exclusively source-only. BUG=chromium-os:23032 TEST=trybot chromiumos-sdk Change-Id: Ib888cf2886218622d9cfeebb17b9cd4462d06c89 Reviewed-on: https://gerrit.chromium.org/gerrit/22578 Tested-by: Zdenek Behan Reviewed-by: Mike Frysinger Reviewed-by: asharif Commit-Ready: Zdenek Behan --- sdk_lib/make_chroot.sh | 33 ++++---- setup_board | 188 +++-------------------------------------- update_chroot | 22 +++-- 3 files changed, 41 insertions(+), 202 deletions(-) diff --git a/sdk_lib/make_chroot.sh b/sdk_lib/make_chroot.sh index d99eca9d26..c0512bcfe6 100755 --- a/sdk_lib/make_chroot.sh +++ b/sdk_lib/make_chroot.sh @@ -396,19 +396,15 @@ sudo sh -c "echo STAGE3=$STAGE3 > $CHROOT_STATE" info "Updating portage" early_enter_chroot emerge -uNv --quiet portage -info "Updating toolchain" -early_enter_chroot emerge -uNv --quiet $USEPKG '>=sys-devel/gcc-4.4' \ - sys-libs/glibc sys-devel/binutils sys-kernel/linux-headers - -# HACK: Select the latest toolchain. We're assuming that when this is -# ran, the chroot has no experimental versions of new toolchains, just -# one that is very old, and one that was just emerged. -GCC_ATOM="$(early_enter_chroot portageq best_version / sys-devel/gcc)" -early_enter_chroot emerge --unmerge "<${GCC_ATOM}" -CHOST="$(early_enter_chroot portageq envvar CHOST)" -LATEST="$(early_enter_chroot gcc-config -l | grep "${CHOST}" | tail -n1 | \ - cut -f3 -d' ')" -early_enter_chroot gcc-config "${LATEST}" +info "Updating host toolchain" +early_enter_chroot emerge -uNv --quiet crossdev +TOOLCHAIN_ARGS=( --deleteold ) +if [[ ${FLAGS_usepkg} -eq ${FLAGS_FALSE} ]]; then + TOOLCHAIN_ARGS+=( --nousepkg ) +fi +# Note: early_enter_chroot executes as root. +early_enter_chroot "${CHROOT_TRUNK}/chromite/bin/cros_setup_toolchains" \ + --hostonly "${TOOLCHAIN_ARGS[@]}" # dhcpcd is included in 'world' by the stage3 that we pull in for some reason. # We have no need to install it in our host environment, so pull it out here. @@ -427,8 +423,10 @@ if [ -n "${INITIALIZE_CHROOT}" ]; then fi # Update chroot. -UPDATE_ARGS=() -if [[ $FLAGS_usepkg -eq $FLAGS_TRUE ]]; then +# Skip toolchain update because it already happened above, and the chroot is +# not ready to emerge all cross toolchains. +UPDATE_ARGS=( --skip_toolchain_update ) +if [[ ${FLAGS_usepkg} -eq ${FLAGS_TRUE} ]]; then UPDATE_ARGS+=( --usepkg ) else UPDATE_ARGS+=( --nousepkg ) @@ -448,6 +446,11 @@ if [[ "$FLAGS_chroot" != "$DEFAULT_CHROOT_DIR" ]]; then CHROOT_EXAMPLE_OPT="--chroot=$FLAGS_chroot" fi +# As a final pass, build all desired cross-toolchains. +info "Updating toolchains" +enter_chroot sudo "${CHROOT_TRUNK}/chromite/bin/cros_setup_toolchains" \ + "${TOOLCHAIN_ARGS[@]}" + print_time_elapsed cat < /dev/null; then - LATEST=$(gcc-config -l | awk -v chost="${CHOST}" '$2 ~ chost { print $2 }' | \ - sort -V | tail -n 1 ) - sudo -E gcc-config "${LATEST}" +if [ "${FLAGS_skip_toolchain_update}" -eq "${FLAGS_FALSE}" ]; then + TOOLCHAIN_FLAGS="" + # This should really only be skipped while bootstrapping. + if [ "${FLAGS_usepkg}" -eq "${FLAGS_FALSE}" ]; then + TOOLCHAIN_FLAGS="--nousepkg" + fi + # Expand the path before sudo, as root doesn't have the same path magic. + sudo $(type -p cros_setup_toolchains) ${TOOLCHAIN_FLAGS} fi # Second pass, update everything else.