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