flatcar-scripts/chroot_version_hooks.d/7_host_gcc_upgrade
Mike Frysinger 6b1abb2a6f fix up function style
The "function" keyword is superfluous, not in POSIX, is inconsistent
between bash files, and generally makes me angry.  So convert every
instance to the form:
	foo() {

BUG=None
TEST=`cbuildbot x86-generic-paladin` works

Change-Id: I97f5ca30a3edfef7222b1e08ac23917dc613b556
Reviewed-on: https://gerrit.chromium.org/gerrit/22467
Reviewed-by: David James <davidjames@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2012-05-11 14:10:38 -07:00

55 lines
1.6 KiB
Bash

#!/bin/bash
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This is a generic script for upgrading the host toolchain. It should:
# - be able to run repeatedly, in case someone has ancient chroot with
# several missed gcc upgrades
# - be easily tweakable for future upgrades of the same kind, if needed
CHOST="$(portageq envvar CHOST)"
# This is the lowest we want to go in this particular case.
MINIMUM_GCC="4.4.6"
env_setup() {
GCC_VERSIONS="$(gcc-config -l | grep "${CHOST}" | \
cut -f3 -d' ')"
GCC_LATEST="$(gcc-config -l | grep "${CHOST}" | tail -n1 | \
cut -f3 -d' ')"
}
env_setup
if ! [ "$(portageq match / ">=sys-devel/gcc-${MINIMUM_GCC}")" ];
then
info "You don't have the latest gcc installed, trying to build it"
if ! sudo emerge -u --getbinpkg sys-devel/gcc; then
error "Emerging gcc failed. Please recreate your chroot."
exit 1
fi
if ! [ "$(portageq match / ">=sys-devel/gcc-${MINIMUM_GCC}")" ];
then
error "You still don't have the latest gcc. Something is very"
error "wrong with your tree. Recreating your chroot will likely fix it."
exit 1
fi
fi
env_setup
info "Updating the host toolchain. crosbug.com/19613"
info "Currently installed host gcc versions: $(echo -n ${GCC_VERSIONS})"
if ! sudo gcc-config "${GCC_LATEST}"; then
error "gcc-config failed. This is really bad. Recreate your chroot."
exit 1
fi
info "Cleaning up the old toolchain"
sudo emerge --unmerge "<sys-devel/gcc-${MINIMUM_GCC}"
exit 0