| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 echo "This may impact chromium build." | 127 echo "This may impact chromium build." |
| 128 fi | 128 fi |
| 129 fi | 129 fi |
| 130 fi | 130 fi |
| 131 ) 200>>"$LOCKFILE" | 131 ) 200>>"$LOCKFILE" |
| 132 } | 132 } |
| 133 | 133 |
| 134 function teardown_env { | 134 function teardown_env { |
| 135 # Only teardown if we're the last enter_chroot to die | 135 # Only teardown if we're the last enter_chroot to die |
| 136 | 136 |
| 137 # We should not return with an error if cleanup has an error. Cleanup is |
| 138 # best effort only. |
| 139 set +e |
| 140 |
| 137 ( | 141 ( |
| 138 flock 200 | 142 flock 200 |
| 139 | 143 |
| 140 # check each pid in $LOCKFILE to see if it's died unexpectedly | 144 # check each pid in $LOCKFILE to see if it's died unexpectedly |
| 141 TMP_LOCKFILE="$LOCKFILE.tmp" | 145 TMP_LOCKFILE="$LOCKFILE.tmp" |
| 142 | 146 |
| 143 echo -n > "$TMP_LOCKFILE" # Erase/reset temp file | 147 echo -n > "$TMP_LOCKFILE" # Erase/reset temp file |
| 144 cat "$LOCKFILE" | while read PID; do | 148 cat "$LOCKFILE" | while read PID; do |
| 145 if [ "$PID" = "$$" ]; then | 149 if [ "$PID" = "$$" ]; then |
| 146 # ourself, leave PROC_NAME empty | 150 # ourself, leave PROC_NAME empty |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 222 |
| 219 # Run command or interactive shell. Also include the non-chrooted path to | 223 # Run command or interactive shell. Also include the non-chrooted path to |
| 220 # the source trunk for scripts that may need to print it (e.g. | 224 # the source trunk for scripts that may need to print it (e.g. |
| 221 # build_image.sh). | 225 # build_image.sh). |
| 222 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \ | 226 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \ |
| 223 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C "$@" | 227 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C "$@" |
| 224 | 228 |
| 225 # Remove trap and explicitly unmount | 229 # Remove trap and explicitly unmount |
| 226 trap - EXIT | 230 trap - EXIT |
| 227 teardown_env | 231 teardown_env |
| OLD | NEW |