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