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 8# repository. Modified from Chromium src/third_party/libvpx/update_libvpx.sh 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 20export LC_ALL=C 21 22die() { 23 echo "@" 24 exit 1 25} 26 27# Location for the remote git repository. 28GIT_REPO="https://aomedia.googlesource.com/aom" 29 30# Update to TOT by default. 31GIT_BRANCH="origin/master" 32 33# Relative path of target checkout. 34LIBAOM_SRC_DIR="libaom" 35 36BASE_DIR=`pwd` 37 38if [ -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 45fi 46 47prev_hash="$(egrep "^Commit: [[:alnum:]]" README.android | awk '{ print $2 }')" 48echo "prev_hash:$prev_hash" 49 50rm -rf $LIBAOM_SRC_DIR 51mkdir $LIBAOM_SRC_DIR || die "Unable to create ${LIBAOM_SRC_DIR}" 52cd $LIBAOM_SRC_DIR || die "Unable to enter ${LIBAOM_SRC_DIR}" 53 54# Start a local git repo. 55git clone $GIT_REPO . 56 57# Switch the content to the desired revision. 58git checkout -b tot $GIT_BRANCH 59 60add="$(git diff-index --diff-filter=A $prev_hash | \ 61tr -s [:blank:] ' ' | cut -f6 -d\ )" 62delete="$(git diff-index --diff-filter=D $prev_hash | \ 63tr -s [:blank:] ' ' | cut -f6 -d\ )" 64 65# Get the current commit hash. 66hash=$(git log -1 --format="%H") 67 68# README reminder. 69echo "Update README.android:" 70echo "===============" 71echo "Date: $(date +"%A %B %d %Y")" 72echo "Branch: $GIT_BRANCH" 73echo "Commit: $hash" 74echo "===============" 75echo "" 76 77# Commit message header. 78echo "Commit message:" 79echo "===============" 80echo "libaom: Pull from upstream" 81echo "" 82 83# Output the current commit hash. 84echo "Current HEAD: $hash" 85echo "" 86 87# Output log for upstream from current hash. 88if [ -n "$prev_hash" ]; then 89 echo "git log from upstream:" 90 pretty_git_log="$(git log \ 91 --no-merges \ 92 --topo-order \ 93 --pretty="%h %s" \ 94 --max-count=20 \ 95 $prev_hash..$hash)" 96 if [ -z "$pretty_git_log" ]; then 97 echo "No log found. Checking for reverts." 98 pretty_git_log="$(git log \ 99 --no-merges \ 100 --topo-order \ 101 --pretty="%h %s" \ 102 --max-count=20 \ 103 $hash..$prev_hash)" 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 110else 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)" 119fi 120 121# Commit message footer. 122echo "" 123echo "===============" 124 125# Git is useless now, remove the local git repo. 126rm -rf .git .gitignore .gitattributes 127 128# Add and remove files. 129echo "$add" | xargs -I {} git add {} 130echo "$delete" | xargs -I {} git rm --ignore-unmatch {} 131 132# Find empty directories and remove them. 133find . -type d -empty -exec git rm {} \; 134 135chmod 755 build/cmake/*.sh build/cmake/*.pl 136