summaryrefslogtreecommitdiff
path: root/packaging/csr-framework.spec
blob: f092b1ee177ccf0915bf6529bbf50f7d81da5d9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# services timeoout time on idle for on-demand activation.
# give it '-1' if don't want to timeout on idle.
%define service_idle_timeout_time       60
%define popup_service_idle_timeout_time 10

# Configure engine file system.
#
# ro_dir_name / rw_dir_name
# - dir name is directory name inside of CSR directory.
# - 'dbspace' cannot be used as a dir_name.
%define engine_ro_dir_name engine
%define engine_rw_dir_name engine

# base of detailed url of content screening engine.
# If it's defined, detailed_url for client will be generated by
#                  concatenating base url + malware name.
# Else it's not defined, detailed_url getter in engine API will be used.
%define with_detailed_base_url 0
%define detailed_base_url %nil

%define with_sample_engine 1

Summary: A general purpose content screening and reputation solution
Name: csr-framework
Version: 2.2.1
Release: 0
Source: %{name}-%{version}.tar.gz
License: Apache-2.0 and BSL-1.0
Group: Security/Service
URL: http://tizen.org
BuildRequires: cmake
BuildRequires: gettext-tools
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(libsystemd-daemon)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(pkgmgr)
BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: pkgconfig(libsmack)
BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(elementary)
BuildRequires: pkgconfig(efl-extension)
BuildRequires: pkgconfig(icu-i18n)
%if "%{?tizen_version}" == "3.0"
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(cynara-client)
%else
BuildRequires: pkgconfig(libsmack)
%endif
Requires:      lib%{name}-common = %{version}-%{release}
%{?systemd_requires}

%description
General purpose content screening and reputation solution. Can scan
file contents and checking url to prevent malicious items.

%global service_name                 csr
%global bin_dir                      %{_bindir}
%global sbin_dir                     /sbin
%global ro_data_dir                  %{_datadir}
%global rw_data_dir                  /opt/share
%global ro_db_dir                    %{ro_data_dir}/%{service_name}/dbspace
%global rw_db_dir                    %{rw_data_dir}/%{service_name}/dbspace
%global ro_res_dir                   %{ro_data_dir}/%{service_name}/res
%global engine_rw_working_dir        %{rw_data_dir}/%{service_name}/%{engine_rw_dir_name}
%global engine_dir                   %{ro_data_dir}/%{service_name}/%{engine_ro_dir_name}
%global test_dir                     %{rw_data_dir}/%{service_name}-test
%global test_res_dir                 %{ro_data_dir}/%{service_name}-test

%if "%{?tizen_version}" == "3.0"
%global service_user                 security_fw
%global service_group                security_fw
%global test_user                    owner
%global popup_service_env_file_path  /run/tizen-system-env
%global smack_domain_name            System
%global popup_unitdir                %{_unitdir_user}
%global upgrade_script_dir           %{ro_data_dir}/upgrade/scripts
%else
%global service_user                 system
%global service_group                system
%global test_user                    system
%global smack_domain_name            %{service_name}
%global popup_service_env_file_path  /run/tizen-mobile-env
%global popup_unitdir                %{_unitdir}
%endif

%package -n lib%{name}-common
Summary: CSR framework (common library)
License: Apache-2.0
Group:   Security/Libraries
%if "%{?tizen_version}" == "3.0"
BuildRequires: pkgconfig(cynara-creds-socket)
%else
BuildRequires: pkgconfig(libsmack)
%endif
Requires: %{sbin_dir}/ldconfig

%description -n lib%{name}-common
Content Screening and Reputation framework package (common library)

%package -n lib%{name}-client
Summary: CSR framework (client library)
License: Apache-2.0
Group:   Security/Libraries
BuildRequires: pkgconfig(capi-base-common)
Requires: %{name} = %{version}-%{release}
Requires: %{sbin_dir}/ldconfig

%description -n lib%{name}-client
Content Screening and Reputation framework package (client library)

%package devel
Summary: CSR framework (development files)
LICENSE: Apache-2.0
Group:   Security/Development
BuildRequires: pkgconfig(capi-base-common)
Requires:      %{name} = %{version}-%{release}
Requires:      lib%{name}-client

%description devel
Content Screening and Reputation framework development files like headers and pkgconfigs

%package engine-devel
Summary: CSR framework (engine development files)
LICENSE: Apache-2.0
Group:   Security/Development

%description engine-devel
Content Screening and Reputation framework engine development files like headers and
pkgconfigs

%package test
Summary: CSR framework (test program)
License: Apache-2.0 and BSL-1.0
Group:   Security/Testing
BuildRequires: boost-devel
BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(storage)
Requires:      %{name} = %{version}

%description test
Content Screening and Reputation framework (test program)

%prep
%setup -q

%build

# define build architecture
%ifarch %{ix86}
%define test_target emulator
%else
%define test_target target
%endif

%cmake . \
    -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}%{!?build_type:RELEASE} \
    -DCMAKE_VERBOSE_MAKEFILE=ON \
    -DCMAKE_INSTALL_PREFIX=%{_prefix} \
    -DSERVICE_USER=%{service_user} \
    -DSERVICE_GROUP=%{service_group} \
    -DSMACK_DOMAIN_NAME=%{smack_domain_name} \
    -DPOPUP_SERVICE_ENV_FILE_PATH:PATH=%{popup_service_env_file_path} \
    -DSERVICE_NAME=%{service_name} \
    -DVERSION=%{version} \
    -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \
    -DBIN_DIR:PATH=%{bin_dir} \
    -DSYSTEMD_UNIT_DIR=%{_unitdir} \
    -DPOPUP_SYSTEMD_UNIT_DIR=%{popup_unitdir} \
    -DRO_DBSPACE:PATH=%{ro_db_dir} \
    -DRW_DBSPACE:PATH=%{rw_db_dir} \
    -DRO_RES_DIR:PATH=%{ro_res_dir} \
    -DRO_DATA_DIR:PATH=%{ro_data_dir} \
    -DSERVICE_IDLE_TIMEOUT_TIME=%{service_idle_timeout_time} \
    -DPOPUP_SERVICE_IDLE_TIMEOUT_TIME=%{popup_service_idle_timeout_time} \
    -DENGINE_RW_WORKING_DIR:PATH=%{engine_rw_working_dir} \
    -DENGINE_DIR:PATH=%{engine_dir} \
    -DTEST_TARGET=%{test_target} \
    -DTEST_DIR:PATH=%{test_dir} \
    -DTEST_RES_DIR:PATH=%{test_res_dir} \
%if 0%{?with_detailed_base_url}
    -DDETAILED_URL_BASE:STRING=%{detailed_base_url} \
%endif
%if 0%{?with_sample_engine}
    -DWITH_SAMPLE_ENGINE:BOOL=ON \
%else
    -DWITH_SAMPLE_ENGINE:BOOL=OFF \
%endif
%if "%{?tizen_version}" == "3.0"
    -DTZ_SYS_STORAGE=%TZ_SYS_STORAGE \
    -DTZ_SYS_RW_APP=%TZ_SYS_RW_APP \
    -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP \
    -DPLATFORM_VERSION_3:BOOL=ON
%else
    -DPLATFORM_VERSION_3:BOOL=OFF
%endif

make %{?jobs:-j%jobs}

%install
%make_install
%install_service sockets.target.wants %{service_name}-cs.socket
%install_service sockets.target.wants %{service_name}-wp.socket
%install_service sockets.target.wants %{service_name}-admin.socket
%install_service ../user/sockets.target.wants %{service_name}-popup.socket

mkdir -p %{buildroot}%{rw_db_dir}
mkdir -p %{buildroot}%{ro_db_dir}
cp data/scripts/*.sql %{buildroot}%{ro_db_dir}

%if "%{?tizen_version}" == "3.0"
mkdir -p %{buildroot}%{upgrade_script_dir}
cp data/scripts/%{service_name}-upgrade.sh %{buildroot}%{upgrade_script_dir}
%endif

mkdir -p %{buildroot}%{engine_dir}
mkdir -p %{buildroot}%{engine_rw_working_dir}

%find_lang %{service_name}

%post
rm -f %{rw_db_dir}/.%{service_name}.db*

systemctl daemon-reload
if [ $1 = 1 ]; then
    systemctl start %{service_name}-cs.socket
    systemctl start %{service_name}-wp.socket
    systemctl start %{service_name}-admin.socket
    systemctl start %{service_name}.service

    systemctl --user start %{service_name}-popup.socket
    systemctl --user start %{service_name}-popup.service
elif [ $1 = 2 ]; then
    systemctl stop %{service_name}-cs.socket
    systemctl stop %{service_name}-wp.socket
    systemctl stop %{service_name}-admin.socket
    systemctl restart %{service_name}.service

    systemctl --user stop %{service_name}-popup.socket
    systemctl --user restart %{service_name}-popup.service
fi

%preun
if [ $1 = 0 ]; then
    systemctl stop %{service_name}-cs.socket
    systemctl stop %{service_name}-wp.socket
    systemctl stop %{service_name}-admin.socket
    systemctl stop %{service_name}.service

    systemctl --user stop %{service_name}-popup.socket
    systemctl --user stop %{service_name}-popup.service
fi

%postun
if [ $1 = 0 ]; then
    systemctl daemon-reload
fi

%post -n lib%{name}-common -p %{sbin_dir}/ldconfig
%post -n lib%{name}-client -p %{sbin_dir}/ldconfig
%postun -n lib%{name}-common -p %{sbin_dir}/ldconfig
%postun -n lib%{name}-client -p %{sbin_dir}/ldconfig

%post -n %{name}-test
chsmack -a "_" %{test_dir}/test_dir/dir1

%files -f %{service_name}.lang
%defattr(-,root,root,-)
%manifest %{service_name}.manifest
%license LICENSE
%license LICENSE.BSL-1.0
%{bin_dir}/%{service_name}-server
%{bin_dir}/%{service_name}-popup
%{_unitdir}/%{service_name}.service
%{_unitdir}/sockets.target.wants/%{service_name}-cs.socket
%{_unitdir}/sockets.target.wants/%{service_name}-wp.socket
%{_unitdir}/sockets.target.wants/%{service_name}-admin.socket
%{_unitdir}/%{service_name}-cs.socket
%{_unitdir}/%{service_name}-wp.socket
%{_unitdir}/%{service_name}-admin.socket
%{popup_unitdir}/%{service_name}-popup.socket
%{popup_unitdir}/sockets.target.wants/%{service_name}-popup.socket
%{popup_unitdir}/%{service_name}-popup.service
%{ro_res_dir}/default-icon.png

%dir %{ro_data_dir}/%{service_name}
%dir %attr(-, %{service_user}, %{service_group}) %{rw_data_dir}/%{service_name}
%dir %{ro_db_dir}
%dir %attr(-, %{service_user}, %{service_group}) %{rw_db_dir}
%attr(444, %{service_user}, %{service_group}) %{ro_db_dir}/*.sql

%dir %{engine_dir}
%dir %attr(775, %{service_user}, %{service_group}) %{engine_rw_working_dir}

# RW area platform upgrade script
%if "%{?tizen_version}" == "3.0"
%attr(755, -, -) %{upgrade_script_dir}/%{service_name}-upgrade.sh
%endif

%files -n lib%{name}-common
%defattr(-,root,root,-)
%manifest %{service_name}-common.manifest
%license LICENSE
%{_libdir}/lib%{service_name}-common.so.*

%files -n lib%{name}-client
%defattr(-,root,root,-)
%manifest %{service_name}-client.manifest
%license LICENSE
%{_libdir}/lib%{service_name}-client.so.*

%files devel
%defattr(-,root,root,-)
%{_includedir}/csr/csr-content-screening.h
%{_includedir}/csr/csr-content-screening-types.h
%{_includedir}/csr/csr-web-protection.h
%{_includedir}/csr/csr-web-protection-types.h
%{_includedir}/csr/csr-error.h
%{_includedir}/csr/csr-engine-manager.h
%{_libdir}/pkgconfig/%{service_name}.pc
%{_libdir}/lib%{service_name}-client.so
%{_libdir}/lib%{service_name}-common.so

%files engine-devel
%defattr(-,root,root,-)
%{_includedir}/csre/csre-content-screening-engine-info.h
%{_includedir}/csre/csre-content-screening.h
%{_includedir}/csre/csre-content-screening-types.h
%{_includedir}/csre/csre-error.h
%{_includedir}/csre/csre-web-protection-engine-info.h
%{_includedir}/csre/csre-web-protection.h
%{_includedir}/csre/csre-web-protection-types.h
%{_libdir}/pkgconfig/%{service_name}-engine.pc

%files test
%defattr(-,root,root,-)
%manifest %{service_name}-test.manifest
%license LICENSE
%license LICENSE.BSL-1.0
%{_libdir}/lib%{service_name}-test-common.so
%attr(-, %{test_user}, %{service_group}) %{bin_dir}/%{service_name}-test
%attr(-, %{test_user}, %{service_group}) %{bin_dir}/%{service_name}-internal-test
%attr(-, %{test_user}, %{service_group}) %{bin_dir}/%{service_name}-popup-test
%attr(-, %{test_user}, %{service_group}) %{bin_dir}/%{service_name}-threadpool-test

# test resources
%dir %attr(-, %{test_user}, %{service_group}) %{test_dir}
%attr(-, %{test_user}, %{service_group}) %{test_dir}/*

%dir %attr(-, %{test_user}, %{service_group}) %{test_res_dir}
%attr(-, %{test_user}, %{service_group}) %{test_res_dir}/*

# sample engine related files
%if 0%{?with_sample_engine}
%{engine_dir}/lib%{service_name}-cs-engine.so
%{engine_dir}/lib%{service_name}-wp-engine.so
%attr(-, %{service_user}, %{service_group}) %{engine_rw_working_dir}/*
%endif