ea62eee7f9b773d5c699742272a328510841ccf2
[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 V=1 PLATFORM=vpp build-release
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 install -p -m 644 %{_vpp_build_dir}/../src/scripts/vppctl_completion %{buildroot}%{_sysconfdir}/bash_completion.d
217 install -p -m 644 %{_vpp_build_dir}/../src/scripts/vppctl-cmd-list %{buildroot}%{_datadir}/vpp
218
219 # Lua bindings
220 mkdir -p -m755 %{buildroot}%{_datadir}/doc/vpp/examples/lua/examples/cli
221 mkdir -p -m755 %{buildroot}%{_datadir}/doc/vpp/examples/lua/examples/lute
222 for file in $(cd %{_vpp_install_dir}/../../src/vpp-api/lua && git ls-files .)
223 do
224         install -p -m 644 %{_vpp_install_dir}/../../src/vpp-api/lua/$file \
225            %{buildroot}%{_datadir}/doc/vpp/examples/lua/$file
226 done
227
228 # Java bindings
229 mkdir -p -m755 %{buildroot}%{_datadir}/java
230 for file in $(find %{_vpp_install_dir}/vpp/share/java -type f -name '*.jar' -print )
231 do
232         install -p -m 644 $file %{buildroot}%{_datadir}/java
233 done
234
235 # Python bindings
236 cd %{_vpp_build_dir}/../src/vpp-api/python && %{py2_install}
237
238 mkdir -p -m755 %{buildroot}%{python_sitelib}/vpp_papi
239 for file in $(find %{_vpp_install_dir}/*/lib/python2.7/site-packages/ -type f -print | grep -v pyc | grep -v pyo)
240 do
241         install -p -m755 $file %{buildroot}%{python_sitelib}/vpp_papi/
242 done
243 chmod -x %{buildroot}%{python_sitelib}/vpp_papi/*.txt
244
245 #
246 # devel
247 #
248 for dir in $(find %{_vpp_install_dir}/*/include/ -maxdepth 0 -type d -print | grep -v dpdk)
249 do
250         for subdir in $(cd ${dir} && find . -type d -print)
251         do
252                 mkdir -p -m755 %{buildroot}%{_includedir}/${subdir}
253         done
254         for file in $(cd ${dir} && find . -type f -print)
255         do
256                 install -p -m 644 $dir/$file %{buildroot}%{_includedir}/$file
257         done
258 done
259
260 mkdir -p -m755 %{buildroot}%{python_sitelib}/jvppgen
261 install -p -m755 %{_vpp_build_dir}/../src/vpp-api/java/jvpp/gen/jvpp_gen.py %{buildroot}%{_prefix}/bin
262 for i in $(ls %{_vpp_build_dir}/../src/vpp-api/java/jvpp/gen/jvppgen/*.py); do
263    install -p -m755 ${i} %{buildroot}%{python_sitelib}/jvppgen
264 done;
265
266 # sample plugin
267 mkdir -p -m755 %{buildroot}%{_datadir}/doc/vpp/examples/sample-plugin/sample
268 for file in $(cd %{_vpp_install_dir}/../../sample-plugin && find -type f -print)
269 do
270         install -p -m 644 %{_vpp_install_dir}/../../sample-plugin/$file \
271            %{buildroot}%{_datadir}/doc/vpp/examples/sample-plugin/$file
272 done
273
274 #
275 # vpp-plugins
276 #
277 mkdir -p -m755 %{buildroot}%{_libdir}/vpp_plugins
278 mkdir -p -m755 %{buildroot}%{_libdir}/vpp_api_test_plugins
279 for file in $(cd %{_vpp_plugins_lib_dir}/vpp_plugins && find -type f -print)
280 do
281         install -p -m 644 %{_vpp_plugins_lib_dir}/vpp_plugins/$file \
282            %{buildroot}/%{_libdir}/vpp_plugins/$file
283 done
284
285 for file in $(cd %{_vpp_plugins_lib_dir}/vpp_api_test_plugins && find -type f -print)
286 do
287         install -p -m 644 %{_vpp_plugins_lib_dir}/vpp_api_test_plugins/$file \
288            %{buildroot}/%{_libdir}/vpp_api_test_plugins/$file
289 done
290
291 for file in $(find %{_vpp_install_dir}/plugins -type f -name '*.api.json' -print )
292 do
293         install -p -m 644 $file %{buildroot}%{_datadir}/vpp/api
294 done
295
296 #
297 # remove RPATH from ELF binaries
298 #
299 %{_vpp_build_dir}/scripts/remove-rpath %{buildroot}
300
301 export NO_BRP_CHECK_RPATH=true
302
303 %post
304 %service_add_post vpp.service
305
306 %post -n %{lname} -p /sbin/ldconfig
307
308 %preun
309 %service_del_preun vpp.service
310
311 %postun
312 %service_del_postun vpp.service
313
314 %postun -n %{lname} -p /sbin/ldconfig
315
316 %files
317 %{_unitdir}/vpp.service
318 %{_bindir}/vpp*
319 %{_bindir}/svm*
320 %{_bindir}/elftool
321 %dir %{_sysconfdir}/vpp
322 %config %{_sysconfdir}/sysctl.d/80-vpp.conf
323 %config %{_sysconfdir}/vpp/startup.conf
324 %{_sysconfdir}/bash_completion.d/vppctl_completion
325 %{_datadir}/vpp/vppctl-cmd-list
326 %license LICENSE
327
328 %files -n %{lname}
329 %exclude %{_libdir}/vpp_plugins
330 %exclude %{_libdir}/vpp_api_test_plugins
331 %{_libdir}/*.so.*
332
333 %files api-lua
334 %{_datadir}/doc/vpp/examples/lua
335
336 %files api-java
337 %{_datadir}/java/*
338
339 %files api-python
340 %dir %{python_sitelib}/vpp_papi*
341 %{python_sitelib}/vpp_papi*
342
343 %files devel
344 %dir %{python_sitelib}/jvppgen
345 %{python_sitelib}/jvppgen/*
346 %dir %{_datadir}/doc/vpp
347 %dir %{_datadir}/doc/vpp/examples
348 %{_libdir}/*.so
349 %{_bindir}/jvpp_gen.py
350 %{_includedir}/*
351 %{_datadir}/doc/vpp/examples/sample-plugin
352 %dir %{_datadir}/vpp
353 %dir %{_datadir}/vpp/api
354 %{_datadir}/vpp/api/*
355
356 %files plugins
357 %dir %{_libdir}/vpp_plugins
358 %dir %{_libdir}/vpp_api_test_plugins
359 %{_libdir}/vpp_plugins/*.so*
360 %{_libdir}/vpp_api_test_plugins/*.so*
361
362 %changelog