blob: 5db0c4bd7c1b1f8d9d49ed03aa2ca1fa23271347 [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
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +030029BuildRequires: systemd
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
Ole Troan57c3d662016-09-12 22:00:32 +020074%package python-api
75Summary: VPP api python bindings
76Group: Development/Libraries
John DeNiscof53f4822016-09-30 08:33:40 -040077Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}
Ole Troan57c3d662016-09-12 22:00:32 +020078
79%description python-api
80This package contains the python bindings for the vpp api
81
Thomas F Herbert20a29c72016-10-13 18:36:50 -040082%prep
83%setup -q -n %{name}-%{_version}
84
85%build
86make bootstrap
87make build-release
88
Ed Warnickeec6290a2016-06-08 17:15:08 -050089%pre
90# Add the vpp group
Ed Warnickeb10427e2016-06-08 19:49:40 -050091groupadd -f -r vpp
Ed Warnickeec6290a2016-06-08 17:15:08 -050092
Ed Warnickecb9cada2015-12-08 15:45:58 -070093%install
94#
95# binaries
96#
97mkdir -p -m755 %{buildroot}%{_bindir}
98mkdir -p -m755 %{buildroot}%{_unitdir}
Thomas F Herbert20a29c72016-10-13 18:36:50 -040099install -p -m 755 %{_mu_build_dir}/%{_vpp_install_dir}/*/bin/* %{buildroot}%{_bindir}
100install -p -m 755 %{_mu_build_dir}/%{_vpp_build_dir}/vppapigen/vppapigen %{buildroot}%{_bindir}
Ole Troanf14e3bf2016-12-01 21:49:03 +0100101
102# core api
103mkdir -p -m755 %{buildroot}/usr/share/vpp/api
104install -p -m 755 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/vpp-api/vpe.api.json %{buildroot}/usr/share/vpp/api
105install -p -m 755 %{_mu_build_dir}/%{_vpp_install_dir}/vlib-api/vlibmemory/memclnt.api.json %{buildroot}/usr/share/vpp/api
106
Ed Warnickecb9cada2015-12-08 15:45:58 -0700107#
108# configs
109#
110mkdir -p -m755 %{buildroot}/etc/vpp
Miroslav Miklus8e08e742016-10-11 13:35:26 +0200111mkdir -p -m755 %{buildroot}/etc/sysctl.d
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400112install -p -m 644 %{_mu_build_dir}/rpm/vpp.service %{buildroot}%{_unitdir}
113install -p -m 644 %{_mu_build_dir}/../vpp/conf/startup.uiopcigeneric.conf %{buildroot}/etc/vpp/startup.conf
114install -p -m 644 %{_mu_build_dir}/../vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d
Ed Warnickecb9cada2015-12-08 15:45:58 -0700115#
116# libraries
117#
118mkdir -p -m755 %{buildroot}%{_libdir}
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400119for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/*/lib* -type f -name '*.so.*.*.*' -print )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700120do
121 install -p -m 755 $file %{buildroot}%{_libdir}
122done
123for file in $(cd %{buildroot}%{_libdir} && find . -type f -print | sed -e 's/^\.\///')
124do
125 # make lib symlinks
126 ( cd %{buildroot}%{_libdir} &&
127 ln -fs $file $(echo $file | sed -e 's/\(\.so\.[0-9]\+\).*/\1/') )
Ed Warnickef5a0e732016-09-07 17:12:52 +0000128 ( cd %{buildroot}%{_libdir} &&
129 ln -fs $file $(echo $file | sed -e 's/\(\.so\)\.[0-9]\+.*/\1/') )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700130done
Ole Troanf14e3bf2016-12-01 21:49:03 +0100131for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/vnet -type f -name '*.api.json' -print )
132do
133 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
134done
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700135
Ole Troan57c3d662016-09-12 22:00:32 +0200136# Python bindings
137mkdir -p -m755 %{buildroot}%{python2_sitelib}/vpp_papi
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400138for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/*/lib/python2.7/site-packages/ -type f -print | grep -v pyc | grep -v pyo)
Ole Troan57c3d662016-09-12 22:00:32 +0200139do
140 install -p -m 666 $file %{buildroot}%{python2_sitelib}/vpp_papi/
141done
142
Ed Warnickecb9cada2015-12-08 15:45:58 -0700143#
144# devel
145#
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400146for 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 -0700147do
148 for subdir in $(cd ${dir} && find . -type d -print)
149 do
150 mkdir -p -m755 %{buildroot}/usr/include/${subdir}
151 done
152 for file in $(cd ${dir} && find . -type f -print)
153 do
154 install -p -m 644 $dir/$file %{buildroot}%{_includedir}/$file
155 done
156done
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700157
158mkdir -p -m755 %{buildroot}%{python2_sitelib}/jvppgen
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400159install -p -m755 %{_mu_build_dir}/../vpp-api/java/jvpp/gen/jvpp_gen.py %{buildroot}/usr/bin
160for i in $(ls %{_mu_build_dir}/../vpp-api/java/jvpp/gen/jvppgen/*.py); do
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700161 install -p -m666 ${i} %{buildroot}%{python2_sitelib}/jvppgen
162done;
163
Ed Warnickecb9cada2015-12-08 15:45:58 -0700164# sample plugin
165mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/sample
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400166for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../sample-plugin && find -type f -print)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700167do
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400168 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/../../sample-plugin/$file \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700169 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/$file
170done
171
Ed Warnickef5a14362016-09-12 20:40:24 +0000172
173#
174# vpp-plugins
175#
Ed Warnickee7637e72016-09-14 16:58:33 -0700176mkdir -p -m755 %{buildroot}/usr/lib/vpp_plugins
177mkdir -p -m755 %{buildroot}/usr/lib/vpp_api_test_plugins
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400178for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/plugins/lib64/vpp_plugins && find -type f -print)
Ed Warnickef5a14362016-09-12 20:40:24 +0000179do
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400180 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/plugins/lib64/vpp_plugins/$file \
Ed Warnickee7637e72016-09-14 16:58:33 -0700181 %{buildroot}/usr/lib/vpp_plugins/$file
Ed Warnickef5a14362016-09-12 20:40:24 +0000182done
183
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400184for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/plugins/lib64/vpp_api_test_plugins && find -type f -print)
Ed Warnickef5a14362016-09-12 20:40:24 +0000185do
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400186 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/plugins/lib64/vpp_api_test_plugins/$file \
Ed Warnickee7637e72016-09-14 16:58:33 -0700187 %{buildroot}/usr/lib/vpp_api_test_plugins/$file
Ed Warnickef5a14362016-09-12 20:40:24 +0000188done
189
Ole Troanf14e3bf2016-12-01 21:49:03 +0100190for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/plugins -type f -name '*.api.json' -print )
191do
192 install -p -m 644 $file %{buildroot}/usr/share/vpp/api
193done
194
Ed Warnickecb9cada2015-12-08 15:45:58 -0700195%post
196sysctl --system
197%systemd_post vpp.service
198
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300199%preun
200%systemd_preun vpp.service
201
Ed Warnickecb9cada2015-12-08 15:45:58 -0700202%postun
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300203%systemd_postun
204
205# Unbind user-mode PCI drivers
206removed=
207pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci`
208for d in $pci_dirs; do
209 for f in ${d}/*; do
210 [ -e "${f}/config" ] || continue
211 echo 1 > ${f}/remove
212 basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}`
213 removed=y
214 done
215done
216if [ -n "${removed}" ]; then
217 echo "There are changes in PCI drivers, rescaning"
218 echo 1 > /sys/bus/pci/rescan
219else
220 echo "There weren't PCI devices binded"
221fi
Ed Warnickecb9cada2015-12-08 15:45:58 -0700222
223%files
224%defattr(-,bin,bin)
225%{_unitdir}/vpp.service
Damjan Marion08ff7e02016-01-20 13:45:36 +0100226/usr/bin/vpp*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700227/usr/bin/svm*
Dave Barach0e5e3c32016-01-25 08:28:22 -0500228/usr/bin/elftool
Miroslav Miklus8e08e742016-10-11 13:35:26 +0200229%config /etc/sysctl.d/80-vpp.conf
Ed Warnickecb9cada2015-12-08 15:45:58 -0700230%config /etc/vpp/startup.conf
Ole Troanf14e3bf2016-12-01 21:49:03 +0100231/usr/share/vpp/api/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700232
233%files lib
234%defattr(-,bin,bin)
Ed Warnickef5a14362016-09-12 20:40:24 +0000235%exclude %{_libdir}/vpp_plugins
236%exclude %{_libdir}/vpp_api_test_plugins
Ed Warnickecb9cada2015-12-08 15:45:58 -0700237%{_libdir}/*
Ole Troanf14e3bf2016-12-01 21:49:03 +0100238/usr/share/vpp/api/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700239
Ole Troan57c3d662016-09-12 22:00:32 +0200240%files python-api
241%defattr(644,root,root)
242%{python2_sitelib}/vpp_papi/*
243
Ed Warnickecb9cada2015-12-08 15:45:58 -0700244%files devel
245%defattr(-,bin,bin)
246/usr/bin/vppapigen
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700247/usr/bin/jvpp_gen.py
Ed Warnickecb9cada2015-12-08 15:45:58 -0700248%{_includedir}/*
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700249%{python2_sitelib}/jvppgen/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700250/usr/share/doc/vpp/examples/sample-plugin
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700251
Ed Warnickef5a14362016-09-12 20:40:24 +0000252%files plugins
253%defattr(-,bin,bin)
Ed Warnickee7637e72016-09-14 16:58:33 -0700254/usr/lib/vpp_plugins/*
255/usr/lib/vpp_api_test_plugins/*
Ole Troanf14e3bf2016-12-01 21:49:03 +0100256/usr/share/vpp/api/*