blob: 6dc04b82f7d3eb4caad479ebeaff61c325dd2f05 [file] [log] [blame]
Thomas F Herbert4b0ac822017-08-29 16:07:51 -04001%bcond_without aesni
Thomas F Herbert20a29c72016-10-13 18:36:50 -04002%define _vpp_build_dir build-tool-native
Ed Warnickecb9cada2015-12-08 15:45:58 -07003%define _unitdir /lib/systemd/system
4%define _topdir %(pwd)
5%define _builddir %{_topdir}
Thomas F Herbert5349f942017-09-13 15:26:46 -04006%define _tmp_build_dir %{name}-%{_version}.0
7%define _mu_build_dir %{_topdir}/%{_tmp_build_dir}/build-root
Igor Mikhailov (imichail)c442e612017-05-18 19:46:17 -07008%define _vpp_tag %{getenv:TAG}
9%if "%{_vpp_tag}" == ""
10%define _vpp_tag vpp
11%endif
12%define _vpp_install_dir install-%{_vpp_tag}-native
Ed Warnickecb9cada2015-12-08 15:45:58 -070013
Ole Troan57c3d662016-09-12 22:00:32 +020014# Failsafe backport of Python2-macros for RHEL <= 6
15%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
16%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
17%{!?python_version: %global python_version %(%{__python} -c "import sys; sys.stdout.write(sys.version[:3])")}
18%{!?__python2: %global __python2 %{__python}}
19%{!?python2_sitelib: %global python2_sitelib %{python_sitelib}}
20%{!?python2_sitearch: %global python2_sitearch %{python_sitearch}}
21%{!?python2_version: %global python2_version %{python_version}}
22
23%{!?python2_minor_version: %define python2_minor_version %(%{__python} -c "import sys ; print sys.version[2:3]")}
24
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +030025%{?systemd_requires}
26
Ed Warnickecb9cada2015-12-08 15:45:58 -070027Name: vpp
28Summary: Vector Packet Processing
Billy McFallf6e3ad02017-07-05 09:33:30 -040029License: ASL 2.0
Ed Warnickecb9cada2015-12-08 15:45:58 -070030Version: %{_version}
31Release: %{_release}
Padraigb21b6762016-09-21 14:59:02 +010032Requires: vpp-lib = %{_version}-%{_release}, net-tools, pciutils, python
Damjan Mariona1bd0232016-12-19 19:08:11 +010033BuildRequires: systemd, chrpath
Thomas F Herberte4128912017-10-09 15:03:55 -040034BuildRequires: check, check-devel
35%if 0%{?fedora} >= 25
36BuildRequires: subunit, subunit-devel
37%endif
Thomas F Herbertbd8e2422017-08-03 11:04:24 -040038%if 0%{?fedora} >= 26
Thomas F Herbert440751b2017-09-11 08:58:23 -040039BuildRequires: compat-openssl10-devel
Thomas F Herbertbd8e2422017-08-03 11:04:24 -040040BuildRequires: python2-devel, python2-virtualenv
41%else
42%if 0%{?fedora} == 25
Thomas F Herbert440751b2017-09-11 08:58:23 -040043BuildRequires: openssl-devel
Thomas F Herbertbd8e2422017-08-03 11:04:24 -040044BuildRequires: python-devel, python2-virtualenv
45%else
Thomas F Herbert440751b2017-09-11 08:58:23 -040046BuildREquires: openssl-devel
Thomas F Herbertbd8e2422017-08-03 11:04:24 -040047BuildRequires: python-devel, python-virtualenv
48%endif
49%endif
Thomas F Herbert440751b2017-09-11 08:58:23 -040050BuildRequires: libffi-devel
Thomas F Herbertbd8e2422017-08-03 11:04:24 -040051BuildRequires: glibc-static, java-1.8.0-openjdk, java-1.8.0-openjdk-devel yum-utils, redhat-lsb
52BuildRequires: apr-devel
Thomas F Herbertbd8e2422017-08-03 11:04:24 -040053BuildRequires: numactl-devel
54BuildRequires: autoconf automake libtool byacc bison flex
Ed Warnickecb9cada2015-12-08 15:45:58 -070055
Thomas F Herbertb60f4962017-07-19 19:17:15 -040056Source: %{name}-%{_version}-%{_release}.tar.xz
57# Source: vpp-latest.tar.xz
Thomas F Herbert20a29c72016-10-13 18:36:50 -040058
Ed Warnickecb9cada2015-12-08 15:45:58 -070059%description
Damjan Marion08ff7e02016-01-20 13:45:36 +010060This package provides VPP executables: vpp, vpp_api_test, vpp_json_test
61vpp - the vector packet engine
62vpp_api_test - vector packet engine API test tool
63vpp_json_test - vector packet engine JSON test tool
Ed Warnickecb9cada2015-12-08 15:45:58 -070064
65%package lib
66Summary: VPP libraries
67Group: System Environment/Libraries
68
69%description lib
70This package contains the VPP shared libraries, including:
71vppinfra - foundation library supporting vectors, hashes, bitmaps, pools, and string formatting.
Ed Warnickecb9cada2015-12-08 15:45:58 -070072svm - vm library
73vlib - vector processing library
74vlib-api - binary API library
75vnet - network stack library
76
77%package devel
78Summary: VPP header files, static libraries
79Group: Development/Libraries
80Requires: vpp-lib
81
82%description devel
Thomas F Herbert3977a212016-10-01 18:09:33 -040083This package contains the header files for VPP.
84Install this package if you want to write a
85program for compilation and linking with vpp lib.
86vlib
87vlibmemory
88vnet - devices, classify, dhcp, ethernet flow, gre, ip, etc.
89vpp-api
90vppinfra
Ed Warnickecb9cada2015-12-08 15:45:58 -070091
Ed Warnickef5a14362016-09-12 20:40:24 +000092%package plugins
93Summary: Vector Packet Processing--runtime plugins
94Group: System Environment/Libraries
95Requires: vpp = %{_version}-%{_release}
96%description plugins
97This package contains VPP plugins
98
Damjan Marioncb034b92016-12-28 18:38:59 +010099%package api-lua
100Summary: VPP api lua bindings
101Group: Development/Libraries
102Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}
103
104%description api-lua
105This package contains the lua bindings for the vpp api
106
107%package api-java
108Summary: VPP api java bindings
109Group: Development/Libraries
110Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}
111
112%description api-java
113This package contains the java bindings for the vpp api
114
115%package api-python
Ole Troan57c3d662016-09-12 22:00:32 +0200116Summary: VPP api python bindings
117Group: Development/Libraries
Ole Troanc60f5572017-03-17 09:54:51 +0100118Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}, python-setuptools libffi-devel
Ole Troan57c3d662016-09-12 22:00:32 +0200119
Damjan Marioncb034b92016-12-28 18:38:59 +0100120%description api-python
Ole Troan57c3d662016-09-12 22:00:32 +0200121This package contains the python bindings for the vpp api
122
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400123%prep
Thomas F Herbert5349f942017-09-13 15:26:46 -0400124# Unpack into dir with longer name as work around of debugedit bug in in rpm-build 4.13
125rm -rf %{name}-%{_version}
Thomas F Herbert41988e52017-10-09 14:50:08 -0400126rm -rf %{_tmp_build_dir}
Thomas F Herbert5349f942017-09-13 15:26:46 -0400127/usr/bin/xz -dc '%{_sourcedir}/%{name}-%{_version}-%{_release}.tar.xz' | /usr/bin/tar -xf -
128mv %{name}-%{_version} %{_tmp_build_dir}
129cd '%{_tmp_build_dir}'
130/usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400131
Ed Warnickeec6290a2016-06-08 17:15:08 -0500132%pre
133# Add the vpp group
Ed Warnickeb10427e2016-06-08 19:49:40 -0500134groupadd -f -r vpp
Ed Warnickeec6290a2016-06-08 17:15:08 -0500135
Ole Troanc60f5572017-03-17 09:54:51 +0100136%build
Thomas F Herbert5349f942017-09-13 15:26:46 -0400137cd '%{_tmp_build_dir}'
Thomas F Herbert4b0ac822017-08-29 16:07:51 -0400138%if %{with aesni}
139 make bootstrap
140 make -C build-root PLATFORM=vpp TAG=%{_vpp_tag} install-packages
141%else
142 make bootstrap AESNI=n
143 make -C build-root PLATFORM=vpp AESNI=n TAG=%{_vpp_tag} install-packages
144%endif
Ole Troanc60f5572017-03-17 09:54:51 +0100145cd %{_mu_build_dir}/../src/vpp-api/python && %py2_build
146
Ed Warnickecb9cada2015-12-08 15:45:58 -0700147%install
148#
149# binaries
150#
151mkdir -p -m755 %{buildroot}%{_bindir}
152mkdir -p -m755 %{buildroot}%{_unitdir}
Gabriel Ganne714968b2017-01-26 15:42:39 +0100153install -p -m 755 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/bin/* %{buildroot}%{_bindir}
Ole Troanf14e3bf2016-12-01 21:49:03 +0100154
Damjan Marion7cd468a2016-12-19 23:05:39 +0100155# api
Ole Troanf14e3bf2016-12-01 21:49:03 +0100156mkdir -p -m755 %{buildroot}/usr/share/vpp/api
Ole Troanf14e3bf2016-12-01 21:49:03 +0100157
Ed Warnickecb9cada2015-12-08 15:45:58 -0700158#
159# configs
160#
161mkdir -p -m755 %{buildroot}/etc/vpp
Miroslav Miklus8e08e742016-10-11 13:35:26 +0200162mkdir -p -m755 %{buildroot}/etc/sysctl.d
Thomas F Herbert5b75b6b2017-07-23 17:21:46 -0400163install -p -m 644 %{_mu_build_dir}/../extras/rpm/vpp.service %{buildroot}%{_unitdir}
Damjan Mariond0f673e2017-01-31 17:29:33 +0100164install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/startup.conf %{buildroot}/etc/vpp/startup.conf
Damjan Marion7cd468a2016-12-19 23:05:39 +0100165install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d
Ed Warnickecb9cada2015-12-08 15:45:58 -0700166#
167# libraries
168#
169mkdir -p -m755 %{buildroot}%{_libdir}
Padraig Connolly69915cb2017-01-10 17:10:39 +0000170mkdir -p -m755 %{buildroot}/etc/bash_completion.d
171mkdir -p -m755 %{buildroot}/usr/share/vpp
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400172for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/*/lib* -type f -name '*.so.*.*.*' -print )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700173do
174 install -p -m 755 $file %{buildroot}%{_libdir}
175done
176for file in $(cd %{buildroot}%{_libdir} && find . -type f -print | sed -e 's/^\.\///')
177do
178 # make lib symlinks
179 ( cd %{buildroot}%{_libdir} &&
180 ln -fs $file $(echo $file | sed -e 's/\(\.so\.[0-9]\+\).*/\1/') )
Ed Warnickef5a0e732016-09-07 17:12:52 +0000181 ( cd %{buildroot}%{_libdir} &&
182 ln -fs $file $(echo $file | sed -e 's/\(\.so\)\.[0-9]\+.*/\1/') )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700183done
Damjan Marion7cd468a2016-12-19 23:05:39 +0100184for 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 +0100185do
186 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
187done
Padraig Connolly69915cb2017-01-10 17:10:39 +0000188install -p -m 644 %{_mu_build_dir}/../src/scripts/vppctl_completion %{buildroot}/etc/bash_completion.d
189install -p -m 644 %{_mu_build_dir}/../src/scripts/vppctl-cmd-list %{buildroot}/usr/share/vpp
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700190
Damjan Marioncb034b92016-12-28 18:38:59 +0100191# Lua bindings
192mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/lua/examples/cli
193mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/lua/examples/lute
Thomas F Herbertbd8e2422017-08-03 11:04:24 -0400194# for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua && git ls-files .)
195for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua && find . -type f -regex '.*/*.[luteamd]' -print | sed -e 's/^\.\///')
Damjan Marioncb034b92016-12-28 18:38:59 +0100196do
Thomas F Herbertbd8e2422017-08-03 11:04:24 -0400197 ( cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua && install -p -m 644 $file \
198 %{buildroot}/usr/share/doc/vpp/examples/lua/$file )
Damjan Marioncb034b92016-12-28 18:38:59 +0100199done
200
201# Java bindings
202mkdir -p -m755 %{buildroot}/usr/share/java
203for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/vpp/share/java -type f -name '*.jar' -print )
204do
205 install -p -m 644 $file %{buildroot}/usr/share/java
206done
207
Ole Troan57c3d662016-09-12 22:00:32 +0200208# Python bindings
Ole Troanc60f5572017-03-17 09:54:51 +0100209cd %{_mu_build_dir}/../src/vpp-api/python && %py2_install
Ole Troan57c3d662016-09-12 22:00:32 +0200210
Ed Warnickecb9cada2015-12-08 15:45:58 -0700211#
212# devel
213#
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400214for 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 -0700215do
216 for subdir in $(cd ${dir} && find . -type d -print)
217 do
218 mkdir -p -m755 %{buildroot}/usr/include/${subdir}
219 done
220 for file in $(cd ${dir} && find . -type f -print)
221 do
222 install -p -m 644 $dir/$file %{buildroot}%{_includedir}/$file
223 done
224done
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700225
226mkdir -p -m755 %{buildroot}%{python2_sitelib}/jvppgen
Damjan Marioncb034b92016-12-28 18:38:59 +0100227install -p -m755 %{_mu_build_dir}/../src/vpp-api/java/jvpp/gen/jvpp_gen.py %{buildroot}/usr/bin
228for i in $(ls %{_mu_build_dir}/../src/vpp-api/java/jvpp/gen/jvppgen/*.py); do
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700229 install -p -m666 ${i} %{buildroot}%{python2_sitelib}/jvppgen
230done;
231
Ed Warnickecb9cada2015-12-08 15:45:58 -0700232# sample plugin
233mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/sample
Thomas F Herbertbd8e2422017-08-03 11:04:24 -0400234#for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin && git ls-files .)
235for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin && find . -type f -regex '.*/*.[acdhimp]' -print | sed -e 's/^\.\///')
Ed Warnickecb9cada2015-12-08 15:45:58 -0700236do
Thomas F Herbertbd8e2422017-08-03 11:04:24 -0400237 ( cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin && install -p -m 644 $file \
238 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/$file )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700239done
240
Ed Warnickef5a14362016-09-12 20:40:24 +0000241
242#
243# vpp-plugins
244#
Ed Warnickee7637e72016-09-14 16:58:33 -0700245mkdir -p -m755 %{buildroot}/usr/lib/vpp_plugins
246mkdir -p -m755 %{buildroot}/usr/lib/vpp_api_test_plugins
Damjan Marion7cd468a2016-12-19 23:05:39 +0100247for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_plugins && find -type f -print)
248do
249 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_plugins/$file \
250 %{buildroot}/usr/lib/vpp_plugins/$file
251done
252
Damjan Marion7cd468a2016-12-19 23:05:39 +0100253for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_api_test_plugins && find -type f -print)
254do
255 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_api_test_plugins/$file \
256 %{buildroot}/usr/lib/vpp_api_test_plugins/$file
257done
258
Ole Troanf14e3bf2016-12-01 21:49:03 +0100259for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/plugins -type f -name '*.api.json' -print )
260do
261 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
262done
263
Damjan Mariona1bd0232016-12-19 19:08:11 +0100264#
265# remove RPATH from ELF binaries
266#
267%{_mu_build_dir}/scripts/remove-rpath %{buildroot}
268
Ed Warnickecb9cada2015-12-08 15:45:58 -0700269%post
Kristina Nevolnikova8ae18732017-06-21 14:20:42 +0200270if [ $1 -eq 1 ] ; then
271 sysctl --system
272fi
Ed Warnickecb9cada2015-12-08 15:45:58 -0700273%systemd_post vpp.service
274
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300275%preun
276%systemd_preun vpp.service
277
Ed Warnickecb9cada2015-12-08 15:45:58 -0700278%postun
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300279%systemd_postun
Kristina Nevolnikova8ae18732017-06-21 14:20:42 +0200280if [ $1 -eq 0 ] ; then
281 echo "Uninstalling, unbind user-mode PCI drivers"
282 # Unbind user-mode PCI drivers
283 removed=
284 pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci`
285 for d in $pci_dirs; do
286 for f in ${d}/*; do
287 [ -e "${f}/config" ] || continue
288 echo ${f##*/} > ${d}/unbind
289 basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}`
290 removed=y
291 done
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300292 done
Kristina Nevolnikova8ae18732017-06-21 14:20:42 +0200293 if [ -n "${removed}" ]; then
294 echo "There are changes in PCI drivers, rescaning"
295 echo 1 > /sys/bus/pci/rescan
296 else
297 echo "There weren't PCI devices binded"
298 fi
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300299else
Kristina Nevolnikova8ae18732017-06-21 14:20:42 +0200300 echo "Upgrading package, dont' unbind interfaces"
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300301fi
Ed Warnickecb9cada2015-12-08 15:45:58 -0700302
303%files
304%defattr(-,bin,bin)
305%{_unitdir}/vpp.service
Damjan Marion08ff7e02016-01-20 13:45:36 +0100306/usr/bin/vpp*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700307/usr/bin/svm*
Dave Barach0e5e3c32016-01-25 08:28:22 -0500308/usr/bin/elftool
Billy McFallce41a5c2017-09-08 20:11:58 +0000309%config(noreplace) /etc/sysctl.d/80-vpp.conf
310%config(noreplace) /etc/vpp/startup.conf
Ole Troanf14e3bf2016-12-01 21:49:03 +0100311/usr/share/vpp/api/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700312
313%files lib
314%defattr(-,bin,bin)
Ed Warnickef5a14362016-09-12 20:40:24 +0000315%exclude %{_libdir}/vpp_plugins
316%exclude %{_libdir}/vpp_api_test_plugins
Ed Warnickecb9cada2015-12-08 15:45:58 -0700317%{_libdir}/*
Ole Troanf14e3bf2016-12-01 21:49:03 +0100318/usr/share/vpp/api/*
Padraig Connolly69915cb2017-01-10 17:10:39 +0000319/etc/bash_completion.d/vppctl_completion
320/usr/share/vpp/vppctl-cmd-list
Ed Warnickecb9cada2015-12-08 15:45:58 -0700321
Damjan Marioncb034b92016-12-28 18:38:59 +0100322%files api-lua
Gabriel Gannef3854e92017-01-17 10:00:54 +0100323%defattr(644,root,root,644)
Damjan Marioncb034b92016-12-28 18:38:59 +0100324/usr/share/doc/vpp/examples/lua
325
326%files api-java
327%defattr(644,root,root)
328/usr/share/java/*
329
330%files api-python
Ole Troan57c3d662016-09-12 22:00:32 +0200331%defattr(644,root,root)
Ole Troanc60f5572017-03-17 09:54:51 +0100332%{python2_sitelib}/vpp_papi*
Ole Troan57c3d662016-09-12 22:00:32 +0200333
Ed Warnickecb9cada2015-12-08 15:45:58 -0700334%files devel
335%defattr(-,bin,bin)
336/usr/bin/vppapigen
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700337/usr/bin/jvpp_gen.py
Ed Warnickecb9cada2015-12-08 15:45:58 -0700338%{_includedir}/*
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700339%{python2_sitelib}/jvppgen/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700340/usr/share/doc/vpp/examples/sample-plugin
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700341
Ed Warnickef5a14362016-09-12 20:40:24 +0000342%files plugins
343%defattr(-,bin,bin)
Ed Warnickee7637e72016-09-14 16:58:33 -0700344/usr/lib/vpp_plugins/*
345/usr/lib/vpp_api_test_plugins/*
Ole Troanf14e3bf2016-12-01 21:49:03 +0100346/usr/share/vpp/api/*