Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / libvpx / update_libvpx.sh
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 #
14 # $ ./update_libvpx.sh [branch | revision | file or url containing a revision]
15 # When specifying a branch it may be necessary to prefix with origin/
16
17 # Tools required for running this tool:
18 #
19 # 1. Linux / Mac
20 # 2. svn
21 # 3. git
22
23 export LC_ALL=C
24
25 # Location for the remote git repository.
26 GIT_REPO="http://git.chromium.org/webm/libvpx.git"
27
28 GIT_BRANCH="origin/master"
29 LIBVPX_SRC_DIR="source/libvpx"
30 BASE_DIR=`pwd`
31
32 if [ -n "$1" ]; then
33   GIT_BRANCH="$1"
34   if [ -f "$1"  ]; then
35     GIT_BRANCH=$(<"$1")
36   elif [[ $1 = http* ]]; then
37     GIT_BRANCH=`curl $1`
38   fi
39 fi
40
41 prev_hash="$(egrep "^Commit: [[:alnum:]]" README.chromium | awk '{ print $2 }')"
42 echo "prev_hash:$prev_hash"
43
44 rm -rf $(svn ls $LIBVPX_SRC_DIR)
45 svn update $LIBVPX_SRC_DIR
46
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
61 add="$(git diff-index --diff-filter=D $GIT_BRANCH | \
62 tr -s '\t' ' ' | cut -f6 -d\ )"
63 delete="$(git diff-index --diff-filter=A $GIT_BRANCH | \
64 tr -s '\t' ' ' | cut -f6 -d\ )"
65
66 # Switch the content to the latest git repo.
67 git checkout -b tot $GIT_BRANCH
68
69 # Output the current commit hash.
70 hash=$(git log -1 --format="%H")
71 echo "Current HEAD: $hash"
72
73 # Output log for upstream from current hash.
74 if [ -n "$prev_hash" ]; then
75   echo "git log from upstream:"
76   pretty_git_log="$(git log \
77                     --no-merges \
78                     --topo-order \
79                     --pretty="%h %s" \
80                     $prev_hash..$hash)"
81   if [ -z "$pretty_git_log" ]; then
82     echo "No log found. Checking for reverts."
83     pretty_git_log="$(git log \
84                       --no-merges \
85                       --topo-order \
86                       --pretty="%h %s" \
87                       $hash..$prev_hash)"
88   fi
89   echo "$pretty_git_log"
90 fi
91
92 # Git is useless now, remove the local git repo.
93 rm -rf .git
94
95 # Update SVN with the added and deleted files.
96 echo "$add" | xargs -I {} svn add --parents {}
97 echo "$delete" | xargs -I {} svn rm {}
98
99 # Find empty directories and remove them from SVN.
100 find . -type d -empty -not -iwholename '*.svn*' -exec svn rm {} \;
101
102 chmod 755 build/make/*.sh build/make/*.pl configure
103
104 cd $BASE_DIR