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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 # which pass each command line into a separate call to enter_chroot | 269 # which pass each command line into a separate call to enter_chroot |
270 # so always have up-to-date info. For developer builds, there may not | 270 # so always have up-to-date info. For developer builds, there may not |
271 # be a single revision, since the developer may have | 271 # be a single revision, since the developer may have |
272 # hand-sync'd some subdirs and edited files in others. | 272 # hand-sync'd some subdirs and edited files in others. |
273 # In that case, check against origin/HEAD and mark** revision. | 273 # In that case, check against origin/HEAD and mark** revision. |
274 # Use git:8 chars of sha1 | 274 # Use git:8 chars of sha1 |
275 REVISION=$(git rev-parse --short=8 HEAD) | 275 REVISION=$(git rev-parse --short=8 HEAD) |
276 CHROOT_PASSTHRU="CHROMEOS_REVISION=$REVISION BUILDBOT_BUILD=$FLAGS_build_number
CHROMEOS_OFFICIAL=$CHROMEOS_OFFICIAL" | 276 CHROOT_PASSTHRU="CHROMEOS_REVISION=$REVISION BUILDBOT_BUILD=$FLAGS_build_number
CHROMEOS_OFFICIAL=$CHROMEOS_OFFICIAL" |
277 if [ -d "$HOME/.subversion" ]; then | 277 if [ -d "$HOME/.subversion" ]; then |
278 # Bind mounting .subversion into chroot | 278 # Bind mounting .subversion into chroot |
279 echo "mounting ~/.subversion into chroot" | 279 echo >&2 "mounting ~/.subversion into chroot" |
280 MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}/home/${USER}/.subversion")" | 280 MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}/home/${USER}/.subversion")" |
281 if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]; then | 281 if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]; then |
282 mkdir -p "$MOUNTED_PATH" | 282 mkdir -p "$MOUNTED_PATH" |
283 sudo mount --bind "$HOME/.subversion" "$MOUNTED_PATH" || \ | 283 sudo mount --bind "$HOME/.subversion" "$MOUNTED_PATH" || \ |
284 die "Could not mount $MOUNTED_PATH" | 284 die "Could not mount $MOUNTED_PATH" |
285 fi | 285 fi |
286 fi | 286 fi |
287 | 287 |
288 # Run command or interactive shell. Also include the non-chrooted path to | 288 # Run command or interactive shell. Also include the non-chrooted path to |
289 # the source trunk for scripts that may need to print it (e.g. | 289 # the source trunk for scripts that may need to print it (e.g. |
290 # build_image.sh). | 290 # build_image.sh). |
291 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \ | 291 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \ |
292 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C SSH_AGENT_PID="${SSH_AGENT_PID}" \ | 292 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C SSH_AGENT_PID="${SSH_AGENT_PID}" \ |
293 SSH_AUTH_SOCK="${SSH_AUTH_SOCK}" -- "$@" | 293 SSH_AUTH_SOCK="${SSH_AUTH_SOCK}" -- "$@" |
294 | 294 |
295 # Remove trap and explicitly unmount | 295 # Remove trap and explicitly unmount |
296 trap - EXIT | 296 trap - EXIT |
297 teardown_env | 297 teardown_env |
OLD | NEW |