diff --git a/build_gpt.sh b/build_gpt.sh index f44a745814..e10a32a55b 100755 --- a/build_gpt.sh +++ b/build_gpt.sh @@ -12,7 +12,7 @@ . "$(dirname "$0")/chromeos-common.sh" # Script must be run inside the chroot. -assert_inside_chroot +restart_in_chroot_if_needed $* get_default_board diff --git a/build_image b/build_image index 86e1346404..8bc0c6179b 100755 --- a/build_image +++ b/build_image @@ -14,7 +14,7 @@ . "$(dirname "$0")/common.sh" # Script must be run inside the chroot. -assert_inside_chroot +restart_in_chroot_if_needed $* get_default_board diff --git a/build_tests.sh b/build_tests.sh index 2e4e403d63..a82c50797e 100755 --- a/build_tests.sh +++ b/build_tests.sh @@ -8,8 +8,8 @@ # The path to common.sh should be relative to your script's location. . "$(dirname "$0")/common.sh" -assert_inside_chroot assert_not_root_user +restart_in_chroot_if_needed $* get_default_board # Flags diff --git a/common.sh b/common.sh index 52bf632779..accb468aaf 100644 --- a/common.sh +++ b/common.sh @@ -207,6 +207,16 @@ function make_pkg_common { popd } +# Enter a chroot and restart the current script if needed +function restart_in_chroot_if_needed { + if [ $INSIDE_CHROOT -ne 1 ] + then + # Equivalent to enter_chroot.sh -- + exec $SCRIPTS_DIR/enter_chroot.sh -- \ + $CHROOT_TRUNK_DIR/src/scripts/$(basename $0) $* + fi +} + # Fail unless we're inside the chroot. This guards against messing up your # workstation. function assert_inside_chroot { diff --git a/run_tests.sh b/run_tests.sh index d9bd0d791e..7bd5c22b1c 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -9,7 +9,7 @@ . "$(dirname "$0")/common.sh" # Script must be run inside the chroot -assert_inside_chroot +restart_in_chroot_if_needed $* get_default_board # Flags diff --git a/set_shared_user_password.sh b/set_shared_user_password.sh index ab6f4b8772..25baca0e63 100755 --- a/set_shared_user_password.sh +++ b/set_shared_user_password.sh @@ -12,7 +12,7 @@ . "$(dirname "$0")/common.sh" # Script must be run inside the chroot -assert_inside_chroot +restart_in_chroot_if_needed $* FLAGS_HELP="USAGE: $0 [flags]" diff --git a/start_devserver b/start_devserver index e79b6f8e23..f56f4c6120 100755 --- a/start_devserver +++ b/start_devserver @@ -10,6 +10,9 @@ COMMON_SH="$(dirname "$0")/common.sh" . "$COMMON_SH" # Script must be run inside the chroot if not in 'always serve' mode. -[[ $1 != "-a" && assert_inside_chroot ]] +if [[ "$1" != "-a" ]] +then + restart_in_chroot_if_needed $* +fi cd ${GCLIENT_ROOT}/src/platform/dev && python devserver.py $*