aboutsummaryrefslogtreecommitdiffstats
path: root/cicn-plugin/scripts
diff options
context:
space:
mode:
authorMauro Sardara <msardara+fdio@cisco.com>2017-04-13 11:51:02 +0200
committerMauro Sardara <msardara+fdio@cisco.com>2017-04-13 13:11:14 +0200
commit92474b0c5c792d418a00d09a6adfaf94ac70d52b (patch)
treea1e1cd5d4c86df780d2156b14a6a65c3c1de4834 /cicn-plugin/scripts
parentd38c9d90331df6e049d98ca48b85f68eeb31ddce (diff)
Adding support for package creation.
The script for creating the package is scripts/build-package.sh, and it will create the correct package depending on the OS and the architecture users are running on. Supported OS: Ubuntu 16.04, Ubuntu 14.04 Change-Id: Ifa8564eda8d7b1f39ea3250500d78b6873072959 Signed-off-by: Mauro Sardara <msardara+fdio@cisco.com>
Diffstat (limited to 'cicn-plugin/scripts')
-rw-r--r--cicn-plugin/scripts/build-package.sh209
-rw-r--r--cicn-plugin/scripts/version57
2 files changed, 266 insertions, 0 deletions
diff --git a/cicn-plugin/scripts/build-package.sh b/cicn-plugin/scripts/build-package.sh
new file mode 100644
index 00000000..f91cab52
--- /dev/null
+++ b/cicn-plugin/scripts/build-package.sh
@@ -0,0 +1,209 @@
+#!/bin/bash
+# basic build script example
+set -euxo pipefail
+IFS=$'\n\t'
+
+APT_PATH=`which apt-get` || true
+apt_get=${APT_PATH:-"/usr/local/bin/apt-get"}
+
+BUILD_TOOLS_UBUNTU="build-essential cmake"
+LIBSSL_LIBEVENT_UBUNTU="libevent-dev libssl-dev"
+DEPS_UBUNTU="vpp-dev vpp-dpdk-dev vpp-lib"
+
+BUILD_TOOLS_GROUP_CENTOS="'Development Tools'"
+BUILD_TOOLS_SINGLE_CENTOS="cmake"
+LIBSSL_LIBEVENT_CENTOS="libevent-devel openssl-devel"
+DEPS_CENTOS="vpp-dev vpp-dpdk-dev vpp-lib"
+
+# Parameters:
+# $1 = Distribution [Trusty / CentOS]
+#
+update_cmake_repo() {
+
+ DISTRIBUTION=$1
+
+ if [ "$DISTRIBUTION" == "trusty" ]; then
+ sudo ${apt_get} install -y --allow-unauthenticated software-properties-common
+ sudo add-apt-repository --yes ppa:george-edison55/cmake-3.x
+ elif [ "$DISTRIBUTION" == "CentOS" ]; then
+ sudo cat << EOF > cmake.repo
+[cmake-repo]
+name=Repo for cmake3
+baseurl=http://mirror.ghettoforge.org/distributions/gf/el/7/plus/x86_64/
+enabled=1
+gpgcheck=0
+EOF
+ sudo cat << EOF > jsoncpp.repo
+[jsoncp-repo]
+name=Repo for jsoncpp
+baseurl=http://dl.fedoraproject.org/pub/epel/7/x86_64/
+enabled=1
+gpgcheck=0
+EOF
+ sudo mv cmake.repo /etc/yum.repos.d/cmake.repo
+ sudo mv jsoncpp.repo /etc/yum.repos.d/jsoncpp.repo
+ fi
+}
+
+# Parameters:
+# $1 = Distribution codename
+#
+update_qt_repo() {
+ DISTRIBUTION_CODENAME=$1
+
+ if [ "$DISTRIBUTION_CODENAME" != "trusty" ] && [ "$DISTRIBUTION_CODENAME" != "xenial" ]; then
+ echo "No valid distribution specified when calling 'update_qt_repo'. Exiting.."
+ exit -1
+ fi
+
+ sudo ${apt_get} install -y --allow-unauthenticated software-properties-common
+ sudo add-apt-repository --yes ppa:beineri/opt-qt571-$DISTRIBUTION_CODENAME
+
+ wget -q -O - http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add -
+ sudo sh -c "echo 'deb http://archive.getdeb.net/ubuntu $DISTRIBUTION_CODENAME-getdeb apps' >> /etc/apt/sources.list.d/getdeb.list"
+
+ sudo ${apt_get} update
+}
+
+# Parameters:
+# $1 = Distribution id
+# $2 = Distribution codename
+#
+update_fdio_repo() {
+ DISTRIB_ID=$1
+ DISTRIB_CODENAME=$2
+
+ NEXUS_PROXY=${NEXUSPROXY:-"http://nexus.fd.io"}
+ REPO_CICN_URL=""
+ REPO_VPP_URL=""
+
+ if [ "$DISTRIB_ID" == "Ubuntu" ]; then
+
+ if [ "$DISTRIB_CODENAME" == "xenial" ]; then
+ REPO_VPP_URL="${NEXUS_PROXY}/content/repositories/fd.io.stable.1701.ubuntu.xenial.main/"
+ elif [ "$DISTRIB_CODENAME" == "trusty" ]; then
+ REPO_VPP_URL="${NEXUS_PROXY}/content/repositories/fd.io.stable.1701.ubuntu.trusty.main/"
+ else
+ echo "Distribution $DISTRIB_CODENAME is not supported"
+ exit -1
+ fi
+
+ echo "deb ${REPO_VPP_URL} ./" | sudo tee /etc/apt/sources.list.d/99fd.io.list
+
+ elif [ "$DISTRIB_ID" == "CentOS" ]; then
+ REPO_VPP_URL="${NEXUS_PROXY}/content/repositories/fd.io.stable.1701.centos7/"
+ REPO=${REPO_NAME:-"master.centos7"}
+ REPO_CICN_URL="${NEXUS_PROXY}/content/repositories/fd.io.${REPO}"
+
+ sudo cat << EOF > fdio.repo
+[fdio-vpp-master]
+name=fd.io master branch latest merge
+baseurl=${REPO_VPP_URL}
+enabled=1
+gpgcheck=0
+EOF
+ sudo mv fdio.repo /etc/yum.repos.d/fdio.repo
+ else
+ echo "Distribution $DISTRIB_CODENAME is not supported"
+ exit -1
+ fi
+
+}
+
+setup() {
+
+ DISTRIB_ID=$1
+ DISTRIB_CODENAME=$2
+
+ if [ "$DISTRIB_ID" == "Ubuntu" ]; then
+ if [ "$DISTRIB_CODENAME" == "trusty" ]; then
+ update_cmake_repo $DISTRIB_CODENAME
+ fi
+
+ update_fdio_repo $DISTRIB_ID $DISTRIB_CODENAME
+
+ sudo ${apt_get} update || true
+
+ elif [ "$DISTRIB_ID" == "CentOS" ]; then
+ update_cmake_repo $DISTRIB_ID
+ update_fdio_repo $DISTRIB_ID $DISTRIB_CODENAME
+ fi
+}
+
+# Parameters:
+# $1 = Package name
+#
+build_package() {
+
+ PACKAGE_NAME=$1
+
+ ARCHITECTURE=`uname -m`
+
+ # Figure out what system we are running on
+ if [ -f /etc/lsb-release ];then
+
+ . /etc/lsb-release
+ DEB=ON
+ RPM=OFF
+
+ if [ "$ARCHITECTURE" == "x86_64" ]; then
+ ARCHITECTURE="amd64"
+ fi
+
+ elif [ -f /etc/redhat-release ];then
+
+ sudo yum install -y redhat-lsb
+ DISTRIB_ID=`lsb_release -si`
+ DISTRIB_RELEASE=`lsb_release -sr`
+ DISTRIB_CODENAME=`lsb_release -sc`
+ DISTRIB_DESCRIPTION=`lsb_release -sd`
+
+ DEB=OFF
+ RPM=ON
+ else
+ echo "ERROR: System configuration not recognized. Build failed"
+ exit -1
+ fi
+
+ echo ARCHITECTURE: $ARCHITECTURE
+ echo DISTRIB_ID: $DISTRIB_ID
+ echo DISTRIB_RELEASE: $DISTRIB_RELEASE
+ echo DISTRIB_CODENAME: $DISTRIB_CODENAME
+ echo DISTRIB_DESCRIPTION: $DISTRIB_DESCRIPTION
+
+ setup $DISTRIB_ID $DISTRIB_CODENAME
+
+ # Install package dependencies
+ if [ $DISTRIB_ID == "Ubuntu" ]; then
+ echo $BUILD_TOOLS_UBUNTU $DEPS_UBUNTU | xargs sudo ${apt_get} install -y --allow-unauthenticated
+ elif [ $DISTRIB_ID == "CentOS" ]; then
+ echo $BUILD_TOOLS_GROUP_CENTOS | xargs sudo yum groupinstall -y --nogpgcheck
+ echo $BUILD_TOOLS_SINGLE_CENTOS | xargs sudo yum install -y --nogpgcheck
+ echo $DEPS_CENTOS | xargs sudo yum install -y --nogpgcheck || true
+ fi
+
+ # do nothing but print the current slave hostname
+ hostname
+
+ # Make the package
+ mkdir -p build && pushd build
+
+ rm -rf *
+ cmake -DCMAKE_INSTALL_PREFIX=/usr -DRPM_PACKAGE=$RPM -DDEB_PACKAGE=$DEB -DDISTRIBUTION=$DISTRIB_CODENAME -DARCHITECTURE=$ARCHITECTURE ..
+ make package
+
+ find . -not -name '*.deb' -not -name '*.rpm' -print0 | xargs -0 rm -rf -- || true
+
+ popd
+
+ echo "*******************************************************************"
+ echo "* $PACKAGE_NAME BUILD SUCCESSFULLY COMPLETED"
+ echo "*******************************************************************"
+
+ exit 0
+}
+
+PACKAGE_NAME="VPP_PLUGIN"
+pushd ..
+build_package $PACKAGE_NAME
+popd
diff --git a/cicn-plugin/scripts/version b/cicn-plugin/scripts/version
new file mode 100644
index 00000000..ad90d1c3
--- /dev/null
+++ b/cicn-plugin/scripts/version
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+path=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
+version_prefix="Vpp-plugin-v"
+
+cd "$path"
+
+git rev-parse 2> /dev/null
+if [ $? == 0 ]; then
+ vstring=$(git describe --dirty --match "$version_prefix*" | sed "s/$version_prefix//")
+elif [ -f .version ]; then
+ vstring=$(cat .version)
+else
+ if [ -f ../rpm/*.gz ]; then
+ vstring=$(ls ../rpm/*.gz)
+ else
+ exit 1
+ fi
+fi
+
+TAG=$(echo ${vstring} | cut -d- -f1 | sed -e "s/$version_prefix//")
+ADD=$(echo ${vstring} | cut -s -d- -f2)
+
+git rev-parse 2> /dev/null
+if [ $? == 0 ]; then
+ CMT=$(git describe --dirty --match "$version_prefix*" | sed "s/$version_prefix//" | cut -s -d- -f3,4)
+else
+ CMT=$(echo ${vstring} | cut -s -d- -f3,4)
+fi
+CMTR=$(echo $CMT | sed 's/-/_/')
+
+if [ -n "${BUILD_NUMBER}" ]; then
+ BLD="~b${BUILD_NUMBER}"
+else
+ BLD="~b1"
+fi
+
+if [ "$1" = "rpm-version" ]; then
+ echo ${TAG}
+ exit
+fi
+
+if [ "$1" = "rpm-release" ]; then
+ [ -z "${ADD}" ] && echo release && exit
+ echo ${ADD}${CMTR:+~${CMTR}}${BLD}
+ exit
+fi
+
+ if [ -n "${ADD}" ]; then
+ if [ "$1" = "rpm-string" ]; then
+ echo ${TAG}-${ADD}${CMTR:+~${CMTR}}${BLD}
+ else
+ echo ${TAG}-${ADD}${CMT:+~${CMT}}${BLD}
+ fi
+ else
+ echo ${TAG}-release
+fi \ No newline at end of file