blob: d266a649a26792d504eecd1fccc874ac4a9697d3 [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
Neale Ranns2ea2e422017-11-07 05:20:16 -080055BuildRequires: boost boost-devel
Ed Warnickecb9cada2015-12-08 15:45:58 -070056
Thomas F Herbertb60f4962017-07-19 19:17:15 -040057Source: %{name}-%{_version}-%{_release}.tar.xz
58# Source: vpp-latest.tar.xz
Thomas F Herbert20a29c72016-10-13 18:36:50 -040059
Ed Warnickecb9cada2015-12-08 15:45:58 -070060%description
Damjan Marion08ff7e02016-01-20 13:45:36 +010061This package provides VPP executables: vpp, vpp_api_test, vpp_json_test
62vpp - the vector packet engine
63vpp_api_test - vector packet engine API test tool
64vpp_json_test - vector packet engine JSON test tool
Ed Warnickecb9cada2015-12-08 15:45:58 -070065
66%package lib
67Summary: VPP libraries
68Group: System Environment/Libraries
69
70%description lib
71This package contains the VPP shared libraries, including:
72vppinfra - foundation library supporting vectors, hashes, bitmaps, pools, and string formatting.
Ed Warnickecb9cada2015-12-08 15:45:58 -070073svm - vm library
74vlib - vector processing library
75vlib-api - binary API library
76vnet - network stack library
77
78%package devel
79Summary: VPP header files, static libraries
80Group: Development/Libraries
81Requires: vpp-lib
82
83%description devel
Thomas F Herbert3977a212016-10-01 18:09:33 -040084This package contains the header files for VPP.
85Install this package if you want to write a
86program for compilation and linking with vpp lib.
87vlib
88vlibmemory
89vnet - devices, classify, dhcp, ethernet flow, gre, ip, etc.
90vpp-api
91vppinfra
Ed Warnickecb9cada2015-12-08 15:45:58 -070092
Ed Warnickef5a14362016-09-12 20:40:24 +000093%package plugins
94Summary: Vector Packet Processing--runtime plugins
95Group: System Environment/Libraries
96Requires: vpp = %{_version}-%{_release}
97%description plugins
98This package contains VPP plugins
99
Damjan Marioncb034b92016-12-28 18:38:59 +0100100%package api-lua
101Summary: VPP api lua bindings
102Group: Development/Libraries
103Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}
104
105%description api-lua
106This package contains the lua bindings for the vpp api
107
108%package api-java
109Summary: VPP api java bindings
110Group: Development/Libraries
111Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}
112
113%description api-java
114This package contains the java bindings for the vpp api
115
116%package api-python
Ole Troan57c3d662016-09-12 22:00:32 +0200117Summary: VPP api python bindings
118Group: Development/Libraries
Ole Troanc60f5572017-03-17 09:54:51 +0100119Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}, python-setuptools libffi-devel
Ole Troan57c3d662016-09-12 22:00:32 +0200120
Damjan Marioncb034b92016-12-28 18:38:59 +0100121%description api-python
Ole Troan57c3d662016-09-12 22:00:32 +0200122This package contains the python bindings for the vpp api
123
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400124%prep
Thomas F Herbert5349f942017-09-13 15:26:46 -0400125# Unpack into dir with longer name as work around of debugedit bug in in rpm-build 4.13
126rm -rf %{name}-%{_version}
Thomas F Herbert41988e52017-10-09 14:50:08 -0400127rm -rf %{_tmp_build_dir}
Thomas F Herbert5349f942017-09-13 15:26:46 -0400128/usr/bin/xz -dc '%{_sourcedir}/%{name}-%{_version}-%{_release}.tar.xz' | /usr/bin/tar -xf -
129mv %{name}-%{_version} %{_tmp_build_dir}
130cd '%{_tmp_build_dir}'
131/usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400132
Ed Warnickeec6290a2016-06-08 17:15:08 -0500133%pre
134# Add the vpp group
Ed Warnickeb10427e2016-06-08 19:49:40 -0500135groupadd -f -r vpp
Ed Warnickeec6290a2016-06-08 17:15:08 -0500136
Ole Troanc60f5572017-03-17 09:54:51 +0100137%build
Thomas F Herbert5349f942017-09-13 15:26:46 -0400138cd '%{_tmp_build_dir}'
Thomas F Herbert4b0ac822017-08-29 16:07:51 -0400139%if %{with aesni}
140 make bootstrap
141 make -C build-root PLATFORM=vpp TAG=%{_vpp_tag} install-packages
142%else
143 make bootstrap AESNI=n
144 make -C build-root PLATFORM=vpp AESNI=n TAG=%{_vpp_tag} install-packages
145%endif
Ole Troanc60f5572017-03-17 09:54:51 +0100146cd %{_mu_build_dir}/../src/vpp-api/python && %py2_build
147
Ed Warnickecb9cada2015-12-08 15:45:58 -0700148%install
149#
150# binaries
151#
152mkdir -p -m755 %{buildroot}%{_bindir}
153mkdir -p -m755 %{buildroot}%{_unitdir}
Gabriel Ganne714968b2017-01-26 15:42:39 +0100154install -p -m 755 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/bin/* %{buildroot}%{_bindir}
Ole Troanf14e3bf2016-12-01 21:49:03 +0100155
Damjan Marion7cd468a2016-12-19 23:05:39 +0100156# api
Ole Troanf14e3bf2016-12-01 21:49:03 +0100157mkdir -p -m755 %{buildroot}/usr/share/vpp/api
Ole Troanf14e3bf2016-12-01 21:49:03 +0100158
Ed Warnickecb9cada2015-12-08 15:45:58 -0700159#
160# configs
161#
162mkdir -p -m755 %{buildroot}/etc/vpp
Miroslav Miklus8e08e742016-10-11 13:35:26 +0200163mkdir -p -m755 %{buildroot}/etc/sysctl.d
Thomas F Herbert5b75b6b2017-07-23 17:21:46 -0400164install -p -m 644 %{_mu_build_dir}/../extras/rpm/vpp.service %{buildroot}%{_unitdir}
Damjan Mariond0f673e2017-01-31 17:29:33 +0100165install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/startup.conf %{buildroot}/etc/vpp/startup.conf
Damjan Marion7cd468a2016-12-19 23:05:39 +0100166install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d
Ed Warnickecb9cada2015-12-08 15:45:58 -0700167#
168# libraries
169#
170mkdir -p -m755 %{buildroot}%{_libdir}
Padraig Connolly69915cb2017-01-10 17:10:39 +0000171mkdir -p -m755 %{buildroot}/etc/bash_completion.d
172mkdir -p -m755 %{buildroot}/usr/share/vpp
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400173for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/*/lib* -type f -name '*.so.*.*.*' -print )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700174do
175 install -p -m 755 $file %{buildroot}%{_libdir}
176done
177for file in $(cd %{buildroot}%{_libdir} && find . -type f -print | sed -e 's/^\.\///')
178do
179 # make lib symlinks
180 ( cd %{buildroot}%{_libdir} &&
181 ln -fs $file $(echo $file | sed -e 's/\(\.so\.[0-9]\+\).*/\1/') )
Ed Warnickef5a0e732016-09-07 17:12:52 +0000182 ( cd %{buildroot}%{_libdir} &&
183 ln -fs $file $(echo $file | sed -e 's/\(\.so\)\.[0-9]\+.*/\1/') )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700184done
Damjan Marion7cd468a2016-12-19 23:05:39 +0100185for 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 +0100186do
187 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
188done
Padraig Connolly69915cb2017-01-10 17:10:39 +0000189install -p -m 644 %{_mu_build_dir}/../src/scripts/vppctl_completion %{buildroot}/etc/bash_completion.d
190install -p -m 644 %{_mu_build_dir}/../src/scripts/vppctl-cmd-list %{buildroot}/usr/share/vpp
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700191
Damjan Marioncb034b92016-12-28 18:38:59 +0100192# Lua bindings
193mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/lua/examples/cli
194mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/lua/examples/lute
Thomas F Herbertbd8e2422017-08-03 11:04:24 -0400195# for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua && git ls-files .)
196for 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 +0100197do
Thomas F Herbertbd8e2422017-08-03 11:04:24 -0400198 ( cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua && install -p -m 644 $file \
199 %{buildroot}/usr/share/doc/vpp/examples/lua/$file )
Damjan Marioncb034b92016-12-28 18:38:59 +0100200done
201
202# Java bindings
203mkdir -p -m755 %{buildroot}/usr/share/java
204for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/vpp/share/java -type f -name '*.jar' -print )
205do
206 install -p -m 644 $file %{buildroot}/usr/share/java
207done
208
Ole Troan57c3d662016-09-12 22:00:32 +0200209# Python bindings
Ole Troanc60f5572017-03-17 09:54:51 +0100210cd %{_mu_build_dir}/../src/vpp-api/python && %py2_install
Ole Troan57c3d662016-09-12 22:00:32 +0200211
Ed Warnickecb9cada2015-12-08 15:45:58 -0700212#
213# devel
214#
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400215for 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 -0700216do
217 for subdir in $(cd ${dir} && find . -type d -print)
218 do
219 mkdir -p -m755 %{buildroot}/usr/include/${subdir}
220 done
221 for file in $(cd ${dir} && find . -type f -print)
222 do
223 install -p -m 644 $dir/$file %{buildroot}%{_includedir}/$file
224 done
225done
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700226
227mkdir -p -m755 %{buildroot}%{python2_sitelib}/jvppgen
Damjan Marioncb034b92016-12-28 18:38:59 +0100228install -p -m755 %{_mu_build_dir}/../src/vpp-api/java/jvpp/gen/jvpp_gen.py %{buildroot}/usr/bin
229for i in $(ls %{_mu_build_dir}/../src/vpp-api/java/jvpp/gen/jvppgen/*.py); do
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700230 install -p -m666 ${i} %{buildroot}%{python2_sitelib}/jvppgen
231done;
232
Ed Warnickecb9cada2015-12-08 15:45:58 -0700233# sample plugin
234mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/sample
Thomas F Herbertbd8e2422017-08-03 11:04:24 -0400235#for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin && git ls-files .)
236for 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 -0700237do
Thomas F Herbertbd8e2422017-08-03 11:04:24 -0400238 ( cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin && install -p -m 644 $file \
239 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/$file )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700240done
241
Ed Warnickef5a14362016-09-12 20:40:24 +0000242
243#
244# vpp-plugins
245#
Ed Warnickee7637e72016-09-14 16:58:33 -0700246mkdir -p -m755 %{buildroot}/usr/lib/vpp_plugins
247mkdir -p -m755 %{buildroot}/usr/lib/vpp_api_test_plugins
Damjan Marion7cd468a2016-12-19 23:05:39 +0100248for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_plugins && find -type f -print)
249do
250 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_plugins/$file \
251 %{buildroot}/usr/lib/vpp_plugins/$file
252done
253
Damjan Marion7cd468a2016-12-19 23:05:39 +0100254for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_api_test_plugins && find -type f -print)
255do
256 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_api_test_plugins/$file \
257 %{buildroot}/usr/lib/vpp_api_test_plugins/$file
258done
259
Ole Troanf14e3bf2016-12-01 21:49:03 +0100260for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/plugins -type f -name '*.api.json' -print )
261do
262 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
263done
264
Damjan Mariona1bd0232016-12-19 19:08:11 +0100265#
266# remove RPATH from ELF binaries
267#
268%{_mu_build_dir}/scripts/remove-rpath %{buildroot}
269
Ed Warnickecb9cada2015-12-08 15:45:58 -0700270%post
Kristina Nevolnikova8ae18732017-06-21 14:20:42 +0200271if [ $1 -eq 1 ] ; then
272 sysctl --system
273fi
Ed Warnickecb9cada2015-12-08 15:45:58 -0700274%systemd_post vpp.service
275
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300276%preun
277%systemd_preun vpp.service
278
Ed Warnickecb9cada2015-12-08 15:45:58 -0700279%postun
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300280%systemd_postun
Kristina Nevolnikova8ae18732017-06-21 14:20:42 +0200281if [ $1 -eq 0 ] ; then
282 echo "Uninstalling, unbind user-mode PCI drivers"
283 # Unbind user-mode PCI drivers
284 removed=
285 pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci`
286 for d in $pci_dirs; do
287 for f in ${d}/*; do
288 [ -e "${f}/config" ] || continue
289 echo ${f##*/} > ${d}/unbind
290 basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}`
291 removed=y
292 done
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300293 done
Kristina Nevolnikova8ae18732017-06-21 14:20:42 +0200294 if [ -n "${removed}" ]; then
295 echo "There are changes in PCI drivers, rescaning"
296 echo 1 > /sys/bus/pci/rescan
297 else
298 echo "There weren't PCI devices binded"
299 fi
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300300else
Kristina Nevolnikova8ae18732017-06-21 14:20:42 +0200301 echo "Upgrading package, dont' unbind interfaces"
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300302fi
Ed Warnickecb9cada2015-12-08 15:45:58 -0700303
304%files
305%defattr(-,bin,bin)
306%{_unitdir}/vpp.service
Damjan Marion08ff7e02016-01-20 13:45:36 +0100307/usr/bin/vpp*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700308/usr/bin/svm*
Dave Barach0e5e3c32016-01-25 08:28:22 -0500309/usr/bin/elftool
Billy McFallce41a5c2017-09-08 20:11:58 +0000310%config(noreplace) /etc/sysctl.d/80-vpp.conf
311%config(noreplace) /etc/vpp/startup.conf
Ole Troanf14e3bf2016-12-01 21:49:03 +0100312/usr/share/vpp/api/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700313
314%files lib
315%defattr(-,bin,bin)
Ed Warnickef5a14362016-09-12 20:40:24 +0000316%exclude %{_libdir}/vpp_plugins
317%exclude %{_libdir}/vpp_api_test_plugins
Ed Warnickecb9cada2015-12-08 15:45:58 -0700318%{_libdir}/*
Ole Troanf14e3bf2016-12-01 21:49:03 +0100319/usr/share/vpp/api/*
Padraig Connolly69915cb2017-01-10 17:10:39 +0000320/etc/bash_completion.d/vppctl_completion
321/usr/share/vpp/vppctl-cmd-list
Ed Warnickecb9cada2015-12-08 15:45:58 -0700322
Damjan Marioncb034b92016-12-28 18:38:59 +0100323%files api-lua
Gabriel Gannef3854e92017-01-17 10:00:54 +0100324%defattr(644,root,root,644)
Damjan Marioncb034b92016-12-28 18:38:59 +0100325/usr/share/doc/vpp/examples/lua
326
327%files api-java
328%defattr(644,root,root)
329/usr/share/java/*
330
331%files api-python
Ole Troan57c3d662016-09-12 22:00:32 +0200332%defattr(644,root,root)
Ole Troanc60f5572017-03-17 09:54:51 +0100333%{python2_sitelib}/vpp_papi*
Ole Troan57c3d662016-09-12 22:00:32 +0200334
Ed Warnickecb9cada2015-12-08 15:45:58 -0700335%files devel
336%defattr(-,bin,bin)
337/usr/bin/vppapigen
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700338/usr/bin/jvpp_gen.py
Ed Warnickecb9cada2015-12-08 15:45:58 -0700339%{_includedir}/*
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700340%{python2_sitelib}/jvppgen/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700341/usr/share/doc/vpp/examples/sample-plugin
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700342
Ed Warnickef5a14362016-09-12 20:40:24 +0000343%files plugins
344%defattr(-,bin,bin)
Ed Warnickee7637e72016-09-14 16:58:33 -0700345/usr/lib/vpp_plugins/*
346/usr/lib/vpp_api_test_plugins/*
Ole Troanf14e3bf2016-12-01 21:49:03 +0100347/usr/share/vpp/api/*