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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 # Remove any dups from lock file while installing new one | 182 # Remove any dups from lock file while installing new one |
183 sort -n "$TMP_LOCKFILE" | uniq > "$LOCKFILE" | 183 sort -n "$TMP_LOCKFILE" | uniq > "$LOCKFILE" |
184 | 184 |
185 if [ -s "$LOCKFILE" ]; then | 185 if [ -s "$LOCKFILE" ]; then |
186 echo "At least one other pid is running in the chroot, so not" | 186 echo "At least one other pid is running in the chroot, so not" |
187 echo "tearing down env." | 187 echo "tearing down env." |
188 else | 188 else |
189 MOUNTED_PATH=$(readlink -f "$FLAGS_chroot") | 189 MOUNTED_PATH=$(readlink -f "$FLAGS_chroot") |
190 echo "Unmounting chroot environment." | 190 echo "Unmounting chroot environment." |
191 for i in $(mount | grep -F "on $MOUNTED_PATH/" | awk '{print $3}'); do | 191 for i in $(mount | grep -F "on $MOUNTED_PATH/" | awk '{print $3}'); do |
192 sudo umount "$i" || die "Failed to umount $i" | 192 safe_umount "$i" |
193 done | 193 done |
194 fi | 194 fi |
195 ) 200>>"$LOCKFILE" || die "teardown_env failed" | 195 ) 200>>"$LOCKFILE" || die "teardown_env failed" |
196 } | 196 } |
197 | 197 |
198 if [ $FLAGS_mount -eq $FLAGS_TRUE ] | 198 if [ $FLAGS_mount -eq $FLAGS_TRUE ] |
199 then | 199 then |
200 setup_env | 200 setup_env |
201 echo "Make sure you run" | 201 echo "Make sure you run" |
202 echo " $0 --unmount" | 202 echo " $0 --unmount" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 245 |
246 # Run command or interactive shell. Also include the non-chrooted path to | 246 # Run command or interactive shell. Also include the non-chrooted path to |
247 # the source trunk for scripts that may need to print it (e.g. | 247 # the source trunk for scripts that may need to print it (e.g. |
248 # build_image.sh). | 248 # build_image.sh). |
249 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \ | 249 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \ |
250 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C "$@" | 250 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C "$@" |
251 | 251 |
252 # Remove trap and explicitly unmount | 252 # Remove trap and explicitly unmount |
253 trap - EXIT | 253 trap - EXIT |
254 teardown_env | 254 teardown_env |
OLD | NEW |