[IOT-1511] Update mbedTLS to use 2.4.0 release tagged version
authorKevin Kane <kkane@microsoft.com>
Wed, 2 Nov 2016 19:57:38 +0000 (12:57 -0700)
committerPhil Coval <philippe.coval@osg.samsung.com>
Wed, 16 Nov 2016 18:59:44 +0000 (18:59 +0000)
Reviewed-on: https://gerrit.iotivity.org/gerrit/13973
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: David Antler <david.a.antler@intel.com>
Reviewed-by: Habib Virji <habib.virji@samsung.com>
Reviewed-by: Oleksandr Dmytrenko <o.dmytrenko@samsung.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
This change also includes the fix:

Fix mbedtls-2.4.0 build error

.git/refs/tags directory is empty

Reviewed-on: https://gerrit.iotivity.org/gerrit/14223
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Kevin Kane <kkane@microsoft.com>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: Chul Lee <chuls.lee@samsung.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Change-Id: I259709cd2024eb9eca83aa19c90783bc2a9f8c72
Signed-off-by: Kevin Kane <kkane@microsoft.com>
Signed-off-by: Dmitriy Zhuravlev <d.zhuravlev@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14195
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
extlibs/mbedtls/SConscript
extlibs/mbedtls/prep.sh [new file with mode: 0755]
gbsbuild.sh
resource/csdk/connectivity/build/tizen/gbsbuild.sh
resource/csdk/stack/samples/tizen/build/gbsbuild.sh
service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/tizen/gbsbuild.sh

index 1b7c3a8..b8b9cca 100644 (file)
@@ -22,11 +22,16 @@ Import('env')
 
 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 '''
@@ -36,8 +41,28 @@ if not os.path.exists(mbedtls_dir):
 ***********************************************************************************
  '''
     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'
@@ -57,7 +82,7 @@ mbedtls_env.AppendUnique(CFLAGS = ['-fPIC', '-Wall'])
 ######################################################################
 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',
diff --git a/extlibs/mbedtls/prep.sh b/extlibs/mbedtls/prep.sh
new file mode 100755 (executable)
index 0000000..8fde51b
--- /dev/null
@@ -0,0 +1,36 @@
+#!/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
+
index a87ba42..5c85f44 100755 (executable)
@@ -91,21 +91,8 @@ done
 
 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*
index 8ccc9b1..458e227 100755 (executable)
@@ -87,12 +87,8 @@ cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp/
 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
index 97e77bd..ddc18cb 100644 (file)
@@ -89,21 +89,8 @@ cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp/
 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
index dfcadac..c66fc44 100644 (file)
@@ -59,14 +59,10 @@ cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp
 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