1#!/bin/bash
2# fetch, check & extract the current vendor package
3set -e
4
5DIR_PARENT=$(cd $(dirname $0); pwd)
6if [ -z "${ANDROID_BUILD_TOP}" ]; then
7    ANDROID_BUILD_TOP=$(cd ${DIR_PARENT}/../../../; pwd)
8fi
9
10. "${ANDROID_BUILD_TOP}/device/linaro/hikey/vendor-package-ver.sh"
11
12PKG_FILE=extract-linaro_devices-${EXPECTED_LINARO_VENDOR_VERSION}
13
14pushd ${ANDROID_BUILD_TOP}
15
16# remove the older vendor-package, if any, because upstream
17# mesa prebuilts in linaro-vendor-package ain't declared
18# within a contained namespace and we can run into build
19# errors because of redefinition of mesa prebuilt modules
20# from the previous vendor-package.
21# FIXME move mesa prebuilts from Android.mk to Android.bp
22rm -rf ${ANDROID_BUILD_TOP}/vendor/linaro/
23
24if [ ! -e "${PKG_FILE}.tgz"  ]; then
25    curl -L ${VND_PKG_URL} -o  ${PKG_FILE}.tgz
26fi
27
28# generate expected sha512sum, check & cleanup
29echo "${EXPECTED_LINARO_VENDOR_SHA}  ${PKG_FILE}.tgz" > ${PKG_FILE}.tgz.sha
30sha512sum -c ${PKG_FILE}.tgz.sha
31rm ${PKG_FILE}.tgz.sha
32
33tar -xf ${PKG_FILE}.tgz
34./${PKG_FILE}.sh
35popd
36