From 934675d19b4f65ad505c9033bb073e0550db5366 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Sun, 23 Mar 2014 20:17:05 -0400 Subject: [PATCH] fix(build_image): Add auto-enter-chroot call This makes build_image and image_to_vm behave like build_packages, where if you call the script outside of the SDK's chroot it will automatically reexecute itself inside of the chroot. --- build_image | 5 +++++ image_to_vm.sh | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/build_image b/build_image index a9f54ecf99..5ea08da4b2 100755 --- a/build_image +++ b/build_image @@ -12,6 +12,11 @@ SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || exit 1 +# Script must run inside the chroot +restart_in_chroot_if_needed "$@" + +assert_not_root_user + # Developer-visible flags. DEFINE_string board "${DEFAULT_BOARD}" \ "The board to build an image for." diff --git a/image_to_vm.sh b/image_to_vm.sh index 37d25de020..585f02abe4 100755 --- a/image_to_vm.sh +++ b/image_to_vm.sh @@ -8,10 +8,15 @@ # disk image, supporting a variety of different targets. - # Helper scripts should be run from the same location as this script. SCRIPT_ROOT=$(dirname "$(readlink -f "$0")") . "${SCRIPT_ROOT}/common.sh" || exit 1 + +# Script must run inside the chroot +restart_in_chroot_if_needed "$@" + +assert_not_root_user + . "${BUILD_LIBRARY_DIR}/toolchain_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/build_image_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/vm_image_util.sh" || exit 1