build: Suggest to download supported mbedtls
[platform/upstream/iotivity.git] / extlibs / mbedtls / prep.sh
1 #!/bin/sh
2
3 set -e
4
5 # Keep mbedtls_revision in sync with extlibs/mbedtls/SConscript's setting. Right now this script
6 # assumes mbedtls_revision is a tag; comment out the second clause if mbedtls_revision becomes
7 # a branch or a specific commit.
8 mbedtls_url="https://github.com/ARMmbed/mbedtls"
9 mbedtls_dir=`dirname -- "$(readlink -f "$0")"`/mbedtls
10 mbedtls_reldir="extlibs/mbedtls/mbedtls"
11
12 mbedtls_revision="mbedtls-2.4.0"
13 if [ ! -d ${mbedtls_dir} ]; then
14     echo ""
15     echo "*********************************** Error: ****************************************"
16     echo "* Please download mbedTLS using the following command:                            *"
17     echo "*     $ git clone ${mbedtls_url} ${mbedtls_reldir} -b ${mbedtls_revision}"
18     echo "***********************************************************************************"
19     echo ""
20     exit
21 elif [ ! -z $(git tag -l $mbedtls_revision) ]; then
22     echo ""
23     echo "*********************************** Error: ****************************************"
24     echo "* mbedTLS repo is out of date. Please update mbedtls using the following commands:*"
25     echo "*     $ cd (authoritative mbedTLS source repo location)                           *"
26     echo "*     $ git fetch                                                                 *"
27     echo "***********************************************************************************"
28     echo ""
29     exit
30 elif [ -d ${mbedtls_dir}/.git ]; then
31     cd ${mbedtls_dir}
32     git reset --hard ${mbedtls_revision} ; git apply --whitespace=fix ../ocf.patch
33     cd -
34     rm -rf ${mbedtls_dir}/.git*
35 else
36     echo "tizen: Checking if ocf.patch is applied in ${mbedtls_dir}"
37     grep -r 'TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256' "${mbedtls_dir}"
38 fi
39