#!/bin/bash -x

#mkdir android
#cd android
if [ ${MANIFEST_FILENAME} ]; then
    echo ${MANIFEST_FILENAME}
    yes '' | repo init -u ${MANIFEST_REPO} -b ${MANIFEST_BRANCH} -m ${MANIFEST_FILENAME}
else
    echo No MANIFEST_FILENAME
    yes '' | repo init -u ${MANIFEST_REPO} -b ${MANIFEST_BRANCH}
fi
repo sync

if [ ${TOOLCHAIN_URL} ]; then
    wget --no-check-certificate ${TOOLCHAIN_URL}
    tar -jxvf android-toolchain-eabi-linaro*
    make TARGET_PRODUCT=${TARGET_PRODUCT} TARGET_TOOLS_PREFIX=./android-toolchain-eabi/bin/arm-eabi- boottarball systemtarball userdatatarball
fi