| 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 # the wrong version, which would mess up the .git directories. | 265 # the wrong version, which would mess up the .git directories. |
| 266 # | 266 # |
| 267 # Note that this fixes $CHROMEOS_REVISION at the time the chroot is | 267 # Note that this fixes $CHROMEOS_REVISION at the time the chroot is |
| 268 # entered. That's ok for the main use case of automated builds, | 268 # entered. That's ok for the main use case of automated builds, |
| 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=$(cd ${FLAGS_trunk}/src/scripts ; 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 info "mounting ~/.subversion into chroot" | 279 info "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 # Configure committer username and email in chroot .gitconfig | 288 # Configure committer username and email in chroot .gitconfig |
| 289 git config -f ${FLAGS_chroot}/home/${USER}/.gitconfig --replace-all user.name \ | 289 git config -f ${FLAGS_chroot}/home/${USER}/.gitconfig --replace-all user.name \ |
| 290 "$(cd /tmp; git var GIT_COMMITTER_IDENT | sed -e 's/ *<.*//')" | 290 "$(cd /tmp; git var GIT_COMMITTER_IDENT | sed -e 's/ *<.*//')" |
| 291 git config -f ${FLAGS_chroot}/home/${USER}/.gitconfig --replace-all user.email \ | 291 git config -f ${FLAGS_chroot}/home/${USER}/.gitconfig --replace-all user.email \ |
| 292 "$(cd /tmp; git var GIT_COMMITTER_IDENT | sed -e 's/.*<\([^>]*\)>.*/\1/')" | 292 "$(cd /tmp; git var GIT_COMMITTER_IDENT | sed -e 's/.*<\([^>]*\)>.*/\1/')" |
| 293 | 293 |
| 294 # Run command or interactive shell. Also include the non-chrooted path to | 294 # Run command or interactive shell. Also include the non-chrooted path to |
| 295 # the source trunk for scripts that may need to print it (e.g. | 295 # the source trunk for scripts that may need to print it (e.g. |
| 296 # build_image.sh). | 296 # build_image.sh). |
| 297 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \ | 297 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \ |
| 298 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C SSH_AGENT_PID="${SSH_AGENT_PID}" \ | 298 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C SSH_AGENT_PID="${SSH_AGENT_PID}" \ |
| 299 SSH_AUTH_SOCK="${SSH_AUTH_SOCK}" -- "$@" | 299 SSH_AUTH_SOCK="${SSH_AUTH_SOCK}" -- "$@" |
| 300 | 300 |
| 301 # Remove trap and explicitly unmount | 301 # Remove trap and explicitly unmount |
| 302 trap - EXIT | 302 trap - EXIT |
| 303 teardown_env | 303 teardown_env |
| OLD | NEW |