From 342f156c3594e34a47d0bab9a99fd0f7add9cb67 Mon Sep 17 00:00:00 2001 From: David James Date: Fri, 15 Jul 2011 15:21:18 -0700 Subject: [PATCH] enter_chroot should only modify things within a lock. enter_chroot is often called from multiple processes and we expect that it doesn't modify anything unless it's within a lock. This CL moves chroot modifications up to occur during the lock so that we don't have multiple modifications to .gitconfig occurring at the same time. This prevents the following warning: error: could not lock config file /b/cbuild/chroot/home/chrome-bot/.gitconfig: File exists See http://chromeos-botmaster.mtv.corp.google.com:8026/builders/TOT%20Pre-Flight%20Queue/builds/3771/steps/Test/logs/stdio BUG=chromium-os:17661 TEST=Run enter_chroot.sh and verify gitconfig is still setup. Change-Id: I73a7755d62cce895c76b8e0f35838b3874e5db33 Reviewed-on: http://gerrit.chromium.org/gerrit/4208 Reviewed-by: Chris Sosa Tested-by: David James --- enter_chroot.sh | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/enter_chroot.sh b/enter_chroot.sh index 44468a3a00..8fa593a6ea 100755 --- a/enter_chroot.sh +++ b/enter_chroot.sh @@ -277,6 +277,20 @@ function setup_env { fi fi + if [ -d "$HOME/.subversion" ]; then + TARGET="/home/${USER}/.subversion" + mkdir -p "${FLAGS_chroot}${TARGET}" + ensure_mounted "${HOME}/.subversion" "--bind" "${TARGET}" + fi + + # Configure committer username and email in chroot .gitconfig + git config -f ${FLAGS_chroot}/home/${USER}/.gitconfig --replace-all \ + user.name "$(cd /tmp; git var GIT_COMMITTER_IDENT | \ + sed -e 's/ *<.*//')" || true + git config -f ${FLAGS_chroot}/home/${USER}/.gitconfig --replace-all \ + user.email "$(cd /tmp; git var GIT_COMMITTER_IDENT | \ + sed -e 's/.*<\([^>]*\)>.*/\1/')" || true + # Fix permissions on shared memory to allow non-root users access to POSIX # semaphores. sudo chmod -R 777 "${FLAGS_chroot}/dev/shm" @@ -377,21 +391,6 @@ for type in http_proxy ftp_proxy all_proxy GIT_PROXY_COMMAND GIT_SSH; do fi done -if [ -d "$HOME/.subversion" ]; then - TARGET="/home/${USER}/.subversion" - mkdir -p "${FLAGS_chroot}${TARGET}" - ensure_mounted "${HOME}/.subversion" "--bind" "${TARGET}" -fi - -# Configure committer username and email in chroot .gitconfig -git config -f ${FLAGS_chroot}/home/${USER}/.gitconfig --replace-all \ - user.name "$(cd /tmp; git var GIT_COMMITTER_IDENT | sed -e 's/ *<.*//')" || - true -git config -f ${FLAGS_chroot}/home/${USER}/.gitconfig --replace-all \ - user.email "$(cd /tmp; git var GIT_COMMITTER_IDENT | \ - sed -e 's/.*<\([^>]*\)>.*/\1/')" || - true - # Run command or interactive shell. Also include the non-chrooted path to # the source trunk for scripts that may need to print it (e.g. # build_image.sh).