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