Sample engine build featuring
[platform/upstream/csr-framework.git] / packaging / csr-framework.spec
1 %define platform_version 2.4
2
3 # services timeoout time on idle for on-demand activation.
4 # give it '-1' if don't want to timeout on idle.
5 %define service_idle_timeout_time       60
6 %define popup_service_idle_timeout_time 10
7
8 # Configure engine file system.
9 #
10 # ro_dir_name / rw_dir_name
11 # - dir name is directory name inside of CSR directory.
12 # - 'dbspace' cannot be used as a dir_name.
13 %define engine_ro_dir_name engine
14 %define engine_rw_dir_name engine
15
16 # base of detailed url of content screening engine.
17 # If it's defined, detailed_url for client will be generated by
18 #                  concatenating base url + malware name.
19 # Else it's not defined, detailed_url getter in engine API will be used.
20 %define with_detailed_base_url 0
21 %define detailed_base_url %nil
22
23 %define with_sample_engine 0
24
25 Summary: A general purpose content screening and reputation solution
26 Name: csr-framework
27 Version: 2.0.0
28 Release: 0
29 Source: %{name}-%{version}.tar.gz
30 License: Apache-2.0 and BSL-1.0
31 Group: Security/Service
32 URL: http://tizen.org
33 BuildRequires: cmake
34 BuildRequires: pkgconfig(dlog)
35 BuildRequires: pkgconfig(libsystemd-daemon)
36 BuildRequires: pkgconfig(vconf)
37 BuildRequires: pkgconfig(elementary)
38 BuildRequires: pkgconfig(sqlite3)
39 BuildRequires: pkgconfig(pkgmgr)
40 BuildRequires: pkgconfig(pkgmgr-info)
41 BuildRequires: pkgconfig(libsmack)
42 %if "%{platform_version}" == "3.0"
43 BuildRequires: pkgconfig(cynara-client)
44 %else
45 BuildRequires: pkgconfig(libsmack)
46 %endif
47 Requires:      lib%{name}-common = %{version}-%{release}
48 %{?systemd_requires}
49
50 %description
51 General purpose content screening and reputation solution. Can scan
52 file contents and checking url to prevent malicious items.
53
54 %global service_name                 csr
55 %global bin_dir                      %{_bindir}
56 %global sbin_dir                     /sbin
57 %global ro_data_dir                  %{_datadir}
58 %global rw_data_dir                  /opt/share
59 %global ro_db_dir                    %{ro_data_dir}/%{service_name}/dbspace
60 %global rw_db_dir                    %{rw_data_dir}/%{service_name}/dbspace
61 %global ro_res_dir                   %{ro_data_dir}/%{service_name}/res
62 %global engine_rw_working_dir        %{rw_data_dir}/%{service_name}/%{engine_rw_dir_name}
63 %global engine_dir                   %{ro_data_dir}/%{service_name}/%{engine_ro_dir_name}
64 %global test_dir                     %{rw_data_dir}/%{service_name}-test
65
66 %if "%{platform_version}" == "3.0"
67 %global service_user                 security_fw
68 %global service_group                security_fw
69 %global popup_service_env_file_path  /run/tizen-system-env
70 %global smack_domain_name            System
71 %global popup_unitdir                %{_unitdir_user}
72 %else
73 %global service_user                 system
74 %global service_group                system
75 %global smack_domain_name            %{service_name}
76 %global popup_service_env_file_path  /run/tizen-mobile-env
77 %global popup_unitdir                %{_unitdir}
78 %endif
79
80 %package -n lib%{name}-common
81 Summary: Common library package for %{name}
82 License: Apache-2.0
83 Group:   Security/Libraries
84 %if "%{platform_version}" == "3.0"
85 BuildRequires: pkgconfig(cynara-creds-socket)
86 %else
87 BuildRequires: pkgconfig(libsmack)
88 %endif
89 Requires: %{sbin_dir}/ldconfig
90
91 %description -n lib%{name}-common
92 csr-framework common library package.
93
94 %package -n lib%{name}-client
95 Summary: Client library package for %{name}
96 License: Apache-2.0
97 Group:   Security/Libraries
98 BuildRequires: pkgconfig(capi-base-common)
99 Requires: %{name} = %{version}-%{release}
100 Requires: %{sbin_dir}/ldconfig
101
102 %description -n lib%{name}-client
103 csr-framework client library package.
104
105 %package devel
106 Summary: Development files for %{name}
107 LICENSE: Apache-2.0
108 Group:   Security/Development
109 BuildRequires: pkgconfig(capi-base-common)
110 Requires:      %{name} = %{version}-%{release}
111
112 %description devel
113 csr-framework development files including headers and pkgconfig file.
114
115 %package engine-devel
116 Summary: Development files for %{name} engine
117 LICENSE: Apache-2.0
118 Group:   Security/Development
119
120 %description engine-devel
121 csr-framework engine development files including headers and pkgconfig file.
122
123 %package test
124 Summary: test program for %{name}
125 License: Apache-2.0 and BSL-1.0
126 Group:   Security/Testing
127 BuildRequires: boost-devel
128 BuildRequires: pkgconfig(pkgmgr-info)
129 BuildRequires: pkgconfig(glib-2.0)
130 Requires:      %{name} = %{version}
131
132 %description test
133 test program of csr-framework
134
135 %prep
136 %setup -q
137
138 %build
139
140 # define build architecture
141 %ifarch %{ix86}
142 %define test_target emulator
143 %else
144 %define test_target target
145 %endif
146
147 %cmake . \
148     -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}%{!?build_type:RELEASE} \
149     -DCMAKE_VERBOSE_MAKEFILE=ON \
150     -DCMAKE_INSTALL_PREFIX=%{_prefix} \
151     -DSERVICE_USER=%{service_user} \
152     -DSERVICE_GROUP=%{service_group} \
153     -DSMACK_DOMAIN_NAME=%{smack_domain_name} \
154     -DPOPUP_SERVICE_ENV_FILE_PATH:PATH=%{popup_service_env_file_path} \
155     -DSERVICE_NAME=%{service_name} \
156     -DVERSION=%{version} \
157     -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \
158     -DBIN_DIR:PATH=%{bin_dir} \
159     -DSYSTEMD_UNIT_DIR=%{_unitdir} \
160     -DPOPUP_SYSTEMD_UNIT_DIR=%{popup_unitdir} \
161     -DRO_DBSPACE:PATH=%{ro_db_dir} \
162     -DRW_DBSPACE:PATH=%{rw_db_dir} \
163     -DRO_RES_DIR:PATH=%{ro_res_dir} \
164     -DSERVICE_IDLE_TIMEOUT_TIME=%{service_idle_timeout_time} \
165     -DPOPUP_SERVICE_IDLE_TIMEOUT_TIME=%{popup_service_idle_timeout_time} \
166     -DENGINE_RW_WORKING_DIR:PATH=%{engine_rw_working_dir} \
167     -DENGINE_DIR:PATH=%{engine_dir} \
168     -DTEST_TARGET=%{test_target} \
169     -DTEST_DIR:PATH=%{test_dir} \
170 %if 0%{?with_detailed_base_url}
171     -DDETAILED_URL_BASE:STRING=%{detailed_base_url} \
172 %endif
173 %if 0%{?with_sample_engine}
174     -DWITH_SAMPLE_ENGINE:BOOL=ON \
175 %else
176     -DWITH_SAMPLE_ENGINE:BOOL=OFF \
177 %endif
178 %if "%{platform_version}" == "3.0"
179     -DPLATFORM_VERSION_3:BOOL=ON
180 %else
181     -DPLATFORM_VERSION_3:BOOL=OFF
182 %endif
183
184 make %{?jobs:-j%jobs}
185
186 %install
187 %make_install
188 mkdir -p %{buildroot}%{_unitdir}/sockets.target.wants
189 mkdir -p %{buildroot}%{popup_unitdir}/sockets.target.wants
190 ln -s ../%{service_name}-cs.socket %{buildroot}%{_unitdir}/sockets.target.wants/%{service_name}-cs.socket
191 ln -s ../%{service_name}-wp.socket %{buildroot}%{_unitdir}/sockets.target.wants/%{service_name}-wp.socket
192 ln -s ../%{service_name}-admin.socket %{buildroot}%{_unitdir}/sockets.target.wants/%{service_name}-admin.socket
193 ln -s ../%{service_name}-popup.socket %{buildroot}%{popup_unitdir}/sockets.target.wants/%{service_name}-popup.socket
194
195 mkdir -p %{buildroot}%{ro_data_dir}/license
196 cp LICENSE %{buildroot}%{ro_data_dir}/license/%{name}
197 cp LICENSE.BSL-1.0 %{buildroot}%{ro_data_dir}/license/%{name}.BSL-1.0
198 cp LICENSE %{buildroot}%{ro_data_dir}/license/lib%{name}-client
199 cp LICENSE %{buildroot}%{ro_data_dir}/license/lib%{name}-common
200
201 cp LICENSE %{buildroot}%{ro_data_dir}/license/%{name}-test
202 cp LICENSE.BSL-1.0 %{buildroot}%{ro_data_dir}/license/%{name}-test.BSL-1.0
203
204
205 mkdir -p %{buildroot}%{rw_db_dir}
206 mkdir -p %{buildroot}%{ro_db_dir}
207 cp data/scripts/*.sql %{buildroot}%{ro_db_dir}
208
209 mkdir -p %{buildroot}%{engine_dir}
210 mkdir -p %{buildroot}%{engine_rw_working_dir}
211
212 %post
213 systemctl daemon-reload
214 if [ $1 = 1 ]; then
215     systemctl start %{service_name}-cs.socket
216     systemctl start %{service_name}-wp.socket
217     systemctl start %{service_name}-admin.socket
218     systemctl start %{service_name}-popup.socket
219     systemctl start %{service_name}.service
220 fi
221
222 if [ $1 = 2 ]; then
223     systemctl restart %{service_name}-cs.socket
224     systemctl restart %{service_name}-wp.socket
225     systemctl restart %{service_name}-admin.socket
226     systemctl restart %{service_name}-popup.socket
227     systemctl restart %{service_name}.service
228 fi
229
230 %preun
231 if [ $1 = 0 ]; then
232     systemctl stop %{service_name}.service
233     systemctl stop %{service_name}-cs.socket
234     systemctl stop %{service_name}-wp.socket
235     systemctl stop %{service_name}-admin.socket
236     systemctl stop %{service_name}-popup.socket
237 fi
238
239 %postun
240 if [ $1 = 0 ]; then
241     systemctl daemon-reload
242 fi
243
244 %post -n lib%{name}-common -p %{sbin_dir}/ldconfig
245 %post -n lib%{name}-client -p %{sbin_dir}/ldconfig
246 %postun -n lib%{name}-common -p %{sbin_dir}/ldconfig
247 %postun -n lib%{name}-client -p %{sbin_dir}/ldconfig
248
249 %files
250 %defattr(-,root,root,-)
251 %manifest %{service_name}.manifest
252 %{ro_data_dir}/license/%{name}
253 %{ro_data_dir}/license/%{name}.BSL-1.0
254 %{bin_dir}/%{service_name}-server
255 %{bin_dir}/%{service_name}-popup
256 %{_unitdir}/%{service_name}.service
257 %{_unitdir}/sockets.target.wants/%{service_name}-cs.socket
258 %{_unitdir}/sockets.target.wants/%{service_name}-wp.socket
259 %{_unitdir}/sockets.target.wants/%{service_name}-admin.socket
260 %{_unitdir}/%{service_name}-cs.socket
261 %{_unitdir}/%{service_name}-wp.socket
262 %{_unitdir}/%{service_name}-admin.socket
263 %{popup_unitdir}/%{service_name}-popup.socket
264 %{popup_unitdir}/sockets.target.wants/%{service_name}-popup.socket
265 %{popup_unitdir}/%{service_name}-popup.service
266 %{ro_res_dir}/default-icon.png
267
268 %dir %{ro_data_dir}/%{service_name}
269 %dir %attr(-, %{service_user}, %{service_group}) %{rw_data_dir}/%{service_name}
270 %dir %{ro_db_dir}
271 %dir %attr(-, %{service_user}, %{service_group}) %{rw_db_dir}
272 %attr(444, %{service_user}, %{service_group}) %{ro_db_dir}/*.sql
273
274 %dir %{engine_dir}
275 %dir %attr(775, %{service_user}, %{service_group}) %{engine_rw_working_dir}
276
277 %files -n lib%{name}-common
278 %defattr(-,root,root,-)
279 %manifest %{service_name}-common.manifest
280 %{ro_data_dir}/license/lib%{name}-common
281 %{_libdir}/lib%{service_name}-common.so.*
282
283 %files -n lib%{name}-client
284 %defattr(-,root,root,-)
285 %manifest %{service_name}-client.manifest
286 %{ro_data_dir}/license/lib%{name}-client
287 %{_libdir}/lib%{service_name}-client.so.*
288
289 %files devel
290 %defattr(-,root,root,-)
291 %{_includedir}/csr/csr-content-screening.h
292 %{_includedir}/csr/csr-content-screening-types.h
293 %{_includedir}/csr/csr-web-protection.h
294 %{_includedir}/csr/csr-web-protection-types.h
295 %{_includedir}/csr/csr-error.h
296 %{_includedir}/csr/csr-engine-manager.h
297 %{_libdir}/pkgconfig/%{service_name}.pc
298 %{_libdir}/lib%{service_name}-client.so
299 %{_libdir}/lib%{service_name}-common.so
300
301 %files engine-devel
302 %defattr(-,root,root,-)
303 %{_includedir}/csre/csre-content-screening-engine-info.h
304 %{_includedir}/csre/csre-content-screening.h
305 %{_includedir}/csre/csre-content-screening-types.h
306 %{_includedir}/csre/csre-error.h
307 %{_includedir}/csre/csre-web-protection-engine-info.h
308 %{_includedir}/csre/csre-web-protection.h
309 %{_includedir}/csre/csre-web-protection-types.h
310 %{_libdir}/pkgconfig/%{service_name}-engine.pc
311
312 %files test
313 %defattr(-,root,root,-)
314 %manifest %{service_name}-test.manifest
315 %{ro_data_dir}/license/%{name}-test
316 %{ro_data_dir}/license/%{name}-test.BSL-1.0
317 %{_libdir}/lib%{service_name}-test-common.so
318 %attr(-, %{service_user}, %{service_group}) %{bin_dir}/%{service_name}-test
319 %attr(-, %{service_user}, %{service_group}) %{bin_dir}/%{service_name}-internal-test
320 %attr(-, %{service_user}, %{service_group}) %{bin_dir}/%{service_name}-popup-test
321 %attr(-, %{service_user}, %{service_group}) %{bin_dir}/%{service_name}-threadpool-test
322
323 # test resources
324 %dir %attr(-, %{service_user}, %{service_group}) %{test_dir}
325 %attr(-, %{service_user}, %{service_group}) %{test_dir}/*
326
327 # sample engine related files
328 %if 0%{?with_sample_engine}
329 %{engine_dir}/lib%{service_name}-cs-engine.so
330 %{engine_dir}/lib%{service_name}-wp-engine.so
331 %attr(-, %{service_user}, %{service_group}) %{engine_rw_working_dir}/*
332 %endif