OLD | NEW |
1 #!/usr/bin/env bash | 1 #!/usr/bin/env bash |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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 # Test if this script is running under a MSys install. If it is, we will | |
21 # hardcode the paths to SVN and Git where possible. | |
22 OUTPUT="$(uname | grep 'MINGW')" | |
23 MINGW=$? | |
24 | |
25 SVN="svn" | |
26 if [ -d "$base_dir/svn_bin" -a $MINGW = 0 ]; then | |
27 SVN="$base_dir/svn_bin/svn.exe" | |
28 fi | |
29 | |
30 GIT="git" | |
31 if [ -d "$base_dir/git_bin" -a $MINGW = 0 ]; then | |
32 GIT="$base_dir/git_bin/bin/git.exe" | |
33 fi | |
34 | |
35 # Test git and git --version. | 20 # Test git and git --version. |
36 function test_git { | 21 function test_git { |
37 local GITV="$("$GIT" --version)" || { | 22 local GITV="$(git --version)" || { |
38 echo "git isn't installed, please install it" | 23 echo "git isn't installed, please install it" |
39 exit 1 | 24 exit 1 |
40 } | 25 } |
41 | 26 |
42 GITV="${GITV##* }" # Only examine last word (i.e. version number) | 27 GITV="${GITV##* }" # Only examine last word (i.e. version number) |
43 local GITD=( ${GITV//./ } ) # Split version number into decimals | 28 local GITD=( ${GITV//./ } ) # Split version number into decimals |
44 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then | 29 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then |
45 echo "git version is ${GITV}, please update to a version later than 1.6" | 30 echo "git version is ${GITV}, please update to a version later than 1.6" |
46 exit 1 | 31 exit 1 |
47 fi | 32 fi |
48 } | 33 } |
49 | 34 |
50 # Test git svn and git svn --version. | 35 # Test git svn and git svn --version. |
51 function test_git_svn { | 36 function test_git_svn { |
52 local GITV="$("$GIT" svn --version)" || { | 37 local GITV="$(git svn --version)" || { |
53 echo "git-svn isn't installed, please install it" | 38 echo "git-svn isn't installed, please install it" |
54 exit 1 | 39 exit 1 |
55 } | 40 } |
56 | 41 |
57 GITV="${GITV#* version }" # git svn --version has extra output to remove. | 42 GITV="${GITV#* version }" # git svn --version has extra output to remove. |
58 GITV="${GITV% (svn*}" | 43 GITV="${GITV% (svn*}" |
59 local GITD=( ${GITV//./ } ) # Split version number into decimals | 44 local GITD=( ${GITV//./ } ) # Split version number into decimals |
60 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then | 45 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then |
61 echo "git version is ${GITV}, please update to a version later than 1.6" | 46 echo "git version is ${GITV}, please update to a version later than 1.6" |
62 exit 1 | 47 exit 1 |
63 fi | 48 fi |
64 } | 49 } |
65 | 50 |
66 # Get the current SVN revision. | 51 # Get the current SVN revision. |
67 get_svn_revision() { | 52 get_svn_revision() { |
68 LANGUAGE=C "$SVN" info "$base_dir" | \ | 53 LANGUAGE=C svn info "$base_dir" | \ |
69 awk -F': ' '{ if ($1 == "Last Changed Rev") { print $2 }}' | 54 awk -F': ' '{ if ($1 == "Last Changed Rev") { print $2 }}' |
70 } | 55 } |
71 | 56 |
72 # Update git checkouts. | 57 # Update git checkouts. |
73 if [ "X$DEPOT_TOOLS_UPDATE" != "X0" -a -e "$base_dir/.git" ] | 58 if [ "X$DEPOT_TOOLS_UPDATE" != "X0" -a -e "$base_dir/.git" ] |
74 then | 59 then |
75 cd $base_dir | 60 cd $base_dir |
76 test_git_svn | 61 test_git_svn |
77 # work around a git-svn --quiet bug | 62 # work around a git-svn --quiet bug |
78 OUTPUT=`"$GIT" svn rebase -q -q` | 63 OUTPUT=`git svn rebase -q -q` |
79 if [[ ! "$OUTPUT" == *Current.branch* ]]; then | 64 if [[ ! "$OUTPUT" == *Current.branch* ]]; then |
80 echo $OUTPUT 1>&2 | 65 echo $OUTPUT 1>&2 |
81 fi | 66 fi |
82 cd - > /dev/null | 67 cd - > /dev/null |
83 fi | 68 fi |
84 | 69 |
85 # We're on POSIX. We can now safely look for svn checkout. | 70 # We're on POSIX. We can now safely look for svn checkout. |
86 if [ "X$DEPOT_TOOLS_UPDATE" != "X0" -a -e "$base_dir/.svn" ] | 71 if [ "X$DEPOT_TOOLS_UPDATE" != "X0" -a -e "$base_dir/.svn" ] |
87 then | 72 then |
88 # Update the bootstrap directory to stay up-to-date with the latest | 73 # Update the bootstrap directory to stay up-to-date with the latest |
89 # depot_tools. | 74 # depot_tools. |
90 BEFORE_REVISION=$(get_svn_revision) | 75 BEFORE_REVISION=$(get_svn_revision) |
91 "$SVN" -q up "$base_dir" | 76 svn -q up "$base_dir" |
92 AFTER_REVISION=$(get_svn_revision) | 77 AFTER_REVISION=$(get_svn_revision) |
93 if [[ "$BEFORE_REVISION" != "$AFTER_REVISION" ]]; then | 78 if [[ "$BEFORE_REVISION" != "$AFTER_REVISION" ]]; then |
94 echo "Depot Tools has been updated to revision $AFTER_REVISION." 1>&2 | 79 echo "Depot Tools has been updated to revision $AFTER_REVISION." 1>&2 |
95 fi | 80 fi |
96 fi | 81 fi |
OLD | NEW |