blob: e5b87f17e096ee2be96fbc51cb63429750ab2c99 [file] [log] [blame]
Dan Albert8420be92016-08-15 13:22:07 -07001#!/bin/bash
2DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3cd $DIR
4
5which versioner >/dev/null 2>&1
6if [ $? -ne 0 ]; then
7 >&2 echo "versioner not in path; run mma in $DIR/versioner"
8 exit 1
9fi
10
11VERSION=$(git rev-parse --short HEAD)
12git diff-index --quiet HEAD
13DIRTY=$?
14git branch -r --contains HEAD | grep -q aosp/master
15SUBMITTED=$?
16
17if [ $DIRTY -ne 0 ]; then
18 >&2 echo "Warning: bionic has uncommitted changes"
19 VERSION="${VERSION}-dirty"
20elif [ $SUBMITTED -ne 0 ]; then
21 >&2 echo "Warning: current HEAD does not exist in aosp/master"
22 VERSION="${VERSION}-unsubmitted"
23fi
24
25PREBUILTS_DIR=$ANDROID_BUILD_TOP/prebuilts/ndk
26BRANCH_NAME=$(git -C $PREBUILTS_DIR symbolic-ref --short -q HEAD)
27if [ $? -ne 0 ]; then
28 BRANCH_NAME=update-bionic-headers-$VERSION
29 echo "prebuilts/ndk has detached head; creating branch $BRANCH_NAME"
30 repo start $BRANCH_NAME $PREBUILTS_DIR
31else
32 echo "prebuilts/ndk already on branch $BRANCH_NAME"
33fi
34
35HEADERS_INSTALL=$PREBUILTS_DIR/headers
36if [ -d "$HEADERS_INSTALL" ]; then
37 git -C $PREBUILTS_DIR rm -r --ignore-unmatch $HEADERS_INSTALL
38 rm -r $HEADERS_INSTALL
39fi
40
41versioner -p versioner/platforms versioner/current versioner/dependencies \
42 -o $HEADERS_INSTALL
43
Dan Albertae50e9d2016-10-20 12:45:03 -070044cp ../libc/NOTICE $PREBUILTS_DIR
45
46git -C $PREBUILTS_DIR add $HEADERS_INSTALL $PREBUILTS_DIR/NOTICE
Dan Albert8420be92016-08-15 13:22:07 -070047git -C $PREBUILTS_DIR commit -m "Update bionic headers to $VERSION."