blob: c3c0d927b10a0b760c37a506a81ff833b55c5c71 [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.
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
Damjan Marioncb034b92016-12-28 18:38:59 +010074%package api-lua
75Summary: VPP api lua bindings
76Group: Development/Libraries
77Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}
78
79%description api-lua
80This package contains the lua bindings for the vpp api
81
82%package api-java
83Summary: VPP api java bindings
84Group: Development/Libraries
85Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}
86
87%description api-java
88This package contains the java bindings for the vpp api
89
90%package api-python
Ole Troan57c3d662016-09-12 22:00:32 +020091Summary: VPP api python bindings
92Group: Development/Libraries
Gabriel Ganne32905662016-12-06 19:12:49 +010093Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}, python-setuptools
Ole Troan57c3d662016-09-12 22:00:32 +020094
Damjan Marioncb034b92016-12-28 18:38:59 +010095%description api-python
Ole Troan57c3d662016-09-12 22:00:32 +020096This package contains the python bindings for the vpp api
97
Thomas F Herbert20a29c72016-10-13 18:36:50 -040098%prep
99%setup -q -n %{name}-%{_version}
100
101%build
102make bootstrap
103make build-release
104
Ed Warnickeec6290a2016-06-08 17:15:08 -0500105%pre
106# Add the vpp group
Ed Warnickeb10427e2016-06-08 19:49:40 -0500107groupadd -f -r vpp
Ed Warnickeec6290a2016-06-08 17:15:08 -0500108
Ed Warnickecb9cada2015-12-08 15:45:58 -0700109%install
110#
111# binaries
112#
113mkdir -p -m755 %{buildroot}%{_bindir}
114mkdir -p -m755 %{buildroot}%{_unitdir}
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400115install -p -m 755 %{_mu_build_dir}/%{_vpp_install_dir}/*/bin/* %{buildroot}%{_bindir}
Ole Troanf14e3bf2016-12-01 21:49:03 +0100116
Damjan Marion7cd468a2016-12-19 23:05:39 +0100117# api
Ole Troanf14e3bf2016-12-01 21:49:03 +0100118mkdir -p -m755 %{buildroot}/usr/share/vpp/api
Ole Troanf14e3bf2016-12-01 21:49:03 +0100119
Ed Warnickecb9cada2015-12-08 15:45:58 -0700120#
121# configs
122#
123mkdir -p -m755 %{buildroot}/etc/vpp
Miroslav Miklus8e08e742016-10-11 13:35:26 +0200124mkdir -p -m755 %{buildroot}/etc/sysctl.d
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400125install -p -m 644 %{_mu_build_dir}/rpm/vpp.service %{buildroot}%{_unitdir}
Damjan Marion7cd468a2016-12-19 23:05:39 +0100126install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/startup.uiopcigeneric.conf %{buildroot}/etc/vpp/startup.conf
127install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d
Ed Warnickecb9cada2015-12-08 15:45:58 -0700128#
129# libraries
130#
131mkdir -p -m755 %{buildroot}%{_libdir}
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400132for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/*/lib* -type f -name '*.so.*.*.*' -print )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700133do
134 install -p -m 755 $file %{buildroot}%{_libdir}
135done
136for file in $(cd %{buildroot}%{_libdir} && find . -type f -print | sed -e 's/^\.\///')
137do
138 # make lib symlinks
139 ( cd %{buildroot}%{_libdir} &&
140 ln -fs $file $(echo $file | sed -e 's/\(\.so\.[0-9]\+\).*/\1/') )
Ed Warnickef5a0e732016-09-07 17:12:52 +0000141 ( cd %{buildroot}%{_libdir} &&
142 ln -fs $file $(echo $file | sed -e 's/\(\.so\)\.[0-9]\+.*/\1/') )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700143done
Damjan Marion7cd468a2016-12-19 23:05:39 +0100144for 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 +0100145do
146 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
147done
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700148
Damjan Marioncb034b92016-12-28 18:38:59 +0100149# Lua bindings
150mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/lua/examples/cli
151mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/lua/examples/lute
152for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua && git ls-files .)
153do
154 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua/$file \
155 %{buildroot}/usr/share/doc/vpp/examples/lua/$file
156done
157
158# Java bindings
159mkdir -p -m755 %{buildroot}/usr/share/java
160for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/vpp/share/java -type f -name '*.jar' -print )
161do
162 install -p -m 644 $file %{buildroot}/usr/share/java
163done
164
Ole Troan57c3d662016-09-12 22:00:32 +0200165# Python bindings
Gabriel Ganne32905662016-12-06 19:12:49 +0100166mkdir -p -m755 %{buildroot}%{python2_sitelib}
167install -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 +0200168
Ed Warnickecb9cada2015-12-08 15:45:58 -0700169#
170# devel
171#
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400172for 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 -0700173do
174 for subdir in $(cd ${dir} && find . -type d -print)
175 do
176 mkdir -p -m755 %{buildroot}/usr/include/${subdir}
177 done
178 for file in $(cd ${dir} && find . -type f -print)
179 do
180 install -p -m 644 $dir/$file %{buildroot}%{_includedir}/$file
181 done
182done
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700183
184mkdir -p -m755 %{buildroot}%{python2_sitelib}/jvppgen
Damjan Marioncb034b92016-12-28 18:38:59 +0100185install -p -m755 %{_mu_build_dir}/../src/vpp-api/java/jvpp/gen/jvpp_gen.py %{buildroot}/usr/bin
186for i in $(ls %{_mu_build_dir}/../src/vpp-api/java/jvpp/gen/jvppgen/*.py); do
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700187 install -p -m666 ${i} %{buildroot}%{python2_sitelib}/jvppgen
188done;
189
Ed Warnickecb9cada2015-12-08 15:45:58 -0700190# sample plugin
191mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/sample
Damjan Marioncb034b92016-12-28 18:38:59 +0100192for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin && git ls-files .)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700193do
Damjan Marioncb034b92016-12-28 18:38:59 +0100194 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin/$file \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700195 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/$file
196done
197
Ed Warnickef5a14362016-09-12 20:40:24 +0000198
199#
200# vpp-plugins
201#
Ed Warnickee7637e72016-09-14 16:58:33 -0700202mkdir -p -m755 %{buildroot}/usr/lib/vpp_plugins
203mkdir -p -m755 %{buildroot}/usr/lib/vpp_api_test_plugins
Damjan Marion7cd468a2016-12-19 23:05:39 +0100204for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_plugins && find -type f -print)
205do
206 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_plugins/$file \
207 %{buildroot}/usr/lib/vpp_plugins/$file
208done
209
Damjan Marion7cd468a2016-12-19 23:05:39 +0100210for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_api_test_plugins && find -type f -print)
211do
212 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_api_test_plugins/$file \
213 %{buildroot}/usr/lib/vpp_api_test_plugins/$file
214done
215
Ole Troanf14e3bf2016-12-01 21:49:03 +0100216for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/plugins -type f -name '*.api.json' -print )
217do
218 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
219done
220
Damjan Mariona1bd0232016-12-19 19:08:11 +0100221#
222# remove RPATH from ELF binaries
223#
224%{_mu_build_dir}/scripts/remove-rpath %{buildroot}
225
Ed Warnickecb9cada2015-12-08 15:45:58 -0700226%post
227sysctl --system
228%systemd_post vpp.service
229
Damjan Marioncb034b92016-12-28 18:38:59 +0100230%post api-python
Gabriel Ganne32905662016-12-06 19:12:49 +0100231easy_install -z %{python2_sitelib}/vpp_papi-*.egg
232
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300233%preun
234%systemd_preun vpp.service
235
Damjan Marioncb034b92016-12-28 18:38:59 +0100236%preun api-python
Gabriel Ganne32905662016-12-06 19:12:49 +0100237easy_install -mxNq vpp_papi
238
Ed Warnickecb9cada2015-12-08 15:45:58 -0700239%postun
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300240%systemd_postun
241
242# Unbind user-mode PCI drivers
243removed=
244pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci`
245for d in $pci_dirs; do
246 for f in ${d}/*; do
247 [ -e "${f}/config" ] || continue
248 echo 1 > ${f}/remove
249 basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}`
250 removed=y
251 done
252done
253if [ -n "${removed}" ]; then
254 echo "There are changes in PCI drivers, rescaning"
255 echo 1 > /sys/bus/pci/rescan
256else
257 echo "There weren't PCI devices binded"
258fi
Ed Warnickecb9cada2015-12-08 15:45:58 -0700259
260%files
261%defattr(-,bin,bin)
262%{_unitdir}/vpp.service
Damjan Marion08ff7e02016-01-20 13:45:36 +0100263/usr/bin/vpp*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700264/usr/bin/svm*
Dave Barach0e5e3c32016-01-25 08:28:22 -0500265/usr/bin/elftool
Miroslav Miklus8e08e742016-10-11 13:35:26 +0200266%config /etc/sysctl.d/80-vpp.conf
Ed Warnickecb9cada2015-12-08 15:45:58 -0700267%config /etc/vpp/startup.conf
Ole Troanf14e3bf2016-12-01 21:49:03 +0100268/usr/share/vpp/api/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700269
270%files lib
271%defattr(-,bin,bin)
Ed Warnickef5a14362016-09-12 20:40:24 +0000272%exclude %{_libdir}/vpp_plugins
273%exclude %{_libdir}/vpp_api_test_plugins
Ed Warnickecb9cada2015-12-08 15:45:58 -0700274%{_libdir}/*
Ole Troanf14e3bf2016-12-01 21:49:03 +0100275/usr/share/vpp/api/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700276
Damjan Marioncb034b92016-12-28 18:38:59 +0100277%files api-lua
278%defattr(644,root,root)
279/usr/share/doc/vpp/examples/lua
280
281%files api-java
282%defattr(644,root,root)
283/usr/share/java/*
284
285%files api-python
Ole Troan57c3d662016-09-12 22:00:32 +0200286%defattr(644,root,root)
Gabriel Ganne32905662016-12-06 19:12:49 +0100287%{python2_sitelib}/vpp_papi-*.egg
Ole Troan57c3d662016-09-12 22:00:32 +0200288
Ed Warnickecb9cada2015-12-08 15:45:58 -0700289%files devel
290%defattr(-,bin,bin)
291/usr/bin/vppapigen
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700292/usr/bin/jvpp_gen.py
Ed Warnickecb9cada2015-12-08 15:45:58 -0700293%{_includedir}/*
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700294%{python2_sitelib}/jvppgen/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700295/usr/share/doc/vpp/examples/sample-plugin
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700296
Ed Warnickef5a14362016-09-12 20:40:24 +0000297%files plugins
298%defattr(-,bin,bin)
Ed Warnickee7637e72016-09-14 16:58:33 -0700299/usr/lib/vpp_plugins/*
300/usr/lib/vpp_api_test_plugins/*
Ole Troanf14e3bf2016-12-01 21:49:03 +0100301/usr/share/vpp/api/*