22420fa154c23eb678c3a65ba80db823ea18469d
[vpp.git] / extras / rpm / vpp-suse.spec
1 #
2 # spec file for package vpp
3 #
4 # Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
5 #
6 # All modifications and additions to the file contributed by third parties
7 # remain the property of their copyright owners, unless otherwise agreed
8 # upon. The license for this file, and modifications and additions to the
9 # file, is the same license as for the pristine package itself (unless the
10 # license for the pristine package is not an Open Source License, in which
11 # case the license is the MIT License). An "Open Source License" is a
12 # license that conforms to the Open Source Definition (Version 1.9)
13 # published by the Open Source Initiative.
14
15 # Please submit bugfixes or comments via http://bugs.opensuse.org/
16 #
17
18
19 %define _vpp_build_dir       %{buildroot}/../../BUILD/vpp-%{version}/build-root
20 %define _vpp_install_dir     %{_vpp_build_dir}/install-vpp-native/
21 %define _vpp_plugins_lib_dir %{_vpp_install_dir}/vpp/lib64
22
23 %define lname libvpp0
24
25 Name:           vpp
26 Version:        %{_version}
27 Release:        %{_release}
28 Summary:        Set of libraries and drivers for fast packet processing
29 License:        Apache-2.0
30 Group:          Productivity/Networking/Routing
31 Url:            https://wiki.fd.io/view/VPP
32 Source0:        %{name}-%{version}-%{_release}.tar.xz
33 BuildRequires:  autoconf
34 BuildRequires:  automake
35 BuildRequires:  bison
36 BuildRequires:  ccache
37 BuildRequires:  check-devel
38 BuildRequires:  chrpath
39 BuildRequires:  distribution-release
40 BuildRequires:  gcc
41 BuildRequires:  gcc-c++
42 BuildRequires:  glibc-devel
43 BuildRequires:  glibc-devel-static
44 BuildRequires:  java-devel >= 1.8
45 BuildRequires:  libboost_headers-devel
46 BuildRequires:  libboost_thread-devel
47 BuildRequires:  libnuma-devel
48 BuildRequires:  libopenssl-devel
49 BuildRequires:  libtool
50 BuildRequires:  lsb-release
51 BuildRequires:  make
52 BuildRequires:  mbedtls-devel
53 BuildRequires:  openssl-devel
54 BuildRequires:  python-devel
55 BuildRequires:  python-pip
56 BuildRequires:  python-rpm-macros
57 BuildRequires:  python2-ply
58 BuildRequires:  python3-devel
59 BuildRequires:  python3-pip
60 BuildRequires:  shadow
61 Conflicts:      otherproviders(vpp-any)
62 Provides:       %{name}-any = %{version}
63 ExclusiveArch:  x86_64 aarch64
64 %if 0%{?suse_version} >= 1210
65 BuildRequires:  systemd-rpm-macros
66 %endif
67
68 %description
69 The Vector Packet Processing platform is a framework that provides
70 switch/router functionality. It is based on Cisco's packet processing
71 stack that can run on commodity CPUs.
72 This package provides VPP executables: vpp, vpp_api_test, vpp_json_test
73 vpp - the vector packet engine
74 vpp_api_test - vector packet engine API test tool
75 vpp_json_test - vector packet engine JSON test tool
76
77 %package -n %{lname}
78 Summary:        VPP libraries
79 Group:          System/Libraries
80 Provides:       %{lname}-any = %{version}
81
82 %description -n %{lname}
83 This package contains the VPP shared libraries, including:
84 vppinfra - foundation library supporting vectors, hashes, bitmaps, pools, and string formatting.
85 svm - vm library
86 vlib - vector processing library
87 vlib-api - binary API library
88 vnet -  network stack library
89
90 %package devel
91 Summary:        VPP header files, static libraries
92 Group:          Development/Libraries/C and C++
93 Requires:       %{lname} = %{version}
94 Conflicts:      otherproviders(%{name}-any-devel)
95 Provides:       %{name}-any-devel = %{version}
96
97 %description devel
98 This package contains the header files for VPP.
99 Install this package if you want to write a
100 program for compilation and linking with vpp lib.
101 vlib
102 vlibmemory
103 vnet - devices, classify, dhcp, ethernet flow, gre, ip, etc.
104 vpp-api
105 vppinfra
106
107 %package plugins
108 Summary:        Vector Packet Processing--runtime plugins
109 Group:          Productivity/Networking/Routing
110 Conflicts:      otherproviders(%{name}-any-plugins)
111 Provides:       %{name}-any-plugins = %{version}
112
113 %description plugins
114 This package contains the VPP plugins which are loaded by VPP at startup
115
116 %package api-lua
117 Summary:        VPP api lua bindings
118 Group:          Development/Libraries/Other
119 Requires:       %{lname} = %{version}
120 Requires:       %{name} = %{version}
121 Requires:       %{name}-devel = %{version}
122 Conflicts:      otherproviders(%{name}-any-api-lua)
123 Provides:       %{name}-any-api-lua = %{version}
124
125 %description api-lua
126 This package contains the lua bindings for the vpp api
127
128 %package api-java
129 Summary:        VPP api java bindings
130 Group:          Development/Libraries/Java
131 Requires:       %{lname} = %{version}
132 Requires:       %{name} = %{version}
133 Requires:       %{name}-devel = %{version}
134 Conflicts:      otherproviders(%{name}-any-api-java)
135 Provides:       %{name}-any-api-java = %{version}
136
137 %description api-java
138 This package contains the java bindings for the vpp api
139
140 %package api-python
141 Summary:        VPP api python bindings
142 Group:          Development/Libraries/Python
143 Requires:       %{lname} = %{version}
144 Requires:       %{name} = %{version}
145 Requires:       %{name}-devel = %{version}
146 Requires:       python-setuptools
147 Conflicts:      otherproviders(%{name}-any-python-api)
148 Provides:       %{name}-any-python-api = %{version}
149
150 %description api-python
151 This package contains the python bindings for the vpp api
152
153 %prep
154 %setup -q -n %{name}-%{version}
155
156 %build
157 export VPP_BUILD_USER=suse
158 export VPP_BUILD_HOST=SUSE
159
160 make -C build-root V=1 CC=gcc-7 CXX=g++-7 PLATFORM=vpp TAG=vpp install-packages
161
162 cd %{_vpp_build_dir}/../src/vpp-api/python && %{py2_build}
163
164 %pre
165 # Add the vpp group
166 getent group vpp >/dev/null || groupadd -r vpp
167 %service_add_pre vpp.service
168
169 %install
170 #
171 # binaries
172 #
173 mkdir -p -m755 %{buildroot}%{_bindir}
174 mkdir -p -m755 %{buildroot}%{_unitdir}
175 install  -m 755 %{_vpp_install_dir}/*/bin/* %{buildroot}%{_bindir}
176
177 # api
178 mkdir -p -m755 %{buildroot}%{_datadir}/vpp/api
179
180 #
181 # core api
182 #
183 mkdir -p -m755 %{buildroot}%{_datadir}/vpp/api
184 install -p -m 644 %{_vpp_install_dir}/vpp/share/vpp/api/core/*.api.json %{buildroot}%{_datadir}/vpp/api
185 install -p -m 644 %{_vpp_install_dir}/vpp/share/vpp/api/plugins/*.api.json %{buildroot}%{_datadir}/vpp/api
186 #
187 # configs
188 #
189 mkdir -p -m755 %{buildroot}%{_sysconfdir}/vpp
190 mkdir -p -m755 %{buildroot}%{_sysconfdir}/sysctl.d
191 install -p -m 644 %{_vpp_build_dir}/../extras/rpm/vpp.service %{buildroot}%{_unitdir}
192 install -p -m 644 %{_vpp_build_dir}/../src/vpp/conf/startup.conf %{buildroot}%{_sysconfdir}/vpp/startup.conf
193 install -p -m 644 %{_vpp_build_dir}/../src/vpp/conf/80-vpp.conf %{buildroot}%{_sysconfdir}/sysctl.d
194 #
195 # libraries
196 #
197 mkdir -p -m755 %{buildroot}%{_libdir}
198 mkdir -p -m755 %{buildroot}%{_sysconfdir}/bash_completion.d
199 mkdir -p -m755 %{buildroot}%{_datadir}/vpp
200 for file in $(find %{_vpp_install_dir}/*/lib* -type f -name '*.so.*.*.*' -print )
201 do
202         install -p -m 755 $file %{buildroot}%{_libdir}
203 done
204 for file in $(cd %{buildroot}%{_libdir} && find . -type f -print | sed -e 's/^\.\///')
205 do
206         # make lib symlinks
207         ( cd %{buildroot}%{_libdir} &&
208           ln -fs $file $(echo $file | sed -e 's/\(\.so\.[0-9]\+\).*/\1/') )
209         ( cd %{buildroot}%{_libdir} &&
210           ln -fs $file $(echo $file | sed -e 's/\(\.so\)\.[0-9]\+.*/\1/') )
211 done
212 for file in $(find %{_vpp_install_dir}/vpp/share/vpp/api  -type f -name '*.api.json' -print )
213 do
214         install -p -m 644 $file %{buildroot}%{_datadir}/vpp/api
215 done
216
217 # Lua bindings
218 mkdir -p -m755 %{buildroot}%{_datadir}/doc/vpp/examples/lua/examples/cli
219 mkdir -p -m755 %{buildroot}%{_datadir}/doc/vpp/examples/lua/examples/lute
220 for file in $(cd %{_vpp_install_dir}/../../src/vpp-api/lua && git ls-files .)
221 do
222         install -p -m 644 %{_vpp_install_dir}/../../src/vpp-api/lua/$file \
223            %{buildroot}%{_datadir}/doc/vpp/examples/lua/$file
224 done
225
226 # Java bindings
227 mkdir -p -m755 %{buildroot}%{_datadir}/java
228 for file in $(find %{_vpp_install_dir}/japi/share/java -type f -name '*.jar' -print )
229 do
230         install -p -m 644 $file %{buildroot}%{_datadir}/java
231 done
232
233 # Python bindings
234 cd %{_vpp_build_dir}/../src/vpp-api/python && %{py2_install}
235
236 mkdir -p -m755 %{buildroot}%{python_sitelib}/vpp_papi
237 for file in $(find %{_vpp_install_dir}/*/lib/python2.7/site-packages/ -type f -print | grep -v pyc | grep -v pyo)
238 do
239         install -p -m755 $file %{buildroot}%{python_sitelib}/vpp_papi/
240 done
241 chmod -x %{buildroot}%{python_sitelib}/vpp_papi/*.txt
242
243 #
244 # devel
245 #
246 for dir in $(find %{_vpp_install_dir}/*/include/ -maxdepth 0 -type d -print | grep -v dpdk)
247 do
248         for subdir in $(cd ${dir} && find . -type d -print)
249         do
250                 mkdir -p -m755 %{buildroot}%{_includedir}/${subdir}
251         done
252         for file in $(cd ${dir} && find . -type f -print)
253         do
254                 install -p -m 644 $dir/$file %{buildroot}%{_includedir}/$file
255         done
256 done
257
258 mkdir -p -m755 %{buildroot}%{python_sitelib}/jvppgen
259 install -p -m755 %{_vpp_build_dir}/../extras/japi/java/jvpp/gen/jvpp_gen.py %{buildroot}%{_prefix}/bin
260 for i in $(ls %{_vpp_build_dir}/../extras/japi/java/jvpp/gen/jvppgen/*.py); do
261    install -p -m755 ${i} %{buildroot}%{python_sitelib}/jvppgen
262 done;
263
264 # sample plugin
265 mkdir -p -m755 %{buildroot}%{_datadir}/doc/vpp/examples/sample-plugin/sample
266 for file in $(cd %{_vpp_install_dir}/../../sample-plugin && find -type f -print)
267 do
268         install -p -m 644 %{_vpp_install_dir}/../../sample-plugin/$file \
269            %{buildroot}%{_datadir}/doc/vpp/examples/sample-plugin/$file
270 done
271
272 #
273 # vpp-plugins
274 #
275 mkdir -p -m755 %{buildroot}%{_libdir}/vpp_plugins
276 mkdir -p -m755 %{buildroot}%{_libdir}/vpp_api_test_plugins
277 for file in $(cd %{_vpp_plugins_lib_dir}/vpp_plugins && find -type f -print)
278 do
279         install -p -m 644 %{_vpp_plugins_lib_dir}/vpp_plugins/$file \
280            %{buildroot}/%{_libdir}/vpp_plugins/$file
281 done
282
283 for file in $(cd %{_vpp_plugins_lib_dir}/vpp_api_test_plugins && find -type f -print)
284 do
285         install -p -m 644 %{_vpp_plugins_lib_dir}/vpp_api_test_plugins/$file \
286            %{buildroot}/%{_libdir}/vpp_api_test_plugins/$file
287 done
288
289 for file in $(find %{_vpp_install_dir}/plugins -type f -name '*.api.json' -print )
290 do
291         install -p -m 644 $file %{buildroot}%{_datadir}/vpp/api
292 done
293
294 #
295 # remove RPATH from ELF binaries
296 #
297 %{_vpp_build_dir}/scripts/remove-rpath %{buildroot}
298
299 export NO_BRP_CHECK_RPATH=true
300
301 %post
302 %service_add_post vpp.service
303
304 %post -n %{lname} -p /sbin/ldconfig
305
306 %preun
307 %service_del_preun vpp.service
308
309 %postun
310 %service_del_postun vpp.service
311
312 %postun -n %{lname} -p /sbin/ldconfig
313
314 %files
315 %{_unitdir}/vpp.service
316 %{_bindir}/vpp*
317 %{_bindir}/svm*
318 %{_bindir}/elftool
319 %dir %{_sysconfdir}/vpp
320 %config %{_sysconfdir}/sysctl.d/80-vpp.conf
321 %config %{_sysconfdir}/vpp/startup.conf
322 %license LICENSE
323
324 %files -n %{lname}
325 %exclude %{_libdir}/vpp_plugins
326 %exclude %{_libdir}/vpp_api_test_plugins
327 %{_libdir}/*.so.*
328
329 %files api-lua
330 %{_datadir}/doc/vpp/examples/lua
331
332 %files api-java
333 %{_datadir}/java/*
334
335 %files api-python
336 %dir %{python_sitelib}/vpp_papi*
337 %{python_sitelib}/vpp_papi*
338
339 %files devel
340 %dir %{python_sitelib}/jvppgen
341 %{python_sitelib}/jvppgen/*
342 %dir %{_datadir}/doc/vpp
343 %dir %{_datadir}/doc/vpp/examples
344 %{_libdir}/*.so
345 %{_bindir}/jvpp_gen.py
346 %{_includedir}/*
347 %{_datadir}/doc/vpp/examples/sample-plugin
348 %dir %{_datadir}/vpp
349 %dir %{_datadir}/vpp/api
350 %{_datadir}/vpp/api/*
351
352 %files plugins
353 %dir %{_libdir}/vpp_plugins
354 %dir %{_libdir}/vpp_api_test_plugins
355 %{_libdir}/vpp_plugins/*.so*
356 %{_libdir}/vpp_api_test_plugins/*.so*
357
358 %changelog