Python API: Preparation for RPM/DEB packaging.
[vpp.git] / build-root / rpm / vpp.spec
1 %define _vpp_install_dir ../%{_install_dir}
2 %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
9 # 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
20 Name: vpp
21 Summary: Vector Packet Processing
22 License: MIT
23 Version: %{_version}
24 Release: %{_release}
25 Requires: vpp-lib = %{_version}-%{_release}, net-tools, pciutils
26
27 %description
28 This package provides VPP executables: vpp, vpp_api_test, vpp_json_test
29 vpp - the vector packet engine
30 vpp_api_test - vector packet engine API test tool
31 vpp_json_test - vector packet engine JSON test tool
32
33 %package lib
34 Summary: VPP libraries
35 Group: System Environment/Libraries
36
37 %description lib
38 This package contains the VPP shared libraries, including:
39 vppinfra - foundation library supporting vectors, hashes, bitmaps, pools, and string formatting.
40 dpdk - Intel DPDK library
41 svm - vm library
42 vlib - vector processing library
43 vlib-api - binary API library
44 vnet -  network stack library
45
46 %package devel
47 Summary: VPP header files, static libraries
48 Group: Development/Libraries
49 Requires: vpp-lib
50
51 %description devel
52 This package contains the header files and static libraries for
53 vppinfra.  Install this package if you want to write or compile a
54 program that needs vpp.
55 Do we need to list those header files or just leave it blank ? 
56 dynamic vectors (vec.c), dynamic bitmaps (bitmap.h), allocation heap of
57 objects (heap.c), allocation pool(pool.h), dynamic hash tables (hash.c), memory
58 allocator (mheap.c), extendable printf-like interface built on top of vectors
59 (format.c), formats for data structures (std-formats.c), and support for clock
60 time-based function calls (timer.c).
61 TODO: reference and describe only the .h files
62
63 %package plugins
64 Summary: Vector Packet Processing--runtime plugins
65 Group: System Environment/Libraries
66 Requires: vpp = %{_version}-%{_release}
67 %description plugins
68 This package contains VPP plugins
69
70 %package python-api
71 Summary: VPP api python bindings
72 Group: Development/Libraries
73 Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release}, devel = %{_version}-%{_release}
74
75 %description python-api
76 This package contains the python bindings for the vpp api
77
78 %pre
79 # Add the vpp group
80 groupadd -f -r vpp
81
82 %install
83 #
84 # binaries
85 #
86 mkdir -p -m755 %{buildroot}%{_bindir}
87 mkdir -p -m755 %{buildroot}%{_unitdir}
88 install -p -m 755 %{_vpp_install_dir}/*/bin/* %{buildroot}%{_bindir}
89 install -p -m 755 %{_vpp_build_dir}/vppapigen/vppapigen %{buildroot}%{_bindir}
90 install -p -m 755 ../../vppapigen/pyvppapigen.py %{buildroot}%{_bindir}
91 #
92 # configs
93 #
94 mkdir -p -m755 %{buildroot}/etc/vpp
95 mkdir -p -m755 %{buildroot}/etc/sysctl.d
96 install -p -m 644 vpp.service %{buildroot}%{_unitdir}
97 install -p -m 644 ../../vpp/conf/startup.uiopcigeneric.conf %{buildroot}/etc/vpp/startup.conf
98 install -p -m 644 ../../vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d
99 #
100 # libraries
101 #
102 mkdir -p -m755 %{buildroot}%{_libdir}
103 for file in $(find %{_vpp_install_dir}/*/lib* -type f -name '*.so.*.*.*' -print )
104 do
105         install -p -m 755 $file %{buildroot}%{_libdir}
106 done
107 for file in $(cd %{buildroot}%{_libdir} && find . -type f -print | sed -e 's/^\.\///')
108 do
109         # make lib symlinks
110         ( cd %{buildroot}%{_libdir} && 
111           ln -fs $file $(echo $file | sed -e 's/\(\.so\.[0-9]\+\).*/\1/') )
112         ( cd %{buildroot}%{_libdir} && 
113           ln -fs $file $(echo $file | sed -e 's/\(\.so\)\.[0-9]\+.*/\1/') )
114 done
115
116 # Python bindings
117 mkdir -p -m755 %{buildroot}%{python2_sitelib}/vpp_papi
118 for file in $(find %{_vpp_install_dir}/*/lib/python2.7/site-packages/ -type f -print | grep -v pyc | grep -v pyo)
119 do
120         install -p -m 666 $file %{buildroot}%{python2_sitelib}/vpp_papi/
121 done
122
123 #
124 # devel
125 #
126 for dir in $(find %{_vpp_install_dir}/*/include/ -maxdepth 0 -type d -print | grep -v dpdk)
127 do
128         for subdir in $(cd ${dir} && find . -type d -print)
129         do
130                 mkdir -p -m755 %{buildroot}/usr/include/${subdir}
131         done
132         for file in $(cd ${dir} && find . -type f -print)
133         do
134                 install -p -m 644 $dir/$file %{buildroot}%{_includedir}/$file
135         done
136 done
137
138 mkdir -p -m755 %{buildroot}%{python2_sitelib}/jvppgen
139 install -p -m755 ../../vpp-api/java/jvpp/gen/jvpp_gen.py %{buildroot}/usr/bin
140 for i in $(ls ../../vpp-api/java/jvpp/gen/jvppgen/*.py); do
141    install -p -m666 ${i} %{buildroot}%{python2_sitelib}/jvppgen
142 done;
143
144 # sample plugin
145 mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/sample
146 for file in $(cd %{_vpp_install_dir}/../../sample-plugin && find -type f -print)
147 do
148         install -p -m 644 %{_vpp_install_dir}/../../sample-plugin/$file \
149            %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/$file
150 done
151
152
153 #
154 # vpp-plugins
155
156 mkdir -p -m755 %{buildroot}%{_libdir}/vpp_plugins
157 mkdir -p -m755 %{buildroot}%{_libdir}/vpp_api_test_plugins
158 for file in $(cd %{_vpp_install_dir}/plugins/lib64/vpp_plugins && find -type f -print)
159 do
160         install -p -m 644 %{_vpp_install_dir}/plugins/lib64/vpp_plugins/$file \
161            %{buildroot}%{_libdir}/vpp_plugins/$file
162 done
163
164 for file in $(cd %{_vpp_install_dir}/plugins/lib64/vpp_api_test_plugins && find -type f -print)
165 do
166         install -p -m 644 %{_vpp_install_dir}/plugins/lib64/vpp_api_test_plugins/$file \
167            %{buildroot}%{_libdir}/vpp_api_test_plugins/$file
168 done
169
170 %post
171 sysctl --system
172 %systemd_post vpp.service
173
174 %postun
175 %systemd_postun_with_restart vpp.service
176
177 %files
178 %defattr(-,bin,bin)
179 %{_unitdir}/vpp.service
180 /usr/bin/vpp*
181 /usr/bin/svm*
182 /usr/bin/elftool
183 %config /etc/sysctl.d/80-vpp.conf
184 %config /etc/vpp/startup.conf
185
186 %files lib
187 %defattr(-,bin,bin)
188 %exclude %{_libdir}/vpp_plugins
189 %exclude %{_libdir}/vpp_api_test_plugins
190 %{_libdir}/*
191
192 %files python-api
193 %defattr(644,root,root)
194 %{python2_sitelib}/vpp_papi/*
195
196 %files devel
197 %defattr(-,bin,bin)
198 /usr/bin/vppapigen
199 /usr/bin/jvpp_gen.py
200 /usr/bin/pyvppapigen.py
201 %{_includedir}/*
202 %{python2_sitelib}/jvppgen/*
203 /usr/share/doc/vpp/examples/sample-plugin
204
205 %files plugins
206 %defattr(-,bin,bin)
207 %{_libdir}/vpp_plugins/*
208 %{_libdir}/vpp_api_test_plugins/*