yaml: Add scriptlet to clone before scons 79/22079/2
authorPhilippe Coval <philippe.coval@osg.samsung.com>
Tue, 25 Jul 2017 16:13:18 +0000 (18:13 +0200)
committerMats Wichmann <mats@linux.com>
Wed, 30 Aug 2017 22:04:42 +0000 (22:04 +0000)
Bug: https://jira.iotivity.org/browse/IOT-1760
Change-Id: Ief605d40b83d437df4049d18af7188eaea0ecbcb
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/21623
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
(cherry picked from commit 286bc151acf0e8f2b67932d0fca2405cc859375e)
Reviewed-on: https://gerrit.iotivity.org/gerrit/22079
Reviewed-by: Mats Wichmann <mats@linux.com>
extlibs/yaml/prep.sh [new file with mode: 0755]

diff --git a/extlibs/yaml/prep.sh b/extlibs/yaml/prep.sh
new file mode 100755 (executable)
index 0000000..0727303
--- /dev/null
@@ -0,0 +1,80 @@
+#!/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
+
+topdir="${PWD}"
+
+# Keep packageRevision in sync with 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="yaml"
+packageUrl="https://github.com/jbeder/yaml-cpp"
+packageDir="./extlibs/${package}/${package}"
+packageVersion="master"
+# TODO: pin
+packageRevision="$packageVersion"
+
+
+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 ${packageVersion}"
+    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
+    fi
+    if [ -d "${packageDir}/.git" ]; then
+        cd "${packageDir}" || exit 1
+        git clean -f -d -x
+        git reset --hard "${packageRevision}"
+        cd -
+        rm -rf -- "${packageDir}/.git"
+    else
+        echo "log: Assuming ${package} is already on correct revision: \"${packageRevision}\""
+    fi
+}
+
+
+main_ "$@"
+