build: Prepare building by installing dependencies libs
authorPhilippe Coval <philippe.coval@osg.samsung.com>
Mon, 29 Aug 2016 14:59:34 +0000 (16:59 +0200)
committerDan Mihai <Daniel.Mihai@microsoft.com>
Wed, 22 Mar 2017 19:34:15 +0000 (19:34 +0000)
It is strongly recommended to rely on scons,
 if not possible, this can be done differently using this script.

For more details about building IoTivity please check:

https://wiki.iotivity.org/build

The main purpose of prep.sh, is for continuous integration experiments
 for Tizen platform, but could be used for others too.

Bug: https://jira.iotivity.org/browse/IOT-1600
Change-Id: I63e713c8531f0eea698277993cf21c3d55c80270
Origin: https://gerrit.iotivity.org/gerrit/#/c/11699/
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/12477
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Kevin Kane <kkane@microsoft.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
(cherry picked from commit 10c5f532f85a2e97dbbe91c94276fc9bfff5d016)
Reviewed-on: https://gerrit.iotivity.org/gerrit/11699
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
extlibs/gtest/prep.sh [new file with mode: 0644]
extlibs/mbedtls/prep.sh
extlibs/tinycbor/prep.sh
prep.sh [new file with mode: 0755]

diff --git a/extlibs/gtest/prep.sh b/extlibs/gtest/prep.sh
new file mode 100644 (file)
index 0000000..5fb4209
--- /dev/null
@@ -0,0 +1,58 @@
+#!/bin/bash
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+set -e
+
+[ ! -z ${EXEC_MODE} ] || EXEC_MODE=false
+
+package="gtest"
+packageRevision='1.7.0'
+packageUrl='http://pkgs.fedoraproject.org/repo/pkgs/gtest/gtest-1.7.0.zip/2d6ec8ccdf5c46b05ba54a9fd1d130d7/gtest-1.7.0.zip'
+packageArchive=$(basename -- "${packageUrl}")
+packageDir="extlibs/${package}/${package}-${packageRevision}"
+packageSourceFile="${packageDir}/CMakeLists.txt"
+
+
+do_()
+{
+    set +f
+    if $EXEC_MODE; then
+        echo "warning: fetching online resources may not be reproductible"
+        printf "%s \n" "trying: \"$@\""
+        eval "$@"
+    else
+        cat<<EOF
+error: Something should be prepared, please manually execute from shell
+EOF
+        printf "%s \n" "$@"
+        exit 1
+    fi
+}
+
+
+main_()
+{
+    echo "# Checking for gtest presence:"
+    if [ ! -e "${packageSourceFile}" ] ; then
+        which wget 2>/dev/null
+        which unzip 2>/dev/null
+        do_ "cd extlibs/${package} && wget -nc -O ${packageArchive} ${packageUrl} && unzip ${packageArchive}"
+    fi
+}
+
+
+main_ "$@"
index acc660a..d32b2c7 100755 (executable)
@@ -1,39 +1,72 @@
-#!/bin/sh
+#!/bin/bash
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 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_url="https://github.com/ARMmbed/mbedtls"
-mbedtls_dir=`dirname -- "$(readlink -f "$0")"`/mbedtls
-mbedtls_reldir="extlibs/mbedtls/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 ${mbedtls_url} ${mbedtls_reldir} -b ${mbedtls_revision}"
-    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
+[ ! -z ${EXEC_MODE} ] || EXEC_MODE=false
 
+
+# Right now this script assumes packageRevision is a tag; 
+# comment out the second clause if packageRevision becomes a branch or a specific commit.
+package="mbedtls"
+packageRevision='mbedtls-2.4.0'
+packageUrl="https://github.com/ARMmbed/mbedtls"
+packageDir="extlibs/${package}/${package}"
+
+
+do_()
+{
+    set +f
+    if $EXEC_MODE; then
+        echo "warning: fetching online resources may not be reproductible"
+        printf "%s \n" "trying: \"$@\""
+        eval "$@"
+    else
+        cat<<EOF
+error: Something should be prepared, please manually execute from shell
+EOF
+        printf "%s \n" "$@"
+        exit 1
+    fi
+}
+
+
+main_()
+{
+    if [ ! -d "${packageDir}" ]; then
+        do_ "git clone ${packageUrl} ${packageDir} -b ${packageRevision}"
+    elif [ ! -z $(git tag -l "${packageRevision}") ]; then
+        cat<<EOF
+error: $packageDir is unaligned with supported release of ${package}
+Please update ${package} using "cd ${packageDir} && git fetch"
+For more support please refer to:
+https://wiki.iotivity.org/build
+EOF
+        exit 2
+    elif [ -d "${packageDir}/.git" ]; then
+        cd "${packageDir}"
+        git reset --hard "${packageRevision}"
+        git apply --whitespace=fix "../ocf.patch"
+        cd -
+        rm -rf -- "${packageDir}/.git"
+    else
+        echo "log: Assuming ${package} is already on correct revision: \"${packageRevision}\""
+    fi
+}
+
+
+main_ "$@"
index dd533b1..f17b919 100755 (executable)
@@ -1,35 +1,76 @@
-#!/bin/sh
+#!/bin/bash
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
 
 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.
-cborUrl="https://github.com/01org/tinycbor"
-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 ${cborUrl} ${cborDir} -b ${cborRevision} "
-    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
+[ ! -z ${EXEC_MODE} ] || EXEC_MODE=false
+
+topdir="${PWD}"
+
+# Keep packageRevision in sync with extlibs/tinycbor/SConscript's setting
+# Right now this script assumes packageRevision is a tag; 
+# comment out the second clause 
+# if packageRevision becomes a branch or a specific commit.
+package="tinycbor"
+packageUrl="https://github.com/01org/tinycbor"
+packageDir="./extlibs/tinycbor/tinycbor"
+packageRevision="v0.4"
+
+
+do_()
+{
+    set +f
+    if $EXEC_MODE; then
+        echo "warning: fetching online resources may not be reproductible"
+        printf "%s \n" "trying: \"$@\""
+        eval "$@"
+    else
+cat<<EOF
+error: Something should be prepared, please manually execute from shell
+EOF
+        printf "%s \n" "$@"
+        exit 1
+    fi
+}
+
+
+main_()
+{
+    if [ ! -d "${packageDir}" ]; then
+        do_ "git clone ${packageUrl} ${packageDir} -b ${packageRevision}"
+    elif [ ! -z $(git tag -l "${packageRevision}") ]; then
+        cat<<EOF
+error: $packageDir is unaligned with supported release of ${package}
+Please update ${package} using "cd ${packageDir} && git fetch"
+For more support please refer to:
+https://wiki.iotivity.org/build
+EOF
+        exit 2
+    elif [ -d "${packageDir}/.git" ]; then
+        cd "${packageDir}"
+        git reset --hard "${packageRevision}"
+        cd -
+        rm -rf -- "${packageDir}/.git"
+    else
+        echo "log: Assuming ${package} is already on correct revision: \"${packageRevision}\""
+    fi
+}
+
+
+main_ "$@"
+
diff --git a/prep.sh b/prep.sh
new file mode 100755 (executable)
index 0000000..33e996c
--- /dev/null
+++ b/prep.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+set -f
+set -e
+
+[ ! -z ${EXEC_MODE} ] || EXEC_MODE=false
+
+topdir="${PWD}"
+
+
+main_()
+{
+    cat<<EOF
+#
+# WARNING: This helper script is DISCOURAGED to be used
+#
+#  Instead please use the supported build tool "scons"
+#
+#  However in some specific cases it's not possible
+#  so this script is providing a fallback option.
+#
+#  Reminder: it's not safe to access online resources at build time,
+#  so by default the script will tell what to do (like scons),
+#  to enable tasks executions it should be run with EXEC_MODE enabled:
+#
+#  EXEC_MODE=true ./prep.sh
+#
+#  More details at:
+#  https://wiki.iotivity.org/build
+#
+EOF
+
+    which bash > /dev/null
+    which git > /dev/null
+    which unzip > /dev/null
+    which wget > /dev/null
+
+    find ./extlibs/ -maxdepth 2 -a -iname "prep.sh" | xargs -n1 bash
+}
+
+
+main_