blob: 00859e338be2dad2bc210cafc514a4613b78b71f [file] [log] [blame]
[email protected]711a16a2011-05-21 09:30:431#!/usr/bin/env bash
[email protected]4c6e4042011-06-01 18:52:312# Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]2a949042010-10-18 18:04:013# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6# This script will try to sync the bootstrap directories and then defer control.
7
[email protected]31dcb492011-05-12 20:36:388if [ "$USER" == "root" ];
9then
10 echo Running depot tools as root is sad.
11 exit
12fi
13
[email protected]2a949042010-10-18 18:04:0114base_dir=$(dirname "$0")
[email protected]6fe66e12011-04-12 23:12:3515if [ -L "$base_dir" ]
16then
17 base_dir=`cd "$base_dir" && pwd -P`
18fi
[email protected]2a949042010-10-18 18:04:0119
[email protected]4c6e4042011-06-01 18:52:3120# 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.
22OUTPUT="$(uname | grep 'MINGW')"
23MINGW=$?
24
25SVN="svn"
26if [ -d "$base_dir/svn_bin" -a $MINGW = 0 ]; then
27 SVN="$base_dir/svn_bin/svn.exe"
28fi
29
30GIT="git"
31if [ -d "$base_dir/git_bin" -a $MINGW = 0 ]; then
32 GIT="$base_dir/git_bin/bin/git.exe"
33fi
34
[email protected]2a949042010-10-18 18:04:0135# Test git and git --version.
36function test_git {
[email protected]4c6e4042011-06-01 18:52:3137 local GITV="$("$GIT" --version)" || {
[email protected]2a949042010-10-18 18:04:0138 echo "git isn't installed, please install it"
39 exit 1
40 }
41
42 GITV="${GITV##* }" # Only examine last word (i.e. version number)
43 local GITD=( ${GITV//./ } ) # Split version number into decimals
44 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"
46 exit 1
47 fi
48}
49
50# Test git svn and git svn --version.
51function test_git_svn {
[email protected]4c6e4042011-06-01 18:52:3152 local GITV="$("$GIT" svn --version)" || {
[email protected]2a949042010-10-18 18:04:0153 echo "git-svn isn't installed, please install it"
54 exit 1
55 }
56
57 GITV="${GITV#* version }" # git svn --version has extra output to remove.
58 GITV="${GITV% (svn*}"
59 local GITD=( ${GITV//./ } ) # Split version number into decimals
60 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"
62 exit 1
63 fi
64}
65
[email protected]31ced092011-03-14 01:37:3566# Get the current SVN revision.
67get_svn_revision() {
[email protected]4c6e4042011-06-01 18:52:3168 LANGUAGE=C "$SVN" info "$base_dir" | \
[email protected]736aefe2011-04-19 18:01:0869 awk -F': ' '{ if ($1 == "Last Changed Rev") { print $2 }}'
[email protected]31ced092011-03-14 01:37:3570}
[email protected]2a949042010-10-18 18:04:0171
[email protected]3bc36d12011-04-14 22:02:0872# Update git checkouts.
[email protected]2a949042010-10-18 18:04:0173if [ "X$DEPOT_TOOLS_UPDATE" != "X0" -a -e "$base_dir/.git" ]
74then
75 cd $base_dir
76 test_git_svn
77 # work around a git-svn --quiet bug
[email protected]4c6e4042011-06-01 18:52:3178 OUTPUT=`"$GIT" svn rebase -q -q`
[email protected]7ace24d2011-02-28 17:58:4779 if [[ ! "$OUTPUT" == *Current.branch* ]]; then
[email protected]529e97b2011-03-23 01:04:4580 echo $OUTPUT 1>&2
[email protected]2a949042010-10-18 18:04:0181 fi
82 cd - > /dev/null
83fi
84
[email protected]28e0e942011-02-23 18:49:5485# We're on POSIX. We can now safely look for svn checkout.
[email protected]2a949042010-10-18 18:04:0186if [ "X$DEPOT_TOOLS_UPDATE" != "X0" -a -e "$base_dir/.svn" ]
87then
[email protected]e6c00f32012-04-13 15:39:4988 # Update the root directory to stay up-to-date with the latest depot_tools.
[email protected]31ced092011-03-14 01:37:3589 BEFORE_REVISION=$(get_svn_revision)
[email protected]4c6e4042011-06-01 18:52:3190 "$SVN" -q up "$base_dir"
[email protected]31ced092011-03-14 01:37:3591 AFTER_REVISION=$(get_svn_revision)
92 if [[ "$BEFORE_REVISION" != "$AFTER_REVISION" ]]; then
[email protected]529e97b2011-03-23 01:04:4593 echo "Depot Tools has been updated to revision $AFTER_REVISION." 1>&2
[email protected]31ced092011-03-14 01:37:3594 fi
[email protected]2a949042010-10-18 18:04:0195fi
[email protected]81a82a92011-09-28 00:05:1596
[email protected]bda05032011-09-29 00:36:2797find "$base_dir" -iname "*.pyc" -exec rm {} \;