Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 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 | 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. | 21 # hardcode the paths to SVN and Git where possible. |
| 22 OUTPUT="$(uname | grep 'MINGW')" | 22 OUTPUT="$(uname | grep 'MINGW')" |
| 23 MINGW=$? | 23 MINGW=$? |
| 24 | 24 |
| 25 CANONICAL_GIT_URL="https://chromium.googlesource.com/chromium/tools/depot_tools" | |
|
M-A Ruel
2013/01/07 16:19:18
Wouldn't it be better to use ".../depot_tools.git"
| |
| 26 | |
| 25 SVN="svn" | 27 SVN="svn" |
| 26 if [ -d "$base_dir/svn_bin" -a $MINGW = 0 ]; then | 28 if [ -d "$base_dir/svn_bin" -a $MINGW = 0 ]; then |
| 27 SVN="$base_dir/svn_bin/svn.exe" | 29 SVN="$base_dir/svn_bin/svn.exe" |
| 28 fi | 30 fi |
| 29 | 31 |
| 30 GIT="git" | 32 GIT="git" |
| 31 if [ -d "$base_dir/git_bin" -a $MINGW = 0 ]; then | 33 if [ -d "$base_dir/git_bin" -a $MINGW = 0 ]; then |
| 32 GIT="$base_dir/git_bin/bin/git.exe" | 34 GIT="$base_dir/git_bin/bin/git.exe" |
| 33 fi | 35 fi |
| 34 | 36 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 63 echo "git version is ${GITV}, please update to a version later than 1.6" | 65 echo "git version is ${GITV}, please update to a version later than 1.6" |
| 64 exit 1 | 66 exit 1 |
| 65 fi | 67 fi |
| 66 } | 68 } |
| 67 | 69 |
| 68 function is_git_clone_repo { | 70 function is_git_clone_repo { |
| 69 "$GIT" config remote.origin.fetch > /dev/null | 71 "$GIT" config remote.origin.fetch > /dev/null |
| 70 } | 72 } |
| 71 | 73 |
| 72 function update_git_repo { | 74 function update_git_repo { |
| 75 remote_url=$("$GIT" config --get remote.origin.url) | |
| 76 if [ -n "$remote_url" -a "$remote_url" != "$CANONICAL_GIT_URL" ]; then | |
| 77 echo "Your copy of depot_tools is configured to fetch from an obsolete URL:" | |
| 78 echo | |
| 79 echo " $remote_url" | |
| 80 echo | |
| 81 read -t 60 -p "OK to update it to $CANONICAL_GIT_URL ? [Y/n] " -n 1 | |
| 82 echo | |
| 83 if [ $? -ne "0" ]; then | |
| 84 echo "Timeout; not updating remote URL." | |
| 85 elif [ -z "$REPLY" -o "$REPLY" = "Y" -o "$REPLY" = "y" ]; then | |
| 86 "$GIT" config remote.origin.url "$CANONICAL_GIT_URL" | |
| 87 echo "Remote URL updated." | |
| 88 fi | |
| 89 fi | |
| 90 | |
| 73 if is_git_clone_repo; then | 91 if is_git_clone_repo; then |
| 74 git fetch -q origin &> /dev/null | 92 git fetch -q origin &> /dev/null |
| 75 local REBASE_TXT STATUS | 93 local REBASE_TXT STATUS |
| 76 REBASE_TXT=$(git rebase -q origin/master 2>&1) | 94 REBASE_TXT=$(git rebase -q origin/master 2>&1) |
| 77 STATUS=$? | 95 STATUS=$? |
| 78 if [[ $STATUS -ne 0 ]]; then | 96 if [[ $STATUS -ne 0 ]]; then |
| 79 echo "depot_tools update failed. Conflict in $base_dir" >&2 | 97 echo "depot_tools update failed. Conflict in $base_dir" >&2 |
| 80 echo "$REBASE_TXT" >&2 | 98 echo "$REBASE_TXT" >&2 |
| 81 git rebase --abort 2> /dev/null | 99 git rebase --abort 2> /dev/null |
| 82 fi | 100 fi |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 112 # Update the root directory to stay up-to-date with the latest depot_tools. | 130 # Update the root directory to stay up-to-date with the latest depot_tools. |
| 113 BEFORE_REVISION=$(get_svn_revision) | 131 BEFORE_REVISION=$(get_svn_revision) |
| 114 "$SVN" -q up "$base_dir" | 132 "$SVN" -q up "$base_dir" |
| 115 AFTER_REVISION=$(get_svn_revision) | 133 AFTER_REVISION=$(get_svn_revision) |
| 116 if [[ "$BEFORE_REVISION" != "$AFTER_REVISION" ]]; then | 134 if [[ "$BEFORE_REVISION" != "$AFTER_REVISION" ]]; then |
| 117 echo "Depot Tools has been updated to revision $AFTER_REVISION." 1>&2 | 135 echo "Depot Tools has been updated to revision $AFTER_REVISION." 1>&2 |
| 118 fi | 136 fi |
| 119 fi | 137 fi |
| 120 | 138 |
| 121 find "$base_dir" -iname "*.pyc" -exec rm {} \; | 139 find "$base_dir" -iname "*.pyc" -exec rm {} \; |
| OLD | NEW |