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. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 teardown_env | 96 teardown_env |
97 exit 0 | 97 exit 0 |
98 fi | 98 fi |
99 | 99 |
100 # Make sure we unmount before exiting | 100 # Make sure we unmount before exiting |
101 trap teardown_env EXIT | 101 trap teardown_env EXIT |
102 setup_env | 102 setup_env |
103 | 103 |
104 if [ $FLAGS_revision -eq $FLAGS_TRUE ] | 104 if [ $FLAGS_revision -eq $FLAGS_TRUE ] |
105 then | 105 then |
106 # Get the subversion revision to pass into the chroot. | 106 # Get the subversion revision to pass into the chroot. |
107 # | 107 # |
108 # This must be determined outside the chroot because (1) there is no | 108 # This must be determined outside the chroot because (1) there is no |
109 # svn/git inside the chroot, and (2) if there were it would likely be | 109 # svn/git inside the chroot, and (2) if there were it would likely be |
110 # the wrong version, which would mess up the .svn/.git directories. | 110 # the wrong version, which would mess up the .svn/.git directories. |
111 # | 111 # |
112 # Note that this fixes $CHROMEOS_REVISION at the time the chroot is | 112 # Note that this fixes $CHROMEOS_REVISION at the time the chroot is |
113 # entered. That's ok for the main use case of automated builds, | 113 # entered. That's ok for the main use case of automated builds, |
114 # which pass each command line into a separate call to enter_chroot | 114 # which pass each command line into a separate call to enter_chroot |
115 # so always have up-to-date info. For developer builds, there isn't | 115 # so always have up-to-date info. For developer builds, there isn't |
116 # really a single revision anyway, since the developer may have | 116 # really a single revision anyway, since the developer may have |
117 # hand-sync'd some subdirs and edited files in others. | 117 # hand-sync'd some subdirs and edited files in others. |
118 REVISION="$(svn info 2>&- | grep "Revision: " | awk '{print $2}')" | 118 REVISION="$(svn info 2>&- | grep "Revision: " | awk '{print $2}')" |
119 if [ -z "$REVISION" ] | 119 if [ -z "$REVISION" ] |
120 then | 120 then |
121 # Use git:8 chars of sha1 | 121 # Use git:8 chars of sha1 |
122 REVISION=$(git rev-parse HEAD) | 122 REVISION=$(git rev-parse HEAD) |
123 REVISION="${REVISION:8}" | 123 REVISION="${REVISION:8}" |
124 fi | 124 fi |
125 REVISION="CHROMEOS_REVISION=$REVISION" | 125 REVISION="CHROMEOS_REVISION=$REVISION" |
126 fi | 126 fi |
127 | 127 |
128 # Run command or interactive shell | 128 # Run command or interactive shell. Also include the non-chrooted path to |
129 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $REVISION "$@" | 129 # the source trunk for scripts that may need to print it (e.g. |
| 130 # build_image.sh). |
| 131 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $REVISION \ |
| 132 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" "$@" |
130 | 133 |
131 # Remove trap and explicitly unmount | 134 # Remove trap and explicitly unmount |
132 trap - EXIT | 135 trap - EXIT |
133 teardown_env | 136 teardown_env |
134 | |
OLD | NEW |