flatcar-scripts/update_chroot
Brian Harring d5d5dbffa1 Fix/standardize exiting if common.sh can't be found
The problem here is that most were doing their exiting w/in a subshell;
exit within a subshell kills the subshell, not the parent.  Not all scripts
were using set -e (which would pick up the failing subshell); as such
just rewriting them to remove the potential via eliminateing the subshelling.

Beyond that, removed a couple of custom (working, although non-standard)
approaches, and removed a duplicate common.sh sourc'ing w/in mk_memento_images.sh

TEST=force 'find_common_sh' to fail, note the scripts fails to exit
BUG=none

Change-Id: Ia1108a091a6399ad6aedd3cade4a107f4411686c
Reviewed-on: http://gerrit.chromium.org/gerrit/3905
Reviewed-by: Brian Harring <ferringb@chromium.org>
Tested-by: Brian Harring <ferringb@chromium.org>
2011-07-22 12:06:59 -07:00

61 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# Copyright (c) 2010 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.
# Performs an update of the chroot.
# Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
. "$(dirname $0)/common.sh" || { echo "Unable to load common.sh"; exit 1; }
# Script must run inside the chroot
assert_inside_chroot "$@"
# Do not run as root
assert_not_root_user
# Flags
DEFINE_boolean usepkg $FLAGS_TRUE \
"Use binary packages to bootstrap."
DEFINE_boolean fast ${DEFAULT_FAST} "Call many emerges in parallel"
DEFINE_integer retries -1 \
"On build failure, the number of times to retry."
# Parse command line flags
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
# Only now can we die on error. shflags functions leak non-zero error codes,
# so will die prematurely if 'set -e' is specified before now.
set -e
# Run version hooks as pre-update
${SCRIPTS_DIR}/run_chroot_version_hooks
info "Updating chroot"
EMERGE_FLAGS="-uDNv --with-bdeps=y"
if [ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]; then
EMERGE_FLAGS="${EMERGE_FLAGS} --getbinpkg"
# Only update toolchain when binpkgs are available. Toolchain rollout
# process only takes place when the chromiumos sdk builder finishes
# a successful build.
EMERGE_FLAGS+=" --useoldpkg-atoms=sys-devel/binutils"
EMERGE_FLAGS+=" --useoldpkg-atoms=sys-devel/gcc"
EMERGE_FLAGS+=" --useoldpkg-atoms=sys-libs/glibc"
fi
# Perform an update of hard-host-depends and world in the chroot.
EMERGE_CMD="emerge"
if [ "${FLAGS_fast}" -eq "${FLAGS_TRUE}" ]; then
EMERGE_CMD="${GCLIENT_ROOT}/chromite/bin/parallel_emerge"
fi
eretry sudo -E ${EMERGE_CMD} ${EMERGE_FLAGS} \
chromeos-base/hard-host-depends world