blob: dd4817ee920577b68c7bbf2979f66aabed81ed39 [file] [log] [blame]
Thomas F Herbert20a29c72016-10-13 18:36:50 -04001%define _mu_build_dir %{_mu_build_root_dir}
2%define _vpp_install_dir %{_install_dir}
3%define _vpp_build_dir build-tool-native
Ed Warnickecb9cada2015-12-08 15:45:58 -07004%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 Troan57c3d662016-09-12 22:00:32 +020010# 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 Ginchevdfa9c5b2016-10-11 15:34:24 +030021%{?systemd_requires}
22
Ed Warnickecb9cada2015-12-08 15:45:58 -070023Name: vpp
24Summary: Vector Packet Processing
25License: MIT
26Version: %{_version}
27Release: %{_release}
Padraigb21b6762016-09-21 14:59:02 +010028Requires: vpp-lib = %{_version}-%{_release}, net-tools, pciutils, python
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +030029BuildRequires: systemd
Ed Warnickecb9cada2015-12-08 15:45:58 -070030
Thomas F Herbert20a29c72016-10-13 18:36:50 -040031Source: %{name}-%{_version}-%{_release}.tar.gz
32
Ed Warnickecb9cada2015-12-08 15:45:58 -070033%description
Damjan Marion08ff7e02016-01-20 13:45:36 +010034This package provides VPP executables: vpp, vpp_api_test, vpp_json_test
35vpp - the vector packet engine
36vpp_api_test - vector packet engine API test tool
37vpp_json_test - vector packet engine JSON test tool
Ed Warnickecb9cada2015-12-08 15:45:58 -070038
39%package lib
40Summary: VPP libraries
41Group: System Environment/Libraries
42
43%description lib
44This package contains the VPP shared libraries, including:
45vppinfra - foundation library supporting vectors, hashes, bitmaps, pools, and string formatting.
Padraig Connolly999bbc42016-11-15 09:35:50 +000046dpdk - DPDK library
Ed Warnickecb9cada2015-12-08 15:45:58 -070047svm - vm library
48vlib - vector processing library
49vlib-api - binary API library
50vnet - network stack library
51
52%package devel
53Summary: VPP header files, static libraries
54Group: Development/Libraries
55Requires: vpp-lib
56
57%description devel
Thomas F Herbert3977a212016-10-01 18:09:33 -040058This package contains the header files for VPP.
59Install this package if you want to write a
60program for compilation and linking with vpp lib.
61vlib
62vlibmemory
63vnet - devices, classify, dhcp, ethernet flow, gre, ip, etc.
64vpp-api
65vppinfra
Ed Warnickecb9cada2015-12-08 15:45:58 -070066
Ed Warnickef5a14362016-09-12 20:40:24 +000067%package plugins
68Summary: Vector Packet Processing--runtime plugins
69Group: System Environment/Libraries
70Requires: vpp = %{_version}-%{_release}
71%description plugins
72This package contains VPP plugins
73
Ole Troan57c3d662016-09-12 22:00:32 +020074%package python-api
75Summary: VPP api python bindings
76Group: Development/Libraries
Gabriel Ganne32905662016-12-06 19:12:49 +010077Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}, python-setuptools
Ole Troan57c3d662016-09-12 22:00:32 +020078
79%description python-api
80This package contains the python bindings for the vpp api
81
Thomas F Herbert20a29c72016-10-13 18:36:50 -040082%prep
83%setup -q -n %{name}-%{_version}
84
85%build
86make bootstrap
87make build-release
88
Ed Warnickeec6290a2016-06-08 17:15:08 -050089%pre
90# Add the vpp group
Ed Warnickeb10427e2016-06-08 19:49:40 -050091groupadd -f -r vpp
Ed Warnickeec6290a2016-06-08 17:15:08 -050092
Ed Warnickecb9cada2015-12-08 15:45:58 -070093%install
94#
95# binaries
96#
97mkdir -p -m755 %{buildroot}%{_bindir}
98mkdir -p -m755 %{buildroot}%{_unitdir}
Thomas F Herbert20a29c72016-10-13 18:36:50 -040099install -p -m 755 %{_mu_build_dir}/%{_vpp_install_dir}/*/bin/* %{buildroot}%{_bindir}
100install -p -m 755 %{_mu_build_dir}/%{_vpp_build_dir}/vppapigen/vppapigen %{buildroot}%{_bindir}
Ole Troanf14e3bf2016-12-01 21:49:03 +0100101
102# core api
103mkdir -p -m755 %{buildroot}/usr/share/vpp/api
104install -p -m 755 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/vpp-api/vpe.api.json %{buildroot}/usr/share/vpp/api
105install -p -m 755 %{_mu_build_dir}/%{_vpp_install_dir}/vlib-api/vlibmemory/memclnt.api.json %{buildroot}/usr/share/vpp/api
106
Ed Warnickecb9cada2015-12-08 15:45:58 -0700107#
108# configs
109#
110mkdir -p -m755 %{buildroot}/etc/vpp
Miroslav Miklus8e08e742016-10-11 13:35:26 +0200111mkdir -p -m755 %{buildroot}/etc/sysctl.d
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400112install -p -m 644 %{_mu_build_dir}/rpm/vpp.service %{buildroot}%{_unitdir}
113install -p -m 644 %{_mu_build_dir}/../vpp/conf/startup.uiopcigeneric.conf %{buildroot}/etc/vpp/startup.conf
114install -p -m 644 %{_mu_build_dir}/../vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d
Ed Warnickecb9cada2015-12-08 15:45:58 -0700115#
116# libraries
117#
118mkdir -p -m755 %{buildroot}%{_libdir}
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400119for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/*/lib* -type f -name '*.so.*.*.*' -print )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700120do
121 install -p -m 755 $file %{buildroot}%{_libdir}
122done
123for file in $(cd %{buildroot}%{_libdir} && find . -type f -print | sed -e 's/^\.\///')
124do
125 # make lib symlinks
126 ( cd %{buildroot}%{_libdir} &&
127 ln -fs $file $(echo $file | sed -e 's/\(\.so\.[0-9]\+\).*/\1/') )
Ed Warnickef5a0e732016-09-07 17:12:52 +0000128 ( cd %{buildroot}%{_libdir} &&
129 ln -fs $file $(echo $file | sed -e 's/\(\.so\)\.[0-9]\+.*/\1/') )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700130done
Ole Troanf14e3bf2016-12-01 21:49:03 +0100131for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/vnet -type f -name '*.api.json' -print )
132do
133 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
134done
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700135
Ole Troan57c3d662016-09-12 22:00:32 +0200136# Python bindings
Gabriel Ganne32905662016-12-06 19:12:49 +0100137mkdir -p -m755 %{buildroot}%{python2_sitelib}
138install -p -m 666 %{_mu_build_dir}/%{_vpp_install_dir}/*/lib/python2.7/site-packages/vpp_papi-*.egg %{buildroot}%{python2_sitelib}
Ole Troan57c3d662016-09-12 22:00:32 +0200139
Ed Warnickecb9cada2015-12-08 15:45:58 -0700140#
141# devel
142#
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400143for dir in $(find %{_mu_build_dir}/%{_vpp_install_dir}/*/include/ -maxdepth 0 -type d -print | grep -v dpdk)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700144do
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
153done
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700154
155mkdir -p -m755 %{buildroot}%{python2_sitelib}/jvppgen
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400156install -p -m755 %{_mu_build_dir}/../vpp-api/java/jvpp/gen/jvpp_gen.py %{buildroot}/usr/bin
157for i in $(ls %{_mu_build_dir}/../vpp-api/java/jvpp/gen/jvppgen/*.py); do
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700158 install -p -m666 ${i} %{buildroot}%{python2_sitelib}/jvppgen
159done;
160
Ed Warnickecb9cada2015-12-08 15:45:58 -0700161# sample plugin
162mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/sample
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400163for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../sample-plugin && find -type f -print)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700164do
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400165 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/../../sample-plugin/$file \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700166 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/$file
167done
168
Ed Warnickef5a14362016-09-12 20:40:24 +0000169
170#
171# vpp-plugins
172#
Ed Warnickee7637e72016-09-14 16:58:33 -0700173mkdir -p -m755 %{buildroot}/usr/lib/vpp_plugins
174mkdir -p -m755 %{buildroot}/usr/lib/vpp_api_test_plugins
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400175for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/plugins/lib64/vpp_plugins && find -type f -print)
Ed Warnickef5a14362016-09-12 20:40:24 +0000176do
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400177 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/plugins/lib64/vpp_plugins/$file \
Ed Warnickee7637e72016-09-14 16:58:33 -0700178 %{buildroot}/usr/lib/vpp_plugins/$file
Ed Warnickef5a14362016-09-12 20:40:24 +0000179done
180
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400181for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/plugins/lib64/vpp_api_test_plugins && find -type f -print)
Ed Warnickef5a14362016-09-12 20:40:24 +0000182do
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400183 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/plugins/lib64/vpp_api_test_plugins/$file \
Ed Warnickee7637e72016-09-14 16:58:33 -0700184 %{buildroot}/usr/lib/vpp_api_test_plugins/$file
Ed Warnickef5a14362016-09-12 20:40:24 +0000185done
186
Ole Troanf14e3bf2016-12-01 21:49:03 +0100187for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/plugins -type f -name '*.api.json' -print )
188do
189 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
190done
191
Ed Warnickecb9cada2015-12-08 15:45:58 -0700192%post
193sysctl --system
194%systemd_post vpp.service
195
Gabriel Ganne32905662016-12-06 19:12:49 +0100196%post python-api
197easy_install -z %{python2_sitelib}/vpp_papi-*.egg
198
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300199%preun
200%systemd_preun vpp.service
201
Gabriel Ganne32905662016-12-06 19:12:49 +0100202%preun python-api
203easy_install -mxNq vpp_papi
204
Ed Warnickecb9cada2015-12-08 15:45:58 -0700205%postun
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300206%systemd_postun
207
208# Unbind user-mode PCI drivers
209removed=
210pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci`
211for 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
218done
219if [ -n "${removed}" ]; then
220 echo "There are changes in PCI drivers, rescaning"
221 echo 1 > /sys/bus/pci/rescan
222else
223 echo "There weren't PCI devices binded"
224fi
Ed Warnickecb9cada2015-12-08 15:45:58 -0700225
226%files
227%defattr(-,bin,bin)
228%{_unitdir}/vpp.service
Damjan Marion08ff7e02016-01-20 13:45:36 +0100229/usr/bin/vpp*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700230/usr/bin/svm*
Dave Barach0e5e3c32016-01-25 08:28:22 -0500231/usr/bin/elftool
Miroslav Miklus8e08e742016-10-11 13:35:26 +0200232%config /etc/sysctl.d/80-vpp.conf
Ed Warnickecb9cada2015-12-08 15:45:58 -0700233%config /etc/vpp/startup.conf
Ole Troanf14e3bf2016-12-01 21:49:03 +0100234/usr/share/vpp/api/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700235
236%files lib
237%defattr(-,bin,bin)
Ed Warnickef5a14362016-09-12 20:40:24 +0000238%exclude %{_libdir}/vpp_plugins
239%exclude %{_libdir}/vpp_api_test_plugins
Ed Warnickecb9cada2015-12-08 15:45:58 -0700240%{_libdir}/*
Ole Troanf14e3bf2016-12-01 21:49:03 +0100241/usr/share/vpp/api/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700242
Ole Troan57c3d662016-09-12 22:00:32 +0200243%files python-api
244%defattr(644,root,root)
Gabriel Ganne32905662016-12-06 19:12:49 +0100245%{python2_sitelib}/vpp_papi-*.egg
Ole Troan57c3d662016-09-12 22:00:32 +0200246
Ed Warnickecb9cada2015-12-08 15:45:58 -0700247%files devel
248%defattr(-,bin,bin)
249/usr/bin/vppapigen
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700250/usr/bin/jvpp_gen.py
Ed Warnickecb9cada2015-12-08 15:45:58 -0700251%{_includedir}/*
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700252%{python2_sitelib}/jvppgen/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700253/usr/share/doc/vpp/examples/sample-plugin
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700254
Ed Warnickef5a14362016-09-12 20:40:24 +0000255%files plugins
256%defattr(-,bin,bin)
Ed Warnickee7637e72016-09-14 16:58:33 -0700257/usr/lib/vpp_plugins/*
258/usr/lib/vpp_api_test_plugins/*
Ole Troanf14e3bf2016-12-01 21:49:03 +0100259/usr/share/vpp/api/*