From 4748e87341e78fa6bc062f0a29f1a03e63500667 Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Tue, 11 Oct 2011 03:23:11 +0200 Subject: [PATCH] update_chroot: update toolchain and portage first, also select gcc BUG=chromium-os:21474 TEST=run the script, see my chroot being updated, cases below: 1) run normally, see the latest gcc being selected 2) run while having an older gcc manually selected, see no updates 3) set an invalid native profile, see it being fixed Change-Id: Ic84187b8acf39fba11f2e39f36457e6f696ad7e4 Reviewed-on: http://gerrit.chromium.org/gerrit/9832 Tested-by: Zdenek Behan Reviewed-by: David James Commit-Ready: Zdenek Behan --- update_chroot | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/update_chroot b/update_chroot index 6d8883e025..07c561f385 100755 --- a/update_chroot +++ b/update_chroot @@ -37,7 +37,7 @@ ${SCRIPTS_DIR}/run_chroot_version_hooks info "Updating chroot" -EMERGE_FLAGS="-uDNv --with-bdeps=y" +EMERGE_FLAGS="-uNv --with-bdeps=y" if [ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]; then EMERGE_FLAGS="${EMERGE_FLAGS} --getbinpkg" @@ -55,6 +55,24 @@ if [ "${FLAGS_fast}" -eq "${FLAGS_TRUE}" ]; then EMERGE_CMD="${GCLIENT_ROOT}/chromite/bin/parallel_emerge" fi +# In first pass, update portage and toolchains. Lagged updates of both +# can cause serious issues later. +CHOST="$(portageq envvar CHOST)" +LATEST="$(gcc-config -l | grep "${CHOST}" | awk '{ print $2 }' | \ + sort -V | tail -n 1 )" +CURRENT="$(gcc-config -c)" || true # This fails if current profile is invalid. +eretry sudo -E ${EMERGE_CMD} ${EMERGE_FLAGS} \ + sys-devel/gcc sys-devel/binutils sys-libs/glibc sys-apps/portage +# If the latest toolchain wasn't already selected before we updated, do nothing, +# otherwise autoselect the latest. Also fix if the current profile is invalid. +if [ "${LATEST}" = "${CURRENT}" ] || ! gcc-config -c &> /dev/null; then + LATEST="$(gcc-config -l | grep "${CHOST}" | awk '{ print $2 }' | \ + sort -V | tail -n 1 )" + sudo gcc-config "${LATEST}" +fi + +# Second pass, update everything else. +EMERGE_FLAGS+=" --deep" eretry sudo -E ${EMERGE_CMD} ${EMERGE_FLAGS} \ chromeos-base/hard-host-depends world