blob: 7f0e2a342c47e7232f0f28dac671f3bd68b24f80 [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.
46dpdk - Intel DPDK library
47svm - 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}
101install -p -m 755 %{_mu_build_dir}/../vppapigen/pyvppapigen.py %{buildroot}%{_bindir}
Ed Warnickecb9cada2015-12-08 15:45:58 -0700102#
103# configs
104#
105mkdir -p -m755 %{buildroot}/etc/vpp
Miroslav Miklus8e08e742016-10-11 13:35:26 +0200106mkdir -p -m755 %{buildroot}/etc/sysctl.d
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400107install -p -m 644 %{_mu_build_dir}/rpm/vpp.service %{buildroot}%{_unitdir}
108install -p -m 644 %{_mu_build_dir}/../vpp/conf/startup.uiopcigeneric.conf %{buildroot}/etc/vpp/startup.conf
109install -p -m 644 %{_mu_build_dir}/../vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d
Ed Warnickecb9cada2015-12-08 15:45:58 -0700110#
111# libraries
112#
113mkdir -p -m755 %{buildroot}%{_libdir}
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400114for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/*/lib* -type f -name '*.so.*.*.*' -print )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700115do
116 install -p -m 755 $file %{buildroot}%{_libdir}
117done
118for file in $(cd %{buildroot}%{_libdir} && find . -type f -print | sed -e 's/^\.\///')
119do
120 # make lib symlinks
121 ( cd %{buildroot}%{_libdir} &&
122 ln -fs $file $(echo $file | sed -e 's/\(\.so\.[0-9]\+\).*/\1/') )
Ed Warnickef5a0e732016-09-07 17:12:52 +0000123 ( cd %{buildroot}%{_libdir} &&
124 ln -fs $file $(echo $file | sed -e 's/\(\.so\)\.[0-9]\+.*/\1/') )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700125done
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700126
Ole Troan57c3d662016-09-12 22:00:32 +0200127# Python bindings
128mkdir -p -m755 %{buildroot}%{python2_sitelib}/vpp_papi
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400129for 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 +0200130do
131 install -p -m 666 $file %{buildroot}%{python2_sitelib}/vpp_papi/
132done
133
Ed Warnickecb9cada2015-12-08 15:45:58 -0700134#
135# devel
136#
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400137for 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 -0700138do
139 for subdir in $(cd ${dir} && find . -type d -print)
140 do
141 mkdir -p -m755 %{buildroot}/usr/include/${subdir}
142 done
143 for file in $(cd ${dir} && find . -type f -print)
144 do
145 install -p -m 644 $dir/$file %{buildroot}%{_includedir}/$file
146 done
147done
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700148
149mkdir -p -m755 %{buildroot}%{python2_sitelib}/jvppgen
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400150install -p -m755 %{_mu_build_dir}/../vpp-api/java/jvpp/gen/jvpp_gen.py %{buildroot}/usr/bin
151for i in $(ls %{_mu_build_dir}/../vpp-api/java/jvpp/gen/jvppgen/*.py); do
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700152 install -p -m666 ${i} %{buildroot}%{python2_sitelib}/jvppgen
153done;
154
Ed Warnickecb9cada2015-12-08 15:45:58 -0700155# sample plugin
156mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/sample
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400157for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../sample-plugin && find -type f -print)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700158do
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400159 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/../../sample-plugin/$file \
Ed Warnickecb9cada2015-12-08 15:45:58 -0700160 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/$file
161done
162
Ed Warnickef5a14362016-09-12 20:40:24 +0000163
164#
165# vpp-plugins
166#
Ed Warnickee7637e72016-09-14 16:58:33 -0700167mkdir -p -m755 %{buildroot}/usr/lib/vpp_plugins
168mkdir -p -m755 %{buildroot}/usr/lib/vpp_api_test_plugins
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400169for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/plugins/lib64/vpp_plugins && find -type f -print)
Ed Warnickef5a14362016-09-12 20:40:24 +0000170do
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400171 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/plugins/lib64/vpp_plugins/$file \
Ed Warnickee7637e72016-09-14 16:58:33 -0700172 %{buildroot}/usr/lib/vpp_plugins/$file
Ed Warnickef5a14362016-09-12 20:40:24 +0000173done
174
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400175for 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 +0000176do
Thomas F Herbert20a29c72016-10-13 18:36:50 -0400177 install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/plugins/lib64/vpp_api_test_plugins/$file \
Ed Warnickee7637e72016-09-14 16:58:33 -0700178 %{buildroot}/usr/lib/vpp_api_test_plugins/$file
Ed Warnickef5a14362016-09-12 20:40:24 +0000179done
180
Ed Warnickecb9cada2015-12-08 15:45:58 -0700181%post
182sysctl --system
183%systemd_post vpp.service
184
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300185%preun
186%systemd_preun vpp.service
187
Ed Warnickecb9cada2015-12-08 15:45:58 -0700188%postun
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300189%systemd_postun
190
191# Unbind user-mode PCI drivers
192removed=
193pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci`
194for d in $pci_dirs; do
195 for f in ${d}/*; do
196 [ -e "${f}/config" ] || continue
197 echo 1 > ${f}/remove
198 basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}`
199 removed=y
200 done
201done
202if [ -n "${removed}" ]; then
203 echo "There are changes in PCI drivers, rescaning"
204 echo 1 > /sys/bus/pci/rescan
205else
206 echo "There weren't PCI devices binded"
207fi
Ed Warnickecb9cada2015-12-08 15:45:58 -0700208
209%files
210%defattr(-,bin,bin)
211%{_unitdir}/vpp.service
Damjan Marion08ff7e02016-01-20 13:45:36 +0100212/usr/bin/vpp*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700213/usr/bin/svm*
Dave Barach0e5e3c32016-01-25 08:28:22 -0500214/usr/bin/elftool
Miroslav Miklus8e08e742016-10-11 13:35:26 +0200215%config /etc/sysctl.d/80-vpp.conf
Ed Warnickecb9cada2015-12-08 15:45:58 -0700216%config /etc/vpp/startup.conf
217
218%files lib
219%defattr(-,bin,bin)
Ed Warnickef5a14362016-09-12 20:40:24 +0000220%exclude %{_libdir}/vpp_plugins
221%exclude %{_libdir}/vpp_api_test_plugins
Ed Warnickecb9cada2015-12-08 15:45:58 -0700222%{_libdir}/*
223
Ole Troan57c3d662016-09-12 22:00:32 +0200224%files python-api
225%defattr(644,root,root)
226%{python2_sitelib}/vpp_papi/*
227
Ed Warnickecb9cada2015-12-08 15:45:58 -0700228%files devel
229%defattr(-,bin,bin)
230/usr/bin/vppapigen
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700231/usr/bin/jvpp_gen.py
Ole Troan57c3d662016-09-12 22:00:32 +0200232/usr/bin/pyvppapigen.py
Ed Warnickecb9cada2015-12-08 15:45:58 -0700233%{_includedir}/*
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700234%{python2_sitelib}/jvppgen/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700235/usr/share/doc/vpp/examples/sample-plugin
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700236
Ed Warnickef5a14362016-09-12 20:40:24 +0000237%files plugins
238%defattr(-,bin,bin)
Ed Warnickee7637e72016-09-14 16:58:33 -0700239/usr/lib/vpp_plugins/*
240/usr/lib/vpp_api_test_plugins/*