blob: af4d70727c01063b18742aec4d56b662ac34ad08 [file] [log] [blame]
Sachin693b7022016-06-18 15:28:08 +05301%define _vpp_install_dir ../%{_install_dir}
Ed Warnickecb9cada2015-12-08 15:45:58 -07002%define _vpp_build_dir ../build-tool-native
3%define _unitdir /lib/systemd/system
4%define _topdir %(pwd)
5%define _builddir %{_topdir}
6%define _version %(../scripts/version rpm-version)
7%define _release %(../scripts/version rpm-release)
8
Ole Troan57c3d662016-09-12 22:00:32 +02009# Failsafe backport of Python2-macros for RHEL <= 6
10%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
11%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
12%{!?python_version: %global python_version %(%{__python} -c "import sys; sys.stdout.write(sys.version[:3])")}
13%{!?__python2: %global __python2 %{__python}}
14%{!?python2_sitelib: %global python2_sitelib %{python_sitelib}}
15%{!?python2_sitearch: %global python2_sitearch %{python_sitearch}}
16%{!?python2_version: %global python2_version %{python_version}}
17
18%{!?python2_minor_version: %define python2_minor_version %(%{__python} -c "import sys ; print sys.version[2:3]")}
19
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +030020%{?systemd_requires}
21
Ed Warnickecb9cada2015-12-08 15:45:58 -070022Name: vpp
23Summary: Vector Packet Processing
24License: MIT
25Version: %{_version}
26Release: %{_release}
Padraigb21b6762016-09-21 14:59:02 +010027Requires: vpp-lib = %{_version}-%{_release}, net-tools, pciutils, python
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +030028BuildRequires: systemd
Ed Warnickecb9cada2015-12-08 15:45:58 -070029
30%description
Damjan Marion08ff7e02016-01-20 13:45:36 +010031This package provides VPP executables: vpp, vpp_api_test, vpp_json_test
32vpp - the vector packet engine
33vpp_api_test - vector packet engine API test tool
34vpp_json_test - vector packet engine JSON test tool
Ed Warnickecb9cada2015-12-08 15:45:58 -070035
36%package lib
37Summary: VPP libraries
38Group: System Environment/Libraries
39
40%description lib
41This package contains the VPP shared libraries, including:
42vppinfra - foundation library supporting vectors, hashes, bitmaps, pools, and string formatting.
43dpdk - Intel DPDK library
44svm - vm library
45vlib - vector processing library
46vlib-api - binary API library
47vnet - network stack library
48
49%package devel
50Summary: VPP header files, static libraries
51Group: Development/Libraries
52Requires: vpp-lib
53
54%description devel
Thomas F Herbert3977a212016-10-01 18:09:33 -040055This package contains the header files for VPP.
56Install this package if you want to write a
57program for compilation and linking with vpp lib.
58vlib
59vlibmemory
60vnet - devices, classify, dhcp, ethernet flow, gre, ip, etc.
61vpp-api
62vppinfra
Ed Warnickecb9cada2015-12-08 15:45:58 -070063
Ed Warnickef5a14362016-09-12 20:40:24 +000064%package plugins
65Summary: Vector Packet Processing--runtime plugins
66Group: System Environment/Libraries
67Requires: vpp = %{_version}-%{_release}
68%description plugins
69This package contains VPP plugins
70
Ole Troan57c3d662016-09-12 22:00:32 +020071%package python-api
72Summary: VPP api python bindings
73Group: Development/Libraries
John DeNiscof53f4822016-09-30 08:33:40 -040074Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}
Ole Troan57c3d662016-09-12 22:00:32 +020075
76%description python-api
77This package contains the python bindings for the vpp api
78
Ed Warnickeec6290a2016-06-08 17:15:08 -050079%pre
80# Add the vpp group
Ed Warnickeb10427e2016-06-08 19:49:40 -050081groupadd -f -r vpp
Ed Warnickeec6290a2016-06-08 17:15:08 -050082
Ed Warnickecb9cada2015-12-08 15:45:58 -070083%install
84#
85# binaries
86#
87mkdir -p -m755 %{buildroot}%{_bindir}
88mkdir -p -m755 %{buildroot}%{_unitdir}
89install -p -m 755 %{_vpp_install_dir}/*/bin/* %{buildroot}%{_bindir}
90install -p -m 755 %{_vpp_build_dir}/vppapigen/vppapigen %{buildroot}%{_bindir}
Ole Troan57c3d662016-09-12 22:00:32 +020091install -p -m 755 ../../vppapigen/pyvppapigen.py %{buildroot}%{_bindir}
Ed Warnickecb9cada2015-12-08 15:45:58 -070092#
93# configs
94#
95mkdir -p -m755 %{buildroot}/etc/vpp
Miroslav Miklus8e08e742016-10-11 13:35:26 +020096mkdir -p -m755 %{buildroot}/etc/sysctl.d
Ed Warnickecb9cada2015-12-08 15:45:58 -070097install -p -m 644 vpp.service %{buildroot}%{_unitdir}
Ed Warnicke40c66392016-06-08 14:41:40 -050098install -p -m 644 ../../vpp/conf/startup.uiopcigeneric.conf %{buildroot}/etc/vpp/startup.conf
Miroslav Miklus8e08e742016-10-11 13:35:26 +020099install -p -m 644 ../../vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d
Ed Warnickecb9cada2015-12-08 15:45:58 -0700100#
101# libraries
102#
103mkdir -p -m755 %{buildroot}%{_libdir}
104for file in $(find %{_vpp_install_dir}/*/lib* -type f -name '*.so.*.*.*' -print )
105do
106 install -p -m 755 $file %{buildroot}%{_libdir}
107done
108for file in $(cd %{buildroot}%{_libdir} && find . -type f -print | sed -e 's/^\.\///')
109do
110 # make lib symlinks
111 ( cd %{buildroot}%{_libdir} &&
112 ln -fs $file $(echo $file | sed -e 's/\(\.so\.[0-9]\+\).*/\1/') )
Ed Warnickef5a0e732016-09-07 17:12:52 +0000113 ( cd %{buildroot}%{_libdir} &&
114 ln -fs $file $(echo $file | sed -e 's/\(\.so\)\.[0-9]\+.*/\1/') )
Ed Warnickecb9cada2015-12-08 15:45:58 -0700115done
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700116
Ole Troan57c3d662016-09-12 22:00:32 +0200117# Python bindings
118mkdir -p -m755 %{buildroot}%{python2_sitelib}/vpp_papi
119for file in $(find %{_vpp_install_dir}/*/lib/python2.7/site-packages/ -type f -print | grep -v pyc | grep -v pyo)
120do
121 install -p -m 666 $file %{buildroot}%{python2_sitelib}/vpp_papi/
122done
123
Ed Warnickecb9cada2015-12-08 15:45:58 -0700124#
125# devel
126#
127for dir in $(find %{_vpp_install_dir}/*/include/ -maxdepth 0 -type d -print | grep -v dpdk)
128do
129 for subdir in $(cd ${dir} && find . -type d -print)
130 do
131 mkdir -p -m755 %{buildroot}/usr/include/${subdir}
132 done
133 for file in $(cd ${dir} && find . -type f -print)
134 do
135 install -p -m 644 $dir/$file %{buildroot}%{_includedir}/$file
136 done
137done
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700138
139mkdir -p -m755 %{buildroot}%{python2_sitelib}/jvppgen
140install -p -m755 ../../vpp-api/java/jvpp/gen/jvpp_gen.py %{buildroot}/usr/bin
141for i in $(ls ../../vpp-api/java/jvpp/gen/jvppgen/*.py); do
142 install -p -m666 ${i} %{buildroot}%{python2_sitelib}/jvppgen
143done;
144
Ed Warnickecb9cada2015-12-08 15:45:58 -0700145# sample plugin
146mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/sample
147for file in $(cd %{_vpp_install_dir}/../../sample-plugin && find -type f -print)
148do
149 install -p -m 644 %{_vpp_install_dir}/../../sample-plugin/$file \
150 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/$file
151done
152
Ed Warnickef5a14362016-09-12 20:40:24 +0000153
154#
155# vpp-plugins
156#
157mkdir -p -m755 %{buildroot}%{_libdir}/vpp_plugins
158mkdir -p -m755 %{buildroot}%{_libdir}/vpp_api_test_plugins
159for file in $(cd %{_vpp_install_dir}/plugins/lib64/vpp_plugins && find -type f -print)
160do
161 install -p -m 644 %{_vpp_install_dir}/plugins/lib64/vpp_plugins/$file \
162 %{buildroot}%{_libdir}/vpp_plugins/$file
163done
164
165for file in $(cd %{_vpp_install_dir}/plugins/lib64/vpp_api_test_plugins && find -type f -print)
166do
167 install -p -m 644 %{_vpp_install_dir}/plugins/lib64/vpp_api_test_plugins/$file \
168 %{buildroot}%{_libdir}/vpp_api_test_plugins/$file
169done
170
Ed Warnickecb9cada2015-12-08 15:45:58 -0700171%post
172sysctl --system
173%systemd_post vpp.service
174
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300175%preun
176%systemd_preun vpp.service
177
Ed Warnickecb9cada2015-12-08 15:45:58 -0700178%postun
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +0300179%systemd_postun
180
181# Unbind user-mode PCI drivers
182removed=
183pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci`
184for d in $pci_dirs; do
185 for f in ${d}/*; do
186 [ -e "${f}/config" ] || continue
187 echo 1 > ${f}/remove
188 basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}`
189 removed=y
190 done
191done
192if [ -n "${removed}" ]; then
193 echo "There are changes in PCI drivers, rescaning"
194 echo 1 > /sys/bus/pci/rescan
195else
196 echo "There weren't PCI devices binded"
197fi
Ed Warnickecb9cada2015-12-08 15:45:58 -0700198
199%files
200%defattr(-,bin,bin)
201%{_unitdir}/vpp.service
Damjan Marion08ff7e02016-01-20 13:45:36 +0100202/usr/bin/vpp*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700203/usr/bin/svm*
Dave Barach0e5e3c32016-01-25 08:28:22 -0500204/usr/bin/elftool
Miroslav Miklus8e08e742016-10-11 13:35:26 +0200205%config /etc/sysctl.d/80-vpp.conf
Ed Warnickecb9cada2015-12-08 15:45:58 -0700206%config /etc/vpp/startup.conf
207
208%files lib
209%defattr(-,bin,bin)
Ed Warnickef5a14362016-09-12 20:40:24 +0000210%exclude %{_libdir}/vpp_plugins
211%exclude %{_libdir}/vpp_api_test_plugins
Ed Warnickecb9cada2015-12-08 15:45:58 -0700212%{_libdir}/*
213
Ole Troan57c3d662016-09-12 22:00:32 +0200214%files python-api
215%defattr(644,root,root)
216%{python2_sitelib}/vpp_papi/*
217
Ed Warnickecb9cada2015-12-08 15:45:58 -0700218%files devel
219%defattr(-,bin,bin)
220/usr/bin/vppapigen
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700221/usr/bin/jvpp_gen.py
Ole Troan57c3d662016-09-12 22:00:32 +0200222/usr/bin/pyvppapigen.py
Ed Warnickecb9cada2015-12-08 15:45:58 -0700223%{_includedir}/*
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700224%{python2_sitelib}/jvppgen/*
Ed Warnickecb9cada2015-12-08 15:45:58 -0700225/usr/share/doc/vpp/examples/sample-plugin
Ed Warnicke406ab9d2016-08-31 18:48:47 -0700226
Ed Warnickef5a14362016-09-12 20:40:24 +0000227%files plugins
228%defattr(-,bin,bin)
229%{_libdir}/vpp_plugins/*
230%{_libdir}/vpp_api_test_plugins/*