Dirk Vogt | 545b348 | 2016-02-18 19:30:26 +0100 | [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 to a revision of the upstream |
| 8 | # repository. Modified from Chromium src/third_party/libvpx/update_libvpx.sh |
| 9 | |
| 10 | # Usage: |
| 11 | # |
| 12 | # $ ./update_libvpx.sh [branch | revision | file or url containing a revision] |
| 13 | # When specifying a branch it must be prefixed with origin/ |
| 14 | |
| 15 | # Tools required for running this tool: |
| 16 | # |
| 17 | # 1. Linux / Mac |
| 18 | # 2. git |
| 19 | |
| 20 | export LC_ALL=C |
| 21 | |
| 22 | # Location for the remote git repository. |
| 23 | GIT_REPO="https://chromium.googlesource.com/webm/libvpx" |
| 24 | |
| 25 | # Update to TOT by default. |
| 26 | GIT_BRANCH="origin/master" |
| 27 | |
| 28 | # Relative path of target checkout. |
| 29 | LIBVPX_SRC_DIR="libvpx" |
| 30 | |
| 31 | BASE_DIR=`pwd` |
| 32 | |
| 33 | if [ -n "$1" ]; then |
| 34 | GIT_BRANCH="$1" |
| 35 | if [ -f "$1" ]; then |
| 36 | GIT_BRANCH=$(<"$1") |
| 37 | elif [[ $1 = http* ]]; then |
| 38 | GIT_BRANCH=`curl $1` |
| 39 | fi |
| 40 | fi |
| 41 | |
| 42 | prev_hash="$(egrep "^Commit: [[:alnum:]]" README.android | awk '{ print $2 }')" |
| 43 | echo "prev_hash:$prev_hash" |
| 44 | |
| 45 | rm -rf $LIBVPX_SRC_DIR |
| 46 | mkdir $LIBVPX_SRC_DIR |
| 47 | cd $LIBVPX_SRC_DIR |
| 48 | |
| 49 | # Start a local git repo. |
| 50 | git clone $GIT_REPO . |
| 51 | |
| 52 | # Switch the content to the desired revision. |
| 53 | git checkout -b tot $GIT_BRANCH |
| 54 | |
| 55 | add="$(git diff-index --diff-filter=A $prev_hash | \ |
| 56 | tr -s [:blank:] ' ' | cut -f6 -d\ )" |
| 57 | delete="$(git diff-index --diff-filter=D $prev_hash | \ |
| 58 | tr -s [:blank:] ' ' | cut -f6 -d\ )" |
| 59 | |
| 60 | # Get the current commit hash. |
| 61 | hash=$(git log -1 --format="%H") |
| 62 | |
| 63 | # README reminder. |
| 64 | echo "Update README.android:" |
| 65 | echo "===============" |
| 66 | echo "Date: $(date +"%A %B %d %Y")" |
| 67 | echo "Branch: $GIT_BRANCH" |
| 68 | echo "Commit: $hash" |
| 69 | echo "===============" |
| 70 | echo "" |
| 71 | |
| 72 | # Commit message header. |
| 73 | echo "Commit message:" |
| 74 | echo "===============" |
| 75 | echo "libvpx: Pull from upstream" |
| 76 | echo "" |
| 77 | |
| 78 | # Output the current commit hash. |
| 79 | echo "Current HEAD: $hash" |
| 80 | echo "" |
| 81 | |
| 82 | # Output log for upstream from current hash. |
| 83 | if [ -n "$prev_hash" ]; then |
| 84 | echo "git log from upstream:" |
| 85 | pretty_git_log="$(git log \ |
| 86 | --no-merges \ |
| 87 | --topo-order \ |
| 88 | --pretty="%h %s" \ |
| 89 | --max-count=20 \ |
| 90 | $prev_hash..$hash)" |
| 91 | if [ -z "$pretty_git_log" ]; then |
| 92 | echo "No log found. Checking for reverts." |
| 93 | pretty_git_log="$(git log \ |
| 94 | --no-merges \ |
| 95 | --topo-order \ |
| 96 | --pretty="%h %s" \ |
| 97 | --max-count=20 \ |
| 98 | $hash..$prev_hash)" |
| 99 | fi |
| 100 | echo "$pretty_git_log" |
| 101 | # If it makes it to 20 then it's probably skipping even more. |
| 102 | if [ `echo "$pretty_git_log" | wc -l` -eq 20 ]; then |
| 103 | echo "<...>" |
| 104 | fi |
| 105 | fi |
| 106 | |
| 107 | # Commit message footer. |
| 108 | echo "" |
| 109 | echo "===============" |
| 110 | |
| 111 | # Git is useless now, remove the local git repo. |
| 112 | rm -rf .git .gitignore .gitattributes |
| 113 | |
| 114 | # Add and remove files. |
| 115 | echo "$add" | xargs -I {} git add {} |
| 116 | echo "$delete" | xargs -I {} git rm {} |
| 117 | |
| 118 | # Find empty directories and remove them. |
| 119 | find . -type d -empty -exec git rm {} \; |
| 120 | |
| 121 | chmod 755 build/make/*.sh build/make/*.pl configure |
| 122 | |
| 123 | cd $BASE_DIR |