aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Sardara <msardara+fdio@cisco.com>2017-04-13 11:58:24 +0200
committerMauro Sardara <msardara+fdio@cisco.com>2017-04-13 12:23:36 +0000
commit0e2c1893b4cf0e31aec7b731162fcb235db459f3 (patch)
treecf2a1286e394f6eb31cdda2072def12b5717686c
parent8b0ac576c778b380ff341ce4022b4d1f83aa7021 (diff)
Adding support for package creation.Vicn-v1.0
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 Change-Id: I852e4b669114cfedaa1bb4d82e970f9aa639919b Signed-off-by: Mauro Sardara <msardara+fdio@cisco.com>
-rw-r--r--.gitignore32
-rw-r--r--emu-radio/CMakeLists.txt2
-rw-r--r--emu-radio/lte-emulator/CMakeLists.txt18
-rw-r--r--emu-radio/scripts/build-package.sh226
-rw-r--r--emu-radio/scripts/version57
-rw-r--r--emu-radio/wifi-emulator/CMakeLists.txt17
6 files changed, 332 insertions, 20 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..fb2d4e25
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,32 @@
+build/
+=======
+liblongbow*tar.gz
+lib
+bin
+include
+*.o
+*.lo
+*.a
+*.la
+.libs
+a.out
+.DS_Store
+.gcda
+.gcno
+.dSYM
+autom4te.cache
+config.h
+config.log
+config.status
+stamp-h1
+*.trs
+Makefile
+.deps
+*.pyc
+.dirstamp
+*.swp
+libtool
+*~
+*.pyc
+.idea
+*.deb
diff --git a/emu-radio/CMakeLists.txt b/emu-radio/CMakeLists.txt
index 10be56d1..e507d228 100644
--- a/emu-radio/CMakeLists.txt
+++ b/emu-radio/CMakeLists.txt
@@ -11,7 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.4)
+cmake_minimum_required(VERSION 3.2)
project(Radio_Emulation)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/")
diff --git a/emu-radio/lte-emulator/CMakeLists.txt b/emu-radio/lte-emulator/CMakeLists.txt
index f98586dd..a265fff5 100644
--- a/emu-radio/lte-emulator/CMakeLists.txt
+++ b/emu-radio/lte-emulator/CMakeLists.txt
@@ -11,12 +11,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.4)
+cmake_minimum_required(VERSION 3.2)
project(lte_emulator)
-set(${CMAKE_PROJECT_NAME}_VERSION_MAJOR 1)
-set(${CMAKE_PROJECT_NAME}_VERSION_MINOR 0)
-
pkg_search_module(NS3-lte REQUIRED libns3.26-lte-optimized libns3.26-lte libns3.26-lte-debug libns3.25-lte-optimized libns3.25-lte libns3.25-lte-debug libns3.24.1-lte-optimized libns3.24.1-lte libns3.24.1-lte-debug)
pkg_search_module(NS3-internet REQUIRED libns3.26-internet-optimized libns3.26-internet libns3.26-internet-debug libns3.25-internet-optimized libns3.25-internet libns3.25-internet-debug libns3.24.1-internet-optimized libns3.24.1-internet libns3.24.1-internet-debug)
pkg_search_module(NS3-csma REQUIRED libns3.26-csma-optimized libns3.26-csma libns3.26-csma-debug libns3.25-csma-optimized libns3.25-csma libns3.25-csma-debug libns3.24.1-csma-optimized libns3.24.1-csma libns3.24.1-csma-debug)
@@ -53,25 +50,26 @@ SET(CONTACT "msardara@cisco.com" CACHE STRING "Contact")
SET(DISTRIBUTION "xenial" CACHE STRING "Distribution")
SET(ARCHITECTURE "amd64" CACHE STRING "Architecture")
SET(PACKAGE_MAINTAINER "Mauro Sardara (msardara@cisco.com)" CACHE STRING "Maintainer")
-SET(PACKAGE_VERSION "1.0" CACHE STRING "Version")
SET(BUILD_NUMBER "1" CACHE STRING "Build Number")
SET(PACKAGE_NAME lte-emulator)
-
SET(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
-SET(CPACK_PACKAGE_VERSION_MAJOR ${${CMAKE_PROJECT_NAME}_VERSION_MAJOR})
-SET(CPACK_PACKAGE_VERSION_MINOR ${${CMAKE_PROJECT_NAME}_VERSION_MINOR})
SET(CPACK_PACKAGE_VENDOR ${VENDOR})
SET(CPACK_PACKAGE_CONTACT ${CONTACT})
+# Get the version
+execute_process(COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/version
+ OUTPUT_VARIABLE PACKAGE_VERSION)
+string(STRIP ${PACKAGE_VERSION} PACKAGE_VERSION)
+
if(DEB_PACKAGE)
SET(TYPE "DEBIAN")
SET(GENERATOR "DEB")
- SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}_${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}-${BUILD_NUMBER}~${DISTRIBUTION}_${ARCHITECTURE}")
+ SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}_${PACKAGE_VERSION}_${ARCHITECTURE}")
SET(CPACK_${TYPE}_PACKAGE_DEPENDS "libns3sx-3v5, ns3sx, libboost-system1.58.0")
elseif(RPM_PACKAGE)
SET(TYPE "RPM")
SET(GENERATOR "RPM")
- SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}-${BUILD_NUMBER}.${DISTRIBUTION}.${ARCHITECTURE}")
+ SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}-${PACKAGE_VERSION}.${ARCHITECTURE}")
SET(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/etc" "/usr/lib/python2.7" "/usr/lib/python2.7/site-packages")
SET(CPACK_${TYPE}_PACKAGE_REQUIRES "")
else()
diff --git a/emu-radio/scripts/build-package.sh b/emu-radio/scripts/build-package.sh
new file mode 100644
index 00000000..d77d1b64
--- /dev/null
+++ b/emu-radio/scripts/build-package.sh
@@ -0,0 +1,226 @@
+#!/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"}
+
+PACKAGE_NAME="RADIO_EMULATOR"
+RADIO_EMULATOR_DEPS_UBUNTU="pkg-config libboost-all-dev libsqlite3-dev libopenmpi-dev libxml2-dev libwebsocketpp-dev"
+
+BUILD_TOOLS="build-essential cmake"
+
+# 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/"
+ REPO=${REPO_NAME:-"master.ubuntu.xenial.main"}
+ REPO_CICN_URL="${NEXUS_PROXY}/content/repositories/fd.io.${REPO}"
+ elif [ "$DISTRIB_CODENAME" == "trusty" ]; then
+ REPO_VPP_URL="${NEXUS_PROXY}/content/repositories/fd.io.stable.1701.ubuntu.trusty.main/"
+ REPO=${REPO_NAME:-"master.ubuntu.trusty.main"}
+ REPO_CICN_URL="${NEXUS_PROXY}/content/repositories/fd.io.${REPO}"
+ 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
+ echo "deb ${REPO_CICN_URL} ./" | sudo tee /etc/apt/sources.list.d/99fd.io.master.list
+
+ elif [ "$DISTRIB_ID" == "CentOS" ]; then
+ REPO_VPP_URL="${NEXUS_PROXY}/content/repositories/fd.io.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
+
+[fdio-cicn-master]
+name=fd.io master branch latest merge
+baseurl=${REPO_CICN_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
+
+}
+
+# Parameters
+# $1 = DISTRIB_ID
+# $2 = DISTRIB_CODENAME
+#
+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 = WIFI / LTE
+#
+build() {
+ PARAM=$1
+ mkdir -p build
+ cd build
+ find . -not -name '*.deb' -not -name '*.rpm' -print0 | xargs -0 rm -rf -- || true
+ echo $PARAM | xargs cmake -DCMAKE_INSTALL_PREFIX=/usr -DRPM_PACKAGE=$RPM -DDEB_PACKAGE=$DEB -DDISTRIBUTION=$DISTRIB_CODENAME -DARCHITECTURE=$ARCHITECTURE ..
+ make
+}
+
+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 deps
+
+if [ $DISTRIB_ID == "Ubuntu" ]; then
+ echo $BUILD_TOOLS $RADIO_EMULATOR_DEPS_UBUNTU | xargs sudo ${apt_get} install -y --allow-unauthenticated || true
+else
+ echo "This package is currently supported only for ubuntu. Exiting.."
+ exit -1
+fi
+
+BLD_NUMBER=${BUILD_NUMBER:-"1"}
+
+# Install libns3
+
+pushd ../ns3-packages
+mv libns3sx-3v5_3.24.1-6~xenial_amd64.deb libns3sx-3v5_3.24.1-$BLD_NUMBER~xenial_amd64.deb || true
+mv libns3sx-dev_3.24.1-6~xenial_amd64.deb libns3sx-dev_3.24.1-$BLD_NUMBER~xenial_amd64.deb || true
+mv ns3sx_3.24.1-6~xenial_amd64.deb ns3sx_3.24.1-$BLD_NUMBER~xenial_amd64.deb || true
+
+sudo dpkg -i *.deb || true
+sudo apt-get -f install -y --allow-unauthenticated || true
+popd
+
+# Build wifi-emualtor
+pushd ..
+build "-DWIFI=ON -DLTE=OFF"
+make package
+find . -not -name '*.deb' -not -name '*.rpm' -print0 | xargs -0 rm -rf -- || true
+popd
+
+# Build lte-emualtor
+pushd ..
+build "-DLTE=ON -DWIFI=OFF"
+make package
+find . -not -name '*.deb' -not -name '*.rpm' -print0 | xargs -0 rm -rf -- || true
+popd \ No newline at end of file
diff --git a/emu-radio/scripts/version b/emu-radio/scripts/version
new file mode 100644
index 00000000..dcf93d83
--- /dev/null
+++ b/emu-radio/scripts/version
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+path=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
+version_prefix="Vicn-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
diff --git a/emu-radio/wifi-emulator/CMakeLists.txt b/emu-radio/wifi-emulator/CMakeLists.txt
index a0caf715..558a751f 100644
--- a/emu-radio/wifi-emulator/CMakeLists.txt
+++ b/emu-radio/wifi-emulator/CMakeLists.txt
@@ -11,12 +11,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.4)
+cmake_minimum_required(VERSION 3.2)
project(wifi_emulator)
-set(${CMAKE_PROJECT_NAME}_VERSION_MAJOR 1)
-set(${CMAKE_PROJECT_NAME}_VERSION_MINOR 0)
-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
pkg_search_module(NS3-wifi REQUIRED libns3.26-wifi-optimized libns3.26-wifi libns3.26-wifi-debug libns3.25-wifi-optimized libns3.25-wifi libns3.25-wifi-debug libns3.24.1-wifi-optimized libns3.24.1-wifi libns3.24.1-wifi-debug)
@@ -46,25 +43,27 @@ SET(CONTACT "msardara@cisco.com" CACHE STRING "Contact")
SET(DISTRIBUTION "xenial" CACHE STRING "Distribution")
SET(ARCHITECTURE "amd64" CACHE STRING "Architecture")
SET(PACKAGE_MAINTAINER "Mauro Sardara (msardara@cisco.com)" CACHE STRING "Maintainer")
-SET(PACKAGE_VERSION "1.0" CACHE STRING "Version")
SET(BUILD_NUMBER "1" CACHE STRING "Build Number")
SET(PACKAGE_NAME wifi-emulator)
SET(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
-SET(CPACK_PACKAGE_VERSION_MAJOR ${${CMAKE_PROJECT_NAME}_VERSION_MAJOR})
-SET(CPACK_PACKAGE_VERSION_MINOR ${${CMAKE_PROJECT_NAME}_VERSION_MINOR})
SET(CPACK_PACKAGE_VENDOR ${VENDOR})
SET(CPACK_PACKAGE_CONTACT ${CONTACT})
+# Get the version
+execute_process(COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/version
+ OUTPUT_VARIABLE PACKAGE_VERSION)
+string(STRIP ${PACKAGE_VERSION} PACKAGE_VERSION)
+
if(DEB_PACKAGE)
SET(TYPE "DEBIAN")
SET(GENERATOR "DEB")
- SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}_${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}-${BUILD_NUMBER}~${DISTRIBUTION}_${ARCHITECTURE}")
+ SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}_${PACKAGE_VERSION}_${ARCHITECTURE}")
SET(CPACK_${TYPE}_PACKAGE_DEPENDS "libns3sx-3v5, ns3sx, libboost-system1.58.0")
elseif(RPM_PACKAGE)
SET(TYPE "RPM")
SET(GENERATOR "RPM")
- SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}-${BUILD_NUMBER}.${DISTRIBUTION}.${ARCHITECTURE}")
+ SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}-${PACKAGE_VERSION}.${ARCHITECTURE}")
SET(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/etc" "/usr/lib/python2.7" "/usr/lib/python2.7/site-packages")
SET(CPACK_${TYPE}_PACKAGE_REQUIRES "")
else()