hclam@chromium.org | 2ddf8a3 | 2012-06-04 21:48:58 +0000 | [diff] [blame] | 1 | #!/bin/bash -e |
| 2 | # |
| 3 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | # This tool is used to update libvpx source code with the latest git |
| 8 | # repository. |
| 9 | # |
| 10 | # Make sure you run this in a svn checkout of deps/third_party/libvpx! |
| 11 | |
| 12 | # Usage: |
| 13 | # |
johannkoenig@chromium.org | 7765c07 | 2014-05-16 15:51:21 +0000 | [diff] [blame] | 14 | # $ ./update_libvpx.sh [branch | revision | file or url containing a revision] |
johannkoenig@chromium.org | ebb1c50 | 2014-04-10 22:49:18 +0000 | [diff] [blame] | 15 | # When specifying a branch it may be necessary to prefix with origin/ |
hclam@chromium.org | 2ddf8a3 | 2012-06-04 21:48:58 +0000 | [diff] [blame] | 16 | |
| 17 | # Tools required for running this tool: |
| 18 | # |
| 19 | # 1. Linux / Mac |
| 20 | # 2. svn |
| 21 | # 3. git |
| 22 | |
tomfinegan@chromium.org | a7ffde1 | 2014-03-28 00:05:23 +0000 | [diff] [blame] | 23 | export LC_ALL=C |
| 24 | |
hclam@chromium.org | 2ddf8a3 | 2012-06-04 21:48:58 +0000 | [diff] [blame] | 25 | # Location for the remote git repository. |
| 26 | GIT_REPO="http://git.chromium.org/webm/libvpx.git" |
| 27 | |
johannkoenig@chromium.org | ebb1c50 | 2014-04-10 22:49:18 +0000 | [diff] [blame] | 28 | GIT_BRANCH="origin/master" |
hclam@chromium.org | 2ddf8a3 | 2012-06-04 21:48:58 +0000 | [diff] [blame] | 29 | LIBVPX_SRC_DIR="source/libvpx" |
| 30 | BASE_DIR=`pwd` |
| 31 | |
hclam@chromium.org | c1e5cf4 | 2012-06-04 22:34:54 +0000 | [diff] [blame] | 32 | if [ -n "$1" ]; then |
| 33 | GIT_BRANCH="$1" |
johannkoenig@chromium.org | ebb1c50 | 2014-04-10 22:49:18 +0000 | [diff] [blame] | 34 | if [ -f "$1" ]; then |
| 35 | GIT_BRANCH=$(<"$1") |
johannkoenig@chromium.org | 7765c07 | 2014-05-16 15:51:21 +0000 | [diff] [blame] | 36 | elif [[ $1 = http* ]]; then |
| 37 | GIT_BRANCH=`curl $1` |
johannkoenig@chromium.org | ebb1c50 | 2014-04-10 22:49:18 +0000 | [diff] [blame] | 38 | fi |
hclam@chromium.org | c1e5cf4 | 2012-06-04 22:34:54 +0000 | [diff] [blame] | 39 | fi |
| 40 | |
johannkoenig@chromium.org | 93a7479 | 2014-04-10 17:14:25 +0000 | [diff] [blame] | 41 | prev_hash="$(egrep "^Commit: [[:alnum:]]" README.chromium | awk '{ print $2 }')" |
fgalligan@chromium.org | 36504e6 | 2012-12-20 16:13:37 +0000 | [diff] [blame] | 42 | echo "prev_hash:$prev_hash" |
| 43 | |
hclam@chromium.org | 5553ee2 | 2012-07-23 18:46:58 +0000 | [diff] [blame] | 44 | rm -rf $(svn ls $LIBVPX_SRC_DIR) |
| 45 | svn update $LIBVPX_SRC_DIR |
| 46 | |
hclam@chromium.org | 2ddf8a3 | 2012-06-04 21:48:58 +0000 | [diff] [blame] | 47 | cd $LIBVPX_SRC_DIR |
| 48 | |
| 49 | # Make sure git doesn't mess up with svn. |
| 50 | echo ".svn" >> .gitignore |
| 51 | |
| 52 | # Start a local git repo. |
| 53 | git init |
| 54 | git add . |
| 55 | git commit -a -m "Current libvpx" |
| 56 | |
| 57 | # Add the remote repo. |
| 58 | git remote add origin $GIT_REPO |
| 59 | git fetch |
| 60 | |
johannkoenig@chromium.org | ebb1c50 | 2014-04-10 22:49:18 +0000 | [diff] [blame] | 61 | add="$(git diff-index --diff-filter=D $GIT_BRANCH | \ |
hclam@chromium.org | 2ddf8a3 | 2012-06-04 21:48:58 +0000 | [diff] [blame] | 62 | tr -s '\t' ' ' | cut -f6 -d\ )" |
johannkoenig@chromium.org | ebb1c50 | 2014-04-10 22:49:18 +0000 | [diff] [blame] | 63 | delete="$(git diff-index --diff-filter=A $GIT_BRANCH | \ |
hclam@chromium.org | 2ddf8a3 | 2012-06-04 21:48:58 +0000 | [diff] [blame] | 64 | tr -s '\t' ' ' | cut -f6 -d\ )" |
| 65 | |
| 66 | # Switch the content to the latest git repo. |
johannkoenig@chromium.org | ebb1c50 | 2014-04-10 22:49:18 +0000 | [diff] [blame] | 67 | git checkout -b tot $GIT_BRANCH |
hclam@chromium.org | 2ddf8a3 | 2012-06-04 21:48:58 +0000 | [diff] [blame] | 68 | |
fgalligan@chromium.org | ff46d66 | 2012-12-14 19:21:34 +0000 | [diff] [blame] | 69 | # Output the current commit hash. |
| 70 | hash=$(git log -1 --format="%H") |
fgalligan@chromium.org | 36504e6 | 2012-12-20 16:13:37 +0000 | [diff] [blame] | 71 | echo "Current HEAD: $hash" |
| 72 | |
| 73 | # Output log for upstream from current hash. |
fgalligan@chromium.org | 36504e6 | 2012-12-20 16:13:37 +0000 | [diff] [blame] | 74 | if [ -n "$prev_hash" ]; then |
| 75 | echo "git log from upstream:" |
johannkoenig@chromium.org | 17fcbf6 | 2014-09-09 20:59:27 +0000 | [diff] [blame] | 76 | pretty_git_log="$(git log \ |
| 77 | --no-merges \ |
| 78 | --topo-order \ |
| 79 | --pretty="%h %s" \ |
| 80 | $prev_hash..$hash)" |
johannkoenig@chromium.org | ebb1c50 | 2014-04-10 22:49:18 +0000 | [diff] [blame] | 81 | if [ -z "$pretty_git_log" ]; then |
| 82 | echo "No log found. Checking for reverts." |
johannkoenig@chromium.org | 17fcbf6 | 2014-09-09 20:59:27 +0000 | [diff] [blame] | 83 | pretty_git_log="$(git log \ |
| 84 | --no-merges \ |
| 85 | --topo-order \ |
| 86 | --pretty="%h %s" \ |
| 87 | $hash..$prev_hash)" |
johannkoenig@chromium.org | ebb1c50 | 2014-04-10 22:49:18 +0000 | [diff] [blame] | 88 | fi |
fgalligan@chromium.org | 36504e6 | 2012-12-20 16:13:37 +0000 | [diff] [blame] | 89 | echo "$pretty_git_log" |
| 90 | fi |
fgalligan@chromium.org | ff46d66 | 2012-12-14 19:21:34 +0000 | [diff] [blame] | 91 | |
hclam@chromium.org | 2ddf8a3 | 2012-06-04 21:48:58 +0000 | [diff] [blame] | 92 | # Git is useless now, remove the local git repo. |
| 93 | rm -rf .git |
| 94 | |
| 95 | # Update SVN with the added and deleted files. |
fgalligan@chromium.org | 36504e6 | 2012-12-20 16:13:37 +0000 | [diff] [blame] | 96 | echo "$add" | xargs -I {} svn add --parents {} |
| 97 | echo "$delete" | xargs -I {} svn rm {} |
hclam@chromium.org | 2ddf8a3 | 2012-06-04 21:48:58 +0000 | [diff] [blame] | 98 | |
| 99 | # Find empty directories and remove them from SVN. |
| 100 | find . -type d -empty -not -iwholename '*.svn*' -exec svn rm {} \; |
| 101 | |
hclam@chromium.org | 5553ee2 | 2012-07-23 18:46:58 +0000 | [diff] [blame] | 102 | chmod 755 build/make/*.sh build/make/*.pl configure |
| 103 | |
hclam@chromium.org | 2ddf8a3 | 2012-06-04 21:48:58 +0000 | [diff] [blame] | 104 | cd $BASE_DIR |