ci: Updating Jenkins-CI and Travis-CI scripts

This commit makes use of has function from `util.sh` script, enables
dependency installation for Jenkins-CI, and unifies dependency
installation between Jenkins-CI and Travis-CI.

Change-Id: I5f4419ea48d4eb333e9d107115ef3df4123f76e5
Refs: #2805
diff --git a/.jenkins.d/00-deps.sh b/.jenkins.d/00-deps.sh
new file mode 100755
index 0000000..c32219b
--- /dev/null
+++ b/.jenkins.d/00-deps.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+set -e
+
+JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+source "$JDIR"/util.sh
+
+if has OSX $NODE_LABELS; then
+    if has OSX-10.8 $NODE_LABELS; then
+        EXTRA_FLAGS=--c++11
+    fi
+
+    set -x
+    brew update
+    brew upgrade
+    brew install boost pkg-config cryptopp $EXTRA_FLAGS
+    brew cleanup
+fi
+
+if has Ubuntu $NODE_LABELS; then
+    BOOST_PKG=libboost-all-dev
+    if has Ubuntu-12.04 $NODE_LABELS; then
+        BOOST_PKG=libboost1.48-all-dev
+    fi
+
+    set -x
+    sudo apt-get update -qq -y
+    sudo apt-get -qq -y install build-essential pkg-config $BOOST_PKG \
+                                libcrypto++-dev libsqlite3-dev
+fi
diff --git a/.jenkins.d/10-build.sh b/.jenkins.d/10-build.sh
index ce7a774..58d0b01 100755
--- a/.jenkins.d/10-build.sh
+++ b/.jenkins.d/10-build.sh
@@ -2,7 +2,8 @@
 set -x
 set -e
 
-COVERAGE=$( python -c "print '--with-coverage --debug' if 'code-coverage' in '$JOB_NAME' else ''" )
+JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+source "$JDIR"/util.sh
 
 sudo rm -Rf /usr/local/include/ndn-cxx
 sudo rm -f /usr/local/lib/libndn-cxx*
@@ -11,26 +12,34 @@
 # Cleanup
 sudo ./waf -j1 --color=yes distclean
 
-# Configure/build in debug mode
-./waf -j1 --color=yes configure --with-tests --debug
+# Configure/build static library in debug mode with precompiled headers
+./waf -j1 --color=yes configure --enable-static --disable-shared --with-tests --debug
 ./waf -j1 --color=yes build
 
 # Cleanup
 sudo ./waf -j1 --color=yes distclean
 
-# Configure/build in optimized mode without tests with precompiled headers
-./waf -j1 --color=yes configure
+# Configure/build static and shared library in optimized mode without tests with precompiled headers
+./waf -j1 --color=yes configure --enable-shared --enable-static
 ./waf -j1 --color=yes build
 
 # Cleanup
 sudo ./waf -j1 --color=yes distclean
 
-# Configure/build in optimized mode
-./waf -j1 --color=yes configure --with-tests --without-pch $COVERAGE
+# Configure/build shared library in debug mode without precompiled headers
+if has code-coverage $JOB_NAME; then
+    COVERAGE="--with-coverage"
+fi
+./waf -j1 --color=yes configure --debug --enable-shared --disable-static --with-tests --without-pch $COVERAGE
 ./waf -j1 --color=yes build
 
-# (tests will be run against optimized version)
+# (tests will be run against debug version)
 
 # Install
 sudo ./waf -j1 --color=yes install
-sudo ldconfig || true
+
+if has Linux $NODE_LABELS; then
+    sudo ldconfig
+elif has FreeBSD $NODE_LABELS; then
+    sudo ldconfig -a
+fi
diff --git a/.jenkins.d/20-tests.sh b/.jenkins.d/20-tests.sh
index 3bc96ce..970bc94 100755
--- a/.jenkins.d/20-tests.sh
+++ b/.jenkins.d/20-tests.sh
@@ -2,13 +2,13 @@
 set -x
 set -e
 
+JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+source "$JDIR"/util.sh
+
 # Prepare environment
-rm -Rf ~/.ndnx ~/.ndn
+rm -Rf ~/.ndn
 
-echo $NODE_LABELS
-IS_OSX=$( python -c "print 'yes' if 'OSX' in '$NODE_LABELS'.strip().split(' ') else 'no'" )
-
-if [[ $IS_OSX == "yes" ]]; then
+if has OSX $NODE_LABELS; then
   echo "Unlocking OSX Keychain"
   security unlock-keychain -p "named-data"
 fi
diff --git a/.jenkins.d/30-coverage.sh b/.jenkins.d/30-coverage.sh
index ccbb62e..6a7b0a8 100755
--- a/.jenkins.d/30-coverage.sh
+++ b/.jenkins.d/30-coverage.sh
@@ -2,9 +2,10 @@
 set -x
 set -e
 
-IS_COVR=$( python -c "print 'yes' if 'code-coverage' in '$JOB_NAME' else 'no'" )
+JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+source "$JDIR"/util.sh
 
-if [[ $IS_COVR == "yes" ]]; then
+if has code-coverage $JOB_NAME; then
   BASE="`pwd | sed -e 's|/|\\\/|g'`\\"
   (cd build && gcovr -x -f $BASE/src -r ../ -o coverage.xml -b ./)
 fi
diff --git a/.jenkins.d/README.md b/.jenkins.d/README.md
new file mode 100644
index 0000000..956ae18
--- /dev/null
+++ b/.jenkins.d/README.md
@@ -0,0 +1,30 @@
+CONTINUOUS INTEGRATION SCRIPTS
+==============================
+
+Environment Variables Used in Build Scripts
+-------------------------------------------
+
+- `NODE_LABELS`: the variable defines a list of OS properties.  The set values are used by the
+  build scripts to select proper behavior for different OS.
+
+  The list should include at least `[OS_TYPE]`, `[DISTRO_TYPE]`, and `[DISTRO_VERSION]`.
+
+  Possible values for Linux OS:
+
+  * `[OS_TYPE]`: `Linux`
+  * `[DISTRO_TYPE]`: `Ubuntu`
+  * `[DISTRO_VERSION]`: `Ubuntu-12.04`, `Ubuntu-14.04`, `Ubuntu-15.04`
+
+  Possible values of OSX OS:
+
+  * `[OS_TYPE]`: `OSX`
+  * `[DISTRO_TYPE]`: `OSX` (can be absent)
+  * `[DISTRO_VERSION]`: `OSX-10.10`, `OSX-10.9`, `OSX-10.8`, `OSX-10.7`
+
+- `JOB_NAME`: optional variable to define type of the job.  Depending on the defined job type,
+  the build scripts can perform different tasks.
+
+  Possible values:
+
+  * empty: default build process
+  * `code-coverage` (Linux OS is assumed): build process with code coverage analysis
diff --git a/.jenkins.d/util.sh b/.jenkins.d/util.sh
new file mode 100755
index 0000000..81c8931
--- /dev/null
+++ b/.jenkins.d/util.sh
@@ -0,0 +1,9 @@
+has() {
+    local p=$1
+    shift
+    local x
+    for x in "$@"; do
+        [[ "${x}" == "${p}" ]] && return 0
+    done
+    return 1
+}
diff --git a/.travis.yml b/.travis.yml
index 3b2c6a6..7f40779 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,11 +1,15 @@
+sudo: true
 language: cpp
+os:
+  - linux
 compiler:
   - gcc
 notifications:
   email:
     on_success: always
     on_failure: always
-before_install:
-  - travis_retry sudo apt-get install -qq libboost1.48-all-dev libcrypto++-dev libsqlite3-dev
 script:
+  - if [[ $TRAVIS_OS_NAME == linux ]]; then export NODE_LABELS="Linux Ubuntu Ubuntu-12.04"; fi
+  - if [[ $TRAVIS_OS_NAME == osx ]]; then export NODE_LABELS="OSX OSX-10.10"; fi
+  - echo $NODE_LABELS
   - ./.jenkins