Added restart_in_chroot_if_needed to common.sh.

Add restart_in_chroot_if_needed to common.sh, and modify the build scripts which referred to assert_inside_chroot to use it instead. The effect is that you don't ever have to explicitly enter_chroot.sh to build (still can, it work's fine).

Update mod_image_for_test.sh to use restart_in_chroot_if_needed

Review URL: http://codereview.chromium.org/1736025
This commit is contained in:
Don Garrett 2010-05-04 16:54:28 -07:00
parent c1214dc327
commit 640a0585f5
7 changed files with 19 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 -- <current command>
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 {

View File

@ -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

View File

@ -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]"

View File

@ -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 $*