OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Script to enter the chroot environment | 7 # Script to enter the chroot environment |
8 | 8 |
9 # Load common constants. This should be the first executable line. | 9 # Load common constants. This should be the first executable line. |
10 # The path to common.sh should be relative to your script's location. | 10 # The path to common.sh should be relative to your script's location. |
11 . "$(dirname "$0")/common.sh" | 11 . "$(dirname "$0")/common.sh" |
12 | 12 |
13 # Script must be run outside the chroot | 13 # Script must be run outside the chroot and as a regular user. |
14 assert_outside_chroot | 14 assert_outside_chroot |
| 15 assert_not_root_user |
15 | 16 |
16 # Define command line flags | 17 # Define command line flags |
17 # See http://code.google.com/p/shflags/wiki/Documentation10x | 18 # See http://code.google.com/p/shflags/wiki/Documentation10x |
18 DEFINE_string chroot "$DEFAULT_CHROOT_DIR" \ | 19 DEFINE_string chroot "$DEFAULT_CHROOT_DIR" \ |
19 "The destination dir for the chroot environment." "d" | 20 "The destination dir for the chroot environment." "d" |
20 DEFINE_string trunk "$GCLIENT_ROOT" \ | 21 DEFINE_string trunk "$GCLIENT_ROOT" \ |
21 "The source trunk to bind mount within the chroot." "s" | 22 "The source trunk to bind mount within the chroot." "s" |
22 | 23 |
23 DEFINE_boolean mount $FLAGS_FALSE "Only set up mounts." | 24 DEFINE_boolean mount $FLAGS_FALSE "Only set up mounts." |
24 DEFINE_boolean unmount $FLAGS_FALSE "Only tear down mounts." | 25 DEFINE_boolean unmount $FLAGS_FALSE "Only tear down mounts." |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 REVISION="CHROMEOS_REVISION=$REVISION" | 125 REVISION="CHROMEOS_REVISION=$REVISION" |
125 fi | 126 fi |
126 | 127 |
127 # Run command or interactive shell | 128 # Run command or interactive shell |
128 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $REVISION "$@" | 129 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $REVISION "$@" |
129 | 130 |
130 # Remove trap and explicitly unmount | 131 # Remove trap and explicitly unmount |
131 trap - EXIT | 132 trap - EXIT |
132 teardown_env | 133 teardown_env |
133 | 134 |
OLD | NEW |