Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Side by Side Diff: update_depot_tools

Issue 166273024: More fixes for hardcoded git directory paths. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Use eval to execute GIT var Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env bash 1 #!/usr/bin/env bash
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 # Test if this script is running under a MSys install. If it is, we will
15 if [ -L "$base_dir" ] 15 # hardcode the paths to SVN and Git where possible.
16 then 16 OUTPUT="$(uname | grep 'MINGW')"
17 MINGW=$?
18
19 if [ $MINGW = 0 ]; then
20 base_dir="${0%\\*}"
iannucci 2014/02/21 08:25:07 TIL: bash variable expansion is freaking nuts :(
21 else
22 base_dir=$(dirname "$0")
23 if [ -L "$base_dir" ]; then
17 base_dir=`cd "$base_dir" && pwd -P` 24 base_dir=`cd "$base_dir" && pwd -P`
25 fi
18 fi 26 fi
19 27
20 # Don't try to use Cygwin tools. Get real win32 tools using the batch script. 28 # Don't try to use Cygwin tools. Get real win32 tools using the batch script.
21 OUTPUT="$(uname | grep 'CYGWIN')" 29 OUTPUT="$(uname | grep 'CYGWIN')"
22 CYGWIN=$? 30 CYGWIN=$?
23 if [ $CYGWIN = 0 ]; then 31 if [ $CYGWIN = 0 ]; then
24 cmd /c `cygpath -w "$base_dir/bootstrap/win/win_tools.bat"` force 32 cmd /c `cygpath -w "$base_dir/bootstrap/win/win_tools.bat"` force
25 fi 33 fi
26 34
27 # Test if this script is running under a MSys install. If it is, we will
28 # hardcode the paths to SVN and Git where possible.
29 OUTPUT="$(uname | grep 'MINGW')"
30 MINGW=$?
31
32 CANONICAL_GIT_URL="https://chromium.googlesource.com/chromium/tools/depot_tools. git" 35 CANONICAL_GIT_URL="https://chromium.googlesource.com/chromium/tools/depot_tools. git"
33 36
34 SVN="svn" 37 SVN="svn"
35 if [ -d "$base_dir/svn_bin" -a $MINGW = 0 ]; then 38 if [ -d "$base_dir/svn_bin" -a $MINGW = 0 ]; then
36 SVN="$base_dir/svn_bin/svn.exe" 39 SVN="$base_dir/svn_bin/svn.exe"
37 fi 40 fi
38 41
39 GIT="git" 42 GIT="git"
40 if [ -d "$base_dir/git-1.8.0_bin" -a $MINGW = 0 ]; then 43 if [ -e "$base_dir/git.bat" -a $MINGW = 0 ]; then
41 GIT="$base_dir/git-1.8.0_bin/bin/git.exe" 44 GIT="cmd.exe //c \"$base_dir\\git.bat\""
42 fi 45 fi
43 46
44 # Test git and git --version. 47 # Test git and git --version.
45 function test_git { 48 function test_git {
46 local GITV 49 local GITV
47 GITV="$("$GIT" --version)" || { 50 GITV="$(eval "$GIT" --version)" || {
48 echo "git isn't installed, please install it" 51 echo "git isn't installed, please install it"
49 exit 1 52 exit 1
50 } 53 }
51 54
52 GITV="${GITV##* }" # Only examine last word (i.e. version number) 55 GITV="${GITV##* }" # Only examine last word (i.e. version number)
53 local GITD=( ${GITV//./ } ) # Split version number into decimals 56 local GITD=( ${GITV//./ } ) # Split version number into decimals
54 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then 57 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then
55 echo "git version is ${GITV}, please update to a version later than 1.6" 58 echo "git version is ${GITV}, please update to a version later than 1.6"
56 exit 1 59 exit 1
57 fi 60 fi
58 } 61 }
59 62
60 # Test git svn and git svn --version. 63 # Test git svn and git svn --version.
61 function test_git_svn { 64 function test_git_svn {
62 local GITV 65 local GITV
63 GITV="$("$GIT" svn --version)" || { 66 GITV="$(eval "$GIT" svn --version)" || {
64 echo "git-svn isn't installed, please install it" 67 echo "git-svn isn't installed, please install it"
65 exit 1 68 exit 1
66 } 69 }
67 70
68 GITV="${GITV#* version }" # git svn --version has extra output to remove. 71 GITV="${GITV#* version }" # git svn --version has extra output to remove.
69 GITV="${GITV% (svn*}" 72 GITV="${GITV% (svn*}"
70 local GITD=( ${GITV//./ } ) # Split version number into decimals 73 local GITD=( ${GITV//./ } ) # Split version number into decimals
71 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then 74 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then
72 echo "git version is ${GITV}, please update to a version later than 1.6" 75 echo "git version is ${GITV}, please update to a version later than 1.6"
73 exit 1 76 exit 1
74 fi 77 fi
75 } 78 }
76 79
77 function is_git_clone_repo { 80 function is_git_clone_repo {
78 "$GIT" config remote.origin.fetch > /dev/null 81 eval "$GIT" config remote.origin.fetch > /dev/null
79 } 82 }
80 83
81 function update_git_repo { 84 function update_git_repo {
82 remote_url=$("$GIT" config --get remote.origin.url) 85 remote_url=$(eval "$GIT" config --get remote.origin.url)
83 if [ -n "$remote_url" -a "$remote_url" != "$CANONICAL_GIT_URL" ]; then 86 if [ -n "$remote_url" -a "$remote_url" != "$CANONICAL_GIT_URL" ]; then
84 echo "Your copy of depot_tools is configured to fetch from an obsolete URL:" 87 echo "Your copy of depot_tools is configured to fetch from an obsolete URL:"
85 echo 88 echo
86 echo " $remote_url" 89 echo " $remote_url"
87 echo 90 echo
88 read -t 60 -p "OK to update it to $CANONICAL_GIT_URL ? [Y/n] " -n 1 91 read -t 60 -p "OK to update it to $CANONICAL_GIT_URL ? [Y/n] " -n 1
89 STATUS=$? 92 STATUS=$?
90 echo 93 echo
91 if [[ $STATUS -ne 0 ]]; then 94 if [[ $STATUS -ne 0 ]]; then
92 echo "Timeout; not updating remote URL." 95 echo "Timeout; not updating remote URL."
93 elif [ -z "$REPLY" -o "$REPLY" = "Y" -o "$REPLY" = "y" ]; then 96 elif [ -z "$REPLY" -o "$REPLY" = "Y" -o "$REPLY" = "y" ]; then
94 "$GIT" config remote.origin.url "$CANONICAL_GIT_URL" 97 eval "$GIT" config remote.origin.url "$CANONICAL_GIT_URL"
95 echo "Remote URL updated." 98 echo "Remote URL updated."
96 fi 99 fi
97 fi 100 fi
98 101
99 if is_git_clone_repo; then 102 if is_git_clone_repo; then
100 git fetch -q origin &> /dev/null 103 git fetch -q origin &> /dev/null
101 local REBASE_TXT STATUS 104 local REBASE_TXT STATUS
102 REBASE_TXT=$(git rebase -q origin/master 2>&1) 105 REBASE_TXT=$(git rebase -q origin/master 2>&1)
103 STATUS=$? 106 STATUS=$?
104 if [[ $STATUS -ne 0 ]]; then 107 if [[ $STATUS -ne 0 ]]; then
105 echo "depot_tools update failed. Conflict in $base_dir" >&2 108 echo "depot_tools update failed. Conflict in $base_dir" >&2
106 echo "$REBASE_TXT" >&2 109 echo "$REBASE_TXT" >&2
107 git rebase --abort 2> /dev/null 110 git rebase --abort 2> /dev/null
108 fi 111 fi
109 return $STATUS 112 return $STATUS
110 fi 113 fi
111 114
112 test_git_svn 115 test_git_svn
113 # work around a git-svn --quiet bug 116 # work around a git-svn --quiet bug
114 OUTPUT=`"$GIT" svn rebase -q -q` 117 OUTPUT=`eval "$GIT" svn rebase -q -q`
115 if [[ ! "$OUTPUT" == *Current.branch* ]]; then 118 if [[ ! "$OUTPUT" == *Current.branch* ]]; then
116 echo $OUTPUT 1>&2 119 echo $OUTPUT 1>&2
117 fi 120 fi
118 return 0 121 return 0
119 } 122 }
120 123
121 # Get the current SVN revision. 124 # Get the current SVN revision.
122 get_svn_revision() { 125 get_svn_revision() {
123 LANGUAGE=C "$SVN" info "$base_dir" | \ 126 LANGUAGE=C "$SVN" info "$base_dir" | \
124 awk -F': ' '{ if ($1 == "Last Changed Rev") { print $2 }}' 127 awk -F': ' '{ if ($1 == "Last Changed Rev") { print $2 }}'
(...skipping 13 matching lines...) Expand all
138 # Update the root directory to stay up-to-date with the latest depot_tools. 141 # Update the root directory to stay up-to-date with the latest depot_tools.
139 BEFORE_REVISION=$(get_svn_revision) 142 BEFORE_REVISION=$(get_svn_revision)
140 "$SVN" -q up "$base_dir" 143 "$SVN" -q up "$base_dir"
141 AFTER_REVISION=$(get_svn_revision) 144 AFTER_REVISION=$(get_svn_revision)
142 if [[ "$BEFORE_REVISION" != "$AFTER_REVISION" ]]; then 145 if [[ "$BEFORE_REVISION" != "$AFTER_REVISION" ]]; then
143 echo "Depot Tools has been updated to revision $AFTER_REVISION." 1>&2 146 echo "Depot Tools has been updated to revision $AFTER_REVISION." 1>&2
144 fi 147 fi
145 fi 148 fi
146 149
147 find "$base_dir" -iname "*.pyc" -exec rm {} \; 150 find "$base_dir" -iname "*.pyc" -exec rm {} \;
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698