From b9a951a13dcd13de2e592f9e7e1977873b751784 Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Tue, 1 Mar 2011 00:27:19 +0100 Subject: [PATCH] scripts: allow calling cros_generate_update_payload from outside the chroot This was broken by 798d75f3be614af161d5687d9335956730d28e45 and there isn't a proper way to fix it right now, as that commit generally moves everything inside the chroot. The few remaining scripts that need to be called from outside need to do a path magic here or there to survive. BUG=n0ne TEST=below 1) generate_au_zip.py, unzip it outside the chroot and try running the script 2) cros_au_test_harness Change-Id: I14bf0267ba2864d7946d657b23812b3dcd512f48 Review URL: http://codereview.chromium.org/6602018 --- cros_generate_update_payload | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cros_generate_update_payload b/cros_generate_update_payload index b55f438526..4f5d86c12a 100755 --- a/cros_generate_update_payload +++ b/cros_generate_update_payload @@ -12,7 +12,8 @@ # /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 thisdir="$(dirname "$(readlink -f "$0")")" + local common_paths=(/usr/lib/crosutils "${thisdir}") local path SCRIPT_ROOT= @@ -22,17 +23,22 @@ find_common_sh() { break fi done + + # HACK(zbehan): We have to fake GCLIENT_ROOT in case we're running inside + # au_zip enviroment. GCLIENT_ROOT detection became fatal... + [ "${SCRIPT_ROOT}" == "${thisdir}" ] && \ + export GCLIENT_ROOT="." } find_common_sh . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) # --- END COMMON.SH BOILERPLATE --- -# Need to be inside the chroot to load chromeos-common.sh -assert_inside_chroot - # Load functions and constants for chromeos-install -. "/usr/lib/installer/chromeos-common.sh" || \ +# NOTE: Needs to be called from outside the chroot. +. "/usr/lib/installer/chromeos-common.sh" &> /dev/null || \ +. "${SRC_ROOT}/platform/installer/chromeos-common.sh" &> /dev/null || \ +. "./chromeos-common.sh" || \ die "Unable to load /usr/lib/installer/chromeos-common.sh" SRC_MNT=""