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