summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2020-11-06 12:42:46 +0100
committerMauro Sardara <msardara@cisco.com>2020-11-06 17:15:30 +0100
commit7f2bbf5f6934be58c016f0159e497fa519d14372 (patch)
tree0d6469b1a4089756dba08b8a76d109dd120095fe
parentda2c11cfd77383f37dd01e67efb5c44dece9c3a9 (diff)
[HICN-653] Cleanup build scripts.
Main changes: - Next VPP version is now counted 4 months (instead of 3) from the current one - CMake will now use Ninja as generator - Build functions are gathered under build/functions.sh and they are shared instead of being duplicated in build-extras and build-packages - Various bug fixes for dependencies and versioning. Signed-off-by: Mauro Sardara <msardara@cisco.com> Change-Id: I3f482d2c87847a465019dd0992ee9375c88bb412 Signed-off-by: Mauro Sardara <msardara@cisco.com>
-rw-r--r--apps/cmake/Modules/Packaging.cmake10
-rw-r--r--cmake/Modules/Packager.cmake17
-rw-r--r--extras/libmemif/CMakeLists.txt3
-rw-r--r--extras/libmemif/cmake/Modules/Packaging.cmake12
-rw-r--r--hicn-plugin/cmake/Modules/Packaging.cmake10
-rw-r--r--scripts/build-extras.sh151
-rw-r--r--scripts/build-packages.sh228
-rw-r--r--scripts/functions.sh161
8 files changed, 246 insertions, 346 deletions
diff --git a/apps/cmake/Modules/Packaging.cmake b/apps/cmake/Modules/Packaging.cmake
index 6a6e34777..9b3fa2e72 100644
--- a/apps/cmake/Modules/Packaging.cmake
+++ b/apps/cmake/Modules/Packaging.cmake
@@ -22,7 +22,17 @@ set(${HICN_APPS}_DEB_DEPENDENCIES
CACHE STRING "Dependencies for deb/rpm package."
)
+set(${HICN_APPS}-dev_DEB_DEPENDENCIES
+ "lib${LIBTRANSPORT}-dev (>= stable_version)"
+ CACHE STRING "Dependencies for deb/rpm package."
+)
+
set(${HICN_APPS}_RPM_DEPENDENCIES
"lib${LIBTRANSPORT} >= stable_version"
CACHE STRING "Dependencies for deb/rpm package."
+)
+
+set(${HICN_APPS}-dev_RPM_DEPENDENCIES
+ "lib${LIBTRANSPORT}-devel >= stable_version"
+ CACHE STRING "Dependencies for deb/rpm package."
) \ No newline at end of file
diff --git a/cmake/Modules/Packager.cmake b/cmake/Modules/Packager.cmake
index 94b0e96a7..a943d1905 100644
--- a/cmake/Modules/Packager.cmake
+++ b/cmake/Modules/Packager.cmake
@@ -26,10 +26,10 @@ function(get_next_version VERSION NEXT_VERSION)
list(GET VER_NUMBERS 0 major)
list(GET VER_NUMBERS 1 minor)
- math(EXPR minor "${minor} + 3")
+ math(EXPR minor "${minor} + 4")
if (minor GREATER 12)
- set(minor "1")
+ math(EXPR minor "${minor} % 12")
math(EXPR major "${major} + 1")
endif()
@@ -63,7 +63,7 @@ macro(extract_version)
list(GET VER 4 COMMIT_NAME)
endmacro(extract_version)
-macro(make_packages)
+function(make_packages)
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
# parse /etc/os-release
file(READ "/etc/os-release" os_version)
@@ -108,11 +108,18 @@ macro(make_packages)
message(STATUS "Version: ${deb_ver}")
get_next_version(${tag} next_version)
+ message(STATUS "Next version: ${next_version}")
get_cmake_property(components COMPONENTS)
list(REMOVE_ITEM components "Unspecified")
set(CPACK_COMPONENTS_ALL ${components})
+ list(LENGTH components N_COMPONENTS)
+
+ if (NOT N_COMPONENTS)
+ return()
+ endif()
+
if(OS_ID MATCHES "debian" OR OS_ID_LIKE MATCHES "debian")
set(CPACK_GENERATOR "DEB")
set(type "DEBIAN")
@@ -166,7 +173,7 @@ macro(make_packages)
set(CPACK_${type}_${uc}_DESCRIPTION "${${lc}_DESCRIPTION}")
set(RPM_DEPS)
- if (NOT ${${lc}_DEB_DEPENDENCIES} STREQUAL "")
+ if (NOT ${${lc}_RPM_DEPENDENCIES} STREQUAL "")
string(REPLACE "stable_version" ${tag} RPM_DEPS ${${lc}_RPM_DEPENDENCIES})
string(REPLACE "next_version" ${next_version} RPM_DEPS ${RPM_DEPS})
endif()
@@ -207,4 +214,4 @@ macro(make_packages)
include(CPack)
endif()
endif()
-endmacro()
+endfunction()
diff --git a/extras/libmemif/CMakeLists.txt b/extras/libmemif/CMakeLists.txt
index 5ac2b7e1b..11c87fe12 100644
--- a/extras/libmemif/CMakeLists.txt
+++ b/extras/libmemif/CMakeLists.txt
@@ -34,8 +34,7 @@ ExternalProject_Add(libmemif
LIST_SEPARATOR |
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_MODULE_PATH=${MODULE_PATH}
SOURCE_SUBDIR ./extras/libmemif
- BUILD_COMMAND make package
- INSTALL_COMMAND make DESTDIR=${DESTDIR} install
+ BUILD_COMMAND ${CMAKE_COMMAND} --build . -- package
)
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
diff --git a/extras/libmemif/cmake/Modules/Packaging.cmake b/extras/libmemif/cmake/Modules/Packaging.cmake
index 50f820589..7f6d53ceb 100644
--- a/extras/libmemif/cmake/Modules/Packaging.cmake
+++ b/extras/libmemif/cmake/Modules/Packaging.cmake
@@ -15,30 +15,30 @@
# Packages section
######################
-set(${LIBMEMIF}_DESCRIPTION
+set(lib${LIBMEMIF}_DESCRIPTION
"Libmemif, shared memory interface"
CACHE STRING "Description for deb/rpm package."
)
-set(${LIBMEMIF}_DEB_DEPENDENCIES
+set(lib${LIBMEMIF}_DEB_DEPENDENCIES
"" CACHE STRING "Dependencies for deb/rpm package."
)
-set(${LIBMEMIF}_RPM_DEPENDENCIES
+set(lib${LIBMEMIF}_RPM_DEPENDENCIES
"" CACHE STRING "Dependencies for deb/rpm package."
)
-set(${LIBMEMIF}-dev_DESCRIPTION
+set(lib${LIBMEMIF}-dev_DESCRIPTION
"Libmemif, shared memory interface header files"
CACHE STRING "Description for deb/rpm package."
)
-set(${LIBMEMIF}-dev_DEB_DEPENDENCIES
+set(lib${LIBMEMIF}-dev_DEB_DEPENDENCIES
"libmemif (>= stable_version)"
CACHE STRING "Dependencies for deb/rpm package."
)
-set(${LIBMEMIF}-dev_RPM_DEPENDENCIES
+set(lib${LIBMEMIF}-dev_RPM_DEPENDENCIES
"libmemif (>= stable_version)"
CACHE STRING "Dependencies for deb/rpm package."
)
diff --git a/hicn-plugin/cmake/Modules/Packaging.cmake b/hicn-plugin/cmake/Modules/Packaging.cmake
index 61453d6fd..f8d49388c 100644
--- a/hicn-plugin/cmake/Modules/Packaging.cmake
+++ b/hicn-plugin/cmake/Modules/Packaging.cmake
@@ -25,11 +25,21 @@ set(${HICN_PLUGIN}_DEB_DEPENDENCIES
CACHE STRING "Dependencies for deb/rpm package."
)
+set(${HICN_PLUGIN}-dev_DEB_DEPENDENCIES
+ "vpp-dev (>= stable_version-release), vpp-dev (<< next_version-release), libvppinfra-dev (>= stable_version-release), libvppinfra-dev (<< next_version-release)"
+ CACHE STRING "Dependencies for deb/rpm package."
+)
+
set(${HICN_PLUGIN}_RPM_DEPENDENCIES
"vpp >= stable_version-release, vpp < next_version-release, vpp-plugins >= stable_version-release, vpp-plugins < next_version-release"
CACHE STRING "Dependencies for deb/rpm package."
)
+set(${HICN_PLUGIN}-dev_RPM_DEPENDENCIES
+ "vpp-dev >= stable_version-release, vpp-dev < next_version-release, libvppinfra-devel >= stable_version-release, libvppinfra-devel < next_version-release"
+ CACHE STRING "Dependencies for deb/rpm package."
+)
+
set(${HICN_PLUGIN}_DEB_PACKAGE_CONTROL_EXTRA
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/postinst"
CACHE STRING "Control scripts conffiles, postinst, postrm, prerm."
diff --git a/scripts/build-extras.sh b/scripts/build-extras.sh
index 2c5d95794..948e2d15b 100644
--- a/scripts/build-extras.sh
+++ b/scripts/build-extras.sh
@@ -15,143 +15,36 @@
set -euxo pipefail
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
-APT_PATH=`which apt-get` || true
-apt_get=${APT_PATH:-"/usr/local/bin/apt-get"}
-
-PACKAGECLOUD_RELEASE_REPO_DEB="https://packagecloud.io/install/repositories/fdio/release/script.deb.sh"
-PACKAGECLOUD_RELEASE_REPO_RPM="https://packagecloud.io/install/repositories/fdio/release/script.rpm.sh"
-
-VPP_GIT_REPO="https://git.fd.io/vpp"
-VPP_BRANCH="stable/2005"
-
-VPP_VERSION_DEB="20.05-release"
-VPP_VERSION_RPM="20.05-release.x86_64"
-
-BUILD_TOOLS_UBUNTU="build-essential doxygen"
-LIBSSL_LIBEVENT_UBUNTU="libevent-dev libssl-dev"
-DEPS_UBUNTU="libvppinfra=${VPP_VERSION_DEB} \
- libvppinfra-dev=${VPP_VERSION_DEB} \
- vpp=${VPP_VERSION_DEB} \
- vpp-dev=${VPP_VERSION_DEB} \
- vpp-plugin-core=${VPP_VERSION_DEB}"
-
-# BUILD_TOOLS_GROUP_CENTOS="'Development Tools'"
-DEPS_CENTOS="vpp-devel-${VPP_VERSION_RPM} \
- vpp-lib-${VPP_VERSION_RPM} \
- centos-release-scl \
- devtoolset-7"
-
-LATEST_EPEL_REPO="http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
-
-install_cmake() {
- if ! grep -q "8.8.8.8" /etc/resolv.conf; then
- echo "nameserver 8.8.8.8" | sudo tee -a /etc/resolv.conf
- fi
-
- cat /etc/resolv.conf
-
- CMAKE_INSTALL_SCRIPT_URL="https://cmake.org/files/v3.8/cmake-3.8.0-Linux-x86_64.sh"
- CMAKE_INSTALL_SCRIPT="/tmp/install_cmake.sh"
- curl ${CMAKE_INSTALL_SCRIPT_URL} > ${CMAKE_INSTALL_SCRIPT}
-
- sudo mkdir -p /opt/cmake
- sudo bash ${CMAKE_INSTALL_SCRIPT} --skip-license --prefix=/opt/cmake
- export PATH=/opt/cmake/bin:${PATH}
-}
-
-# Parameters:
-# $1 = Distribution id
-# $2 = Distribution codename
-#
-setup_fdio_repo() {
- DISTRIB_ID=${1}
-
- if [ "${DISTRIB_ID}" == "ubuntu" ]; then
- curl -s ${PACKAGECLOUD_RELEASE_REPO_DEB} | sudo bash
- elif [ "${DISTRIB_ID}" == "centos" ]; then
- curl -s ${PACKAGECLOUD_RELEASE_REPO_RPM} | sudo bash
- curl ${LATEST_EPEL_REPO} > epel-release-latest-7.noarch.rpm
- rpm -ivh epel-release-latest-7.noarch.rpm || true
- rm epel-release-latest-7.noarch.rpm
- else
- echo "Distribution ${DISTRIB_ID} is not supported"
- exit -1
- fi
-}
-
-setup() {
- # Figure out what system we are running on
- if [ -f /etc/os-release ]; then
- . /etc/os-release
- else
- echo "ERROR: System configuration not recognized. Build failed"
- exit -1
- fi
-
- DISTRIB_ID=${ID}
-
- echo DISTRIBUTION: ${PRETTY_NAME}
- echo ARCHITECTURE: $(uname -m)
-
- ARCH=`uname -m`
- if [ "$ARCH" == "x86_64" ] || [ "$ARCH" == "x86" ]; then
- install_cmake
- fi
- setup_fdio_repo ${DISTRIB_ID}
-
- if [ "${DISTRIB_ID}" == "ubuntu" ]; then
- sudo ${apt_get} update || true
- fi
-
- # Install dependencies
- if [ ${DISTRIB_ID} == "ubuntu" ]; then
- echo ${BUILD_TOOLS_UBUNTU} ${DEPS_UBUNTU} | xargs sudo ${apt_get} install -y --allow-unauthenticated --no-install-recommends
- sudo ${apt_get} clean && sudo ${apt_get} update
- sudo ${apt_get} install -y --allow-unauthenticated --no-install-recommends libpcre3-dev
- elif [ ${DISTRIB_ID} == "centos" ]; then
- # echo ${BUILD_TOOLS_GROUP_CENTOS} | xargs sudo yum groupinstall -y --nogpgcheck
- echo ${DEPS_CENTOS} | xargs sudo yum install -y --nogpgcheck
- sudo yum install devtoolset-7 pcre-devel
-
- CXX_COMPILER="/opt/rh/devtoolset-7/root/usr/bin/c++"
- CC_COMPILER="/opt/rh/devtoolset-7/root/usr/bin/cc"
-
- ${CXX_COMPILER} --version
- ${CC_COMPILER} --version
-
- export CC=${CC_COMPILER} CXX=${CXX_COMPILER}
- fi
-}
+source ${SCRIPT_PATH}/functions.sh
# Parameters:
# $1 = Package name
#
-build_package() {
+function build_package() {
setup
- echo "*******************************************************************"
- echo "********************* STARTING PACKAGE BUILD **********************"
- echo "*******************************************************************"
+ echo "**************************************************************************"
+ echo "********************* STARTING PACKAGE EXTRAS BUILD **********************"
+ echo "**************************************************************************"
mkdir -p build && pushd build
-
- rm -rf *
- cmake -DCMAKE_INSTALL_PREFIX=/usr \
- -DBUILD_LIBHICN=OFF \
- -DBUILD_UTILS=OFF \
- -DBUILD_HICNPLUGIN=OFF \
- -DBUILD_HICNLIGHT=OFF \
- -DBUILD_LIBTRANSPORT=OFF \
- -DBUILD_APPS=OFF \
- -DBUILD_CTRL=OFF \
- -DBUILD_SYSREPOPLUGIN=OFF \
- -DBUILD_EXTRAS=ON \
- ${SCRIPT_PATH}/..
- make package
-
- find . -type d -iname '_CPack_Packages' -print0 | xargs -0 rm -rf -- || true
- find . -iname '*Unspecified*' -print0 | xargs -0 rm -rf -- || true
-
+ rm -rf *
+ cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/usr \
+ -DBUILD_LIBHICN=OFF \
+ -DBUILD_UTILS=OFF \
+ -DBUILD_HICNPLUGIN=OFF \
+ -DBUILD_HICNLIGHT=OFF \
+ -DBUILD_LIBTRANSPORT=OFF \
+ -DBUILD_APPS=OFF \
+ -DBUILD_CTRL=OFF \
+ -DBUILD_SYSREPOPLUGIN=OFF \
+ -DBUILD_EXTRAS=ON \
+ ${SCRIPT_PATH}/..
+ ninja
+
+ find . -type f '(' -name '*.deb' -o -name '*.rpm' ')' -exec mv {} . \;
+ find . -not -name '*.deb' -not -name '*.rpm' -print0 | xargs -0 rm -rf -- || true
+ rm *Unspecified* || true
popd
echo "*******************************************************************"
diff --git a/scripts/build-packages.sh b/scripts/build-packages.sh
index cc9074d38..c9f329d9a 100644
--- a/scripts/build-packages.sh
+++ b/scripts/build-packages.sh
@@ -15,190 +15,12 @@
set -euxo pipefail
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
-APT_PATH=`which apt-get` || true
-apt_get=${APT_PATH:-"/usr/local/bin/apt-get"}
-
-PACKAGECLOUD_RELEASE_REPO_DEB="https://packagecloud.io/install/repositories/fdio/release/script.deb.sh"
-PACKAGECLOUD_RELEASE_REPO_RPM="https://packagecloud.io/install/repositories/fdio/release/script.rpm.sh"
-
-VPP_GIT_REPO="https://git.fd.io/vpp"
-VPP_BRANCH="stable/2005"
-
-VPP_VERSION_DEB="20.09-release"
-VPP_VERSION_RPM="20.09-release.x86_64"
-
-BUILD_TOOLS_UBUNTU="build-essential doxygen"
-LIBSSL_LIBEVENT_UBUNTU="libevent-dev libssl-dev"
-DEPS_UBUNTU="libparc-dev \
- libmemif-dev \
- libmemif \
- libasio-dev \
- libconfig-dev \
- libcurl4-openssl-dev \
- vpp=${VPP_VERSION_DEB} \
- vpp-dev=${VPP_VERSION_DEB} \
- libvppinfra=${VPP_VERSION_DEB} \
- libvppinfra-dev=${VPP_VERSION_DEB} \
- vpp-plugin-core=${VPP_VERSION_DEB} \
- python3-ply"
-
-
-DEPS_UBUNTU_NOVERSION="libparc-dev \
- libmemif-dev \
- libmemif \
- libasio-dev \
- libconfig-dev \
- libcurl4-openssl-dev \
- vpp \
- vpp-dev \
- libvppinfra \
- libvppinfra-dev \
- vpp-plugin-core \
- python3-ply \
- python3-setuptools \
- python3-pip"
-
-DEPS_CMAKE_UBUNTU="curl"
-
-# BUILD_TOOLS_GROUP_CENTOS="'Development Tools'"
-DEPS_CENTOS="vpp-devel-${VPP_VERSION_RPM} \
- vpp-lib-${VPP_VERSION_RPM} \
- libparc-devel \
- libmemif-devel \
- libmemif \
- libcurl-devel \
- asio-devel \
- libconfig-devel \
- centos-release-scl \
- devtoolset-7"
-
-DEPS_CENTOS_NOVERSION="vpp-devel \
- vpp-lib \
- libparc-devel \
- libcurl-devel \
- asio-devel \
- libmemif-devel \
- libmemif \
- centos-release-scl \
- devtoolset-7"
-
-LATEST_EPEL_REPO="http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
-
-install_cmake() {
- if [ "${DISTRIB_ID}" == "ubuntu" ]; then
- sudo apt update
- echo ${DEPS_CMAKE_UBUNTU} | xargs sudo ${apt_get} install -y --allow-unauthenticated --no-install-recommends
- fi
-
- if ! grep -q "8.8.8.8" /etc/resolv.conf; then
- echo "nameserver 8.8.8.8" | sudo tee -a /etc/resolv.conf
- fi
-
- cat /etc/resolv.conf
-
- CMAKE_INSTALL_SCRIPT_URL="https://cmake.org/files/v3.8/cmake-3.8.0-Linux-x86_64.sh"
- CMAKE_INSTALL_SCRIPT="/tmp/install_cmake.sh"
- curl ${CMAKE_INSTALL_SCRIPT_URL} > ${CMAKE_INSTALL_SCRIPT}
-
- sudo mkdir -p /opt/cmake
- sudo bash ${CMAKE_INSTALL_SCRIPT} --skip-license --prefix=/opt/cmake
- export PATH=/opt/cmake/bin:${PATH}
-}
-
-# Parameters:
-# $1 = Distribution id
-# $2 = Distribution codename
-#
-setup_fdio_repo() {
- DISTRIB_ID=${1}
-
- if [ "${DISTRIB_ID}" == "ubuntu" ]; then
- curl -s ${PACKAGECLOUD_RELEASE_REPO_DEB} | sudo bash
- elif [ "${DISTRIB_ID}" == "centos" ]; then
- curl -s ${PACKAGECLOUD_RELEASE_REPO_RPM} | sudo bash
- curl ${LATEST_EPEL_REPO} > epel-release-latest-7.noarch.rpm
- rpm -ivh epel-release-latest-7.noarch.rpm || true
- rm epel-release-latest-7.noarch.rpm
- else
- echo "Distribution ${DISTRIB_ID} is not supported"
- exit -1
- fi
-}
-
-setup() {
- # Figure out what system we are running on
- if [ -f /etc/os-release ]; then
- . /etc/os-release
- else
- echo "ERROR: System configuration not recognized. Build failed"
- exit -1
- fi
-
- DISTRIB_ID=${ID}
-
- echo DISTRIBUTION: ${PRETTY_NAME}
- echo ARCHITECTURE: $(uname -m)
-
- ARCH=`uname -m`
- if [ "$ARCH" == "x86_64" ] || [ "$ARCH" == "x86" ]; then
- install_cmake
- fi
- setup_fdio_repo ${DISTRIB_ID}
-
- if [ "${DISTRIB_ID}" == "ubuntu" ]; then
- sudo ${apt_get} update || true
- fi
-
- # Install dependencies
- if [ ${DISTRIB_ID} == "ubuntu" ]; then
- echo ${BUILD_TOOLS_UBUNTU} ${DEPS_UBUNTU} | xargs sudo ${apt_get} install -y --allow-unauthenticated --no-install-recommends
- elif [ ${DISTRIB_ID} == "centos" ]; then
- # echo ${BUILD_TOOLS_GROUP_CENTOS} | xargs sudo yum groupinstall -y --nogpgcheck
- echo ${DEPS_CENTOS} | xargs sudo yum install -y --nogpgcheck
- sudo yum install devtoolset-7
-
- c++ --version
-
- CXX_COMPILER="/opt/rh/devtoolset-7/root/usr/bin/c++"
- CC_COMPILER="/opt/rh/devtoolset-7/root/usr/bin/cc"
-
- ${CXX_COMPILER} --version
- ${CC_COMPILER} --version
-
- export CC=${CC_COMPILER} CXX=${CXX_COMPILER}
- fi
-
- # do nothing but check compiler version
- c++ --version
-}
-
-
-install_collectd_headers() {
- if [ -f /etc/os-release ]; then
- . /etc/os-release
- else
- echo "ERROR: System configuration not recognized. Build failed"
- exit -1
- fi
-
- if [ "${DISTRIB_ID}" == "ubuntu" ]; then
- sudo apt-get install collectd-dev -y --allow-unauthenticated
-
- if [ "${VERSION_CODENAME}" == "xenial" ]; then
- awk '/config.h/ { print; print "#include \"collectd/liboconfig/oconfig.h\""; next }1' /usr/include/collectd/core/daemon/configfile.h | sudo tee /usr/include/collectd/core/daemon/configfile.h
- fi
- elif [ "${DISTRIB_ID}" == "centos" ]; then
- wget https://storage.googleapis.com/collectd-tarballs/collectd-5.9.2.tar.bz2
- tar -xf collectd-5.9.2.tar.bz2
- cd collectd-5.9.2 && ./configure && make && cd -
- export COLLECTD_HOME=${PWD}/collectd-5.9.2/src
- fi
-}
+source ${SCRIPT_PATH}/functions.sh
# Parameters:
# $1 = Package name
#
-build_package() {
+function build_package() {
setup
echo "*******************************************************************"
@@ -207,29 +29,27 @@ build_package() {
# Make the package
mkdir -p ${SCRIPT_PATH}/../build && pushd ${SCRIPT_PATH}/../build
-
- rm -rf *
- cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_APPS=ON ..
- make VERBOSE=1 -j8 package
-
- rm -rf libtransport ctrl/libhicnctrl
-
- install_collectd_headers
-
- cmake -DCMAKE_INSTALL_PREFIX=/usr \
- -DBUILD_HICNPLUGIN=ON \
- -DBUILD_LIBTRANSPORT=ON \
- -DBUILD_APPS=ON \
- -DBUILD_HICNLIGHT=OFF \
- -DBUILD_SYSREPOPLUGIN=OFF \
- -DBUILD_TELEMETRY=ON \
- ${SCRIPT_PATH}/..
-
- make VERBOSE=1 -j8 package
-
- find . -not -name '*.deb' -not -name '*.rpm' -print0 | xargs -0 rm -rf -- || true
- rm *Unspecified* || true
-
+ rm -rf *
+
+ # First round - Without libmemif
+ cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_APPS=ON ..
+ ninja -j8 package
+
+ # Second round - With Libmemif
+ rm -rf libtransport ctrl/libhicnctrl
+ cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/usr \
+ -DBUILD_HICNPLUGIN=ON \
+ -DBUILD_LIBTRANSPORT=ON \
+ -DBUILD_APPS=ON \
+ -DBUILD_HICNLIGHT=OFF \
+ -DBUILD_SYSREPOPLUGIN=OFF \
+ -DBUILD_TELEMETRY=ON \
+ ${SCRIPT_PATH}/..
+
+ ninja -j8 package
+
+ find . -not -name '*.deb' -not -name '*.rpm' -print0 | xargs -0 rm -rf -- || true
+ rm *Unspecified* || true
popd
echo "*******************************************************************"
@@ -267,7 +87,7 @@ build_doxygen() {
}
function usage() {
- echo "Usage: ${0} [doc|sphinx|doxygen]"
+ echo "Usage: ${0} [sphinx|doxygen|packages]"
exit 1
}
diff --git a/scripts/functions.sh b/scripts/functions.sh
new file mode 100644
index 000000000..d047aa094
--- /dev/null
+++ b/scripts/functions.sh
@@ -0,0 +1,161 @@
+# Copyright (c) 2020 Cisco and/or its affiliates.
+# 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.
+
+#!/bin/bash
+set -euxo pipefail
+
+APT_PATH=`which apt-get` || true
+apt_get=${APT_PATH:-"/usr/local/bin/apt-get"}
+
+# Cmake executable
+CMAKE_INSTALL_DIR="/opt/cmake"
+export PATH=:${CMAKE_INSTALL_DIR}/bin:${PATH}
+
+PACKAGECLOUD_RELEASE_REPO_DEB="https://packagecloud.io/install/repositories/fdio/release/script.deb.sh"
+PACKAGECLOUD_RELEASE_REPO_RPM="https://packagecloud.io/install/repositories/fdio/release/script.rpm.sh"
+
+VPP_GIT_REPO="https://github.com/FDio/vpp"
+VPP_BRANCH="stable/2005"
+
+ # Figure out what system we are running on
+if [ -f /etc/os-release ]; then
+ . /etc/os-release
+else
+ echo "ERROR: System configuration not recognized. Build failed"
+ exit 1
+fi
+
+VERSION_REGEX="s/v([0-9]+).([0-9]+)(.*)?-([0-9]+)-(g[0-9a-f]+)/\1.\2\3-release/g"
+VPP_VERSION_DEB=$(git describe --long --match "v*" | sed -E ${VERSION_REGEX})
+VPP_VERSION_RPM="${VPP_VERSION_DEB}.x86_64"
+
+BUILD_TOOLS_UBUNTU=""
+LIBSSL_LIBEVENT_UBUNTU=" "
+DEPS_UBUNTU="build-essential \
+ doxygen \
+ curl \
+ libparc-dev \
+ libmemif-dev \
+ libmemif \
+ libasio-dev \
+ libconfig-dev \
+ libcurl4-openssl-dev \
+ collectd-dev \
+ libevent-dev \
+ libssl-dev \
+ ninja-build \
+ vpp=${VPP_VERSION_DEB} \
+ vpp-dev=${VPP_VERSION_DEB} \
+ libvppinfra=${VPP_VERSION_DEB} \
+ libvppinfra-dev=${VPP_VERSION_DEB} \
+ vpp-plugin-core=${VPP_VERSION_DEB} \
+ python3-ply"
+
+# BUILD_TOOLS_GROUP_CENTOS="'Development Tools'"
+DEPS_CENTOS="vpp-devel-${VPP_VERSION_RPM} \
+ vpp-lib-${VPP_VERSION_RPM} \
+ libparc-devel \
+ curl \
+ libmemif-devel \
+ ninja-build \
+ libmemif \
+ libcurl-devel \
+ asio-devel \
+ libconfig-devel \
+ centos-release-scl \
+ bzip2 \
+ devtoolset-7"
+
+LATEST_EPEL_REPO="http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
+COLLECTD_SOURCE="https://storage.googleapis.com/collectd-tarballs/collectd-5.9.2.tar.bz2"
+
+function install_collectd_headers() {
+ DISTRIB_ID=${ID}
+ if [ "${DISTRIB_ID}" == "centos" ]; then
+ curl -OL ${COLLECTD_SOURCE}
+ tar -xf collectd-5.9.2.tar.bz2
+
+ pushd collectd-5.9.2
+ ./configure && make -j$(nproc)
+ popd
+
+ export COLLECTD_HOME=${PWD}/collectd-5.9.2/src
+ fi
+}
+
+function install_cmake() {
+ [[ $(uname --hardware-platform) = "x86_64" ]] || return 0
+ CMAKE_INSTALL_SCRIPT_URL="https://github.com/Kitware/CMake/releases/download/v3.18.4/cmake-3.18.4-Linux-x86_64.sh"
+ CMAKE_INSTALL_SCRIPT="/tmp/install_cmake.sh"
+ curl -L ${CMAKE_INSTALL_SCRIPT_URL} > ${CMAKE_INSTALL_SCRIPT}
+
+ sudo mkdir -p ${CMAKE_INSTALL_DIR}
+ sudo bash ${CMAKE_INSTALL_SCRIPT} --skip-license --prefix=${CMAKE_INSTALL_DIR}
+}
+
+function setup_fdio_repo() {
+ DISTRIB_ID=${ID}
+
+ if [ "${DISTRIB_ID}" == "ubuntu" ]; then
+ curl -s ${PACKAGECLOUD_RELEASE_REPO_DEB} | sudo bash
+ elif [ "${DISTRIB_ID}" == "centos" ]; then
+ curl -s ${PACKAGECLOUD_RELEASE_REPO_RPM} | sudo bash
+ curl -L ${LATEST_EPEL_REPO} > /tmp/epel-release-latest-7.noarch.rpm
+ rpm -ivh /tmp/epel-release-latest-7.noarch.rpm || true
+ else
+ echo "Distribution ${DISTRIB_ID} is not supported"
+ exit 1
+ fi
+}
+
+# Install dependencies
+function install_deps() {
+ DISTRIB_ID=${ID}
+
+ if [ ${DISTRIB_ID} == "ubuntu" ]; then
+ echo ${BUILD_TOOLS_UBUNTU} ${DEPS_UBUNTU} | xargs sudo ${apt_get} install -y --allow-unauthenticated --no-install-recommends
+ elif [ ${DISTRIB_ID} == "centos" ]; then
+ echo ${DEPS_CENTOS} | xargs sudo yum install -y --nogpgcheck
+ ${CXX_COMPILER} --version
+ ${CC_COMPILER} --version
+ fi
+}
+
+# Call a function once
+function call_once() {
+ # OP_NAME is the name of the function
+ OP_NAME=${1}
+ # If function was already called return
+ [[ -f /tmp/${OP_NAME} ]] && return 0
+ # Otherwise call the function
+ ${@}
+ # And mark the function as called if no error occurred
+ echo ${OP_NAME} > /tmp/${OP_NAME}
+}
+
+function setup() {
+ echo DISTRIBUTION: ${PRETTY_NAME}
+ # export variables depending on the platform we are running
+
+ if [ ${ID} == "centos" ]; then
+ # Compilers location
+ CXX_COMPILER="/opt/rh/devtoolset-7/root/usr/bin/c++"
+ CC_COMPILER="/opt/rh/devtoolset-7/root/usr/bin/cc"
+ export CC=${CC_COMPILER} CXX=${CXX_COMPILER}
+ fi
+
+ call_once setup_fdio_repo
+ call_once install_deps
+ call_once install_cmake
+ call_once install_collectd_headers
+}