Ray Essick | 247da04 | 2018-11-29 14:14:00 -0800 | [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 libaom source code to a revision of the upstream |
Johann | 39f1322 | 2019-01-09 11:48:14 -0800 | [diff] [blame] | 8 | # repository. Modified from Chromium src/third_party/libvpx/update_libvpx.sh |
Ray Essick | 247da04 | 2018-11-29 14:14:00 -0800 | [diff] [blame] | 9 | |
| 10 | # Usage: |
| 11 | # |
| 12 | # $ ./update_libaom.sh [branch | revision | file or url containing a revision] |
| 13 | # When specifying a branch it may be necessary to prefix 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 | |
Johann | 39f1322 | 2019-01-09 11:48:14 -0800 | [diff] [blame] | 22 | die() { |
| 23 | echo "@" |
| 24 | exit 1 |
| 25 | } |
| 26 | |
Ray Essick | 247da04 | 2018-11-29 14:14:00 -0800 | [diff] [blame] | 27 | # Location for the remote git repository. |
| 28 | GIT_REPO="https://aomedia.googlesource.com/aom" |
| 29 | |
| 30 | # Update to TOT by default. |
| 31 | GIT_BRANCH="origin/master" |
| 32 | |
| 33 | # Relative path of target checkout. |
| 34 | LIBAOM_SRC_DIR="libaom" |
| 35 | |
| 36 | BASE_DIR=`pwd` |
| 37 | |
| 38 | if [ -n "$1" ]; then |
| 39 | GIT_BRANCH="$1" |
| 40 | if [ -f "$1" ]; then |
| 41 | GIT_BRANCH=$(<"$1") |
| 42 | elif [[ $1 = http* ]]; then |
| 43 | GIT_BRANCH=`curl $1` |
| 44 | fi |
| 45 | fi |
| 46 | |
| 47 | prev_hash="$(egrep "^Commit: [[:alnum:]]" README.android | awk '{ print $2 }')" |
| 48 | echo "prev_hash:$prev_hash" |
| 49 | |
| 50 | rm -rf $LIBAOM_SRC_DIR |
Johann | 39f1322 | 2019-01-09 11:48:14 -0800 | [diff] [blame] | 51 | mkdir $LIBAOM_SRC_DIR || die "Unable to create ${LIBAOM_SRC_DIR}" |
| 52 | cd $LIBAOM_SRC_DIR || die "Unable to enter ${LIBAOM_SRC_DIR}" |
Ray Essick | 247da04 | 2018-11-29 14:14:00 -0800 | [diff] [blame] | 53 | |
| 54 | # Start a local git repo. |
| 55 | git clone $GIT_REPO . |
| 56 | |
| 57 | # Switch the content to the desired revision. |
| 58 | git checkout -b tot $GIT_BRANCH |
| 59 | |
| 60 | add="$(git diff-index --diff-filter=A $prev_hash | \ |
| 61 | tr -s [:blank:] ' ' | cut -f6 -d\ )" |
| 62 | delete="$(git diff-index --diff-filter=D $prev_hash | \ |
| 63 | tr -s [:blank:] ' ' | cut -f6 -d\ )" |
| 64 | |
| 65 | # Get the current commit hash. |
| 66 | hash=$(git log -1 --format="%H") |
| 67 | |
| 68 | # README reminder. |
Johann | 39f1322 | 2019-01-09 11:48:14 -0800 | [diff] [blame] | 69 | echo "Update README.android:" |
| 70 | echo "===============" |
| 71 | echo "Date: $(date +"%A %B %d %Y")" |
| 72 | echo "Branch: $GIT_BRANCH" |
| 73 | echo "Commit: $hash" |
| 74 | echo "===============" |
| 75 | echo "" |
Ray Essick | 247da04 | 2018-11-29 14:14:00 -0800 | [diff] [blame] | 76 | |
| 77 | # Commit message header. |
Johann | 39f1322 | 2019-01-09 11:48:14 -0800 | [diff] [blame] | 78 | echo "Commit message:" |
| 79 | echo "===============" |
| 80 | echo "libaom: Pull from upstream" |
| 81 | echo "" |
Ray Essick | 247da04 | 2018-11-29 14:14:00 -0800 | [diff] [blame] | 82 | |
Johann | 39f1322 | 2019-01-09 11:48:14 -0800 | [diff] [blame] | 83 | # Output the current commit hash. |
| 84 | echo "Current HEAD: $hash" |
| 85 | echo "" |
Ray Essick | 247da04 | 2018-11-29 14:14:00 -0800 | [diff] [blame] | 86 | |
Johann | 39f1322 | 2019-01-09 11:48:14 -0800 | [diff] [blame] | 87 | # Output log for upstream from current hash. |
| 88 | if [ -n "$prev_hash" ]; then |
| 89 | echo "git log from upstream:" |
| 90 | pretty_git_log="$(git log \ |
Ray Essick | 247da04 | 2018-11-29 14:14:00 -0800 | [diff] [blame] | 91 | --no-merges \ |
| 92 | --topo-order \ |
| 93 | --pretty="%h %s" \ |
| 94 | --max-count=20 \ |
| 95 | $prev_hash..$hash)" |
Johann | 39f1322 | 2019-01-09 11:48:14 -0800 | [diff] [blame] | 96 | if [ -z "$pretty_git_log" ]; then |
| 97 | echo "No log found. Checking for reverts." |
| 98 | pretty_git_log="$(git log \ |
Ray Essick | 247da04 | 2018-11-29 14:14:00 -0800 | [diff] [blame] | 99 | --no-merges \ |
| 100 | --topo-order \ |
| 101 | --pretty="%h %s" \ |
| 102 | --max-count=20 \ |
| 103 | $hash..$prev_hash)" |
Johann | 39f1322 | 2019-01-09 11:48:14 -0800 | [diff] [blame] | 104 | fi |
| 105 | echo "$pretty_git_log" |
| 106 | # If it makes it to 20 then it's probably skipping even more. |
| 107 | if [ `echo "$pretty_git_log" | wc -l` -eq 20 ]; then |
| 108 | echo "<...>" |
| 109 | fi |
| 110 | else |
| 111 | # no previous hash |
| 112 | echo "git log from upstream:" |
| 113 | pretty_git_log="$(git log \ |
| 114 | --no-merges \ |
| 115 | --topo-order \ |
| 116 | --pretty="%h %s" \ |
| 117 | --max-count=20 \ |
| 118 | $hash)" |
| 119 | fi |
Ray Essick | 247da04 | 2018-11-29 14:14:00 -0800 | [diff] [blame] | 120 | |
Johann | 39f1322 | 2019-01-09 11:48:14 -0800 | [diff] [blame] | 121 | # Commit message footer. |
Ray Essick | 247da04 | 2018-11-29 14:14:00 -0800 | [diff] [blame] | 122 | echo "" |
| 123 | echo "===============" |
| 124 | |
| 125 | # Git is useless now, remove the local git repo. |
| 126 | rm -rf .git .gitignore .gitattributes |
| 127 | |
| 128 | # Add and remove files. |
| 129 | echo "$add" | xargs -I {} git add {} |
| 130 | echo "$delete" | xargs -I {} git rm --ignore-unmatch {} |
| 131 | |
| 132 | # Find empty directories and remove them. |
| 133 | find . -type d -empty -exec git rm {} \; |
| 134 | |
| 135 | chmod 755 build/cmake/*.sh build/cmake/*.pl |