Sachin | 693b702 | 2016-06-18 15:28:08 +0530 | [diff] [blame] | 1 | %define _vpp_install_dir ../%{_install_dir} |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 2 | %define _vpp_build_dir ../build-tool-native |
| 3 | %define _unitdir /lib/systemd/system |
| 4 | %define _topdir %(pwd) |
| 5 | %define _builddir %{_topdir} |
| 6 | %define _version %(../scripts/version rpm-version) |
| 7 | %define _release %(../scripts/version rpm-release) |
| 8 | |
Ole Troan | 57c3d66 | 2016-09-12 22:00:32 +0200 | [diff] [blame] | 9 | # Failsafe backport of Python2-macros for RHEL <= 6 |
| 10 | %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} |
| 11 | %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} |
| 12 | %{!?python_version: %global python_version %(%{__python} -c "import sys; sys.stdout.write(sys.version[:3])")} |
| 13 | %{!?__python2: %global __python2 %{__python}} |
| 14 | %{!?python2_sitelib: %global python2_sitelib %{python_sitelib}} |
| 15 | %{!?python2_sitearch: %global python2_sitearch %{python_sitearch}} |
| 16 | %{!?python2_version: %global python2_version %{python_version}} |
| 17 | |
| 18 | %{!?python2_minor_version: %define python2_minor_version %(%{__python} -c "import sys ; print sys.version[2:3]")} |
| 19 | |
Peter Ginchev | dfa9c5b | 2016-10-11 15:34:24 +0300 | [diff] [blame] | 20 | %{?systemd_requires} |
| 21 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 22 | Name: vpp |
| 23 | Summary: Vector Packet Processing |
| 24 | License: MIT |
| 25 | Version: %{_version} |
| 26 | Release: %{_release} |
Padraig | b21b676 | 2016-09-21 14:59:02 +0100 | [diff] [blame] | 27 | Requires: vpp-lib = %{_version}-%{_release}, net-tools, pciutils, python |
Peter Ginchev | dfa9c5b | 2016-10-11 15:34:24 +0300 | [diff] [blame] | 28 | BuildRequires: systemd |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 29 | |
| 30 | %description |
Damjan Marion | 08ff7e0 | 2016-01-20 13:45:36 +0100 | [diff] [blame] | 31 | This package provides VPP executables: vpp, vpp_api_test, vpp_json_test |
| 32 | vpp - the vector packet engine |
| 33 | vpp_api_test - vector packet engine API test tool |
| 34 | vpp_json_test - vector packet engine JSON test tool |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 35 | |
| 36 | %package lib |
| 37 | Summary: VPP libraries |
| 38 | Group: System Environment/Libraries |
| 39 | |
| 40 | %description lib |
| 41 | This package contains the VPP shared libraries, including: |
| 42 | vppinfra - foundation library supporting vectors, hashes, bitmaps, pools, and string formatting. |
| 43 | dpdk - Intel DPDK library |
| 44 | svm - vm library |
| 45 | vlib - vector processing library |
| 46 | vlib-api - binary API library |
| 47 | vnet - network stack library |
| 48 | |
| 49 | %package devel |
| 50 | Summary: VPP header files, static libraries |
| 51 | Group: Development/Libraries |
| 52 | Requires: vpp-lib |
| 53 | |
| 54 | %description devel |
Thomas F Herbert | 3977a21 | 2016-10-01 18:09:33 -0400 | [diff] [blame] | 55 | This package contains the header files for VPP. |
| 56 | Install this package if you want to write a |
| 57 | program for compilation and linking with vpp lib. |
| 58 | vlib |
| 59 | vlibmemory |
| 60 | vnet - devices, classify, dhcp, ethernet flow, gre, ip, etc. |
| 61 | vpp-api |
| 62 | vppinfra |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 63 | |
Ed Warnicke | f5a1436 | 2016-09-12 20:40:24 +0000 | [diff] [blame] | 64 | %package plugins |
| 65 | Summary: Vector Packet Processing--runtime plugins |
| 66 | Group: System Environment/Libraries |
| 67 | Requires: vpp = %{_version}-%{_release} |
| 68 | %description plugins |
| 69 | This package contains VPP plugins |
| 70 | |
Ole Troan | 57c3d66 | 2016-09-12 22:00:32 +0200 | [diff] [blame] | 71 | %package python-api |
| 72 | Summary: VPP api python bindings |
| 73 | Group: Development/Libraries |
John DeNisco | f53f482 | 2016-09-30 08:33:40 -0400 | [diff] [blame] | 74 | Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release} |
Ole Troan | 57c3d66 | 2016-09-12 22:00:32 +0200 | [diff] [blame] | 75 | |
| 76 | %description python-api |
| 77 | This package contains the python bindings for the vpp api |
| 78 | |
Ed Warnicke | ec6290a | 2016-06-08 17:15:08 -0500 | [diff] [blame] | 79 | %pre |
| 80 | # Add the vpp group |
Ed Warnicke | b10427e | 2016-06-08 19:49:40 -0500 | [diff] [blame] | 81 | groupadd -f -r vpp |
Ed Warnicke | ec6290a | 2016-06-08 17:15:08 -0500 | [diff] [blame] | 82 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 83 | %install |
| 84 | # |
| 85 | # binaries |
| 86 | # |
| 87 | mkdir -p -m755 %{buildroot}%{_bindir} |
| 88 | mkdir -p -m755 %{buildroot}%{_unitdir} |
| 89 | install -p -m 755 %{_vpp_install_dir}/*/bin/* %{buildroot}%{_bindir} |
| 90 | install -p -m 755 %{_vpp_build_dir}/vppapigen/vppapigen %{buildroot}%{_bindir} |
Ole Troan | 57c3d66 | 2016-09-12 22:00:32 +0200 | [diff] [blame] | 91 | install -p -m 755 ../../vppapigen/pyvppapigen.py %{buildroot}%{_bindir} |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 92 | # |
| 93 | # configs |
| 94 | # |
| 95 | mkdir -p -m755 %{buildroot}/etc/vpp |
Miroslav Miklus | 8e08e74 | 2016-10-11 13:35:26 +0200 | [diff] [blame] | 96 | mkdir -p -m755 %{buildroot}/etc/sysctl.d |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 97 | install -p -m 644 vpp.service %{buildroot}%{_unitdir} |
Ed Warnicke | 40c6639 | 2016-06-08 14:41:40 -0500 | [diff] [blame] | 98 | install -p -m 644 ../../vpp/conf/startup.uiopcigeneric.conf %{buildroot}/etc/vpp/startup.conf |
Miroslav Miklus | 8e08e74 | 2016-10-11 13:35:26 +0200 | [diff] [blame] | 99 | install -p -m 644 ../../vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 100 | # |
| 101 | # libraries |
| 102 | # |
| 103 | mkdir -p -m755 %{buildroot}%{_libdir} |
| 104 | for file in $(find %{_vpp_install_dir}/*/lib* -type f -name '*.so.*.*.*' -print ) |
| 105 | do |
| 106 | install -p -m 755 $file %{buildroot}%{_libdir} |
| 107 | done |
| 108 | for file in $(cd %{buildroot}%{_libdir} && find . -type f -print | sed -e 's/^\.\///') |
| 109 | do |
| 110 | # make lib symlinks |
| 111 | ( cd %{buildroot}%{_libdir} && |
| 112 | ln -fs $file $(echo $file | sed -e 's/\(\.so\.[0-9]\+\).*/\1/') ) |
Ed Warnicke | f5a0e73 | 2016-09-07 17:12:52 +0000 | [diff] [blame] | 113 | ( cd %{buildroot}%{_libdir} && |
| 114 | ln -fs $file $(echo $file | sed -e 's/\(\.so\)\.[0-9]\+.*/\1/') ) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 115 | done |
Ed Warnicke | 406ab9d | 2016-08-31 18:48:47 -0700 | [diff] [blame] | 116 | |
Ole Troan | 57c3d66 | 2016-09-12 22:00:32 +0200 | [diff] [blame] | 117 | # Python bindings |
| 118 | mkdir -p -m755 %{buildroot}%{python2_sitelib}/vpp_papi |
| 119 | for file in $(find %{_vpp_install_dir}/*/lib/python2.7/site-packages/ -type f -print | grep -v pyc | grep -v pyo) |
| 120 | do |
| 121 | install -p -m 666 $file %{buildroot}%{python2_sitelib}/vpp_papi/ |
| 122 | done |
| 123 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 124 | # |
| 125 | # devel |
| 126 | # |
| 127 | for dir in $(find %{_vpp_install_dir}/*/include/ -maxdepth 0 -type d -print | grep -v dpdk) |
| 128 | do |
| 129 | for subdir in $(cd ${dir} && find . -type d -print) |
| 130 | do |
| 131 | mkdir -p -m755 %{buildroot}/usr/include/${subdir} |
| 132 | done |
| 133 | for file in $(cd ${dir} && find . -type f -print) |
| 134 | do |
| 135 | install -p -m 644 $dir/$file %{buildroot}%{_includedir}/$file |
| 136 | done |
| 137 | done |
Ed Warnicke | 406ab9d | 2016-08-31 18:48:47 -0700 | [diff] [blame] | 138 | |
| 139 | mkdir -p -m755 %{buildroot}%{python2_sitelib}/jvppgen |
| 140 | install -p -m755 ../../vpp-api/java/jvpp/gen/jvpp_gen.py %{buildroot}/usr/bin |
| 141 | for i in $(ls ../../vpp-api/java/jvpp/gen/jvppgen/*.py); do |
| 142 | install -p -m666 ${i} %{buildroot}%{python2_sitelib}/jvppgen |
| 143 | done; |
| 144 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 145 | # sample plugin |
| 146 | mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/sample |
| 147 | for file in $(cd %{_vpp_install_dir}/../../sample-plugin && find -type f -print) |
| 148 | do |
| 149 | install -p -m 644 %{_vpp_install_dir}/../../sample-plugin/$file \ |
| 150 | %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/$file |
| 151 | done |
| 152 | |
Ed Warnicke | f5a1436 | 2016-09-12 20:40:24 +0000 | [diff] [blame] | 153 | |
| 154 | # |
| 155 | # vpp-plugins |
| 156 | # |
| 157 | mkdir -p -m755 %{buildroot}%{_libdir}/vpp_plugins |
| 158 | mkdir -p -m755 %{buildroot}%{_libdir}/vpp_api_test_plugins |
| 159 | for file in $(cd %{_vpp_install_dir}/plugins/lib64/vpp_plugins && find -type f -print) |
| 160 | do |
| 161 | install -p -m 644 %{_vpp_install_dir}/plugins/lib64/vpp_plugins/$file \ |
| 162 | %{buildroot}%{_libdir}/vpp_plugins/$file |
| 163 | done |
| 164 | |
| 165 | for file in $(cd %{_vpp_install_dir}/plugins/lib64/vpp_api_test_plugins && find -type f -print) |
| 166 | do |
| 167 | install -p -m 644 %{_vpp_install_dir}/plugins/lib64/vpp_api_test_plugins/$file \ |
| 168 | %{buildroot}%{_libdir}/vpp_api_test_plugins/$file |
| 169 | done |
| 170 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 171 | %post |
| 172 | sysctl --system |
| 173 | %systemd_post vpp.service |
| 174 | |
Peter Ginchev | dfa9c5b | 2016-10-11 15:34:24 +0300 | [diff] [blame] | 175 | %preun |
| 176 | %systemd_preun vpp.service |
| 177 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 178 | %postun |
Peter Ginchev | dfa9c5b | 2016-10-11 15:34:24 +0300 | [diff] [blame] | 179 | %systemd_postun |
| 180 | |
| 181 | # Unbind user-mode PCI drivers |
| 182 | removed= |
| 183 | pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci` |
| 184 | for d in $pci_dirs; do |
| 185 | for f in ${d}/*; do |
| 186 | [ -e "${f}/config" ] || continue |
| 187 | echo 1 > ${f}/remove |
| 188 | basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}` |
| 189 | removed=y |
| 190 | done |
| 191 | done |
| 192 | if [ -n "${removed}" ]; then |
| 193 | echo "There are changes in PCI drivers, rescaning" |
| 194 | echo 1 > /sys/bus/pci/rescan |
| 195 | else |
| 196 | echo "There weren't PCI devices binded" |
| 197 | fi |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 198 | |
| 199 | %files |
| 200 | %defattr(-,bin,bin) |
| 201 | %{_unitdir}/vpp.service |
Damjan Marion | 08ff7e0 | 2016-01-20 13:45:36 +0100 | [diff] [blame] | 202 | /usr/bin/vpp* |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 203 | /usr/bin/svm* |
Dave Barach | 0e5e3c3 | 2016-01-25 08:28:22 -0500 | [diff] [blame] | 204 | /usr/bin/elftool |
Miroslav Miklus | 8e08e74 | 2016-10-11 13:35:26 +0200 | [diff] [blame] | 205 | %config /etc/sysctl.d/80-vpp.conf |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 206 | %config /etc/vpp/startup.conf |
| 207 | |
| 208 | %files lib |
| 209 | %defattr(-,bin,bin) |
Ed Warnicke | f5a1436 | 2016-09-12 20:40:24 +0000 | [diff] [blame] | 210 | %exclude %{_libdir}/vpp_plugins |
| 211 | %exclude %{_libdir}/vpp_api_test_plugins |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 212 | %{_libdir}/* |
| 213 | |
Ole Troan | 57c3d66 | 2016-09-12 22:00:32 +0200 | [diff] [blame] | 214 | %files python-api |
| 215 | %defattr(644,root,root) |
| 216 | %{python2_sitelib}/vpp_papi/* |
| 217 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 218 | %files devel |
| 219 | %defattr(-,bin,bin) |
| 220 | /usr/bin/vppapigen |
Ed Warnicke | 406ab9d | 2016-08-31 18:48:47 -0700 | [diff] [blame] | 221 | /usr/bin/jvpp_gen.py |
Ole Troan | 57c3d66 | 2016-09-12 22:00:32 +0200 | [diff] [blame] | 222 | /usr/bin/pyvppapigen.py |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 223 | %{_includedir}/* |
Ed Warnicke | 406ab9d | 2016-08-31 18:48:47 -0700 | [diff] [blame] | 224 | %{python2_sitelib}/jvppgen/* |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 225 | /usr/share/doc/vpp/examples/sample-plugin |
Ed Warnicke | 406ab9d | 2016-08-31 18:48:47 -0700 | [diff] [blame] | 226 | |
Ed Warnicke | f5a1436 | 2016-09-12 20:40:24 +0000 | [diff] [blame] | 227 | %files plugins |
| 228 | %defattr(-,bin,bin) |
| 229 | %{_libdir}/vpp_plugins/* |
| 230 | %{_libdir}/vpp_api_test_plugins/* |