xref: /aosp_15_r20/external/libvpx/update_libvpx.sh (revision fb1b10ab9aebc7c7068eedab379b749d7e3900be)
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 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://chromium.googlesource.com/webm/libvpx"
29
30# Update to TOT by default.
31GIT_BRANCH="main"
32
33BASE_DIR=`pwd`
34
35if [ -n "$1" ]; then
36  GIT_BRANCH="$1"
37  if [ -f "$1"  ]; then
38    GIT_BRANCH=$(<"$1")
39  elif [[ $1 = http* ]]; then
40    GIT_BRANCH=`curl $1`
41  fi
42fi
43
44prev_hash="$(egrep "^Commit: [[:alnum:]]" README.android | awk '{ print $2 }')"
45echo "prev_hash:$prev_hash"
46
47REMOTE="update_upstream"
48
49# Add a remote for upstream git repository
50git remote add $REMOTE $GIT_REPO
51
52# Fetch remote's GIT_BRANCH
53git fetch $REMOTE $GIT_BRANCH --tags
54
55# Get commit id corresponding to branch/revision in upstream repository
56REMOTE_BRANCHES="$(git remote show $REMOTE)"
57
58if [[ "$REMOTE_BRANCHES" == *"$GIT_BRANCH"* ]]; then
59  UPSTREAM_COMMIT=$(git rev-list -n 1 $REMOTE/$GIT_BRANCH)
60else
61  UPSTREAM_COMMIT=$(git rev-list -n 1 $GIT_BRANCH)
62fi
63
64[ -z "$UPSTREAM_COMMIT" ] \
65  && die "Unable to get upstream commit corresponding to ${GIT_BRANCH}";
66
67git merge $UPSTREAM_COMMIT
68
69# Get the current commit hash.
70hash=$(git log $UPSTREAM_COMMIT -1 --format="%H")
71
72# README reminder.
73echo "Update README.android:"
74echo "==============="
75echo "Date: $(date +"%A %B %d %Y")"
76echo "Branch: $GIT_BRANCH"
77echo "Commit: $hash"
78echo "==============="
79echo ""
80
81# Remove the remote added earlier
82git remote remove $REMOTE
83
84cd $BASE_DIR
85