Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # This script will try to sync the bootstrap directories and then defer control. | 6 # This script will try to sync the bootstrap directories and then defer control. |
| 7 | 7 |
| 8 if [ "$USER" == "root" ]; | 8 if [ "$USER" == "root" ]; |
| 9 then | 9 then |
| 10 echo Running depot tools as root is sad. | 10 echo Running depot tools as root is sad. |
| 11 exit | 11 exit |
| 12 fi | 12 fi |
| 13 | 13 |
| 14 base_dir=$(dirname "$0") | 14 base_dir=$(dirname "$0") |
| 15 if [ -L "$base_dir" ] | 15 if [ -L "$base_dir" ] |
| 16 then | 16 then |
| 17 base_dir=`cd "$base_dir" && pwd -P` | 17 base_dir=`cd "$base_dir" && pwd -P` |
| 18 fi | 18 fi |
| 19 | 19 |
| 20 SVN="svn" | |
| 21 if [ -d "$base_dir/svn_bin" ]; then | |
| 22 SVN="$base_dir/svn_bin/svn" | |
|
nsylvain
2011/05/22 21:09:54
svn.exe?
cmp
2011/05/23 22:49:05
Done.
| |
| 23 fi | |
| 24 | |
| 25 GIT="git" | |
| 26 if [ -d "$base_dir/git_bin" ]; then | |
| 27 GIT="$base_dir/git_bin/bin/git" | |
|
nsylvain
2011/05/22 21:09:54
git.exe
cmp
2011/05/23 22:49:05
Done.
| |
| 28 fi | |
| 29 | |
| 20 # Test git and git --version. | 30 # Test git and git --version. |
| 21 function test_git { | 31 function test_git { |
| 22 local GITV="$(git --version)" || { | 32 local GITV="$("$GIT" --version)" || { |
| 23 echo "git isn't installed, please install it" | 33 echo "git isn't installed, please install it" |
| 24 exit 1 | 34 exit 1 |
| 25 } | 35 } |
| 26 | 36 |
| 27 GITV="${GITV##* }" # Only examine last word (i.e. version number) | 37 GITV="${GITV##* }" # Only examine last word (i.e. version number) |
| 28 local GITD=( ${GITV//./ } ) # Split version number into decimals | 38 local GITD=( ${GITV//./ } ) # Split version number into decimals |
| 29 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then | 39 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then |
| 30 echo "git version is ${GITV}, please update to a version later than 1.6" | 40 echo "git version is ${GITV}, please update to a version later than 1.6" |
| 31 exit 1 | 41 exit 1 |
| 32 fi | 42 fi |
| 33 } | 43 } |
| 34 | 44 |
| 35 # Test git svn and git svn --version. | 45 # Test git svn and git svn --version. |
| 36 function test_git_svn { | 46 function test_git_svn { |
| 37 local GITV="$(git svn --version)" || { | 47 local GITV="$("$GIT" svn --version)" || { |
| 38 echo "git-svn isn't installed, please install it" | 48 echo "git-svn isn't installed, please install it" |
| 39 exit 1 | 49 exit 1 |
| 40 } | 50 } |
| 41 | 51 |
| 42 GITV="${GITV#* version }" # git svn --version has extra output to remove. | 52 GITV="${GITV#* version }" # git svn --version has extra output to remove. |
| 43 GITV="${GITV% (svn*}" | 53 GITV="${GITV% (svn*}" |
| 44 local GITD=( ${GITV//./ } ) # Split version number into decimals | 54 local GITD=( ${GITV//./ } ) # Split version number into decimals |
| 45 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then | 55 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then |
| 46 echo "git version is ${GITV}, please update to a version later than 1.6" | 56 echo "git version is ${GITV}, please update to a version later than 1.6" |
| 47 exit 1 | 57 exit 1 |
| 48 fi | 58 fi |
| 49 } | 59 } |
| 50 | 60 |
| 51 # Get the current SVN revision. | 61 # Get the current SVN revision. |
| 52 get_svn_revision() { | 62 get_svn_revision() { |
| 53 LANGUAGE=C svn info "$base_dir" | \ | 63 LANGUAGE=C "$SVN" info "$base_dir" | \ |
| 54 awk -F': ' '{ if ($1 == "Last Changed Rev") { print $2 }}' | 64 awk -F': ' '{ if ($1 == "Last Changed Rev") { print $2 }}' |
| 55 } | 65 } |
| 56 | 66 |
| 57 # Update git checkouts. | 67 # Update git checkouts. |
| 58 if [ "X$DEPOT_TOOLS_UPDATE" != "X0" -a -e "$base_dir/.git" ] | 68 if [ "X$DEPOT_TOOLS_UPDATE" != "X0" -a -e "$base_dir/.git" ] |
| 59 then | 69 then |
| 60 cd $base_dir | 70 cd $base_dir |
| 61 test_git_svn | 71 test_git_svn |
| 62 # work around a git-svn --quiet bug | 72 # work around a git-svn --quiet bug |
| 63 OUTPUT=`git svn rebase -q -q` | 73 OUTPUT=`"$GIT" svn rebase -q -q` |
| 64 if [[ ! "$OUTPUT" == *Current.branch* ]]; then | 74 if [[ ! "$OUTPUT" == *Current.branch* ]]; then |
| 65 echo $OUTPUT 1>&2 | 75 echo $OUTPUT 1>&2 |
| 66 fi | 76 fi |
| 67 cd - > /dev/null | 77 cd - > /dev/null |
| 68 fi | 78 fi |
| 69 | 79 |
| 70 # We're on POSIX. We can now safely look for svn checkout. | 80 # We're on POSIX. We can now safely look for svn checkout. |
| 71 if [ "X$DEPOT_TOOLS_UPDATE" != "X0" -a -e "$base_dir/.svn" ] | 81 if [ "X$DEPOT_TOOLS_UPDATE" != "X0" -a -e "$base_dir/.svn" ] |
| 72 then | 82 then |
| 73 # Update the bootstrap directory to stay up-to-date with the latest | 83 # Update the bootstrap directory to stay up-to-date with the latest |
| 74 # depot_tools. | 84 # depot_tools. |
| 75 BEFORE_REVISION=$(get_svn_revision) | 85 BEFORE_REVISION=$(get_svn_revision) |
| 76 svn -q up "$base_dir" | 86 "$SVN" -q up "$base_dir" |
| 77 AFTER_REVISION=$(get_svn_revision) | 87 AFTER_REVISION=$(get_svn_revision) |
| 78 if [[ "$BEFORE_REVISION" != "$AFTER_REVISION" ]]; then | 88 if [[ "$BEFORE_REVISION" != "$AFTER_REVISION" ]]; then |
| 79 echo "Depot Tools has been updated to revision $AFTER_REVISION." 1>&2 | 89 echo "Depot Tools has been updated to revision $AFTER_REVISION." 1>&2 |
| 80 fi | 90 fi |
| 81 fi | 91 fi |
| OLD | NEW |