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