diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/build-packages.sh | 40 | ||||
-rw-r--r-- | scripts/checkstyle.sh | 4 | ||||
-rw-r--r-- | scripts/functions.sh | 121 | ||||
-rw-r--r-- | scripts/install-vpp.sh | 38 |
4 files changed, 77 insertions, 126 deletions
diff --git a/scripts/build-packages.sh b/scripts/build-packages.sh index bc386c398..d7684e400 100644 --- a/scripts/build-packages.sh +++ b/scripts/build-packages.sh @@ -28,21 +28,11 @@ function build_package() { echo "*******************************************************************" # Make the package - mkdir -p ${SCRIPT_PATH}/../build && pushd ${SCRIPT_PATH}/../build - rm -rf * + make -C ${SCRIPT_PATH}/.. INSTALL_PREFIX=/usr test package-release - cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/usr \ - -DBUILD_HICNPLUGIN=ON \ - -DBUILD_LIBTRANSPORT=ON \ - -DBUILD_APPS=ON \ - -DBUILD_HICNLIGHT=ON \ - -DBUILD_TELEMETRY=ON \ - ${SCRIPT_PATH}/.. - - ninja -j8 package - - find . -not -name '*.deb' -not -name '*.rpm' -print0 | xargs -0 rm -rf -- || true - rm *Unspecified* *Development* *development* || true + pushd ${SCRIPT_PATH}/../build-release-${ID} + find . -not -name '*.deb' -not -name '*.rpm' -print0 | xargs -0 rm -rf -- || true + rm *Unspecified* *Development* *development* || true popd echo "*******************************************************************" @@ -57,30 +47,15 @@ build_sphinx() { echo "********************* STARTING DOC BUILD **************************" echo "*******************************************************************" - # Make the package - pip3 install -r ${SCRIPT_PATH}/../docs/etc/requirements.txt - pushd ${SCRIPT_PATH}/../docs - make html - - popd + make doc echo "*******************************************************************" echo "***************** BUILD COMPLETED SUCCESSFULLY *******************" echo "*******************************************************************" } -build_doxygen() { - setup - - mkdir -p ${SCRIPT_PATH}/../build-doxygen - pushd ${SCRIPT_PATH}/../build-doxygen - cmake -DBUILD_HICNPLUGIN=On -DBUILD_HICNLIGHT=OFF -DBUILD_LIBTRANSPORT=OFF -DBUILD_UTILS=OFF -DBUILD_APPS=OFF -DBUILD_CTRL=OFF .. - make doc - popd -} - function usage() { - echo "Usage: ${0} [sphinx|doxygen|packages]" + echo "Usage: ${0} [sphinx|packages]" exit 1 } @@ -92,9 +67,6 @@ case "${1}" in sphinx) build_sphinx ;; - doxygen) - build_doxygen - ;; packages) build_package ;; diff --git a/scripts/checkstyle.sh b/scripts/checkstyle.sh index ae775aca9..46cba4507 100644 --- a/scripts/checkstyle.sh +++ b/scripts/checkstyle.sh @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2019 Cisco and/or its affiliates. +# Copyright (c) 2021 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: @@ -11,4 +11,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -exit 0
\ No newline at end of file +exit 0 diff --git a/scripts/functions.sh b/scripts/functions.sh index abb34fb7b..e416ee274 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2021 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: @@ -14,121 +14,62 @@ #!/bin/bash set -euxo pipefail -APT_PATH=`which apt-get` || true +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" -PACKAGECLOUD_HICN_REPO_DEB="https://packagecloud.io/install/repositories/fdio/hicn/script.deb.sh" -PACKAGECLOUD_HICN_REPO_RPM="https://packagecloud.io/install/repositories/fdio/hicn/script.rpm.sh" - -VPP_GIT_REPO="https://github.com/FDio/vpp" -VPP_BRANCH="stable/2005" - - # Figure out what system we are running on +# Figure out what system we are running on if [ -f /etc/os-release ]; then - . /etc/os-release + . /etc/os-release else - echo "ERROR: System configuration not recognized. Build failed" - exit 1 + 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-release/g" -VPP_VERSION_DEB=$(git describe --long --match "v*" | sed -E ${VERSION_REGEX}) -VPP_VERSION_RPM="${VPP_VERSION_DEB}.x86_64" - -DEPS_UBUNTU=("build-essential" - "doxygen" - "curl" - "cmake" - "libasio-dev" - "libconfig-dev" - "libconfig++-dev" - "libcurl4-openssl-dev" - "libevent-dev" - "libssl-dev" - "ninja-build" - "python3-ply") - -DEPS_UBUNTU_PKGCLOUD=("libparc-dev" - "libmemif-dev" - "libmemif" - "vpp=${VPP_VERSION_DEB}" - "vpp-dev=${VPP_VERSION_DEB}" - "libvppinfra=${VPP_VERSION_DEB}" - "libvppinfra-dev=${VPP_VERSION_DEB}" - "vpp-plugin-core=${VPP_VERSION_DEB}" - "libparc-dev") - COLLECTD_SOURCE="https://github.com/collectd/collectd/releases/download/collectd-5.12.0/collectd-5.12.0.tar.bz2" function install_collectd_headers() { - curl -OL ${COLLECTD_SOURCE} - tar -xf collectd-5.12.0.tar.bz2 + curl -OL ${COLLECTD_SOURCE} + tar -xf collectd-5.12.0.tar.bz2 - pushd collectd-5.12.0 - ./configure && make -j$(nproc) - popd + pushd collectd-5.12.0 + ./configure && make -j$(nproc) + popd - export COLLECTD_HOME=${PWD}/collectd-5.12.0/src + export COLLECTD_HOME=${PWD}/collectd-5.12.0/src } -function setup_fdio_repo() { - DISTRIB_ID=${ID} - - if [ "${DISTRIB_ID}" == "ubuntu" ]; then - curl -s ${PACKAGECLOUD_RELEASE_REPO_DEB} | sudo bash - curl -s ${PACKAGECLOUD_HICN_REPO_DEB} | sudo bash - elif [ "${DISTRIB_ID}" == "centos" ]; then - curl -s ${PACKAGECLOUD_RELEASE_REPO_RPM} | sudo bash - curl -s ${PACKAGECLOUD_HICN_REPO_RPM} | sudo bash - else - echo "Distribution ${DISTRIB_ID} is not supported" - exit 1 - 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} } # Install dependencies function install_deps() { - DISTRIB_ID=${ID} - echo ${DEPS_UBUNTU[@]} | xargs sudo ${apt_get} install -y --allow-unauthenticated --no-install-recommends -} - -function install_pkgcloud_deps() { - DISTRIB_ID=${ID} - echo ${DEPS_UBUNTU_PKGCLOUD[@]} | xargs sudo ${apt_get} install -y --allow-unauthenticated --no-install-recommends -} - -# 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} + make -C ${SCRIPT_PATH}/.. deps } function setup() { - echo DISTRIBUTION: ${PRETTY_NAME} - # export variables depending on the platform we are running - - call_once setup_fdio_repo - call_once install_deps - call_once install_pkgcloud_deps - call_once install_collectd_headers + echo DISTRIBUTION: ${PRETTY_NAME} + # export variables depending on the platform we are running + call_once install_deps + call_once install_collectd_headers } function setup_extras() { - echo DISTRIBUTION: ${PRETTY_NAME} - # export variables depending on the platform we are running + echo DISTRIBUTION: ${PRETTY_NAME} + # export variables depending on the platform we are running - call_once install_deps - call_once install_collectd_headers + call_once install_deps + call_once install_collectd_headers } diff --git a/scripts/install-vpp.sh b/scripts/install-vpp.sh new file mode 100644 index 000000000..a58e1bcad --- /dev/null +++ b/scripts/install-vpp.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +################################################################ +# Install defined VPP version +################################################################ + +if [[ -z ${VERSION_PATH} ]]; then + echo >&2 "No version path provided. Exit now." + exit 1 +fi + +# Prevent vpp to set sysctl +export VPP_INSTALL_SKIP_SYSCTL=1 +VPP_VERSION=$(cat "${VERSION_PATH}" | grep VPP_DEFAULT_VERSION | cut -d ' ' -f 2 | tr -d '"' | grep -Po '\d\d.\d\d') + +curl -s https://packagecloud.io/install/repositories/fdio/${VPP_VERSION//./}/script.deb.sh | bash +curl -L https://packagecloud.io/fdio/${VPP_VERSION//./}/gpgkey | apt-key add - +sed -E -i 's/(deb.*)(\[.*\])(.*)/\1\3/g' /etc/apt/sources.list.d/fdio_${VPP_VERSION//./}.list + +# create apt pinning +cat << EOF | tee /etc/apt/preferences.d/vpp-pin +Package: vpp* +Pin: release o=packagecloud.io/fdio/${VPP_VERSION//./} +Pin-Priority: 1000 + +Package: libvpp* +Pin: release o=packagecloud.io/fdio/${VPP_VERSION//./} +Pin-Priority: 1000 +EOF + +apt-get update + +apt-get install -y \ + vpp-dev \ + libvppinfra-dev \ + vpp-plugin-core \ + vpp \ + libvppinfra |