import os
import sys
+import subprocess
target_os = env.get('TARGET_OS')
root_dir = env.get('SRC_DIR')
mbedtls_dir = os.path.join(root_dir, 'extlibs','mbedtls','mbedtls/')
-mbedtls_revision = 'ad249f509fd62a3bbea7ccd1fef605dbd482a7bd'
+start_dir = os.getcwd()
+# Right now this script assumes the revision is a tag, and not a branch or an arbitrary
+# commit. If this changes, update the check below, or else the script will always conclude
+# the repo is not up to date because a tag with that name doesn't exist.
+mbedtls_revision = 'mbedtls-2.4.0'
if not os.path.exists(mbedtls_dir):
print '''
***********************************************************************************
'''
Exit(1)
-start_dir = os.getcwd()
+#cd extlib/mbedtls/mbedtls
os.chdir(mbedtls_dir)
+
+# Tizen uses its own process to prepare the mbedTLS repo in gbsbuild.sh. Make sure
+# the mbedtls_revision tag selected is the same as in extlibs/mbedtls/prep.sh.
+# This code also assumes mbedtls_revision is a tag; if it changes to
+# a branch or an arbitrary commit, disable this check below.
+if target_os != 'tizen':
+ out = subprocess.check_output('git tag -l ' + mbedtls_revision, shell = True)
+ if mbedtls_revision not in out:
+ print out
+ print '''
+*********************************** Error: ****************************************
+* Your mbedTLS repo is not up to date with the latest version we require. Please *
+* update with the following commands: *
+* $ cd extlibs/mbedtls/mbedtls *
+* $ git fetch *
+***********************************************************************************
+ '''
+ Exit(1)
+
+
# Apply ocf patch on git revision
if os.path.exists('.git/HEAD'):
cmd = 'git checkout development && git reset --hard ' + mbedtls_revision + ' && git apply --whitespace=fix ../ocf.patch'
######################################################################
mbedtls_src = [
'mbedtls/library/debug.c',
- 'mbedtls/library/net.c',
+ 'mbedtls/library/net_sockets.c',
'mbedtls/library/ssl_cache.c',
'mbedtls/library/ssl_ciphersuites.c',
'mbedtls/library/ssl_cli.c',
--- /dev/null
+#!/bin/sh
+
+set -e
+
+# Keep mbedtls_revision in sync with extlibs/mbedtls/SConscript's setting. Right now this script
+# assumes mbedtls_revision is a tag; comment out the second clause if mbedtls_revision becomes
+# a branch or a specific commit.
+mbedtls_dir=`dirname -- "$(readlink -f "$0")"`/mbedtls
+mbedtls_revision="mbedtls-2.4.0"
+if [ ! -d ${mbedtls_dir} ]; then
+ echo ""
+ echo "*********************************** Error: ****************************************"
+ echo "* Please download mbedTLS using the following command: *"
+ echo "* $ git clone https://github.com/ARMmbed/mbedtls.git extlibs/mbedtls/mbedtls *"
+ echo "***********************************************************************************"
+ echo ""
+ exit
+elif [ ! -z $(git tag -l $mbedtls_revision) ]; then
+ echo ""
+ echo "*********************************** Error: ****************************************"
+ echo "* mbedTLS repo is out of date. Please update mbedtls using the following commands:*"
+ echo "* $ cd (authoritative mbedTLS source repo location) *"
+ echo "* $ git fetch *"
+ echo "***********************************************************************************"
+ echo ""
+ exit
+elif [ -d ${mbedtls_dir}/.git ]; then
+ cd ${mbedtls_dir}
+ git reset --hard ${mbedtls_revision} ; git apply --whitespace=fix ../ocf.patch
+ cd -
+ rm -rf ${mbedtls_dir}/.git*
+else
+ echo "tizen: Checking if ocf.patch is applied in ${mbedtls_dir}"
+ grep -r 'TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256' "${mbedtls_dir}"
+fi
+
if [ $secured -eq 1 ];then
echo `pwd`
- if [ -d ./extlibs/mbedtls/mbedtls ];then
- cd ./extlibs/mbedtls/mbedtls
- git reset --hard ad249f509fd62a3bbea7ccd1fef605dbd482a7bd ; git apply ../ocf.patch
- cd -
- rm -rf ./extlibs/mbedtls/mbedtls/.git*
-
- else
- echo ""
- echo "*********************************** Error: ****************************************"
- echo "* Please download mbedtls using the following command: *"
- echo "* $ git clone https://github.com/ARMmbed/mbedtls.git extlibs/mbedtls/mbedtls *"
- echo "***********************************************************************************"
- echo ""
- exit
- fi
+ # Prepare mbedTLS dependency
+ $SHELL ./extlibs/mbedtls/prep.sh
fi
rm -rf ./extlibs/tinycbor/tinycbor/.git*
cd $sourcedir/tmp
echo `pwd`
-if [ -d ./extlibs/mbedtls/mbedtls ];then
- cd ./extlibs/mbedtls/mbedtls
- git reset --hard ad249f509fd62a3bbea7ccd1fef605dbd482a7bd ; git apply --whitespace=fix ../ocf.patch
- cd -
- rm -rf ./extlibs/mbedtls/mbedtls/.git*
-fi
+# Prepare mbedTLS dependency
+$SHELL ./extlibs/mbedtls/prep.sh
whoami
# Initialize Git repository
cd $sourcedir/tmp
echo `pwd`
-
-# Apply OCF patch on upstream's git only once
-# Note, If building from scratch using GBS, git patches are more convenient
-mbedtls_revision="ad249f509fd62a3bbea7ccd1fef605dbd482a7bd"
-mbedtls_dir="./extlibs/mbedtls/mbedtls/"
-if [ -f "${mbedtls_dir}/.git/HEAD" ];then
- cd "${mbedtls_dir}"
- git reset --hard "${mbedtls_revision}"
- git apply --whitespace=fix "../ocf.patch"
- cd -
- rm -rf "${mbedtls_dir}/.git"
-else
- echo "tizen: Checking if ocf.patch is applied in ${mbedtls_dir}"
- grep -r 'TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256' "${mbedtls_dir}"
-fi
+# Prepare mbedTLS dependency
+$SHELL ./extlibs/mbedtls/prep.sh
whoami
# Initialize Git repository
cd $sourcedir/tmp
echo `pwd`
-if [ -d ./extlibs/mbedtls/mbedtls ];then
- cd ./extlibs/mbedtls/mbedtls
- git reset --hard ad249f509fd62a3bbea7ccd1fef605dbd482a7bd ; git apply --whitespace=fix ../ocf.patch
- cd -
- rm -rf ./extlibs/mbedtls/mbedtls/.git*
-fi
-rm -rf ./extlibs/tinycbor/tinycbor/.git*
+# Prepare mbedTLS dependency
+$SHELL ./extlibs/mbedtls/prep.sh
+rm -rf ./extlibs/tinycbor/tinycbor/.git*
# Build IoTivity
# Initialize Git repository