Fix rpm spec warnings
[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: CSR framework (common library)
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 Content Screening and Reputation framework package (common library)
99
100 %package -n lib%{name}-client
101 Summary: CSR framework (client library)
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 Content Screening and Reputation framework package (client library)
110
111 %package devel
112 Summary: CSR framework (development files)
113 LICENSE: Apache-2.0
114 Group:   Security/Development
115 BuildRequires: pkgconfig(capi-base-common)
116 Requires:      %{name} = %{version}-%{release}
117 Requires:      lib%{name}-client
118
119 %description devel
120 Content Screening and Reputation framework development files like headers and pkgconfigs
121
122 %package engine-devel
123 Summary: CSR framework (engine development files)
124 LICENSE: Apache-2.0
125 Group:   Security/Development
126
127 %description engine-devel
128 Content Screening and Reputation framework engine development files like headers and
129 pkgconfigs
130
131 %package test
132 Summary: CSR framework (test program)
133 License: Apache-2.0 and BSL-1.0
134 Group:   Security/Testing
135 BuildRequires: boost-devel
136 BuildRequires: pkgconfig(pkgmgr-info)
137 BuildRequires: pkgconfig(glib-2.0)
138 Requires:      %{name} = %{version}
139
140 %description test
141 Content Screening and Reputation framework (test program)
142
143 %prep
144 %setup -q
145
146 %build
147
148 # define build architecture
149 %ifarch %{ix86}
150 %define test_target emulator
151 %else
152 %define test_target target
153 %endif
154
155 %cmake . \
156     -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}%{!?build_type:RELEASE} \
157     -DCMAKE_VERBOSE_MAKEFILE=ON \
158     -DCMAKE_INSTALL_PREFIX=%{_prefix} \
159     -DSERVICE_USER=%{service_user} \
160     -DSERVICE_GROUP=%{service_group} \
161     -DSMACK_DOMAIN_NAME=%{smack_domain_name} \
162     -DPOPUP_SERVICE_ENV_FILE_PATH:PATH=%{popup_service_env_file_path} \
163     -DSERVICE_NAME=%{service_name} \
164     -DVERSION=%{version} \
165     -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \
166     -DBIN_DIR:PATH=%{bin_dir} \
167     -DSYSTEMD_UNIT_DIR=%{_unitdir} \
168     -DPOPUP_SYSTEMD_UNIT_DIR=%{popup_unitdir} \
169     -DRO_DBSPACE:PATH=%{ro_db_dir} \
170     -DRW_DBSPACE:PATH=%{rw_db_dir} \
171     -DRO_RES_DIR:PATH=%{ro_res_dir} \
172     -DRO_DATA_DIR:PATH=%{ro_data_dir} \
173     -DSERVICE_IDLE_TIMEOUT_TIME=%{service_idle_timeout_time} \
174     -DPOPUP_SERVICE_IDLE_TIMEOUT_TIME=%{popup_service_idle_timeout_time} \
175     -DENGINE_RW_WORKING_DIR:PATH=%{engine_rw_working_dir} \
176     -DENGINE_DIR:PATH=%{engine_dir} \
177     -DTEST_TARGET=%{test_target} \
178     -DTEST_DIR:PATH=%{test_dir} \
179     -DTEST_RES_DIR:PATH=%{test_res_dir} \
180 %if 0%{?with_detailed_base_url}
181     -DDETAILED_URL_BASE:STRING=%{detailed_base_url} \
182 %endif
183 %if 0%{?with_sample_engine}
184     -DWITH_SAMPLE_ENGINE:BOOL=ON \
185 %else
186     -DWITH_SAMPLE_ENGINE:BOOL=OFF \
187 %endif
188 %if "%{?tizen_version}" == "3.0"
189     -DPLATFORM_VERSION_3:BOOL=ON
190 %else
191     -DPLATFORM_VERSION_3:BOOL=OFF
192 %endif
193
194 make %{?jobs:-j%jobs}
195
196 %install
197 %make_install
198 %install_service sockets.target.wants %{service_name}-cs.socket
199 %install_service sockets.target.wants %{service_name}-wp.socket
200 %install_service sockets.target.wants %{service_name}-admin.socket
201 %install_service ../user/sockets.target.wants %{service_name}-popup.socket
202
203 mkdir -p %{buildroot}%{rw_db_dir}
204 mkdir -p %{buildroot}%{ro_db_dir}
205 cp data/scripts/*.sql %{buildroot}%{ro_db_dir}
206
207 %if "%{?tizen_version}" == "3.0"
208 mkdir -p %{buildroot}%{upgrade_script_dir}
209 cp data/scripts/%{service_name}-upgrade.sh %{buildroot}%{upgrade_script_dir}
210 %endif
211
212 mkdir -p %{buildroot}%{engine_dir}
213 mkdir -p %{buildroot}%{engine_rw_working_dir}
214
215 %post
216 rm -f %{rw_db_dir}/.%{service_name}.db*
217
218 systemctl daemon-reload
219 if [ $1 = 1 ]; then
220     systemctl start %{service_name}-cs.socket
221     systemctl start %{service_name}-wp.socket
222     systemctl start %{service_name}-admin.socket
223     systemctl start %{service_name}.service
224
225     systemctl --user start %{service_name}-popup.socket
226     systemctl --user start %{service_name}-popup.service
227 elif [ $1 = 2 ]; then
228     systemctl stop %{service_name}-cs.socket
229     systemctl stop %{service_name}-wp.socket
230     systemctl stop %{service_name}-admin.socket
231     systemctl restart %{service_name}.service
232
233     systemctl --user stop %{service_name}-popup.socket
234     systemctl --user restart %{service_name}-popup.service
235 fi
236
237 %preun
238 if [ $1 = 0 ]; 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}.service
243
244     systemctl --user stop %{service_name}-popup.socket
245     systemctl --user stop %{service_name}-popup.service
246 fi
247
248 %postun
249 if [ $1 = 0 ]; then
250     systemctl daemon-reload
251 fi
252
253 %post -n lib%{name}-common -p %{sbin_dir}/ldconfig
254 %post -n lib%{name}-client -p %{sbin_dir}/ldconfig
255 %postun -n lib%{name}-common -p %{sbin_dir}/ldconfig
256 %postun -n lib%{name}-client -p %{sbin_dir}/ldconfig
257
258 %post -n %{name}-test
259 chsmack -a "_" %{test_dir}/test_dir/dir1
260
261 %files
262 %defattr(-,root,root,-)
263 %manifest %{service_name}.manifest
264 %license LICENSE
265 %license LICENSE.BSL-1.0
266 %{bin_dir}/%{service_name}-server
267 %{bin_dir}/%{service_name}-popup
268 %{_unitdir}/%{service_name}.service
269 %{_unitdir}/sockets.target.wants/%{service_name}-cs.socket
270 %{_unitdir}/sockets.target.wants/%{service_name}-wp.socket
271 %{_unitdir}/sockets.target.wants/%{service_name}-admin.socket
272 %{_unitdir}/%{service_name}-cs.socket
273 %{_unitdir}/%{service_name}-wp.socket
274 %{_unitdir}/%{service_name}-admin.socket
275 %{popup_unitdir}/%{service_name}-popup.socket
276 %{popup_unitdir}/sockets.target.wants/%{service_name}-popup.socket
277 %{popup_unitdir}/%{service_name}-popup.service
278 %{ro_data_dir}/locale/*
279 %{ro_res_dir}/default-icon.png
280
281 %dir %{ro_data_dir}/%{service_name}
282 %dir %attr(-, %{service_user}, %{service_group}) %{rw_data_dir}/%{service_name}
283 %dir %{ro_db_dir}
284 %dir %attr(-, %{service_user}, %{service_group}) %{rw_db_dir}
285 %attr(444, %{service_user}, %{service_group}) %{ro_db_dir}/*.sql
286
287 %dir %{engine_dir}
288 %dir %attr(775, %{service_user}, %{service_group}) %{engine_rw_working_dir}
289
290 # RW area platform upgrade script
291 %if "%{?tizen_version}" == "3.0"
292 %attr(755, -, -) %{upgrade_script_dir}/%{service_name}-upgrade.sh
293 %endif
294
295 %files -n lib%{name}-common
296 %defattr(-,root,root,-)
297 %manifest %{service_name}-common.manifest
298 %license LICENSE
299 %{_libdir}/lib%{service_name}-common.so.*
300
301 %files -n lib%{name}-client
302 %defattr(-,root,root,-)
303 %manifest %{service_name}-client.manifest
304 %license LICENSE
305 %{_libdir}/lib%{service_name}-client.so.*
306
307 %files devel
308 %defattr(-,root,root,-)
309 %{_includedir}/csr/csr-content-screening.h
310 %{_includedir}/csr/csr-content-screening-types.h
311 %{_includedir}/csr/csr-web-protection.h
312 %{_includedir}/csr/csr-web-protection-types.h
313 %{_includedir}/csr/csr-error.h
314 %{_includedir}/csr/csr-engine-manager.h
315 %{_libdir}/pkgconfig/%{service_name}.pc
316 %{_libdir}/lib%{service_name}-client.so
317 %{_libdir}/lib%{service_name}-common.so
318
319 %files engine-devel
320 %defattr(-,root,root,-)
321 %{_includedir}/csre/csre-content-screening-engine-info.h
322 %{_includedir}/csre/csre-content-screening.h
323 %{_includedir}/csre/csre-content-screening-types.h
324 %{_includedir}/csre/csre-error.h
325 %{_includedir}/csre/csre-web-protection-engine-info.h
326 %{_includedir}/csre/csre-web-protection.h
327 %{_includedir}/csre/csre-web-protection-types.h
328 %{_libdir}/pkgconfig/%{service_name}-engine.pc
329
330 %files test
331 %defattr(-,root,root,-)
332 %manifest %{service_name}-test.manifest
333 %license LICENSE
334 %license LICENSE.BSL-1.0
335 %{_libdir}/lib%{service_name}-test-common.so
336 %attr(-, %{test_user}, %{service_group}) %{bin_dir}/%{service_name}-test
337 %attr(-, %{test_user}, %{service_group}) %{bin_dir}/%{service_name}-internal-test
338 %attr(-, %{test_user}, %{service_group}) %{bin_dir}/%{service_name}-popup-test
339 %attr(-, %{test_user}, %{service_group}) %{bin_dir}/%{service_name}-threadpool-test
340
341 # test resources
342 %dir %attr(-, %{test_user}, %{service_group}) %{test_dir}
343 %attr(-, %{test_user}, %{service_group}) %{test_dir}/*
344
345 %dir %attr(-, %{test_user}, %{service_group}) %{test_res_dir}
346 %attr(-, %{test_user}, %{service_group}) %{test_res_dir}/*
347
348 # sample engine related files
349 %if 0%{?with_sample_engine}
350 %{engine_dir}/lib%{service_name}-cs-engine.so
351 %{engine_dir}/lib%{service_name}-wp-engine.so
352 %attr(-, %{service_user}, %{service_group}) %{engine_rw_working_dir}/*
353 %endif