diff --git a/image_to_vm.sh b/image_to_vm.sh index ed360a15f0..cf9804152f 100755 --- a/image_to_vm.sh +++ b/image_to_vm.sh @@ -7,26 +7,9 @@ # Script to convert the output of build_image.sh to a VMware image and write a # corresponding VMware config file. -# --- 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 path - - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} - -find_common_sh +# Helper scripts should be run from the same location as this script. +SCRIPT_ROOT=$(dirname "$(readlink -f "$0")") . "${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 @@ -103,7 +86,7 @@ fi IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" # Default to the most recent image if [ -z "${FLAGS_from}" ] ; then - FLAGS_from="$(./get_latest_image.sh --board=${FLAGS_board})" + FLAGS_from="$(${SCRIPT_ROOT}/get_latest_image.sh --board=${FLAGS_board})" else pushd "${FLAGS_from}" && FLAGS_from=`pwd` && popd fi diff --git a/mount_gpt_image.sh b/mount_gpt_image.sh index fd9eda7a88..368af5c7e1 100755 --- a/mount_gpt_image.sh +++ b/mount_gpt_image.sh @@ -7,26 +7,9 @@ # Helper script that mounts chromium os image from a device or directory # and creates mount points for /var and /usr/local (if in dev_mode). -# --- 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 path - - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} - -find_common_sh +# Helper scripts should be run from the same location as this script. +SCRIPT_ROOT=$(dirname "$(readlink -f "$0")") . "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- if [ $INSIDE_CHROOT -ne 1 ]; then INSTALL_ROOT="$SRC_ROOT/platform/installer/" @@ -194,7 +177,7 @@ function mount_image() { # Find the last image built on the board. if [ ${FLAGS_most_recent} -eq ${FLAGS_TRUE} ] ; then - FLAGS_from="$(./get_latest_image.sh --board="${FLAGS_board}")" + FLAGS_from="$(${SCRIPT_ROOT}/get_latest_image.sh --board="${FLAGS_board}")" fi # Turn paths into absolute paths.