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