blob: 7490a165b3778bbaba39bf3c57807cc7eb1e0ef4 [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 Herbert4b0ac822017-08-29 16:07:51 -040053%if %{with aesni}
Thomas F Herbertbd8e2422017-08-03 11:04:24 -040054BuildRequires: nasm
Thomas F Herbert4b0ac822017-08-29 16:07:51 -040055%endif
Thomas F Herbertbd8e2422017-08-03 11:04:24 -040056BuildRequires: numactl-devel
57BuildRequires: autoconf automake libtool byacc bison flex
Ed Warnickecb9cada2015-12-08 15:45:58 -070058
Thomas F Herbertb60f4962017-07-19 19:17:15 -040059Source: %{name}-%{_version}-%{_release}.tar.xz
60# Source: vpp-latest.tar.xz
Thomas F Herbert20a29c72016-10-13 18:36:50 -040061
Ed Warnickecb9cada2015-12-08 15:45:58 -070062%description
Damjan Marion08ff7e02016-01-20 13:45:36 +010063This package provides VPP executables: vpp, vpp_api_test, vpp_json_test
64vpp - the vector packet engine
65vpp_api_test - vector packet engine API test tool
66vpp_json_test - vector packet engine JSON test tool
Ed Warnickecb9cada2015-12-08 15:45:58 -070067
68%package lib
69Summary: VPP libraries
70Group: System Environment/Libraries
71
72%description lib
73This package contains the VPP shared libraries, including:
74vppinfra - foundation library supporting vectors, hashes, bitmaps, pools, and string formatting.
Ed Warnickecb9cada2015-12-08 15:45:58 -070075svm - vm library
76vlib - vector processing library
77vlib-api - binary API library
78vnet - network stack library
79
80%package devel
81Summary: VPP header files, static libraries
82Group: Development/Libraries
83Requires: vpp-lib
84
85%description devel
Thomas F Herbert3977a212016-10-01 18:09:33 -040086This package contains the header files for VPP.
87Install this package if you want to write a
88program for compilation and linking with vpp lib.
89vlib
90vlibmemory
91vnet - devices, classify, dhcp, ethernet flow, gre, ip, etc.
92vpp-api
93vppinfra
Ed Warnickecb9cada2015-12-08 15:45:58 -070094
Ed Warnickef5a14362016-09-12 20:40:24 +000095%package plugins
96Summary: Vector Packet Processing--runtime plugins
97Group: System Environment/Libraries
98Requires: vpp = %{_version}-%{_release}
99%description plugins
100This package contains VPP plugins
101
Damjan Marioncb034b92016-12-28 18:38:59 +0100102%package api-lua
103Summary: VPP api lua bindings
104Group: Development/Libraries
105Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}
106
107%description api-lua
108This package contains the lua bindings for the vpp api
109
110%package api-java
111Summary: VPP api java bindings
112Group: Development/Libraries
113Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}
114
115%description api-java
116This package contains the java bindings for the vpp api
117
118%package api-python
Ole Troan57c3d662016-09-12 22:00:32 +0200119Summary: VPP api python bindings
120Group: Development/Libraries
Ole Troanc60f5572017-03-17 09:54:51 +0100121Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}, python-setuptools libffi-devel
Ole Troan57c3d662016-09-12 22:00:32 +0200122
Damjan Marioncb034b92016-12-28 18:38:59 +0100123%description api-python
Ole Troan57c3d662016-09-12 22:00:32 +0200124This package contains the python bindings for the vpp api
125
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400126%prep
Thomas F Herbert5349f942017-09-13 15:26:46 -0400127# Unpack into dir with longer name as work around of debugedit bug in in rpm-build 4.13
128rm -rf %{name}-%{_version}
Thomas F Herbert41988e52017-10-09 14:50:08 -0400129rm -rf %{_tmp_build_dir}
Thomas F Herbert5349f942017-09-13 15:26:46 -0400130/usr/bin/xz -dc '%{_sourcedir}/%{name}-%{_version}-%{_release}.tar.xz' | /usr/bin/tar -xf -
131mv %{name}-%{_version} %{_tmp_build_dir}
132cd '%{_tmp_build_dir}'
133/usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400134
Ed Warnickeec6290a2016-06-08 17:15:08 -0500135%pre
136# Add the vpp group
Ed Warnickeb10427e2016-06-08 19:49:40 -0500137groupadd -f -r vpp
Ed Warnickeec6290a2016-06-08 17:15:08 -0500138
Ole Troanc60f5572017-03-17 09:54:51 +0100139%build
Thomas F Herbert5349f942017-09-13 15:26:46 -0400140cd '%{_tmp_build_dir}'
Thomas F Herbert4b0ac822017-08-29 16:07:51 -0400141%if %{with aesni}
142 make bootstrap
143 make -C build-root PLATFORM=vpp TAG=%{_vpp_tag} install-packages
144%else
145 make bootstrap AESNI=n
146 make -C build-root PLATFORM=vpp AESNI=n TAG=%{_vpp_tag} install-packages
147%endif
Ole Troanc60f5572017-03-17 09:54:51 +0100148cd %{_mu_build_dir}/../src/vpp-api/python && %py2_build
149
Ed Warnickecb9cada2015-12-08 15:45:58 -0700150%install
151#
152# binaries
153#
154mkdir -p -m755 %{buildroot}%{_bindir}
155mkdir -p -m755 %{buildroot}%{_unitdir}
Gabriel Ganne714968b2017-01-26 15:42:39 +0100156install -p -m 755 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/bin/* %{buildroot}%{_bindir}
Ole Troanf14e3bf2016-12-01 21:49:03 +0100157
Damjan Marion7cd468a2016-12-19 23:05:39 +0100158# api
Ole Troanf14e3bf2016-12-01 21:49:03 +0100159mkdir -p -m755 %{buildroot}/usr/share/vpp/api
Ole Troanf14e3bf2016-12-01 21:49:03 +0100160
Ed Warnickecb9cada2015-12-08 15:45:58 -0700161#
162# configs
163#
164mkdir -p -m755 %{buildroot}/etc/vpp
Miroslav Miklus8e08e742016-10-11 13:35:26 +0200165mkdir -p -m755 %{buildroot}/etc/sysctl.d
Thomas F Herbert5b75b6b2017-07-23 17:21:46 -0400166install -p -m 644 %{_mu_build_dir}/../extras/rpm/vpp.service %{buildroot}%{_unitdir}
Damjan Mariond0f673e2017-01-31 17:29:33 +0100167install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/startup.conf %{buildroot}/etc/vpp/startup.conf
Damjan Marion7cd468a2016-12-19 23:05:39 +0100168install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d
Ed Warnickecb9cada2015-12-08 15:45:58 -0700169#
170# libraries
171#
172mkdir -p -m755 %{buildroot}%{_libdir}
Padraig Connolly69915cb2017-01-10 17:10:39 +0000173mkdir -p -m755 %{buildroot}/etc/bash_completion.d
174mkdir -p -m755 %{buildroot}/usr/share/vpp
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400175for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/*/lib* -type f -name '*.so.*.*.*' -print )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700176do
177 install -p -m 755 $file %{buildroot}%{_libdir}
178done
179for file in $(cd %{buildroot}%{_libdir} && find . -type f -print | sed -e 's/^\.\///')
180do
181 # make lib symlinks
182 ( cd %{buildroot}%{_libdir} &&
183 ln -fs $file $(echo $file | sed -e 's/\(\.so\.[0-9]\+\).*/\1/') )
Ed Warnickef5a0e732016-09-07 17:12:52 +0000184 ( cd %{buildroot}%{_libdir} &&
185 ln -fs $file $(echo $file | sed -e 's/\(\.so\)\.[0-9]\+.*/\1/') )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700186done
Damjan Marion7cd468a2016-12-19 23:05:39 +0100187for 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 +0100188do
189 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
190done
Padraig Connolly69915cb2017-01-10 17:10:39 +0000191install -p -m 644 %{_mu_build_dir}/../src/scripts/vppctl_completion %{buildroot}/etc/bash_completion.d
192install -p -m 644 %{_mu_build_dir}/../src/scripts/vppctl-cmd-list %{buildroot}/usr/share/vpp
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700193
Damjan Marioncb034b92016-12-28 18:38:59 +0100194# Lua bindings
195mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/lua/examples/cli
196mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/lua/examples/lute
Thomas F Herbertbd8e2422017-08-03 11:04:24 -0400197# for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua && git ls-files .)
198for 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 +0100199do
Thomas F Herbertbd8e2422017-08-03 11:04:24 -0400200 ( cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua && install -p -m 644 $file \
201 %{buildroot}/usr/share/doc/vpp/examples/lua/$file )
Damjan Marioncb034b92016-12-28 18:38:59 +0100202done
203
204# Java bindings
205mkdir -p -m755 %{buildroot}/usr/share/java
206for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/vpp/share/java -type f -name '*.jar' -print )
207do
208 install -p -m 644 $file %{buildroot}/usr/share/java
209done
210
Ole Troan57c3d662016-09-12 22:00:32 +0200211# Python bindings
Ole Troanc60f5572017-03-17 09:54:51 +0100212cd %{_mu_build_dir}/../src/vpp-api/python && %py2_install
Ole Troan57c3d662016-09-12 22:00:32 +0200213
Ed Warnickecb9cada2015-12-08 15:45:58 -0700214#
215# devel
216#
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400217for 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 -0700218do
219 for subdir in $(cd ${dir} && find . -type d -print)
220 do
221 mkdir -p -m755 %{buildroot}/usr/include/${subdir}
222 done
223 for file in $(cd ${dir} && find . -type f -print)
224 do
225 install -p -m 644 $dir/$file %{buildroot}%{_includedir}/$file
226 done
227done
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700228
229mkdir -p -m755 %{buildroot}%{python2_sitelib}/jvppgen
Damjan Marioncb034b92016-12-28 18:38:59 +0100230install -p -m755 %{_mu_build_dir}/../src/vpp-api/java/jvpp/gen/jvpp_gen.py %{buildroot}/usr/bin
231for i in $(ls %{_mu_build_dir}/../src/vpp-api/java/jvpp/gen/jvppgen/*.py); do
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700232 install -p -m666 ${i} %{buildroot}%{python2_sitelib}/jvppgen
233done;
234
Ed Warnickecb9cada2015-12-08 15:45:58 -0700235# sample plugin
236mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/sample
Thomas F Herbertbd8e2422017-08-03 11:04:24 -0400237#for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin && git ls-files .)
238for 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 -0700239do
Thomas F Herbertbd8e2422017-08-03 11:04:24 -0400240 ( cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin && install -p -m 644 $file \
241 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/$file )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700242done
243
Ed Warnickef5a14362016-09-12 20:40:24 +0000244
245#
246# vpp-plugins
247#
Ed Warnickee7637e72016-09-14 16:58:33 -0700248mkdir -p -m755 %{buildroot}/usr/lib/vpp_plugins
249mkdir -p -m755 %{buildroot}/usr/lib/vpp_api_test_plugins
Damjan Marion7cd468a2016-12-19 23:05:39 +0100250for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_plugins && find -type f -print)
251do
252 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_plugins/$file \
253 %{buildroot}/usr/lib/vpp_plugins/$file
254done
255
Damjan Marion7cd468a2016-12-19 23:05:39 +0100256for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_api_test_plugins && find -type f -print)
257do
258 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_api_test_plugins/$file \
259 %{buildroot}/usr/lib/vpp_api_test_plugins/$file
260done
261
Ole Troanf14e3bf2016-12-01 21:49:03 +0100262for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/plugins -type f -name '*.api.json' -print )
263do
264 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
265done
266
Damjan Mariona1bd0232016-12-19 19:08:11 +0100267#
268# remove RPATH from ELF binaries
269#
270%{_mu_build_dir}/scripts/remove-rpath %{buildroot}
271
Ed Warnickecb9cada2015-12-08 15:45:58 -0700272%post
Kristina Nevolnikova8ae18732017-06-21 14:20:42 +0200273if [ $1 -eq 1 ] ; then
274 sysctl --system
275fi
Ed Warnickecb9cada2015-12-08 15:45:58 -0700276%systemd_post vpp.service
277
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300278%preun
279%systemd_preun vpp.service
280
Ed Warnickecb9cada2015-12-08 15:45:58 -0700281%postun
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300282%systemd_postun
Kristina Nevolnikova8ae18732017-06-21 14:20:42 +0200283if [ $1 -eq 0 ] ; then
284 echo "Uninstalling, unbind user-mode PCI drivers"
285 # Unbind user-mode PCI drivers
286 removed=
287 pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci`
288 for d in $pci_dirs; do
289 for f in ${d}/*; do
290 [ -e "${f}/config" ] || continue
291 echo ${f##*/} > ${d}/unbind
292 basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}`
293 removed=y
294 done
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300295 done
Kristina Nevolnikova8ae18732017-06-21 14:20:42 +0200296 if [ -n "${removed}" ]; then
297 echo "There are changes in PCI drivers, rescaning"
298 echo 1 > /sys/bus/pci/rescan
299 else
300 echo "There weren't PCI devices binded"
301 fi
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300302else
Kristina Nevolnikova8ae18732017-06-21 14:20:42 +0200303 echo "Upgrading package, dont' unbind interfaces"
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300304fi
Ed Warnickecb9cada2015-12-08 15:45:58 -0700305
306%files
307%defattr(-,bin,bin)
308%{_unitdir}/vpp.service
Damjan Marion08ff7e02016-01-20 13:45:36 +0100309/usr/bin/vpp*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700310/usr/bin/svm*
Dave Barach0e5e3c32016-01-25 08:28:22 -0500311/usr/bin/elftool
Billy McFallce41a5c2017-09-08 20:11:58 +0000312%config(noreplace) /etc/sysctl.d/80-vpp.conf
313%config(noreplace) /etc/vpp/startup.conf
Ole Troanf14e3bf2016-12-01 21:49:03 +0100314/usr/share/vpp/api/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700315
316%files lib
317%defattr(-,bin,bin)
Ed Warnickef5a14362016-09-12 20:40:24 +0000318%exclude %{_libdir}/vpp_plugins
319%exclude %{_libdir}/vpp_api_test_plugins
Ed Warnickecb9cada2015-12-08 15:45:58 -0700320%{_libdir}/*
Ole Troanf14e3bf2016-12-01 21:49:03 +0100321/usr/share/vpp/api/*
Padraig Connolly69915cb2017-01-10 17:10:39 +0000322/etc/bash_completion.d/vppctl_completion
323/usr/share/vpp/vppctl-cmd-list
Ed Warnickecb9cada2015-12-08 15:45:58 -0700324
Damjan Marioncb034b92016-12-28 18:38:59 +0100325%files api-lua
Gabriel Gannef3854e92017-01-17 10:00:54 +0100326%defattr(644,root,root,644)
Damjan Marioncb034b92016-12-28 18:38:59 +0100327/usr/share/doc/vpp/examples/lua
328
329%files api-java
330%defattr(644,root,root)
331/usr/share/java/*
332
333%files api-python
Ole Troan57c3d662016-09-12 22:00:32 +0200334%defattr(644,root,root)
Ole Troanc60f5572017-03-17 09:54:51 +0100335%{python2_sitelib}/vpp_papi*
Ole Troan57c3d662016-09-12 22:00:32 +0200336
Ed Warnickecb9cada2015-12-08 15:45:58 -0700337%files devel
338%defattr(-,bin,bin)
339/usr/bin/vppapigen
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700340/usr/bin/jvpp_gen.py
Ed Warnickecb9cada2015-12-08 15:45:58 -0700341%{_includedir}/*
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700342%{python2_sitelib}/jvppgen/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700343/usr/share/doc/vpp/examples/sample-plugin
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700344
Ed Warnickef5a14362016-09-12 20:40:24 +0000345%files plugins
346%defattr(-,bin,bin)
Ed Warnickee7637e72016-09-14 16:58:33 -0700347/usr/lib/vpp_plugins/*
348/usr/lib/vpp_api_test_plugins/*
Ole Troanf14e3bf2016-12-01 21:49:03 +0100349/usr/share/vpp/api/*