update_chroot: update gcc-config logic slightly

The latest gcc-config will accept the CHOST setting from the host env,
so export that variable since we already spent the time running portageq
to get it.  This allows gcc-config to never execute portageq, and since
we run it multiple times, it helps in every invocation.

Along those lines, make sure we run gcc-config with `sudo -E` to pass
through the setting.

Since awk can handle regexps, merge the grep|awk into a single awk call.

Finally, there was a slight logic typo where we would always re-run
gcc-config even when the profiles were the same.  This does not match
the comments, nor the spirit of this code, so fix the operator typo.

BUG=None
TEST=`./update_chroot` still works and doesn't re-select the toolchain

Change-Id: If73df81c014219f8f9ab5895e59d055696add777
Reviewed-on: https://gerrit.chromium.org/gerrit/19164
Reviewed-by: Zdenek Behan <zbehan@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Mike Frysinger 2012-03-27 12:31:43 -04:00 committed by Gerrit
parent 0957a18357
commit bf41543707

View File

@ -80,18 +80,18 @@ fi
# In first pass, update portage and toolchains. Lagged updates of both # In first pass, update portage and toolchains. Lagged updates of both
# can cause serious issues later. # can cause serious issues later.
CHOST="$(portageq envvar CHOST)" export CHOST="$(portageq envvar CHOST)"
LATEST="$(gcc-config -l | grep "${CHOST}" | awk '{ print $2 }' | \ LATEST=$(gcc-config -l | awk -v chost="${CHOST}" '$2 ~ chost { print $2 }' | \
sort -V | tail -n 1 )" sort -V | tail -n 1)
CURRENT="$(gcc-config -c)" || true # This fails if current profile is invalid. CURRENT="$(gcc-config -c)" || true # This fails if current profile is invalid.
sudo -E ${EMERGE_CMD} ${EMERGE_FLAGS} \ sudo -E ${EMERGE_CMD} ${EMERGE_FLAGS} \
sys-devel/gcc sys-devel/binutils sys-libs/glibc sys-apps/portage 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, # 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. # otherwise autoselect the latest. Also fix if the current profile is invalid.
if [ "${LATEST}" = "${CURRENT}" ] || ! gcc-config -c &> /dev/null; then if [ "${LATEST}" != "${CURRENT}" ] || ! gcc-config -c &> /dev/null; then
LATEST="$(gcc-config -l | grep "${CHOST}" | awk '{ print $2 }' | \ LATEST=$(gcc-config -l | awk -v chost="${CHOST}" '$2 ~ chost { print $2 }' | \
sort -V | tail -n 1 )" sort -V | tail -n 1 )
sudo gcc-config "${LATEST}" sudo -E gcc-config "${LATEST}"
fi fi
# Second pass, update everything else. # Second pass, update everything else.