From 17d44e3659c2d248328c9828cea2f5ebef09d0c1 Mon Sep 17 00:00:00 2001 From: David James Date: Tue, 8 Feb 2011 14:48:51 -0800 Subject: [PATCH] Verify that SCRIPTS_DIR exists in build_image. This hack is necessary for old chroots to ensure that we source a good common.sh when the one inside the chroot is out of date. We'll be able to get rid of this after everybody has updated their chroot to have a working version of common.sh and/or we have deprecated running scripts from the source directory. Also fix logic for when common.sh is missing to exit properly. BUG=chromium-os:11598 TEST=Verify that build_image still works when the old common.sh is present in the chroot. Change-Id: I2e8c2fd5ad06446e669ad665ee2e70f4364958fe Review URL: http://codereview.chromium.org/6286084 --- build_image | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/build_image b/build_image index 2dc7c7887b..d56edac157 100755 --- a/build_image +++ b/build_image @@ -9,17 +9,17 @@ # the given target's root with binary packages turned on. This script will # build the Chrome OS image using only pre-built binary packages. -# --- BEGIN COMMON.SH BOILERPLATE --- # 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. find_common_sh() { - local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) + local common_paths=(/usr/lib/crosutils $(dirname "$0")) local path SCRIPT_ROOT= for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then + local common="${path}/common.sh" + if ([ -r "${common}" ] && . "${common}" && [ -d "${SCRIPTS_DIR}" ]); then SCRIPT_ROOT=${path} break fi @@ -27,8 +27,7 @@ find_common_sh() { } find_common_sh -. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) -# --- END COMMON.SH BOILERPLATE --- +. "${SCRIPT_ROOT}/common.sh" || ! echo "Unable to load common.sh" || exit 1 # Load functions and constants for chromeos-install [ -f /usr/lib/installer/chromeos-common.sh ] && \