Support detailed url base usage
[platform/upstream/csr-framework.git] / packaging / csr-framework.spec
1 %define platform_version 2.4
2
3 # services timeoout time on idle for on-demand activation.
4 # give it '-1' if don't want to timeout on idle.
5 %define service_idle_timeout_time       60
6 %define popup_service_idle_timeout_time 10
7
8 # Configure engine file system.
9 #
10 # ro_dir_name / rw_dir_name
11 # - dir name is directory name inside of CSR directory.
12 # - 'dbspace' cannot be used as a dir_name.
13 %define engine_ro_dir_name engine
14 %define engine_rw_dir_name engine
15
16 # base of detailed url of content screening engine.
17 # If it's defined, detailed_url for client will be generated by
18 #                  concatenating base url + malware name.
19 # Else it's not defined, detailed_url getter in engine API will be used.
20 %define with_detailed_base_url 0
21 %define detailed_base_url
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: pkgconfig(dlog)
33 BuildRequires: pkgconfig(libsystemd-daemon)
34 BuildRequires: pkgconfig(vconf)
35 BuildRequires: pkgconfig(elementary)
36 BuildRequires: pkgconfig(sqlite3)
37 BuildRequires: pkgconfig(pkgmgr)
38 BuildRequires: pkgconfig(pkgmgr-info)
39 BuildRequires: pkgconfig(libsmack)
40 %if "%{platform_version}" == "3.0"
41 BuildRequires: pkgconfig(cynara-client)
42 %else
43 BuildRequires: pkgconfig(libsmack)
44 %endif
45 Requires:      lib%{name}-common = %{version}-%{release}
46 %{?systemd_requires}
47
48 %description
49 General purpose content screening and reputation solution. Can scan
50 file contents and checking url to prevent malicious items.
51
52 %global service_name                 csr
53 %global bin_dir                      %{_bindir}
54 %global sbin_dir                     /sbin
55 %global ro_data_dir                  %{_datadir}
56 %global rw_data_dir                  /opt/share
57 %global ro_db_dir                    %{ro_data_dir}/%{service_name}/dbspace
58 %global rw_db_dir                    %{rw_data_dir}/%{service_name}/dbspace
59 %global engine_rw_working_dir        %{rw_data_dir}/%{service_name}/%{engine_rw_dir_name}
60 %global engine_dir                   %{ro_data_dir}/%{service_name}/%{engine_ro_dir_name}
61 %global test_dir                     %{rw_data_dir}/%{service_name}-test
62
63 %if "%{platform_version}" == "3.0"
64 %global service_user                 security_fw
65 %global service_group                security_fw
66 %global popup_service_env_file_path  /run/tizen-system-env
67 %global smack_domain_name            System
68 %global popup_unitdir                %{_unitdir_user}
69 %else
70 %global service_user                 system
71 %global service_group                system
72 %global smack_domain_name            %{service_name}
73 %global popup_service_env_file_path  /run/tizen-mobile-env
74 %global popup_unitdir                %{_unitdir}
75 %endif
76
77 %package -n lib%{name}-common
78 Summary: Common library package for %{name}
79 License: Apache-2.0
80 Group:   Security/Libraries
81 %if "%{platform_version}" == "3.0"
82 BuildRequires: pkgconfig(cynara-creds-socket)
83 %else
84 BuildRequires: pkgconfig(libsmack)
85 %endif
86 Requires: %{sbin_dir}/ldconfig
87
88 %description -n lib%{name}-common
89 csr-framework common library package.
90
91 %package -n lib%{name}-client
92 Summary: Client library package for %{name}
93 License: Apache-2.0
94 Group:   Security/Libraries
95 BuildRequires: pkgconfig(capi-base-common)
96 Requires: %{name} = %{version}-%{release}
97 Requires: %{sbin_dir}/ldconfig
98
99 %description -n lib%{name}-client
100 csr-framework client library package.
101
102 %package devel
103 Summary: Development files for %{name}
104 LICENSE: Apache-2.0
105 Group:   Security/Development
106 BuildRequires: pkgconfig(capi-base-common)
107 Requires:      %{name} = %{version}-%{release}
108
109 %description devel
110 csr-framework development files including headers and pkgconfig file.
111
112 %package engine-devel
113 Summary: Development files for %{name} engine
114 LICENSE: Apache-2.0
115 Group:   Security/Development
116
117 %description engine-devel
118 csr-framework engine development files including headers and pkgconfig file.
119
120 %package test
121 Summary: test program for %{name}
122 License: Apache-2.0 and BSL-1.0
123 Group:   Security/Testing
124 BuildRequires: boost-devel
125 BuildRequires: pkgconfig(pkgmgr-info)
126 BuildRequires: pkgconfig(glib-2.0)
127 Requires:      %{name} = %{version}
128
129 %description test
130 test program of csr-framework
131
132 %prep
133 %setup -q
134
135 %build
136
137 # define build architecture
138 %ifarch %{ix86}
139 %define test_target emulator
140 %else
141 %define test_target target
142 %endif
143
144 %cmake . \
145     -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}%{!?build_type:RELEASE} \
146     -DCMAKE_VERBOSE_MAKEFILE=ON \
147     -DCMAKE_INSTALL_PREFIX=%{_prefix} \
148     -DSERVICE_USER=%{service_user} \
149     -DSERVICE_GROUP=%{service_group} \
150     -DSMACK_DOMAIN_NAME=%{smack_domain_name} \
151     -DPOPUP_SERVICE_ENV_FILE_PATH:PATH=%{popup_service_env_file_path} \
152     -DSERVICE_NAME=%{service_name} \
153     -DVERSION=%{version} \
154     -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \
155     -DBIN_DIR:PATH=%{bin_dir} \
156     -DSYSTEMD_UNIT_DIR=%{_unitdir} \
157     -DPOPUP_SYSTEMD_UNIT_DIR=%{popup_unitdir} \
158     -DRO_DBSPACE:PATH=%{ro_db_dir} \
159     -DRW_DBSPACE:PATH=%{rw_db_dir} \
160     -DSERVICE_IDLE_TIMEOUT_TIME=%{service_idle_timeout_time} \
161     -DPOPUP_SERVICE_IDLE_TIMEOUT_TIME=%{popup_service_idle_timeout_time} \
162     -DENGINE_RW_WORKING_DIR:PATH=%{engine_rw_working_dir} \
163     -DENGINE_DIR:PATH=%{engine_dir} \
164     -DTEST_TARGET=%{test_target} \
165     -DTEST_DIR:PATH=%{test_dir} \
166 %if 0%{?with_detailed_base_url}
167     -DDETAILED_URL_BASE:STRING=%{detailed_base_url} \
168 %endif
169 %if "%{platform_version}" == "3.0"
170     -DPLATFORM_VERSION_3:BOOL=ON
171 %else
172     -DPLATFORM_VERSION_3:BOOL=OFF
173 %endif
174
175 make %{?jobs:-j%jobs}
176
177 %install
178 %make_install
179 mkdir -p %{buildroot}%{_unitdir}/sockets.target.wants
180 mkdir -p %{buildroot}%{popup_unitdir}/sockets.target.wants
181 ln -s ../%{service_name}-cs.socket %{buildroot}%{_unitdir}/sockets.target.wants/%{service_name}-cs.socket
182 ln -s ../%{service_name}-wp.socket %{buildroot}%{_unitdir}/sockets.target.wants/%{service_name}-wp.socket
183 ln -s ../%{service_name}-admin.socket %{buildroot}%{_unitdir}/sockets.target.wants/%{service_name}-admin.socket
184 ln -s ../%{service_name}-popup.socket %{buildroot}%{popup_unitdir}/sockets.target.wants/%{service_name}-popup.socket
185
186 mkdir -p %{buildroot}%{ro_data_dir}/license
187 cp LICENSE %{buildroot}%{ro_data_dir}/license/%{name}
188 cp LICENSE.BSL-1.0 %{buildroot}%{ro_data_dir}/license/%{name}.BSL-1.0
189 cp LICENSE %{buildroot}%{ro_data_dir}/license/lib%{name}-client
190 cp LICENSE %{buildroot}%{ro_data_dir}/license/lib%{name}-common
191 cp LICENSE %{buildroot}%{ro_data_dir}/license/%{name}-test
192 cp LICENSE.BSL-1.0 %{buildroot}%{ro_data_dir}/license/%{name}-test.BSL-1.0
193
194 mkdir -p %{buildroot}%{rw_db_dir}
195 mkdir -p %{buildroot}%{ro_db_dir}
196 cp data/scripts/*.sql %{buildroot}%{ro_db_dir}
197
198 mkdir -p %{buildroot}%{engine_dir}
199 mkdir -p %{buildroot}%{engine_rw_working_dir}
200
201 %post
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}-popup.socket
208     systemctl start %{service_name}.service
209 fi
210
211 if [ $1 = 2 ]; then
212     systemctl restart %{service_name}-cs.socket
213     systemctl restart %{service_name}-wp.socket
214     systemctl restart %{service_name}-admin.socket
215     systemctl restart %{service_name}-popup.socket
216     systemctl restart %{service_name}.service
217 fi
218
219 %preun
220 if [ $1 = 0 ]; then
221     systemctl stop %{service_name}.service
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}-popup.socket
226 fi
227
228 %postun
229 if [ $1 = 0 ]; then
230     systemctl daemon-reload
231 fi
232
233 %post -n lib%{name}-common -p %{sbin_dir}/ldconfig
234 %post -n lib%{name}-client -p %{sbin_dir}/ldconfig
235 %postun -n lib%{name}-common -p %{sbin_dir}/ldconfig
236 %postun -n lib%{name}-client -p %{sbin_dir}/ldconfig
237
238 %files
239 %defattr(-,root,root,-)
240 %manifest %{service_name}.manifest
241 %{ro_data_dir}/license/%{name}
242 %{ro_data_dir}/license/%{name}.BSL-1.0
243 %{bin_dir}/%{service_name}-server
244 %{bin_dir}/%{service_name}-popup
245 %{_unitdir}/%{service_name}.service
246 %{_unitdir}/sockets.target.wants/%{service_name}-cs.socket
247 %{_unitdir}/sockets.target.wants/%{service_name}-wp.socket
248 %{_unitdir}/sockets.target.wants/%{service_name}-admin.socket
249 %{_unitdir}/%{service_name}-cs.socket
250 %{_unitdir}/%{service_name}-wp.socket
251 %{_unitdir}/%{service_name}-admin.socket
252 %{popup_unitdir}/%{service_name}-popup.socket
253 %{popup_unitdir}/sockets.target.wants/%{service_name}-popup.socket
254 %{popup_unitdir}/%{service_name}-popup.service
255
256 %dir %{ro_data_dir}/%{service_name}
257 %dir %attr(-, %{service_user}, %{service_group}) %{rw_data_dir}/%{service_name}
258 %dir %{ro_db_dir}
259 %dir %attr(-, %{service_user}, %{service_group}) %{rw_db_dir}
260 %attr(444, %{service_user}, %{service_group}) %{ro_db_dir}/*.sql
261
262 %dir %{engine_dir}
263 %dir %attr(775, %{service_user}, %{service_group}) %{engine_rw_working_dir}
264
265 %files -n lib%{name}-common
266 %defattr(-,root,root,-)
267 %manifest %{service_name}-common.manifest
268 %{ro_data_dir}/license/lib%{name}-common
269 %{_libdir}/lib%{service_name}-common.so.*
270
271 %files -n lib%{name}-client
272 %defattr(-,root,root,-)
273 %manifest %{service_name}-client.manifest
274 %{ro_data_dir}/license/lib%{name}-client
275 %{_libdir}/lib%{service_name}-client.so.*
276
277 %files devel
278 %defattr(-,root,root,-)
279 %{_includedir}/csr/csr-content-screening.h
280 %{_includedir}/csr/csr-content-screening-types.h
281 %{_includedir}/csr/csr-web-protection.h
282 %{_includedir}/csr/csr-web-protection-types.h
283 %{_includedir}/csr/csr-error.h
284 %{_includedir}/csr/csr-engine-manager.h
285 %{_libdir}/pkgconfig/%{service_name}.pc
286 %{_libdir}/lib%{service_name}-client.so
287 %{_libdir}/lib%{service_name}-common.so
288
289 %files engine-devel
290 %defattr(-,root,root,-)
291 %{_includedir}/csre/csre-content-screening-engine-info.h
292 %{_includedir}/csre/csre-content-screening.h
293 %{_includedir}/csre/csre-content-screening-types.h
294 %{_includedir}/csre/csre-error.h
295 %{_includedir}/csre/csre-web-protection-engine-info.h
296 %{_includedir}/csre/csre-web-protection.h
297 %{_includedir}/csre/csre-web-protection-types.h
298 %{_libdir}/pkgconfig/%{service_name}-engine.pc
299
300 %files test
301 %defattr(-,root,root,-)
302 %manifest %{service_name}-test.manifest
303 %{ro_data_dir}/license/%{name}-test
304 %{ro_data_dir}/license/%{name}-test.BSL-1.0
305 %{_libdir}/lib%{service_name}-test-common.so
306 %attr(-, %{service_user}, %{service_group}) %{bin_dir}/%{service_name}-test
307 %attr(-, %{service_user}, %{service_group}) %{bin_dir}/%{service_name}-internal-test
308 %attr(-, %{service_user}, %{service_group}) %{bin_dir}/%{service_name}-popup-test
309 %attr(-, %{service_user}, %{service_group}) %{bin_dir}/%{service_name}-threadpool-test
310
311 # test resources
312 %dir %attr(-, %{service_user}, %{service_group}) %{test_dir}
313 %attr(-, %{service_user}, %{service_group}) %{test_dir}/*
314
315 # sample engine related files
316 %{engine_dir}/lib%{service_name}-cs-engine.so
317 %{engine_dir}/lib%{service_name}-wp-engine.so
318 %attr(-, %{service_user}, %{service_group}) %{engine_rw_working_dir}/*