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