Release 2.3.0
[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.3.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(libtzplatform-config)
46 BuildRequires: pkgconfig(cynara-client)
47 %else
48 BuildRequires: pkgconfig(libsmack)
49 %endif
50 Requires:      lib%{name}-common = %{version}-%{release}
51 %{?systemd_requires}
52
53 %description
54 General purpose content screening and reputation solution. Can scan
55 file contents and checking url to prevent malicious items.
56
57 %global service_name                 csr
58 %global bin_dir                      %{_bindir}
59 %global sbin_dir                     /sbin
60 %global ro_data_dir                  %{_datadir}
61 %global rw_data_dir                  /opt/share
62 %global ro_db_dir                    %{ro_data_dir}/%{service_name}/dbspace
63 %global rw_db_dir                    %{rw_data_dir}/%{service_name}/dbspace
64 %global ro_res_dir                   %{ro_data_dir}/%{service_name}/res
65 %global engine_rw_working_dir        %{rw_data_dir}/%{service_name}/%{engine_rw_dir_name}
66 %global engine_dir                   %{ro_data_dir}/%{service_name}/%{engine_ro_dir_name}
67 %global test_dir                     %{rw_data_dir}/%{service_name}-test
68 %global test_res_dir                 %{ro_data_dir}/%{service_name}-test
69
70 %if "%{?tizen_version}" == "3.0"
71 %global service_user                 security_fw
72 %global service_group                security_fw
73 %global test_user                    owner
74 %global popup_service_env_file_path  /run/tizen-system-env
75 %global smack_domain_name            System
76 %global popup_unitdir                %{_unitdir_user}
77 %global upgrade_script_dir           %{ro_data_dir}/upgrade/scripts
78 %else
79 %global service_user                 system
80 %global service_group                system
81 %global test_user                    system
82 %global smack_domain_name            %{service_name}
83 %global popup_service_env_file_path  /run/tizen-mobile-env
84 %global popup_unitdir                %{_unitdir}
85 %endif
86
87 %package -n lib%{name}-common
88 Summary: CSR framework (common library)
89 License: Apache-2.0
90 Group:   Security/Libraries
91 %if "%{?tizen_version}" == "3.0"
92 BuildRequires: pkgconfig(cynara-creds-socket)
93 %else
94 BuildRequires: pkgconfig(libsmack)
95 %endif
96 Requires: %{sbin_dir}/ldconfig
97
98 %description -n lib%{name}-common
99 Content Screening and Reputation framework package (common library)
100
101 %package -n lib%{name}-client
102 Summary: CSR framework (client library)
103 License: Apache-2.0
104 Group:   Security/Libraries
105 BuildRequires: pkgconfig(capi-base-common)
106 Requires: %{name} = %{version}-%{release}
107 Requires: %{sbin_dir}/ldconfig
108
109 %description -n lib%{name}-client
110 Content Screening and Reputation framework package (client library)
111
112 %package devel
113 Summary: CSR framework (development files)
114 LICENSE: Apache-2.0
115 Group:   Security/Development
116 BuildRequires: pkgconfig(capi-base-common)
117 Requires:      %{name} = %{version}-%{release}
118 Requires:      lib%{name}-client
119
120 %description devel
121 Content Screening and Reputation framework development files like headers and pkgconfigs
122
123 %package engine-devel
124 Summary: CSR framework (engine development files)
125 LICENSE: Apache-2.0
126 Group:   Security/Development
127
128 %description engine-devel
129 Content Screening and Reputation framework engine development files like headers and
130 pkgconfigs
131
132 %package test
133 Summary: CSR framework (test program)
134 License: Apache-2.0 and BSL-1.0
135 Group:   Security/Testing
136 BuildRequires: boost-devel
137 BuildRequires: pkgconfig(pkgmgr-info)
138 BuildRequires: pkgconfig(glib-2.0)
139 BuildRequires: pkgconfig(storage)
140 Requires:      %{name} = %{version}
141
142 %description test
143 Content Screening and Reputation framework (test program)
144
145 %prep
146 %setup -q
147
148 %build
149
150 # define build architecture
151 %ifarch %{ix86}
152 %define test_target emulator
153 %else
154 %define test_target target
155 %endif
156
157 %cmake . \
158     -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}%{!?build_type:RELEASE} \
159     -DCMAKE_VERBOSE_MAKEFILE=ON \
160     -DCMAKE_INSTALL_PREFIX=%{_prefix} \
161     -DSERVICE_USER=%{service_user} \
162     -DSERVICE_GROUP=%{service_group} \
163     -DSMACK_DOMAIN_NAME=%{smack_domain_name} \
164     -DPOPUP_SERVICE_ENV_FILE_PATH:PATH=%{popup_service_env_file_path} \
165     -DSERVICE_NAME=%{service_name} \
166     -DVERSION=%{version} \
167     -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \
168     -DBIN_DIR:PATH=%{bin_dir} \
169     -DSYSTEMD_UNIT_DIR=%{_unitdir} \
170     -DPOPUP_SYSTEMD_UNIT_DIR=%{popup_unitdir} \
171     -DRO_DBSPACE:PATH=%{ro_db_dir} \
172     -DRW_DBSPACE:PATH=%{rw_db_dir} \
173     -DRO_RES_DIR:PATH=%{ro_res_dir} \
174     -DRO_DATA_DIR:PATH=%{ro_data_dir} \
175     -DSERVICE_IDLE_TIMEOUT_TIME=%{service_idle_timeout_time} \
176     -DPOPUP_SERVICE_IDLE_TIMEOUT_TIME=%{popup_service_idle_timeout_time} \
177     -DENGINE_RW_WORKING_DIR:PATH=%{engine_rw_working_dir} \
178     -DENGINE_DIR:PATH=%{engine_dir} \
179     -DTEST_TARGET=%{test_target} \
180     -DTEST_DIR:PATH=%{test_dir} \
181     -DTEST_RES_DIR:PATH=%{test_res_dir} \
182 %if 0%{?with_detailed_base_url}
183     -DDETAILED_URL_BASE:STRING=%{detailed_base_url} \
184 %endif
185 %if 0%{?with_sample_engine}
186     -DWITH_SAMPLE_ENGINE:BOOL=ON \
187 %else
188     -DWITH_SAMPLE_ENGINE:BOOL=OFF \
189 %endif
190 %if "%{?tizen_version}" == "3.0"
191     -DTZ_SYS_STORAGE=%TZ_SYS_STORAGE \
192     -DTZ_SYS_RW_APP=%TZ_SYS_RW_APP \
193     -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP \
194     -DPLATFORM_VERSION_3:BOOL=ON
195 %else
196     -DPLATFORM_VERSION_3:BOOL=OFF
197 %endif
198
199 make %{?jobs:-j%jobs}
200
201 %install
202 %make_install
203 %install_service sockets.target.wants %{service_name}-cs.socket
204 %install_service sockets.target.wants %{service_name}-wp.socket
205 %install_service sockets.target.wants %{service_name}-admin.socket
206 %install_service ../user/sockets.target.wants %{service_name}-popup.socket
207
208 mkdir -p %{buildroot}%{rw_db_dir}
209 mkdir -p %{buildroot}%{ro_db_dir}
210 cp data/scripts/*.sql %{buildroot}%{ro_db_dir}
211
212 %if "%{?tizen_version}" == "3.0"
213 mkdir -p %{buildroot}%{upgrade_script_dir}
214 cp data/scripts/500.%{service_name}.sh %{buildroot}%{upgrade_script_dir}
215 %endif
216
217 mkdir -p %{buildroot}%{engine_dir}
218 mkdir -p %{buildroot}%{engine_rw_working_dir}
219
220 %find_lang %{service_name}
221
222 %post
223 rm -f %{rw_db_dir}/.%{service_name}.db*
224
225 systemctl daemon-reload
226 if [ $1 = 1 ]; then
227     systemctl start %{service_name}-cs.socket
228     systemctl start %{service_name}-wp.socket
229     systemctl start %{service_name}-admin.socket
230     systemctl start %{service_name}.service
231
232     systemctl --user start %{service_name}-popup.socket
233     systemctl --user start %{service_name}-popup.service
234 elif [ $1 = 2 ]; then
235     systemctl stop %{service_name}-cs.socket
236     systemctl stop %{service_name}-wp.socket
237     systemctl stop %{service_name}-admin.socket
238     systemctl restart %{service_name}.service
239
240     systemctl --user stop %{service_name}-popup.socket
241     systemctl --user restart %{service_name}-popup.service
242 fi
243
244 %preun
245 if [ $1 = 0 ]; then
246     systemctl stop %{service_name}-cs.socket
247     systemctl stop %{service_name}-wp.socket
248     systemctl stop %{service_name}-admin.socket
249     systemctl stop %{service_name}.service
250
251     systemctl --user stop %{service_name}-popup.socket
252     systemctl --user stop %{service_name}-popup.service
253 fi
254
255 %postun
256 if [ $1 = 0 ]; then
257     systemctl daemon-reload
258 fi
259
260 %post -n lib%{name}-common -p %{sbin_dir}/ldconfig
261 %post -n lib%{name}-client -p %{sbin_dir}/ldconfig
262 %postun -n lib%{name}-common -p %{sbin_dir}/ldconfig
263 %postun -n lib%{name}-client -p %{sbin_dir}/ldconfig
264
265 %post -n %{name}-test
266 chsmack -a "_" %{test_dir}/test_dir/dir1
267
268 %files -f %{service_name}.lang
269 %defattr(-,root,root,-)
270 %manifest %{service_name}.manifest
271 %license LICENSE
272 %license LICENSE.BSL-1.0
273 %{bin_dir}/%{service_name}-server
274 %{bin_dir}/%{service_name}-popup
275 %{_unitdir}/%{service_name}.service
276 %{_unitdir}/sockets.target.wants/%{service_name}-cs.socket
277 %{_unitdir}/sockets.target.wants/%{service_name}-wp.socket
278 %{_unitdir}/sockets.target.wants/%{service_name}-admin.socket
279 %{_unitdir}/%{service_name}-cs.socket
280 %{_unitdir}/%{service_name}-wp.socket
281 %{_unitdir}/%{service_name}-admin.socket
282 %{popup_unitdir}/%{service_name}-popup.socket
283 %{popup_unitdir}/sockets.target.wants/%{service_name}-popup.socket
284 %{popup_unitdir}/%{service_name}-popup.service
285 %{ro_res_dir}/default-icon.png
286
287 %dir %{ro_data_dir}/%{service_name}
288 %dir %attr(-, %{service_user}, %{service_group}) %{rw_data_dir}/%{service_name}
289 %dir %{ro_db_dir}
290 %dir %attr(-, %{service_user}, %{service_group}) %{rw_db_dir}
291 %attr(444, %{service_user}, %{service_group}) %{ro_db_dir}/*.sql
292
293 %dir %{engine_dir}
294 %dir %attr(775, %{service_user}, %{service_group}) %{engine_rw_working_dir}
295
296 # RW area platform upgrade script
297 %if "%{?tizen_version}" == "3.0"
298 %attr(755, -, -) %{upgrade_script_dir}/500.%{service_name}.sh
299 %endif
300
301 %files -n lib%{name}-common
302 %defattr(-,root,root,-)
303 %manifest %{service_name}-common.manifest
304 %license LICENSE
305 %{_libdir}/lib%{service_name}-common.so.*
306
307 %files -n lib%{name}-client
308 %defattr(-,root,root,-)
309 %manifest %{service_name}-client.manifest
310 %license LICENSE
311 %{_libdir}/lib%{service_name}-client.so.*
312
313 %files devel
314 %defattr(-,root,root,-)
315 %{_includedir}/csr/csr-content-screening.h
316 %{_includedir}/csr/csr-content-screening-types.h
317 %{_includedir}/csr/csr-web-protection.h
318 %{_includedir}/csr/csr-web-protection-types.h
319 %{_includedir}/csr/csr-error.h
320 %{_includedir}/csr/csr-engine-manager.h
321 %{_libdir}/pkgconfig/%{service_name}.pc
322 %{_libdir}/lib%{service_name}-client.so
323 %{_libdir}/lib%{service_name}-common.so
324
325 %files engine-devel
326 %defattr(-,root,root,-)
327 %{_includedir}/csre/csre-content-screening-engine-info.h
328 %{_includedir}/csre/csre-content-screening.h
329 %{_includedir}/csre/csre-content-screening-types.h
330 %{_includedir}/csre/csre-error.h
331 %{_includedir}/csre/csre-web-protection-engine-info.h
332 %{_includedir}/csre/csre-web-protection.h
333 %{_includedir}/csre/csre-web-protection-types.h
334 %{_libdir}/pkgconfig/%{service_name}-engine.pc
335
336 %files test
337 %defattr(-,root,root,-)
338 %manifest %{service_name}-test.manifest
339 %license LICENSE
340 %license LICENSE.BSL-1.0
341 %{_libdir}/lib%{service_name}-test-common.so
342 %attr(-, %{test_user}, %{service_group}) %{bin_dir}/%{service_name}-test
343 %attr(-, %{test_user}, %{service_group}) %{bin_dir}/%{service_name}-internal-test
344 %attr(-, %{test_user}, %{service_group}) %{bin_dir}/%{service_name}-popup-test
345 %attr(-, %{test_user}, %{service_group}) %{bin_dir}/%{service_name}-threadpool-test
346
347 # test resources
348 %dir %attr(-, %{test_user}, %{service_group}) %{test_dir}
349 %attr(-, %{test_user}, %{service_group}) %{test_dir}/*
350
351 %dir %attr(-, %{test_user}, %{service_group}) %{test_res_dir}
352 %attr(-, %{test_user}, %{service_group}) %{test_res_dir}/*
353
354 # sample engine related files
355 %if 0%{?with_sample_engine}
356 %{engine_dir}/lib%{service_name}-cs-engine.so
357 %{engine_dir}/lib%{service_name}-wp-engine.so
358 %attr(-, %{service_user}, %{service_group}) %{engine_rw_working_dir}/*
359 %endif