[IOT-1529] Sync TinyCBOR to release tag before using
authorKevin Kane <kkane@microsoft.com>
Wed, 9 Nov 2016 17:38:22 +0000 (09:38 -0800)
committerPhil Coval <philippe.coval@osg.samsung.com>
Mon, 21 Nov 2016 17:46:41 +0000 (17:46 +0000)
Current build will sync to the head of TinyCBOR's master branch.
To remove this unpredictability from the build, always sync to
a particular release tag.

Change-Id: I471ac19aedc787bca64ee01c4733ab319d6f32d3
Signed-off-by: Kevin Kane <kkane@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14165
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
(cherry picked from commit 6b368cb9e7f45efccad93455aff98ad5b4e0ccb0)
Reviewed-on: https://gerrit.iotivity.org/gerrit/14425

extlibs/tinycbor/SConscript
extlibs/tinycbor/prep.sh [new file with mode: 0755]
gbsbuild.sh
resource/csdk/stack/samples/tizen/build/gbsbuild.sh
service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/tizen/gbsbuild.sh

index cc989dc..3be061e 100644 (file)
 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 import os
+import subprocess
 
 Import('env')
 
 src_dir = env.get('SRC_DIR')
+target_os = env.get('TARGET_OS')
 
 cborDir = os.path.join(src_dir, 'extlibs','tinycbor','tinycbor')
+cborRevision = 'v0.4'
 
 if not os.path.exists(cborDir):
     print '''
@@ -35,6 +38,37 @@ if not os.path.exists(cborDir):
 '''
     Exit(1)
 
+start_dir = os.getcwd()
+os.chdir(cborDir)
+
+# Tizen uses a separate process to sync to a particular revision of TinyCBOR.
+# Make sure tinycbor_revision stays in sync with extlibs/tinycbor/prep.sh.
+# This code also assumes tinycbor_revision is a tag; if it changes to a branch
+# or an arbitrary commit, disable this check below.
+if target_os != 'tizen' and os.path.exists('.git/HEAD'):
+    out = subprocess.check_output('git tag -l ' + cborRevision, shell = True)
+    if cborRevision not in out:
+        print out
+        print '''
+*********************************** Error: ****************************************
+* Your TinyCBOR repo is not up to date with the latest version we require. Please *
+* update with the following commands:                                             *
+*     $ cd extlibs/tinycbor/tinycbor                                              *
+*     $ git fetch                                                                 *
+***********************************************************************************
+ '''
+        Exit(1)
+
+
+# Point TinyCBOR repo to desired release tag
+if os.path.exists('.git/HEAD'):
+    cmd = 'git reset --hard ' + cborRevision
+    os.system(cmd)
+else:
+    print 'Assume TinyCBOR is on tag ', cborRevision
+
+os.chdir(start_dir)
+
 cbor_src = [
     os.path.join(cborDir,'src/cborparser.c'),
     os.path.join(cborDir,'src/cborparser_dup_string.c'),
diff --git a/extlibs/tinycbor/prep.sh b/extlibs/tinycbor/prep.sh
new file mode 100755 (executable)
index 0000000..b136253
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+set -e
+
+# Keep cborRevision in sync with extlibs/tinycbor/SConscript's setting. Right now this script
+# assumes cborRevision is a tag; comment out the second clause if cborRevision becomes
+# a branch or a specific commit.
+cborDir="./extlibs/tinycbor/tinycbor"
+cborRevision="v0.4"
+if [ ! -d ${cborDir} ]; then
+    echo ""
+    echo "*********************************** Error: ****************************************"
+    echo "* Please download TinyCBOR using the following command:                           *"
+    echo "*     $ git clone https://github.com/01org/tinycbor.git extlibs/tinycbor/tinycbor *"
+    echo "***********************************************************************************"
+    echo ""
+    exit
+elif [ ! -z $(git tag -l $cborRevision) ]; then
+    echo ""
+    echo "*********************************** Error: *******************************************"
+    echo "* TinyCBOR repo is out of date. Please update TinyCBOR using the following commands: *"
+    echo "*     $ cd (authoritative TinyCBOR source repo location)                             *"
+    echo "*     $ git fetch                                                                    *"
+    echo "**************************************************************************************"
+    echo ""
+    exit
+elif [ -d ${cborDir}/.git ]; then
+    cd ${cborDir}
+    git reset --hard ${cborRevision}
+    cd -
+    rm -rf ${cborDir}/.git*
+else
+    echo "Assuming TinyCBOR is already on correct revision ${cborRevision}"
+fi
index 5c85f44..c90d7b3 100755 (executable)
@@ -95,7 +95,8 @@ if [ $secured -eq 1 ];then
   $SHELL ./extlibs/mbedtls/prep.sh
 fi
 
-rm -rf ./extlibs/tinycbor/tinycbor/.git*
+# Prepare TinyCBOR dependency
+$SHELL ./extlibs/tinycbor/prep.sh
 
 # Initialize Git repositoryㅣ
 if [ ! -d .git ]; then
index ddc18cb..1af1de6 100644 (file)
@@ -51,7 +51,6 @@ mkdir ./tmp
 mkdir ./tmp/extlibs/
 mkdir ./tmp/packaging
 cp -LR ./extlibs/tinycbor $sourcedir/tmp/extlibs
-rm -rf $sourcedir/tmp/extlibs/tinycbor/tinycbor/.git
 cp -Rf ./extlibs/mbedtls $sourcedir/tmp/extlibs
 cp -R ./extlibs/cjson $sourcedir/tmp/extlibs
 cp -R ./extlibs/tinydtls $sourcedir/tmp/extlibs
@@ -92,6 +91,9 @@ echo `pwd`
 # Prepare mbedTLS dependency
 $SHELL ./extlibs/mbedtls/prep.sh
 
+# Prepare TinyCBOR dependency
+$SHELL ./extlibs/tinycbor/prep.sh
+
 whoami
 # Initialize Git repository
 if [ ! -d .git ]; then
index c66fc44..bdf7a8a 100644 (file)
@@ -30,7 +30,6 @@ cp -R ./examples $sourcedir/tmp
 
 # tinycbor is available as soft-link, so copying with 'dereference' option.
 cp -LR ./extlibs/tinycbor $sourcedir/tmp/extlibs
-rm -rf $sourcedir/tmp/extlibs/tinycbor/tinycbor/.git
 
 cp -R ./extlibs/cjson $sourcedir/tmp/extlibs
 cp -R ./extlibs/mbedtls $sourcedir/tmp/extlibs
@@ -62,7 +61,8 @@ echo `pwd`
 # Prepare mbedTLS dependency
 $SHELL ./extlibs/mbedtls/prep.sh
 
-rm -rf ./extlibs/tinycbor/tinycbor/.git*
+# Prepare TinyCBOR dependency
+$SHELL ./extlibs/tinycbor/prep.sh
 
 # Build IoTivity
 # Initialize Git repository