blob: d0a7a84a8f100028cc9a616236d7c412902ed769 [file] [log] [blame]
hclam@chromium.org2ddf8a32012-06-04 21:48:58 +00001#!/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.org7765c072014-05-16 15:51:21 +000014# $ ./update_libvpx.sh [branch | revision | file or url containing a revision]
johannkoenig@chromium.orgebb1c502014-04-10 22:49:18 +000015# When specifying a branch it may be necessary to prefix with origin/
hclam@chromium.org2ddf8a32012-06-04 21:48:58 +000016
17# Tools required for running this tool:
18#
19# 1. Linux / Mac
20# 2. svn
21# 3. git
22
tomfinegan@chromium.orga7ffde12014-03-28 00:05:23 +000023export LC_ALL=C
24
hclam@chromium.org2ddf8a32012-06-04 21:48:58 +000025# Location for the remote git repository.
26GIT_REPO="http://git.chromium.org/webm/libvpx.git"
27
johannkoenig@chromium.orgebb1c502014-04-10 22:49:18 +000028GIT_BRANCH="origin/master"
hclam@chromium.org2ddf8a32012-06-04 21:48:58 +000029LIBVPX_SRC_DIR="source/libvpx"
30BASE_DIR=`pwd`
31
hclam@chromium.orgc1e5cf42012-06-04 22:34:54 +000032if [ -n "$1" ]; then
33 GIT_BRANCH="$1"
johannkoenig@chromium.orgebb1c502014-04-10 22:49:18 +000034 if [ -f "$1" ]; then
35 GIT_BRANCH=$(<"$1")
johannkoenig@chromium.org7765c072014-05-16 15:51:21 +000036 elif [[ $1 = http* ]]; then
37 GIT_BRANCH=`curl $1`
johannkoenig@chromium.orgebb1c502014-04-10 22:49:18 +000038 fi
hclam@chromium.orgc1e5cf42012-06-04 22:34:54 +000039fi
40
johannkoenig@chromium.org93a74792014-04-10 17:14:25 +000041prev_hash="$(egrep "^Commit: [[:alnum:]]" README.chromium | awk '{ print $2 }')"
fgalligan@chromium.org36504e62012-12-20 16:13:37 +000042echo "prev_hash:$prev_hash"
43
hclam@chromium.org5553ee22012-07-23 18:46:58 +000044rm -rf $(svn ls $LIBVPX_SRC_DIR)
45svn update $LIBVPX_SRC_DIR
46
hclam@chromium.org2ddf8a32012-06-04 21:48:58 +000047cd $LIBVPX_SRC_DIR
48
49# Make sure git doesn't mess up with svn.
50echo ".svn" >> .gitignore
51
52# Start a local git repo.
53git init
54git add .
55git commit -a -m "Current libvpx"
56
57# Add the remote repo.
58git remote add origin $GIT_REPO
59git fetch
60
johannkoenig@chromium.orgebb1c502014-04-10 22:49:18 +000061add="$(git diff-index --diff-filter=D $GIT_BRANCH | \
hclam@chromium.org2ddf8a32012-06-04 21:48:58 +000062tr -s '\t' ' ' | cut -f6 -d\ )"
johannkoenig@chromium.orgebb1c502014-04-10 22:49:18 +000063delete="$(git diff-index --diff-filter=A $GIT_BRANCH | \
hclam@chromium.org2ddf8a32012-06-04 21:48:58 +000064tr -s '\t' ' ' | cut -f6 -d\ )"
65
66# Switch the content to the latest git repo.
johannkoenig@chromium.orgebb1c502014-04-10 22:49:18 +000067git checkout -b tot $GIT_BRANCH
hclam@chromium.org2ddf8a32012-06-04 21:48:58 +000068
fgalligan@chromium.orgff46d662012-12-14 19:21:34 +000069# Output the current commit hash.
70hash=$(git log -1 --format="%H")
fgalligan@chromium.org36504e62012-12-20 16:13:37 +000071echo "Current HEAD: $hash"
72
73# Output log for upstream from current hash.
fgalligan@chromium.org36504e62012-12-20 16:13:37 +000074if [ -n "$prev_hash" ]; then
75 echo "git log from upstream:"
johannkoenig@chromium.org17fcbf62014-09-09 20:59:27 +000076 pretty_git_log="$(git log \
77 --no-merges \
78 --topo-order \
79 --pretty="%h %s" \
80 $prev_hash..$hash)"
johannkoenig@chromium.orgebb1c502014-04-10 22:49:18 +000081 if [ -z "$pretty_git_log" ]; then
82 echo "No log found. Checking for reverts."
johannkoenig@chromium.org17fcbf62014-09-09 20:59:27 +000083 pretty_git_log="$(git log \
84 --no-merges \
85 --topo-order \
86 --pretty="%h %s" \
87 $hash..$prev_hash)"
johannkoenig@chromium.orgebb1c502014-04-10 22:49:18 +000088 fi
fgalligan@chromium.org36504e62012-12-20 16:13:37 +000089 echo "$pretty_git_log"
90fi
fgalligan@chromium.orgff46d662012-12-14 19:21:34 +000091
hclam@chromium.org2ddf8a32012-06-04 21:48:58 +000092# Git is useless now, remove the local git repo.
93rm -rf .git
94
95# Update SVN with the added and deleted files.
fgalligan@chromium.org36504e62012-12-20 16:13:37 +000096echo "$add" | xargs -I {} svn add --parents {}
97echo "$delete" | xargs -I {} svn rm {}
hclam@chromium.org2ddf8a32012-06-04 21:48:58 +000098
99# Find empty directories and remove them from SVN.
100find . -type d -empty -not -iwholename '*.svn*' -exec svn rm {} \;
101
hclam@chromium.org5553ee22012-07-23 18:46:58 +0000102chmod 755 build/make/*.sh build/make/*.pl configure
103
hclam@chromium.org2ddf8a32012-06-04 21:48:58 +0000104cd $BASE_DIR