Zdenek Behan | d7bfd86 | 2011-05-11 23:56:46 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | # Performs an update of the chroot. |
| 8 | |
| 9 | # Load common CrOS utilities. Inside the chroot this file is installed in |
| 10 | # /usr/lib/crosutils. Outside the chroot we find it relative to the script's |
| 11 | # location. |
Brian Harring | d5d5dbf | 2011-07-11 16:36:21 -0700 | [diff] [blame] | 12 | . "$(dirname $0)/common.sh" || { echo "Unable to load common.sh"; exit 1; } |
Zdenek Behan | d7bfd86 | 2011-05-11 23:56:46 +0200 | [diff] [blame] | 13 | |
| 14 | # Script must run inside the chroot |
| 15 | assert_inside_chroot "$@" |
| 16 | |
Zdenek Behan | 308e9fd | 2011-05-12 22:25:47 +0200 | [diff] [blame] | 17 | # Do not run as root |
| 18 | assert_not_root_user |
| 19 | |
Zdenek Behan | d7bfd86 | 2011-05-11 23:56:46 +0200 | [diff] [blame] | 20 | # Flags |
| 21 | DEFINE_boolean usepkg $FLAGS_TRUE \ |
| 22 | "Use binary packages to bootstrap." |
| 23 | DEFINE_boolean fast ${DEFAULT_FAST} "Call many emerges in parallel" |
| 24 | DEFINE_integer retries -1 \ |
| 25 | "On build failure, the number of times to retry." |
| 26 | |
| 27 | # Parse command line flags |
| 28 | FLAGS "$@" || exit 1 |
| 29 | eval set -- "${FLAGS_ARGV}" |
| 30 | |
| 31 | # Only now can we die on error. shflags functions leak non-zero error codes, |
| 32 | # so will die prematurely if 'set -e' is specified before now. |
| 33 | set -e |
| 34 | |
Zdenek Behan | 308e9fd | 2011-05-12 22:25:47 +0200 | [diff] [blame] | 35 | # Run version hooks as pre-update |
| 36 | ${SCRIPTS_DIR}/run_chroot_version_hooks |
| 37 | |
Zdenek Behan | d7bfd86 | 2011-05-11 23:56:46 +0200 | [diff] [blame] | 38 | info "Updating chroot" |
| 39 | |
Zdenek Behan | a29fb20 | 2011-05-12 05:21:14 +0200 | [diff] [blame] | 40 | EMERGE_FLAGS="-uDNv --with-bdeps=y" |
Zdenek Behan | 9562620 | 2011-05-12 05:54:19 +0200 | [diff] [blame] | 41 | if [ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]; then |
| 42 | EMERGE_FLAGS="${EMERGE_FLAGS} --getbinpkg" |
David James | 0dccff3 | 2011-06-09 13:03:47 -0700 | [diff] [blame] | 43 | |
| 44 | # Only update toolchain when binpkgs are available. Toolchain rollout |
| 45 | # process only takes place when the chromiumos sdk builder finishes |
| 46 | # a successful build. |
| 47 | EMERGE_FLAGS+=" --useoldpkg-atoms=sys-devel/binutils" |
| 48 | EMERGE_FLAGS+=" --useoldpkg-atoms=sys-devel/gcc" |
| 49 | EMERGE_FLAGS+=" --useoldpkg-atoms=sys-libs/glibc" |
Zdenek Behan | 9562620 | 2011-05-12 05:54:19 +0200 | [diff] [blame] | 50 | fi |
Zdenek Behan | a29fb20 | 2011-05-12 05:21:14 +0200 | [diff] [blame] | 51 | |
Zdenek Behan | d7bfd86 | 2011-05-11 23:56:46 +0200 | [diff] [blame] | 52 | # Perform an update of hard-host-depends and world in the chroot. |
| 53 | EMERGE_CMD="emerge" |
| 54 | if [ "${FLAGS_fast}" -eq "${FLAGS_TRUE}" ]; then |
| 55 | EMERGE_CMD="${GCLIENT_ROOT}/chromite/bin/parallel_emerge" |
| 56 | fi |
Zdenek Behan | 9562620 | 2011-05-12 05:54:19 +0200 | [diff] [blame] | 57 | |
Zdenek Behan | a29fb20 | 2011-05-12 05:21:14 +0200 | [diff] [blame] | 58 | eretry sudo -E ${EMERGE_CMD} ${EMERGE_FLAGS} \ |
| 59 | chromeos-base/hard-host-depends world |
Zdenek Behan | d7bfd86 | 2011-05-11 23:56:46 +0200 | [diff] [blame] | 60 | |
David James | d899f8d | 2011-08-17 05:22:52 -0700 | [diff] [blame] | 61 | # If the user still has old perl modules installed, update them. |
| 62 | PERL_VERSIONS=$(find /usr/lib*/perl5/vendor_perl/ -maxdepth 1 -mindepth 1 \ |
| 63 | -type d -printf '%P\n' | sort -u | wc -w) |
| 64 | if [ "$PERL_VERSIONS" -gt 1 ] ; then |
| 65 | sudo /usr/sbin/perl-cleaner --all |
| 66 | fi |