blob: 7bc18ca4e8f3a14f73069644235f2cdc053faea8 [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
Damjan Mariona1bd0232016-12-19 19:08:11 +010029BuildRequires: systemd, chrpath
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.
Ed Warnickecb9cada2015-12-08 15:45:58 -070046svm - vm library
47vlib - vector processing library
48vlib-api - binary API library
49vnet - network stack library
50
51%package devel
52Summary: VPP header files, static libraries
53Group: Development/Libraries
54Requires: vpp-lib
55
56%description devel
Thomas F Herbert3977a212016-10-01 18:09:33 -040057This package contains the header files for VPP.
58Install this package if you want to write a
59program for compilation and linking with vpp lib.
60vlib
61vlibmemory
62vnet - devices, classify, dhcp, ethernet flow, gre, ip, etc.
63vpp-api
64vppinfra
Ed Warnickecb9cada2015-12-08 15:45:58 -070065
Ed Warnickef5a14362016-09-12 20:40:24 +000066%package plugins
67Summary: Vector Packet Processing--runtime plugins
68Group: System Environment/Libraries
69Requires: vpp = %{_version}-%{_release}
70%description plugins
71This package contains VPP plugins
72
Damjan Marioncb034b92016-12-28 18:38:59 +010073%package api-lua
74Summary: VPP api lua bindings
75Group: Development/Libraries
76Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}
77
78%description api-lua
79This package contains the lua bindings for the vpp api
80
81%package api-java
82Summary: VPP api java bindings
83Group: Development/Libraries
84Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}
85
86%description api-java
87This package contains the java bindings for the vpp api
88
89%package api-python
Ole Troan57c3d662016-09-12 22:00:32 +020090Summary: VPP api python bindings
91Group: Development/Libraries
Gabriel Ganne32905662016-12-06 19:12:49 +010092Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}, python-setuptools
Ole Troan57c3d662016-09-12 22:00:32 +020093
Damjan Marioncb034b92016-12-28 18:38:59 +010094%description api-python
Ole Troan57c3d662016-09-12 22:00:32 +020095This package contains the python bindings for the vpp api
96
Thomas F Herbert20a29c72016-10-13 18:36:50 -040097%prep
98%setup -q -n %{name}-%{_version}
99
Ed Warnickeec6290a2016-06-08 17:15:08 -0500100%pre
101# Add the vpp group
Ed Warnickeb10427e2016-06-08 19:49:40 -0500102groupadd -f -r vpp
Ed Warnickeec6290a2016-06-08 17:15:08 -0500103
Ed Warnickecb9cada2015-12-08 15:45:58 -0700104%install
105#
106# binaries
107#
108mkdir -p -m755 %{buildroot}%{_bindir}
109mkdir -p -m755 %{buildroot}%{_unitdir}
Gabriel Ganne714968b2017-01-26 15:42:39 +0100110install -p -m 755 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/bin/* %{buildroot}%{_bindir}
Ole Troanf14e3bf2016-12-01 21:49:03 +0100111
Damjan Marion7cd468a2016-12-19 23:05:39 +0100112# api
Ole Troanf14e3bf2016-12-01 21:49:03 +0100113mkdir -p -m755 %{buildroot}/usr/share/vpp/api
Ole Troanf14e3bf2016-12-01 21:49:03 +0100114
Ed Warnickecb9cada2015-12-08 15:45:58 -0700115#
116# configs
117#
118mkdir -p -m755 %{buildroot}/etc/vpp
Miroslav Miklus8e08e742016-10-11 13:35:26 +0200119mkdir -p -m755 %{buildroot}/etc/sysctl.d
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400120install -p -m 644 %{_mu_build_dir}/rpm/vpp.service %{buildroot}%{_unitdir}
Damjan Mariond0f673e2017-01-31 17:29:33 +0100121install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/startup.conf %{buildroot}/etc/vpp/startup.conf
Damjan Marion7cd468a2016-12-19 23:05:39 +0100122install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d
Ed Warnickecb9cada2015-12-08 15:45:58 -0700123#
124# libraries
125#
126mkdir -p -m755 %{buildroot}%{_libdir}
Padraig Connolly69915cb2017-01-10 17:10:39 +0000127mkdir -p -m755 %{buildroot}/etc/bash_completion.d
128mkdir -p -m755 %{buildroot}/usr/share/vpp
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400129for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/*/lib* -type f -name '*.so.*.*.*' -print )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700130do
131 install -p -m 755 $file %{buildroot}%{_libdir}
132done
133for file in $(cd %{buildroot}%{_libdir} && find . -type f -print | sed -e 's/^\.\///')
134do
135 # make lib symlinks
136 ( cd %{buildroot}%{_libdir} &&
137 ln -fs $file $(echo $file | sed -e 's/\(\.so\.[0-9]\+\).*/\1/') )
Ed Warnickef5a0e732016-09-07 17:12:52 +0000138 ( cd %{buildroot}%{_libdir} &&
139 ln -fs $file $(echo $file | sed -e 's/\(\.so\)\.[0-9]\+.*/\1/') )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700140done
Damjan Marion7cd468a2016-12-19 23:05:39 +0100141for 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 +0100142do
143 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
144done
Padraig Connolly69915cb2017-01-10 17:10:39 +0000145install -p -m 644 %{_mu_build_dir}/../src/scripts/vppctl_completion %{buildroot}/etc/bash_completion.d
146install -p -m 644 %{_mu_build_dir}/../src/scripts/vppctl-cmd-list %{buildroot}/usr/share/vpp
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700147
Damjan Marioncb034b92016-12-28 18:38:59 +0100148# Lua bindings
149mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/lua/examples/cli
150mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/lua/examples/lute
151for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua && git ls-files .)
152do
153 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua/$file \
154 %{buildroot}/usr/share/doc/vpp/examples/lua/$file
155done
156
157# Java bindings
158mkdir -p -m755 %{buildroot}/usr/share/java
159for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/vpp/share/java -type f -name '*.jar' -print )
160do
161 install -p -m 644 $file %{buildroot}/usr/share/java
162done
163
Ole Troan57c3d662016-09-12 22:00:32 +0200164# Python bindings
Gabriel Ganne32905662016-12-06 19:12:49 +0100165mkdir -p -m755 %{buildroot}%{python2_sitelib}
166install -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 +0200167
Ed Warnickecb9cada2015-12-08 15:45:58 -0700168#
169# devel
170#
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400171for 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 -0700172do
173 for subdir in $(cd ${dir} && find . -type d -print)
174 do
175 mkdir -p -m755 %{buildroot}/usr/include/${subdir}
176 done
177 for file in $(cd ${dir} && find . -type f -print)
178 do
179 install -p -m 644 $dir/$file %{buildroot}%{_includedir}/$file
180 done
181done
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700182
183mkdir -p -m755 %{buildroot}%{python2_sitelib}/jvppgen
Damjan Marioncb034b92016-12-28 18:38:59 +0100184install -p -m755 %{_mu_build_dir}/../src/vpp-api/java/jvpp/gen/jvpp_gen.py %{buildroot}/usr/bin
185for i in $(ls %{_mu_build_dir}/../src/vpp-api/java/jvpp/gen/jvppgen/*.py); do
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700186 install -p -m666 ${i} %{buildroot}%{python2_sitelib}/jvppgen
187done;
188
Ed Warnickecb9cada2015-12-08 15:45:58 -0700189# sample plugin
190mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/sample
Damjan Marioncb034b92016-12-28 18:38:59 +0100191for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin && git ls-files .)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700192do
Damjan Marioncb034b92016-12-28 18:38:59 +0100193 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin/$file \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700194 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/$file
195done
196
Ed Warnickef5a14362016-09-12 20:40:24 +0000197
198#
199# vpp-plugins
200#
Ed Warnickee7637e72016-09-14 16:58:33 -0700201mkdir -p -m755 %{buildroot}/usr/lib/vpp_plugins
202mkdir -p -m755 %{buildroot}/usr/lib/vpp_api_test_plugins
Damjan Marion7cd468a2016-12-19 23:05:39 +0100203for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_plugins && find -type f -print)
204do
205 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_plugins/$file \
206 %{buildroot}/usr/lib/vpp_plugins/$file
207done
208
Damjan Marion7cd468a2016-12-19 23:05:39 +0100209for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_api_test_plugins && find -type f -print)
210do
211 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_api_test_plugins/$file \
212 %{buildroot}/usr/lib/vpp_api_test_plugins/$file
213done
214
Ole Troanf14e3bf2016-12-01 21:49:03 +0100215for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/plugins -type f -name '*.api.json' -print )
216do
217 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
218done
219
Damjan Mariona1bd0232016-12-19 19:08:11 +0100220#
221# remove RPATH from ELF binaries
222#
223%{_mu_build_dir}/scripts/remove-rpath %{buildroot}
224
Ed Warnickecb9cada2015-12-08 15:45:58 -0700225%post
226sysctl --system
227%systemd_post vpp.service
228
Damjan Marioncb034b92016-12-28 18:38:59 +0100229%post api-python
Gabriel Ganne32905662016-12-06 19:12:49 +0100230easy_install -z %{python2_sitelib}/vpp_papi-*.egg
231
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300232%preun
233%systemd_preun vpp.service
234
Damjan Marioncb034b92016-12-28 18:38:59 +0100235%preun api-python
Gabriel Ganne32905662016-12-06 19:12:49 +0100236easy_install -mxNq vpp_papi
237
Ed Warnickecb9cada2015-12-08 15:45:58 -0700238%postun
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300239%systemd_postun
240
241# Unbind user-mode PCI drivers
242removed=
243pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci`
244for d in $pci_dirs; do
245 for f in ${d}/*; do
246 [ -e "${f}/config" ] || continue
Radu Nicolau02767e92017-02-23 14:28:49 +0000247 echo ${f##*/} > ${d}/unbind
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300248 basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}`
249 removed=y
250 done
251done
252if [ -n "${removed}" ]; then
253 echo "There are changes in PCI drivers, rescaning"
254 echo 1 > /sys/bus/pci/rescan
255else
256 echo "There weren't PCI devices binded"
257fi
Ed Warnickecb9cada2015-12-08 15:45:58 -0700258
259%files
260%defattr(-,bin,bin)
261%{_unitdir}/vpp.service
Damjan Marion08ff7e02016-01-20 13:45:36 +0100262/usr/bin/vpp*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700263/usr/bin/svm*
Dave Barach0e5e3c32016-01-25 08:28:22 -0500264/usr/bin/elftool
Miroslav Miklus8e08e742016-10-11 13:35:26 +0200265%config /etc/sysctl.d/80-vpp.conf
Ed Warnickecb9cada2015-12-08 15:45:58 -0700266%config /etc/vpp/startup.conf
Ole Troanf14e3bf2016-12-01 21:49:03 +0100267/usr/share/vpp/api/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700268
269%files lib
270%defattr(-,bin,bin)
Ed Warnickef5a14362016-09-12 20:40:24 +0000271%exclude %{_libdir}/vpp_plugins
272%exclude %{_libdir}/vpp_api_test_plugins
Ed Warnickecb9cada2015-12-08 15:45:58 -0700273%{_libdir}/*
Ole Troanf14e3bf2016-12-01 21:49:03 +0100274/usr/share/vpp/api/*
Padraig Connolly69915cb2017-01-10 17:10:39 +0000275/etc/bash_completion.d/vppctl_completion
276/usr/share/vpp/vppctl-cmd-list
Ed Warnickecb9cada2015-12-08 15:45:58 -0700277
Damjan Marioncb034b92016-12-28 18:38:59 +0100278%files api-lua
Gabriel Gannef3854e92017-01-17 10:00:54 +0100279%defattr(644,root,root,644)
Damjan Marioncb034b92016-12-28 18:38:59 +0100280/usr/share/doc/vpp/examples/lua
281
282%files api-java
283%defattr(644,root,root)
284/usr/share/java/*
285
286%files api-python
Ole Troan57c3d662016-09-12 22:00:32 +0200287%defattr(644,root,root)
Gabriel Ganne32905662016-12-06 19:12:49 +0100288%{python2_sitelib}/vpp_papi-*.egg
Ole Troan57c3d662016-09-12 22:00:32 +0200289
Ed Warnickecb9cada2015-12-08 15:45:58 -0700290%files devel
291%defattr(-,bin,bin)
292/usr/bin/vppapigen
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700293/usr/bin/jvpp_gen.py
Ed Warnickecb9cada2015-12-08 15:45:58 -0700294%{_includedir}/*
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700295%{python2_sitelib}/jvppgen/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700296/usr/share/doc/vpp/examples/sample-plugin
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700297
Ed Warnickef5a14362016-09-12 20:40:24 +0000298%files plugins
299%defattr(-,bin,bin)
Ed Warnickee7637e72016-09-14 16:58:33 -0700300/usr/lib/vpp_plugins/*
301/usr/lib/vpp_api_test_plugins/*
Ole Troanf14e3bf2016-12-01 21:49:03 +0100302/usr/share/vpp/api/*