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