blob: 532b9a219d4f0800b11ae5b6fd65cd90c33ee698 [file] [log] [blame]
Thomas F Herbert4b0ac822017-08-29 16:07:51 -04001%bcond_without aesni
Renato Botelho do Coutoe266ea32017-11-30 15:41:22 -06002%{!?_topdir:%define _topdir %(pwd)}
Thomas F Herbert20a29c72016-10-13 18:36:50 -04003%define _vpp_build_dir build-tool-native
Ed Warnickecb9cada2015-12-08 15:45:58 -07004%define _unitdir /lib/systemd/system
Ed Warnickecb9cada2015-12-08 15:45:58 -07005%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
Thomas F Herberte4128912017-10-09 15:03:55 -040035BuildRequires: subunit, subunit-devel
Thomas F Herbertbd8e2422017-08-03 11:04:24 -040036%if 0%{?fedora} >= 26
Thomas F Herbert440751b2017-09-11 08:58:23 -040037BuildRequires: compat-openssl10-devel
Thomas F Herbertbd8e2422017-08-03 11:04:24 -040038BuildRequires: python2-devel, python2-virtualenv
39%else
40%if 0%{?fedora} == 25
Thomas F Herbert440751b2017-09-11 08:58:23 -040041BuildRequires: openssl-devel
Thomas F Herbertbd8e2422017-08-03 11:04:24 -040042BuildRequires: python-devel, python2-virtualenv
43%else
Thomas F Herbert440751b2017-09-11 08:58:23 -040044BuildREquires: openssl-devel
Thomas F Herbertbd8e2422017-08-03 11:04:24 -040045BuildRequires: python-devel, python-virtualenv
46%endif
47%endif
Thomas F Herbert440751b2017-09-11 08:58:23 -040048BuildRequires: libffi-devel
Thomas F Herbertbd8e2422017-08-03 11:04:24 -040049BuildRequires: glibc-static, java-1.8.0-openjdk, java-1.8.0-openjdk-devel yum-utils, redhat-lsb
50BuildRequires: apr-devel
Thomas F Herbertbd8e2422017-08-03 11:04:24 -040051BuildRequires: numactl-devel
52BuildRequires: autoconf automake libtool byacc bison flex
Neale Ranns2ea2e422017-11-07 05:20:16 -080053BuildRequires: boost boost-devel
Ed Warnickecb9cada2015-12-08 15:45:58 -070054
Thomas F Herbertb60f4962017-07-19 19:17:15 -040055Source: %{name}-%{_version}-%{_release}.tar.xz
56# Source: vpp-latest.tar.xz
Thomas F Herbert20a29c72016-10-13 18:36:50 -040057
Ed Warnickecb9cada2015-12-08 15:45:58 -070058%description
Damjan Marion08ff7e02016-01-20 13:45:36 +010059This package provides VPP executables: vpp, vpp_api_test, vpp_json_test
60vpp - the vector packet engine
61vpp_api_test - vector packet engine API test tool
62vpp_json_test - vector packet engine JSON test tool
Ed Warnickecb9cada2015-12-08 15:45:58 -070063
64%package lib
65Summary: VPP libraries
66Group: System Environment/Libraries
67
68%description lib
69This package contains the VPP shared libraries, including:
70vppinfra - foundation library supporting vectors, hashes, bitmaps, pools, and string formatting.
Ed Warnickecb9cada2015-12-08 15:45:58 -070071svm - vm library
72vlib - vector processing library
73vlib-api - binary API library
74vnet - network stack library
75
76%package devel
77Summary: VPP header files, static libraries
78Group: Development/Libraries
79Requires: vpp-lib
80
81%description devel
Thomas F Herbert3977a212016-10-01 18:09:33 -040082This package contains the header files for VPP.
83Install this package if you want to write a
84program for compilation and linking with vpp lib.
85vlib
86vlibmemory
87vnet - devices, classify, dhcp, ethernet flow, gre, ip, etc.
88vpp-api
89vppinfra
Ed Warnickecb9cada2015-12-08 15:45:58 -070090
Ed Warnickef5a14362016-09-12 20:40:24 +000091%package plugins
92Summary: Vector Packet Processing--runtime plugins
93Group: System Environment/Libraries
Gabriel Gannebf246df2018-01-18 11:00:17 +010094Requires: vpp = %{_version}-%{_release} numactl-libs
Ed Warnickef5a14362016-09-12 20:40:24 +000095%description plugins
96This package contains VPP plugins
97
Damjan Marioncb034b92016-12-28 18:38:59 +010098%package api-lua
99Summary: VPP api lua bindings
100Group: Development/Libraries
101Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}
102
103%description api-lua
104This package contains the lua bindings for the vpp api
105
106%package api-java
107Summary: VPP api java bindings
108Group: Development/Libraries
109Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}
110
111%description api-java
112This package contains the java bindings for the vpp api
113
114%package api-python
Ole Troan57c3d662016-09-12 22:00:32 +0200115Summary: VPP api python bindings
116Group: Development/Libraries
Ole Troanc60f5572017-03-17 09:54:51 +0100117Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}, python-setuptools libffi-devel
Ole Troan57c3d662016-09-12 22:00:32 +0200118
Damjan Marioncb034b92016-12-28 18:38:59 +0100119%description api-python
Ole Troan57c3d662016-09-12 22:00:32 +0200120This package contains the python bindings for the vpp api
121
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400122%prep
Thomas F Herbert5349f942017-09-13 15:26:46 -0400123# Unpack into dir with longer name as work around of debugedit bug in in rpm-build 4.13
124rm -rf %{name}-%{_version}
Thomas F Herbert41988e52017-10-09 14:50:08 -0400125rm -rf %{_tmp_build_dir}
Thomas F Herbert5349f942017-09-13 15:26:46 -0400126/usr/bin/xz -dc '%{_sourcedir}/%{name}-%{_version}-%{_release}.tar.xz' | /usr/bin/tar -xf -
127mv %{name}-%{_version} %{_tmp_build_dir}
128cd '%{_tmp_build_dir}'
129/usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400130
Ed Warnickeec6290a2016-06-08 17:15:08 -0500131%pre
132# Add the vpp group
Ed Warnickeb10427e2016-06-08 19:49:40 -0500133groupadd -f -r vpp
Ed Warnickeec6290a2016-06-08 17:15:08 -0500134
Ole Troanc60f5572017-03-17 09:54:51 +0100135%build
Thomas F Herbert5349f942017-09-13 15:26:46 -0400136cd '%{_tmp_build_dir}'
Thomas F Herbert4b0ac822017-08-29 16:07:51 -0400137%if %{with aesni}
138 make bootstrap
139 make -C build-root PLATFORM=vpp TAG=%{_vpp_tag} install-packages
140%else
141 make bootstrap AESNI=n
142 make -C build-root PLATFORM=vpp AESNI=n TAG=%{_vpp_tag} install-packages
143%endif
Ole Troanc60f5572017-03-17 09:54:51 +0100144cd %{_mu_build_dir}/../src/vpp-api/python && %py2_build
145
Ed Warnickecb9cada2015-12-08 15:45:58 -0700146%install
147#
148# binaries
149#
150mkdir -p -m755 %{buildroot}%{_bindir}
151mkdir -p -m755 %{buildroot}%{_unitdir}
Gabriel Ganne714968b2017-01-26 15:42:39 +0100152install -p -m 755 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/bin/* %{buildroot}%{_bindir}
Ole Troanf14e3bf2016-12-01 21:49:03 +0100153
Damjan Marion7cd468a2016-12-19 23:05:39 +0100154# api
Ole Troanf14e3bf2016-12-01 21:49:03 +0100155mkdir -p -m755 %{buildroot}/usr/share/vpp/api
Ole Troanf14e3bf2016-12-01 21:49:03 +0100156
Ed Warnickecb9cada2015-12-08 15:45:58 -0700157#
158# configs
159#
160mkdir -p -m755 %{buildroot}/etc/vpp
Miroslav Miklus8e08e742016-10-11 13:35:26 +0200161mkdir -p -m755 %{buildroot}/etc/sysctl.d
Thomas F Herbert5b75b6b2017-07-23 17:21:46 -0400162install -p -m 644 %{_mu_build_dir}/../extras/rpm/vpp.service %{buildroot}%{_unitdir}
Damjan Mariond0f673e2017-01-31 17:29:33 +0100163install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/startup.conf %{buildroot}/etc/vpp/startup.conf
Damjan Marion7cd468a2016-12-19 23:05:39 +0100164install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d
Ed Warnickecb9cada2015-12-08 15:45:58 -0700165#
166# libraries
167#
168mkdir -p -m755 %{buildroot}%{_libdir}
Padraig Connolly69915cb2017-01-10 17:10:39 +0000169mkdir -p -m755 %{buildroot}/etc/bash_completion.d
170mkdir -p -m755 %{buildroot}/usr/share/vpp
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400171for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/*/lib* -type f -name '*.so.*.*.*' -print )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700172do
173 install -p -m 755 $file %{buildroot}%{_libdir}
174done
175for file in $(cd %{buildroot}%{_libdir} && find . -type f -print | sed -e 's/^\.\///')
176do
177 # make lib symlinks
178 ( cd %{buildroot}%{_libdir} &&
179 ln -fs $file $(echo $file | sed -e 's/\(\.so\.[0-9]\+\).*/\1/') )
Ed Warnickef5a0e732016-09-07 17:12:52 +0000180 ( cd %{buildroot}%{_libdir} &&
181 ln -fs $file $(echo $file | sed -e 's/\(\.so\)\.[0-9]\+.*/\1/') )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700182done
Damjan Marion7cd468a2016-12-19 23:05:39 +0100183for 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 +0100184do
185 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
186done
Padraig Connolly69915cb2017-01-10 17:10:39 +0000187install -p -m 644 %{_mu_build_dir}/../src/scripts/vppctl_completion %{buildroot}/etc/bash_completion.d
188install -p -m 644 %{_mu_build_dir}/../src/scripts/vppctl-cmd-list %{buildroot}/usr/share/vpp
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700189
Damjan Marioncb034b92016-12-28 18:38:59 +0100190# Lua bindings
191mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/lua/examples/cli
192mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/lua/examples/lute
Thomas F Herbertbd8e2422017-08-03 11:04:24 -0400193# for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua && git ls-files .)
194for 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 +0100195do
Thomas F Herbertbd8e2422017-08-03 11:04:24 -0400196 ( cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua && install -p -m 644 $file \
197 %{buildroot}/usr/share/doc/vpp/examples/lua/$file )
Damjan Marioncb034b92016-12-28 18:38:59 +0100198done
199
200# Java bindings
201mkdir -p -m755 %{buildroot}/usr/share/java
202for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/vpp/share/java -type f -name '*.jar' -print )
203do
204 install -p -m 644 $file %{buildroot}/usr/share/java
205done
206
Ole Troan57c3d662016-09-12 22:00:32 +0200207# Python bindings
Ole Troanc60f5572017-03-17 09:54:51 +0100208cd %{_mu_build_dir}/../src/vpp-api/python && %py2_install
Ole Troan57c3d662016-09-12 22:00:32 +0200209
Ed Warnickecb9cada2015-12-08 15:45:58 -0700210#
211# devel
212#
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400213for 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 -0700214do
215 for subdir in $(cd ${dir} && find . -type d -print)
216 do
217 mkdir -p -m755 %{buildroot}/usr/include/${subdir}
218 done
219 for file in $(cd ${dir} && find . -type f -print)
220 do
221 install -p -m 644 $dir/$file %{buildroot}%{_includedir}/$file
222 done
223done
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700224
225mkdir -p -m755 %{buildroot}%{python2_sitelib}/jvppgen
Damjan Marioncb034b92016-12-28 18:38:59 +0100226install -p -m755 %{_mu_build_dir}/../src/vpp-api/java/jvpp/gen/jvpp_gen.py %{buildroot}/usr/bin
227for i in $(ls %{_mu_build_dir}/../src/vpp-api/java/jvpp/gen/jvppgen/*.py); do
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700228 install -p -m666 ${i} %{buildroot}%{python2_sitelib}/jvppgen
229done;
230
Ed Warnickecb9cada2015-12-08 15:45:58 -0700231# sample plugin
232mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/sample
Thomas F Herbertbd8e2422017-08-03 11:04:24 -0400233#for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin && git ls-files .)
234for 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 -0700235do
Thomas F Herbertbd8e2422017-08-03 11:04:24 -0400236 ( cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin && install -p -m 644 $file \
237 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/$file )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700238done
239
Ed Warnickef5a14362016-09-12 20:40:24 +0000240
241#
242# vpp-plugins
243#
Ed Warnickee7637e72016-09-14 16:58:33 -0700244mkdir -p -m755 %{buildroot}/usr/lib/vpp_plugins
245mkdir -p -m755 %{buildroot}/usr/lib/vpp_api_test_plugins
Damjan Marion7cd468a2016-12-19 23:05:39 +0100246for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_plugins && find -type f -print)
247do
248 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_plugins/$file \
249 %{buildroot}/usr/lib/vpp_plugins/$file
250done
251
Damjan Marion7cd468a2016-12-19 23:05:39 +0100252for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_api_test_plugins && find -type f -print)
253do
254 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_api_test_plugins/$file \
255 %{buildroot}/usr/lib/vpp_api_test_plugins/$file
256done
257
Ole Troanf14e3bf2016-12-01 21:49:03 +0100258for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/plugins -type f -name '*.api.json' -print )
259do
260 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
261done
262
Damjan Mariona1bd0232016-12-19 19:08:11 +0100263#
264# remove RPATH from ELF binaries
265#
266%{_mu_build_dir}/scripts/remove-rpath %{buildroot}
267
Ed Warnickecb9cada2015-12-08 15:45:58 -0700268%post
Kristina Nevolnikova8ae18732017-06-21 14:20:42 +0200269if [ $1 -eq 1 ] ; then
270 sysctl --system
271fi
Ed Warnickecb9cada2015-12-08 15:45:58 -0700272%systemd_post vpp.service
273
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300274%preun
275%systemd_preun vpp.service
276
Ed Warnickecb9cada2015-12-08 15:45:58 -0700277%postun
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300278%systemd_postun
Kristina Nevolnikova8ae18732017-06-21 14:20:42 +0200279if [ $1 -eq 0 ] ; then
280 echo "Uninstalling, unbind user-mode PCI drivers"
281 # Unbind user-mode PCI drivers
282 removed=
283 pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci`
284 for d in $pci_dirs; do
285 for f in ${d}/*; do
286 [ -e "${f}/config" ] || continue
287 echo ${f##*/} > ${d}/unbind
288 basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}`
289 removed=y
290 done
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300291 done
Kristina Nevolnikova8ae18732017-06-21 14:20:42 +0200292 if [ -n "${removed}" ]; then
293 echo "There are changes in PCI drivers, rescaning"
294 echo 1 > /sys/bus/pci/rescan
295 else
296 echo "There weren't PCI devices binded"
297 fi
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300298else
Kristina Nevolnikova8ae18732017-06-21 14:20:42 +0200299 echo "Upgrading package, dont' unbind interfaces"
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300300fi
Ed Warnickecb9cada2015-12-08 15:45:58 -0700301
302%files
303%defattr(-,bin,bin)
304%{_unitdir}/vpp.service
Damjan Marion08ff7e02016-01-20 13:45:36 +0100305/usr/bin/vpp*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700306/usr/bin/svm*
Dave Barach0e5e3c32016-01-25 08:28:22 -0500307/usr/bin/elftool
Billy McFallce41a5c2017-09-08 20:11:58 +0000308%config(noreplace) /etc/sysctl.d/80-vpp.conf
309%config(noreplace) /etc/vpp/startup.conf
Ole Troanf14e3bf2016-12-01 21:49:03 +0100310/usr/share/vpp/api/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700311
312%files lib
313%defattr(-,bin,bin)
Ed Warnickef5a14362016-09-12 20:40:24 +0000314%exclude %{_libdir}/vpp_plugins
315%exclude %{_libdir}/vpp_api_test_plugins
Ed Warnickecb9cada2015-12-08 15:45:58 -0700316%{_libdir}/*
Ole Troanf14e3bf2016-12-01 21:49:03 +0100317/usr/share/vpp/api/*
Padraig Connolly69915cb2017-01-10 17:10:39 +0000318/etc/bash_completion.d/vppctl_completion
319/usr/share/vpp/vppctl-cmd-list
Ed Warnickecb9cada2015-12-08 15:45:58 -0700320
Damjan Marioncb034b92016-12-28 18:38:59 +0100321%files api-lua
Gabriel Gannef3854e92017-01-17 10:00:54 +0100322%defattr(644,root,root,644)
Damjan Marioncb034b92016-12-28 18:38:59 +0100323/usr/share/doc/vpp/examples/lua
324
325%files api-java
326%defattr(644,root,root)
327/usr/share/java/*
328
329%files api-python
Ole Troan57c3d662016-09-12 22:00:32 +0200330%defattr(644,root,root)
Ole Troanc60f5572017-03-17 09:54:51 +0100331%{python2_sitelib}/vpp_papi*
Ole Troan57c3d662016-09-12 22:00:32 +0200332
Ed Warnickecb9cada2015-12-08 15:45:58 -0700333%files devel
334%defattr(-,bin,bin)
335/usr/bin/vppapigen
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700336/usr/bin/jvpp_gen.py
Ed Warnickecb9cada2015-12-08 15:45:58 -0700337%{_includedir}/*
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700338%{python2_sitelib}/jvppgen/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700339/usr/share/doc/vpp/examples/sample-plugin
Ole Troan9d420872017-10-12 13:06:35 +0200340/usr/share/vpp
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/*