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