diff options
author | Damjan Marion <damarion@cisco.com> | 2019-01-18 13:28:22 +0100 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2019-01-20 16:14:24 +0000 |
commit | 4d2f86a1ebcfc952080386603354c4767d2c8825 (patch) | |
tree | d20ed373877bfbf145d3b7ed0773a0cdbfaee32e /src | |
parent | e67c1d8242fec255e7449fedcbdec5c66bb3f7b2 (diff) |
Rework of debian packaging
Change-Id: Ifede85d3af36f3ee6c6f8f92dcf5db0ed8f1bfeb
Signed-off-by: Damjan Marion <damarion@cisco.com>
Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/cmake/plugin.cmake | 3 | ||||
-rw-r--r-- | src/pkg/CMakeLists.txt | 43 | ||||
-rw-r--r-- | src/pkg/debian/changelog.in | 6 | ||||
-rw-r--r-- | src/pkg/debian/control | 75 | ||||
-rw-r--r-- | src/pkg/debian/copyright | 9 | ||||
-rwxr-xr-x | src/pkg/debian/rules.in | 45 | ||||
-rw-r--r-- | src/pkg/debian/vpp.postinst | 8 | ||||
-rw-r--r-- | src/pkg/debian/vpp.postrm | 21 | ||||
-rw-r--r-- | src/pkg/debian/vpp.preinst | 4 | ||||
-rw-r--r-- | src/pkg/debian/vpp.service | 13 | ||||
-rwxr-xr-x | src/scripts/remove-rpath | 37 | ||||
-rw-r--r-- | src/vat/main.c | 34 |
13 files changed, 297 insertions, 3 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 09d132ad2ca..05ecd0b4e4b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -97,7 +97,7 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") find_package(OpenSSL REQUIRED) set(SUBDIRS vppinfra svm vlib vlibmemory vlibapi vnet vpp vat vcl plugins - vpp-api tools/vppapigen tools/g2 tools/elftool tools/perftool cmake + vpp-api tools/vppapigen tools/g2 tools/elftool tools/perftool cmake pkg ) elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") set(SUBDIRS vppinfra) diff --git a/src/cmake/plugin.cmake b/src/cmake/plugin.cmake index 1cff910db5f..af3033f0cbd 100644 --- a/src/cmake/plugin.cmake +++ b/src/cmake/plugin.cmake @@ -21,7 +21,7 @@ macro(add_vpp_plugin name) set(plugin_name ${name}_plugin) set(api_includes) if(NOT PLUGIN_COMPONENT) - set(PLUGIN_COMPONENT vpp-plugin-misc) + set(PLUGIN_COMPONENT vpp-plugin-core) endif() if(NOT PLUGIN_DEV_COMPONENT) if(NOT VPP_EXTERNAL_PROJECT) @@ -92,4 +92,3 @@ macro(add_vpp_plugin name) COMPONENT ${PLUGIN_COMPONENT} ) endmacro() - diff --git a/src/pkg/CMakeLists.txt b/src/pkg/CMakeLists.txt new file mode 100644 index 00000000000..a725e668405 --- /dev/null +++ b/src/pkg/CMakeLists.txt @@ -0,0 +1,43 @@ +# Copyright (c) 2019 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. + +get_cmake_property(VPP_COMPONENTS COMPONENTS) +string(REPLACE ";" " " VPP_COMPONENTS "${VPP_COMPONENTS}") + +execute_process( + COMMAND date -R + OUTPUT_VARIABLE TIMESTAMP + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +foreach(f rules changelog) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/debian/${f}.in + ${CMAKE_BINARY_DIR}/debian/${f} + ) +endforeach() + +foreach(f control copyright vpp.postinst vpp.postrm vpp.postinst vpp.service) + file(COPY + ${CMAKE_CURRENT_SOURCE_DIR}/debian/${f} + DESTINATION ${CMAKE_BINARY_DIR}/debian + ) +endforeach() + +file(WRITE ${CMAKE_BINARY_DIR}/debian/compat "9\n") + +add_custom_target(package-deb + COMMENT "Building .deb packages..." + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMAND "dpkg-buildpackage" "-us" "-uc" "-b" +) diff --git a/src/pkg/debian/changelog.in b/src/pkg/debian/changelog.in new file mode 100644 index 00000000000..4d9b87ab553 --- /dev/null +++ b/src/pkg/debian/changelog.in @@ -0,0 +1,6 @@ +vpp (@VPP_VERSION@) unstable; urgency=low + + * no description + + -- fd.io VPP <vpp-dev@fd.io> @TIMESTAMP@ + diff --git a/src/pkg/debian/control b/src/pkg/debian/control new file mode 100644 index 00000000000..c9d4c4642de --- /dev/null +++ b/src/pkg/debian/control @@ -0,0 +1,75 @@ +Source: vpp +Section: net +Priority: extra +Maintainer: fd.io VPP Packaging Team <vpp-dev@fd.io> +Build-Depends: debhelper (>= 9), + dh-systemd, + dh-python, + python-all +Standards-Version: 3.9.4 + +Package: vpp +Architecture: any +Depends: libvppinfra (= ${source:Version}), + ${shlibs:Depends}, + ${misc:Depends}, + ${python:Depends} +Description: Vector Packet Processing--executables + This package provides VPP executables: vpp, vpp_api_test, vpp_json_test + vpp - the vector packet engine + vpp_api_test - vector packet engine API test tool + vpp_json_test - vector packet engine JSON test tool + +Package: vpp-dbg +Architecture: any +Depends: ${misc:Depends} +Description: Vector Packet Processing--debug symbols + +Package: vpp-dev +Architecture: any +Depends: libvppinfra-dev (= ${source:Version}), + ${misc:Depends}, + ${python:Depends} +Description: Vector Packet Processing--development support + This package contains development support files for the VPP libraries + . + +Package: libvppinfra +Architecture: any +Depends: ${shlibs:Depends}, + ${misc:Depends} +Description: Vector Packet Processing--runtime libraries + This package contains the VPP shared libraries, including: + . + +Package: libvppinfra-dev +Architecture: any +Depends: ${misc:Depends} +Description: Vector Packet Processing--runtime libraries + This package contains the VPP shared libraries, including: + . + +Package: vpp-plugin-core +Architecture: any +Depends: vpp (= ${source:Version}), + ${misc:Depends} +Description: Vector Packet Processing--runtime core plugins + This package contains VPP core plugins + . + +Package: vpp-plugin-dpdk +Architecture: any +Depends: vpp (= ${source:Version}), + ${misc:Depends} +Description: Vector Packet Processing--runtime dpdk plugin + This package contains the VPP dpdk plugin + . + +Package: vpp-api-python +Architecture: any +Depends: vpp (= ${source:Version}), + ${python2:Depends}, + ${misc:Depends} +Description: VPP Python API bindings + This package contains VPP python api bindings + . diff --git a/src/pkg/debian/copyright b/src/pkg/debian/copyright new file mode 100644 index 00000000000..f9775c158f9 --- /dev/null +++ b/src/pkg/debian/copyright @@ -0,0 +1,9 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: optional. +Upstream-Contact: optional. +Source: optional. +Disclaimer: optional. +Comment: optional. +License: Apache-2.0 +Copyright: 2015 Cisco and/or its affiliates and others. + diff --git a/src/pkg/debian/rules.in b/src/pkg/debian/rules.in new file mode 100755 index 00000000000..4d2bb408116 --- /dev/null +++ b/src/pkg/debian/rules.in @@ -0,0 +1,45 @@ +#!/usr/bin/make -f +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +DH_VERBOSE = 1 + +# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/* +DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/default.mk + +export PYBUILD_NAME = vpp-api-python +export PYBUILD_DIR = @CMAKE_SOURCE_DIR@/vpp-api/python +export PYBUILD_DESTDIR_python2=debian/vpp-api-python/ +export PYBUILD_DISABLE_python2=test +export PYBUILD_SYSTEM=distutils + +# main packaging script based on dh7 syntax +%: + dh $@ --with systemd,python2 --buildsystem=pybuild + +override_dh_shlibdeps: + @dh_shlibdeps -X_plugin 2>&1 \ + | { grep -v -e "probably a plugin" || true; } + +override_dh_strip: + dh_strip --dbg-package=vpp-dbg + +DEB_HOST_MULTIARCH = $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) + +override_dh_install: + for c in @VPP_COMPONENTS@; do \ + @CMAKE_COMMAND@ \ + -D CMAKE_INSTALL_CONFIG_NAME=@CMAKE_BUILD_TYPE@ \ + -D CMAKE_INSTALL_COMPONENT=$$c \ + -D CMAKE_INSTALL_PREFIX=@CMAKE_BINARY_DIR@/debian/$$c \ + -P @CMAKE_BINARY_DIR@/cmake_install.cmake ; \ + if [ -d debian/$$c/lib ] ; then \ + mv debian/$$c/lib debian/$$c/$(DEB_HOST_MULTIARCH) ; \ + mkdir -p debian/$$c/usr/lib ; \ + mv debian/$$c/$(DEB_HOST_MULTIARCH) debian/$$c/usr/lib ; \ + fi ; \ + if [ -d debian/$$c/bin ] ; then \ + mv debian/$$c/bin debian/$$c/usr/bin ; \ + fi ; \ + @CMAKE_SOURCE_DIR@/scripts/remove-rpath debian/$$c ; \ + done diff --git a/src/pkg/debian/vpp.postinst b/src/pkg/debian/vpp.postinst new file mode 100644 index 00000000000..78fcac226a8 --- /dev/null +++ b/src/pkg/debian/vpp.postinst @@ -0,0 +1,8 @@ +#!/bin/sh -e + +# try to set the required values now. This may or may not work. +sysctl --system + +#DEBHELPER# + +exit 0 diff --git a/src/pkg/debian/vpp.postrm b/src/pkg/debian/vpp.postrm new file mode 100644 index 00000000000..24b4842fd0a --- /dev/null +++ b/src/pkg/debian/vpp.postrm @@ -0,0 +1,21 @@ +#!/bin/sh -e + +removed= + +# Unbind user-mode PCI drivers +pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci` +for d in $pci_dirs; do + for f in ${d}/*; do + [ -e "${f}/config" ] || continue + echo ${f##*/} > ${d}/unbind + basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}` + removed=y + done +done +if [ -n "${removed}" ]; then + echo "There are changes in PCI drivers, rescaning" + echo 1 > /sys/bus/pci/rescan +else + echo "There weren't PCI devices binded" +fi + diff --git a/src/pkg/debian/vpp.preinst b/src/pkg/debian/vpp.preinst new file mode 100644 index 00000000000..d33cacfc3fa --- /dev/null +++ b/src/pkg/debian/vpp.preinst @@ -0,0 +1,4 @@ +#!/bin/sh -e + +# Add the vpp group +groupadd -f -r vpp diff --git a/src/pkg/debian/vpp.service b/src/pkg/debian/vpp.service new file mode 100644 index 00000000000..2e86941de8b --- /dev/null +++ b/src/pkg/debian/vpp.service @@ -0,0 +1,13 @@ +[Unit] +Description=vector packet processing engine +After=network.target + +[Service] +Type=simple +ExecStartPre=-/sbin/modprobe uio_pci_generic +ExecStart=/usr/bin/vpp -c /etc/vpp/startup.conf +ExecStopPost=/bin/rm -f /dev/shm/db /dev/shm/global_vm /dev/shm/vpe-api +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/src/scripts/remove-rpath b/src/scripts/remove-rpath new file mode 100755 index 00000000000..3e20b06dbfa --- /dev/null +++ b/src/scripts/remove-rpath @@ -0,0 +1,37 @@ +#!/bin/bash + +# Copyright (c) 2015 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. + +if [ -z $1 ]; then + echo "Please specify path" + exit 1 +fi + +which chrpath &> /dev/null + +if [ $? -ne 0 ] ; then + echo "Please install chrpath tool" + exit 1 +fi + +libs=$(find $1 -type f -name \*.so\*) +execs=$(find $1 -type f -path \*/bin/\* ) + +for i in $libs $execs; do + chrpath $i 2> /dev/null | grep -q build-root + if [ $? -eq 0 ] ; then + chrpath -d $i + fi +done + diff --git a/src/vat/main.c b/src/vat/main.c index 295ccec2515..a5421140fb3 100644 --- a/src/vat/main.c +++ b/src/vat/main.c @@ -15,6 +15,7 @@ #include "vat.h" #include "plugin.h" #include <signal.h> +#include <limits.h> vat_main_t vat_main; @@ -283,6 +284,37 @@ setup_signal_handlers (void) } } +static void +vat_find_plugin_path () +{ + extern char *vat_plugin_path; + char *p, path[PATH_MAX]; + int rv; + u8 *s; + + /* find executable path */ + if ((rv = readlink ("/proc/self/exe", path, PATH_MAX - 1)) == -1) + return; + + /* readlink doesn't provide null termination */ + path[rv] = 0; + + /* strip filename */ + if ((p = strrchr (path, '/')) == 0) + return; + *p = 0; + + /* strip bin/ */ + if ((p = strrchr (path, '/')) == 0) + return; + *p = 0; + + s = format (0, "%s/lib/" CLIB_TARGET_TRIPLET "/vpp_api_test_plugins:" + "%s/lib/vpp_api_test_plugins", path, path); + vec_add1 (s, 0); + vat_plugin_path = (char *) s; +} + int main (int argc, char **argv) { @@ -309,6 +341,8 @@ main (int argc, char **argv) vec_validate (vam->cmd_reply, 0); vec_reset_length (vam->cmd_reply); + vat_find_plugin_path (); + unformat_init_command_line (a, argv); while (unformat_check_input (a) != UNFORMAT_END_OF_INPUT) |