blob: 55b20109e78c8d0d85ed900c08937dfeadc3fbe8 [file] [log] [blame]
Thomas F Herbert20a29c72016-10-13 18:36:50 -04001%define _vpp_build_dir build-tool-native
Ed Warnickecb9cada2015-12-08 15:45:58 -07002%define _unitdir /lib/systemd/system
3%define _topdir %(pwd)
4%define _builddir %{_topdir}
Damjan Marionc06eeb02017-04-18 15:26:39 +02005%define _mu_build_dir %{_topdir}/%{name}-%{_version}/build-root
6%define _vpp_install_dir install-vpp-native
Ed Warnickecb9cada2015-12-08 15:45:58 -07007
Ole Troan57c3d662016-09-12 22:00:32 +02008# Failsafe backport of Python2-macros for RHEL <= 6
9%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
10%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
11%{!?python_version: %global python_version %(%{__python} -c "import sys; sys.stdout.write(sys.version[:3])")}
12%{!?__python2: %global __python2 %{__python}}
13%{!?python2_sitelib: %global python2_sitelib %{python_sitelib}}
14%{!?python2_sitearch: %global python2_sitearch %{python_sitearch}}
15%{!?python2_version: %global python2_version %{python_version}}
16
17%{!?python2_minor_version: %define python2_minor_version %(%{__python} -c "import sys ; print sys.version[2:3]")}
18
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +030019%{?systemd_requires}
20
Ed Warnickecb9cada2015-12-08 15:45:58 -070021Name: vpp
22Summary: Vector Packet Processing
23License: MIT
24Version: %{_version}
25Release: %{_release}
Padraigb21b6762016-09-21 14:59:02 +010026Requires: vpp-lib = %{_version}-%{_release}, net-tools, pciutils, python
Damjan Mariona1bd0232016-12-19 19:08:11 +010027BuildRequires: systemd, chrpath
Ed Warnickecb9cada2015-12-08 15:45:58 -070028
Damjan Marionc06eeb02017-04-18 15:26:39 +020029# Source: %{name}-%{_version}-%{_release}.tar.xz
30Source: vpp-latest.tar.xz
Thomas F Herbert20a29c72016-10-13 18:36:50 -040031
Ed Warnickecb9cada2015-12-08 15:45:58 -070032%description
Damjan Marion08ff7e02016-01-20 13:45:36 +010033This package provides VPP executables: vpp, vpp_api_test, vpp_json_test
34vpp - the vector packet engine
35vpp_api_test - vector packet engine API test tool
36vpp_json_test - vector packet engine JSON test tool
Ed Warnickecb9cada2015-12-08 15:45:58 -070037
38%package lib
39Summary: VPP libraries
40Group: System Environment/Libraries
41
42%description lib
43This package contains the VPP shared libraries, including:
44vppinfra - foundation library supporting vectors, hashes, bitmaps, pools, and string formatting.
Ed Warnickecb9cada2015-12-08 15:45:58 -070045svm - vm library
46vlib - vector processing library
47vlib-api - binary API library
48vnet - network stack library
49
50%package devel
51Summary: VPP header files, static libraries
52Group: Development/Libraries
53Requires: vpp-lib
54
55%description devel
Thomas F Herbert3977a212016-10-01 18:09:33 -040056This package contains the header files for VPP.
57Install this package if you want to write a
58program for compilation and linking with vpp lib.
59vlib
60vlibmemory
61vnet - devices, classify, dhcp, ethernet flow, gre, ip, etc.
62vpp-api
63vppinfra
Ed Warnickecb9cada2015-12-08 15:45:58 -070064
Ed Warnickef5a14362016-09-12 20:40:24 +000065%package plugins
66Summary: Vector Packet Processing--runtime plugins
67Group: System Environment/Libraries
68Requires: vpp = %{_version}-%{_release}
69%description plugins
70This package contains VPP plugins
71
Damjan Marioncb034b92016-12-28 18:38:59 +010072%package api-lua
73Summary: VPP api lua bindings
74Group: Development/Libraries
75Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}
76
77%description api-lua
78This package contains the lua bindings for the vpp api
79
80%package api-java
81Summary: VPP api java bindings
82Group: Development/Libraries
83Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}
84
85%description api-java
86This package contains the java bindings for the vpp api
87
88%package api-python
Ole Troan57c3d662016-09-12 22:00:32 +020089Summary: VPP api python bindings
90Group: Development/Libraries
Ole Troanc60f5572017-03-17 09:54:51 +010091Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}, python-setuptools libffi-devel
Ole Troan57c3d662016-09-12 22:00:32 +020092
Damjan Marioncb034b92016-12-28 18:38:59 +010093%description api-python
Ole Troan57c3d662016-09-12 22:00:32 +020094This package contains the python bindings for the vpp api
95
Thomas F Herbert20a29c72016-10-13 18:36:50 -040096%prep
97%setup -q -n %{name}-%{_version}
98
Ed Warnickeec6290a2016-06-08 17:15:08 -050099%pre
100# Add the vpp group
Ed Warnickeb10427e2016-06-08 19:49:40 -0500101groupadd -f -r vpp
Ed Warnickeec6290a2016-06-08 17:15:08 -0500102
Ole Troanc60f5572017-03-17 09:54:51 +0100103%build
Damjan Marionc06eeb02017-04-18 15:26:39 +0200104make bootstrap
105make -C build-root PLATFORM=vpp TAG=vpp install-packages
Ole Troanc60f5572017-03-17 09:54:51 +0100106cd %{_mu_build_dir}/../src/vpp-api/python && %py2_build
107
Ed Warnickecb9cada2015-12-08 15:45:58 -0700108%install
109#
110# binaries
111#
112mkdir -p -m755 %{buildroot}%{_bindir}
113mkdir -p -m755 %{buildroot}%{_unitdir}
Gabriel Ganne714968b2017-01-26 15:42:39 +0100114install -p -m 755 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/bin/* %{buildroot}%{_bindir}
Ole Troanf14e3bf2016-12-01 21:49:03 +0100115
Damjan Marion7cd468a2016-12-19 23:05:39 +0100116# api
Ole Troanf14e3bf2016-12-01 21:49:03 +0100117mkdir -p -m755 %{buildroot}/usr/share/vpp/api
Ole Troanf14e3bf2016-12-01 21:49:03 +0100118
Ed Warnickecb9cada2015-12-08 15:45:58 -0700119#
120# configs
121#
122mkdir -p -m755 %{buildroot}/etc/vpp
Miroslav Miklus8e08e742016-10-11 13:35:26 +0200123mkdir -p -m755 %{buildroot}/etc/sysctl.d
Damjan Marionc06eeb02017-04-18 15:26:39 +0200124install -p -m 644 %{_topdir}/vpp.service %{buildroot}%{_unitdir}
Damjan Mariond0f673e2017-01-31 17:29:33 +0100125install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/startup.conf %{buildroot}/etc/vpp/startup.conf
Damjan Marion7cd468a2016-12-19 23:05:39 +0100126install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d
Ed Warnickecb9cada2015-12-08 15:45:58 -0700127#
128# libraries
129#
130mkdir -p -m755 %{buildroot}%{_libdir}
Padraig Connolly69915cb2017-01-10 17:10:39 +0000131mkdir -p -m755 %{buildroot}/etc/bash_completion.d
132mkdir -p -m755 %{buildroot}/usr/share/vpp
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400133for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/*/lib* -type f -name '*.so.*.*.*' -print )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700134do
135 install -p -m 755 $file %{buildroot}%{_libdir}
136done
137for file in $(cd %{buildroot}%{_libdir} && find . -type f -print | sed -e 's/^\.\///')
138do
139 # make lib symlinks
140 ( cd %{buildroot}%{_libdir} &&
141 ln -fs $file $(echo $file | sed -e 's/\(\.so\.[0-9]\+\).*/\1/') )
Ed Warnickef5a0e732016-09-07 17:12:52 +0000142 ( cd %{buildroot}%{_libdir} &&
143 ln -fs $file $(echo $file | sed -e 's/\(\.so\)\.[0-9]\+.*/\1/') )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700144done
Damjan Marion7cd468a2016-12-19 23:05:39 +0100145for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/vpp/share/vpp/api -type f -name '*.api.json' -print )
Ole Troanf14e3bf2016-12-01 21:49:03 +0100146do
147 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
148done
Padraig Connolly69915cb2017-01-10 17:10:39 +0000149install -p -m 644 %{_mu_build_dir}/../src/scripts/vppctl_completion %{buildroot}/etc/bash_completion.d
150install -p -m 644 %{_mu_build_dir}/../src/scripts/vppctl-cmd-list %{buildroot}/usr/share/vpp
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700151
Damjan Marioncb034b92016-12-28 18:38:59 +0100152# Lua bindings
153mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/lua/examples/cli
154mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/lua/examples/lute
155for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua && git ls-files .)
156do
157 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua/$file \
158 %{buildroot}/usr/share/doc/vpp/examples/lua/$file
159done
160
161# Java bindings
162mkdir -p -m755 %{buildroot}/usr/share/java
163for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/vpp/share/java -type f -name '*.jar' -print )
164do
165 install -p -m 644 $file %{buildroot}/usr/share/java
166done
167
Ole Troan57c3d662016-09-12 22:00:32 +0200168# Python bindings
Ole Troanc60f5572017-03-17 09:54:51 +0100169cd %{_mu_build_dir}/../src/vpp-api/python && %py2_install
Ole Troan57c3d662016-09-12 22:00:32 +0200170
Ed Warnickecb9cada2015-12-08 15:45:58 -0700171#
172# devel
173#
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400174for 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 -0700175do
176 for subdir in $(cd ${dir} && find . -type d -print)
177 do
178 mkdir -p -m755 %{buildroot}/usr/include/${subdir}
179 done
180 for file in $(cd ${dir} && find . -type f -print)
181 do
182 install -p -m 644 $dir/$file %{buildroot}%{_includedir}/$file
183 done
184done
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700185
186mkdir -p -m755 %{buildroot}%{python2_sitelib}/jvppgen
Damjan Marioncb034b92016-12-28 18:38:59 +0100187install -p -m755 %{_mu_build_dir}/../src/vpp-api/java/jvpp/gen/jvpp_gen.py %{buildroot}/usr/bin
188for i in $(ls %{_mu_build_dir}/../src/vpp-api/java/jvpp/gen/jvppgen/*.py); do
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700189 install -p -m666 ${i} %{buildroot}%{python2_sitelib}/jvppgen
190done;
191
Ed Warnickecb9cada2015-12-08 15:45:58 -0700192# sample plugin
193mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/sample
Damjan Marioncb034b92016-12-28 18:38:59 +0100194for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin && git ls-files .)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700195do
Damjan Marioncb034b92016-12-28 18:38:59 +0100196 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin/$file \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700197 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/$file
198done
199
Ed Warnickef5a14362016-09-12 20:40:24 +0000200
201#
202# vpp-plugins
203#
Ed Warnickee7637e72016-09-14 16:58:33 -0700204mkdir -p -m755 %{buildroot}/usr/lib/vpp_plugins
205mkdir -p -m755 %{buildroot}/usr/lib/vpp_api_test_plugins
Damjan Marion7cd468a2016-12-19 23:05:39 +0100206for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_plugins && find -type f -print)
207do
208 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_plugins/$file \
209 %{buildroot}/usr/lib/vpp_plugins/$file
210done
211
Damjan Marion7cd468a2016-12-19 23:05:39 +0100212for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_api_test_plugins && find -type f -print)
213do
214 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_api_test_plugins/$file \
215 %{buildroot}/usr/lib/vpp_api_test_plugins/$file
216done
217
Ole Troanf14e3bf2016-12-01 21:49:03 +0100218for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/plugins -type f -name '*.api.json' -print )
219do
220 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
221done
222
Damjan Mariona1bd0232016-12-19 19:08:11 +0100223#
224# remove RPATH from ELF binaries
225#
226%{_mu_build_dir}/scripts/remove-rpath %{buildroot}
227
Ed Warnickecb9cada2015-12-08 15:45:58 -0700228%post
229sysctl --system
230%systemd_post vpp.service
231
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300232%preun
233%systemd_preun vpp.service
234
Ed Warnickecb9cada2015-12-08 15:45:58 -0700235%postun
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300236%systemd_postun
237
238# Unbind user-mode PCI drivers
239removed=
240pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci`
241for d in $pci_dirs; do
242 for f in ${d}/*; do
243 [ -e "${f}/config" ] || continue
Radu Nicolau02767e92017-02-23 14:28:49 +0000244 echo ${f##*/} > ${d}/unbind
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300245 basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}`
246 removed=y
247 done
248done
249if [ -n "${removed}" ]; then
250 echo "There are changes in PCI drivers, rescaning"
251 echo 1 > /sys/bus/pci/rescan
252else
253 echo "There weren't PCI devices binded"
254fi
Ed Warnickecb9cada2015-12-08 15:45:58 -0700255
256%files
257%defattr(-,bin,bin)
258%{_unitdir}/vpp.service
Damjan Marion08ff7e02016-01-20 13:45:36 +0100259/usr/bin/vpp*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700260/usr/bin/svm*
Dave Barach0e5e3c32016-01-25 08:28:22 -0500261/usr/bin/elftool
Miroslav Miklus8e08e742016-10-11 13:35:26 +0200262%config /etc/sysctl.d/80-vpp.conf
Ed Warnickecb9cada2015-12-08 15:45:58 -0700263%config /etc/vpp/startup.conf
Ole Troanf14e3bf2016-12-01 21:49:03 +0100264/usr/share/vpp/api/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700265
266%files lib
267%defattr(-,bin,bin)
Ed Warnickef5a14362016-09-12 20:40:24 +0000268%exclude %{_libdir}/vpp_plugins
269%exclude %{_libdir}/vpp_api_test_plugins
Ed Warnickecb9cada2015-12-08 15:45:58 -0700270%{_libdir}/*
Ole Troanf14e3bf2016-12-01 21:49:03 +0100271/usr/share/vpp/api/*
Padraig Connolly69915cb2017-01-10 17:10:39 +0000272/etc/bash_completion.d/vppctl_completion
273/usr/share/vpp/vppctl-cmd-list
Ed Warnickecb9cada2015-12-08 15:45:58 -0700274
Damjan Marioncb034b92016-12-28 18:38:59 +0100275%files api-lua
Gabriel Gannef3854e92017-01-17 10:00:54 +0100276%defattr(644,root,root,644)
Damjan Marioncb034b92016-12-28 18:38:59 +0100277/usr/share/doc/vpp/examples/lua
278
279%files api-java
280%defattr(644,root,root)
281/usr/share/java/*
282
283%files api-python
Ole Troan57c3d662016-09-12 22:00:32 +0200284%defattr(644,root,root)
Ole Troanc60f5572017-03-17 09:54:51 +0100285%{python2_sitelib}/vpp_papi*
Ole Troan57c3d662016-09-12 22:00:32 +0200286
Ed Warnickecb9cada2015-12-08 15:45:58 -0700287%files devel
288%defattr(-,bin,bin)
289/usr/bin/vppapigen
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700290/usr/bin/jvpp_gen.py
Ed Warnickecb9cada2015-12-08 15:45:58 -0700291%{_includedir}/*
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700292%{python2_sitelib}/jvppgen/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700293/usr/share/doc/vpp/examples/sample-plugin
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700294
Ed Warnickef5a14362016-09-12 20:40:24 +0000295%files plugins
296%defattr(-,bin,bin)
Ed Warnickee7637e72016-09-14 16:58:33 -0700297/usr/lib/vpp_plugins/*
298/usr/lib/vpp_api_test_plugins/*
Ole Troanf14e3bf2016-12-01 21:49:03 +0100299/usr/share/vpp/api/*