blob: 69fa6dbecab04d7b76de11309b43f030a97464e1 [file] [log] [blame]
Ray Essick247da042018-11-29 14:14:00 -08001#!/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.
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
22# Location for the remote git repository.
23GIT_REPO="https://aomedia.googlesource.com/aom"
24
25# Update to TOT by default.
26GIT_BRANCH="origin/master"
27
28# Relative path of target checkout.
29LIBAOM_SRC_DIR="libaom"
30
31BASE_DIR=`pwd`
32
33if [ -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
40fi
41
42prev_hash="$(egrep "^Commit: [[:alnum:]]" README.android | awk '{ print $2 }')"
43echo "prev_hash:$prev_hash"
44
45rm -rf $LIBAOM_SRC_DIR
46# be robust in the face of errors (meaning don't overwrite the wrong place)
47mkdir $LIBAOM_SRC_DIR || exit 1
48cd $LIBAOM_SRC_DIR || exit 1
49
50# Start a local git repo.
51git clone $GIT_REPO .
52
53# Switch the content to the desired revision.
54git checkout -b tot $GIT_BRANCH
55
56add="$(git diff-index --diff-filter=A $prev_hash | \
57tr -s [:blank:] ' ' | cut -f6 -d\ )"
58delete="$(git diff-index --diff-filter=D $prev_hash | \
59tr -s [:blank:] ' ' | cut -f6 -d\ )"
60
61# Get the current commit hash.
62hash=$(git log -1 --format="%H")
63
64# README reminder.
65(
66 # keep meta info / header
67 sed -n '0,/^====/p' < ../README.android
68
69 # sed kept it in there
70 #echo "========"
71
72 echo "Date: $(date +"%A %B %d %Y")"
73 echo "Branch: $GIT_BRANCH"
74 echo "Commit: $hash"
75 echo ""
76) > ../update.$$-README.android
77cat ../update.$$-README.android
78mv ../update.$$-README.android ../README.android
79
80# Commit message header.
81COMMIT_MSG=../commit-message-`date +"%Y%m%d.%H%M%S"`
82(
83 echo "libaom: Pull from upstream"
84 echo ""
85
86 # Output the current commit hash.
87 echo "Prev HEAD: $prev_hash"
88 echo "New HEAD: $hash"
89 echo ""
90
91 # Output log for upstream from current hash.
92 if [ -n "$prev_hash" ]; then
93 echo "git log from upstream:"
94 pretty_git_log="$(git log \
95 --no-merges \
96 --topo-order \
97 --pretty="%h %s" \
98 --max-count=20 \
99 $prev_hash..$hash)"
100 if [ -z "$pretty_git_log" ]; then
101 echo "No log found. Checking for reverts."
102 pretty_git_log="$(git log \
103 --no-merges \
104 --topo-order \
105 --pretty="%h %s" \
106 --max-count=20 \
107 $hash..$prev_hash)"
108 fi
109 echo "$pretty_git_log"
110 # If it makes it to 20 then it's probably skipping even more.
111 if [ `echo "$pretty_git_log" | wc -l` -eq 20 ]; then
112 echo "<...>"
113 fi
114 else
115 # no previous hash
116 echo "git log from upstream:"
117 pretty_git_log="$(git log \
118 --no-merges \
119 --topo-order \
120 --pretty="%h %s" \
121 --max-count=20)"
122 if [ -z "$pretty_git_log" ]; then
123 echo "No log found. Checking for reverts."
124 fi
125 echo "$pretty_git_log"
126 # If it makes it to 20 then it's probably skipping even more.
127 if [ `echo "$pretty_git_log" | wc -l` -eq 20 ]; then
128 echo "<...>"
129 fi
130 fi
131) > ${COMMIT_MSG}
132
133# Tell user about it
134echo "Commit message: (stored in ./${COMMIT_MSG})"
135echo "==============="
136cat ${COMMIT_MSG}
137echo ""
138echo "==============="
139
140# Git is useless now, remove the local git repo.
141rm -rf .git .gitignore .gitattributes
142
143# Add and remove files.
144echo "$add" | xargs -I {} git add {}
145echo "$delete" | xargs -I {} git rm --ignore-unmatch {}
146
147# Find empty directories and remove them.
148find . -type d -empty -exec git rm {} \;
149
150chmod 755 build/cmake/*.sh build/cmake/*.pl
151
152# not even sure why we're doing a chdir here as the last thing in the script
153# it isn't going to make any difference semantically.
154cd $BASE_DIR || exit 1