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 |
John DeNisco | f53f482 | 2016-09-30 08:33:40 -0400 | [diff] [blame] | 77 | Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release} |
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 |
| 137 | mkdir -p -m755 %{buildroot}%{python2_sitelib}/vpp_papi |
Thomas F Herbert | 20a29c7 | 2016-10-13 18:36:50 -0400 | [diff] [blame] | 138 | for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/*/lib/python2.7/site-packages/ -type f -print | grep -v pyc | grep -v pyo) |
Ole Troan | 57c3d66 | 2016-09-12 22:00:32 +0200 | [diff] [blame] | 139 | do |
| 140 | install -p -m 666 $file %{buildroot}%{python2_sitelib}/vpp_papi/ |
| 141 | done |
| 142 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 143 | # |
| 144 | # devel |
| 145 | # |
Thomas F Herbert | 20a29c7 | 2016-10-13 18:36:50 -0400 | [diff] [blame] | 146 | 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] | 147 | do |
| 148 | for subdir in $(cd ${dir} && find . -type d -print) |
| 149 | do |
| 150 | mkdir -p -m755 %{buildroot}/usr/include/${subdir} |
| 151 | done |
| 152 | for file in $(cd ${dir} && find . -type f -print) |
| 153 | do |
| 154 | install -p -m 644 $dir/$file %{buildroot}%{_includedir}/$file |
| 155 | done |
| 156 | done |
Ed Warnicke | 406ab9d | 2016-08-31 18:48:47 -0700 | [diff] [blame] | 157 | |
| 158 | mkdir -p -m755 %{buildroot}%{python2_sitelib}/jvppgen |
Thomas F Herbert | 20a29c7 | 2016-10-13 18:36:50 -0400 | [diff] [blame] | 159 | install -p -m755 %{_mu_build_dir}/../vpp-api/java/jvpp/gen/jvpp_gen.py %{buildroot}/usr/bin |
| 160 | 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] | 161 | install -p -m666 ${i} %{buildroot}%{python2_sitelib}/jvppgen |
| 162 | done; |
| 163 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 164 | # sample plugin |
| 165 | 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] | 166 | 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] | 167 | do |
Thomas F Herbert | 20a29c7 | 2016-10-13 18:36:50 -0400 | [diff] [blame] | 168 | 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] | 169 | %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/$file |
| 170 | done |
| 171 | |
Ed Warnicke | f5a1436 | 2016-09-12 20:40:24 +0000 | [diff] [blame] | 172 | |
| 173 | # |
| 174 | # vpp-plugins |
| 175 | # |
Ed Warnicke | e7637e7 | 2016-09-14 16:58:33 -0700 | [diff] [blame] | 176 | mkdir -p -m755 %{buildroot}/usr/lib/vpp_plugins |
| 177 | mkdir -p -m755 %{buildroot}/usr/lib/vpp_api_test_plugins |
Thomas F Herbert | 20a29c7 | 2016-10-13 18:36:50 -0400 | [diff] [blame] | 178 | 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] | 179 | do |
Thomas F Herbert | 20a29c7 | 2016-10-13 18:36:50 -0400 | [diff] [blame] | 180 | 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] | 181 | %{buildroot}/usr/lib/vpp_plugins/$file |
Ed Warnicke | f5a1436 | 2016-09-12 20:40:24 +0000 | [diff] [blame] | 182 | done |
| 183 | |
Thomas F Herbert | 20a29c7 | 2016-10-13 18:36:50 -0400 | [diff] [blame] | 184 | 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] | 185 | do |
Thomas F Herbert | 20a29c7 | 2016-10-13 18:36:50 -0400 | [diff] [blame] | 186 | 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] | 187 | %{buildroot}/usr/lib/vpp_api_test_plugins/$file |
Ed Warnicke | f5a1436 | 2016-09-12 20:40:24 +0000 | [diff] [blame] | 188 | done |
| 189 | |
Ole Troan | f14e3bf | 2016-12-01 21:49:03 +0100 | [diff] [blame] | 190 | for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/plugins -type f -name '*.api.json' -print ) |
| 191 | do |
| 192 | install -p -m 644 $file %{buildroot}/usr/share/vpp/api |
| 193 | done |
| 194 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 195 | %post |
| 196 | sysctl --system |
| 197 | %systemd_post vpp.service |
| 198 | |
Peter Ginchev | dfa9c5b | 2016-10-11 15:34:24 +0300 | [diff] [blame] | 199 | %preun |
| 200 | %systemd_preun vpp.service |
| 201 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 202 | %postun |
Peter Ginchev | dfa9c5b | 2016-10-11 15:34:24 +0300 | [diff] [blame] | 203 | %systemd_postun |
| 204 | |
| 205 | # Unbind user-mode PCI drivers |
| 206 | removed= |
| 207 | pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci` |
| 208 | for d in $pci_dirs; do |
| 209 | for f in ${d}/*; do |
| 210 | [ -e "${f}/config" ] || continue |
| 211 | echo 1 > ${f}/remove |
| 212 | basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}` |
| 213 | removed=y |
| 214 | done |
| 215 | done |
| 216 | if [ -n "${removed}" ]; then |
| 217 | echo "There are changes in PCI drivers, rescaning" |
| 218 | echo 1 > /sys/bus/pci/rescan |
| 219 | else |
| 220 | echo "There weren't PCI devices binded" |
| 221 | fi |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 222 | |
| 223 | %files |
| 224 | %defattr(-,bin,bin) |
| 225 | %{_unitdir}/vpp.service |
Damjan Marion | 08ff7e0 | 2016-01-20 13:45:36 +0100 | [diff] [blame] | 226 | /usr/bin/vpp* |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 227 | /usr/bin/svm* |
Dave Barach | 0e5e3c3 | 2016-01-25 08:28:22 -0500 | [diff] [blame] | 228 | /usr/bin/elftool |
Miroslav Miklus | 8e08e74 | 2016-10-11 13:35:26 +0200 | [diff] [blame] | 229 | %config /etc/sysctl.d/80-vpp.conf |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 230 | %config /etc/vpp/startup.conf |
Ole Troan | f14e3bf | 2016-12-01 21:49:03 +0100 | [diff] [blame] | 231 | /usr/share/vpp/api/* |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 232 | |
| 233 | %files lib |
| 234 | %defattr(-,bin,bin) |
Ed Warnicke | f5a1436 | 2016-09-12 20:40:24 +0000 | [diff] [blame] | 235 | %exclude %{_libdir}/vpp_plugins |
| 236 | %exclude %{_libdir}/vpp_api_test_plugins |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 237 | %{_libdir}/* |
Ole Troan | f14e3bf | 2016-12-01 21:49:03 +0100 | [diff] [blame] | 238 | /usr/share/vpp/api/* |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 239 | |
Ole Troan | 57c3d66 | 2016-09-12 22:00:32 +0200 | [diff] [blame] | 240 | %files python-api |
| 241 | %defattr(644,root,root) |
| 242 | %{python2_sitelib}/vpp_papi/* |
| 243 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 244 | %files devel |
| 245 | %defattr(-,bin,bin) |
| 246 | /usr/bin/vppapigen |
Ed Warnicke | 406ab9d | 2016-08-31 18:48:47 -0700 | [diff] [blame] | 247 | /usr/bin/jvpp_gen.py |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 248 | %{_includedir}/* |
Ed Warnicke | 406ab9d | 2016-08-31 18:48:47 -0700 | [diff] [blame] | 249 | %{python2_sitelib}/jvppgen/* |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 250 | /usr/share/doc/vpp/examples/sample-plugin |
Ed Warnicke | 406ab9d | 2016-08-31 18:48:47 -0700 | [diff] [blame] | 251 | |
Ed Warnicke | f5a1436 | 2016-09-12 20:40:24 +0000 | [diff] [blame] | 252 | %files plugins |
| 253 | %defattr(-,bin,bin) |
Ed Warnicke | e7637e7 | 2016-09-14 16:58:33 -0700 | [diff] [blame] | 254 | /usr/lib/vpp_plugins/* |
| 255 | /usr/lib/vpp_api_test_plugins/* |
Ole Troan | f14e3bf | 2016-12-01 21:49:03 +0100 | [diff] [blame] | 256 | /usr/share/vpp/api/* |