Change sample engine dir to inside of ro csr dir
[platform/upstream/csr-framework.git] / packaging / csr-framework.spec
1 %define platform_version 2.4
2
3 Summary: A general purpose content screening and reputation solution
4 Name: csr-framework
5 Version: 2.0.0
6 Release: 0
7 Source: %{name}-%{version}.tar.gz
8 License: Apache-2.0 and BSL-1.0
9 Group: Security/Service
10 URL: http://tizen.org
11 BuildRequires: cmake
12 BuildRequires: pkgconfig(dlog)
13 BuildRequires: pkgconfig(libsystemd-daemon)
14 BuildRequires: pkgconfig(vconf)
15 BuildRequires: pkgconfig(elementary)
16 BuildRequires: pkgconfig(sqlite3)
17 BuildRequires: pkgconfig(pkgmgr)
18 BuildRequires: pkgconfig(pkgmgr-info)
19 BuildRequires: pkgconfig(libsmack)
20 %if "%{platform_version}" == "3.0"
21 BuildRequires: pkgconfig(cynara-client)
22 %else
23 BuildRequires: pkgconfig(libsmack)
24 %endif
25 Requires:      lib%{name}-common = %{version}-%{release}
26 %{?systemd_requires}
27
28 %description
29 General purpose content screening and reputation solution. Can scan
30 file contents and checking url to prevent malicious items.
31
32 %global service_user                 system
33 %global service_group                system
34 %global service_name                 csr
35 %global bin_dir                      %{_bindir}
36 %global sbin_dir                     /sbin
37 %global ro_data_dir                  %{_datadir}
38 %global rw_data_dir                  /opt/share
39 %global ro_db_dir                    %{ro_data_dir}/%{service_name}/dbspace
40 %global rw_db_dir                    %{rw_data_dir}/%{service_name}/dbspace
41 %global sample_engine_ro_res_dir     %{ro_data_dir}/%{service_name}/engine
42 %global sample_engine_rw_working_dir %{rw_data_dir}/%{service_name}/engine
43 %global sample_engine_dir            %{ro_data_dir}/%{service_name}/lib
44 %global test_dir                     %{rw_data_dir}/%{service_name}-test
45
46 %package -n lib%{name}-common
47 Summary: Common library package for %{name}
48 License: Apache-2.0
49 Group:   Security/Libraries
50 %if "%{platform_version}" == "3.0"
51 BuildRequires: pkgconfig(cynara-creds-socket)
52 %else
53 BuildRequires: pkgconfig(libsmack)
54 %endif
55 Requires: %{sbin_dir}/ldconfig
56
57 %description -n lib%{name}-common
58 csr-framework common library package.
59
60 %package -n lib%{name}-client
61 Summary: Client library package for %{name}
62 License: Apache-2.0
63 Group:   Security/Libraries
64 BuildRequires: pkgconfig(capi-base-common)
65 Requires: %{name} = %{version}-%{release}
66 Requires: %{sbin_dir}/ldconfig
67
68 %description -n lib%{name}-client
69 csr-framework client library package.
70
71 %package devel
72 Summary: Development files for %{name}
73 LICENSE: Apache-2.0
74 Group:   Security/Development
75 BuildRequires: pkgconfig(capi-base-common)
76 Requires:      %{name} = %{version}-%{release}
77
78 %description devel
79 csr-framework development files including headers and pkgconfig file.
80
81 %package engine-devel
82 Summary: Development files for %{name} engine
83 LICENSE: Apache-2.0
84 Group:   Security/Development
85
86 %description engine-devel
87 csr-framework engine development files including headers and pkgconfig file.
88
89 %package test
90 Summary: test program for %{name}
91 License: Apache-2.0 and BSL-1.0
92 Group:   Security/Testing
93 BuildRequires: boost-devel
94 BuildRequires: pkgconfig(pkgmgr-info)
95 BuildRequires: pkgconfig(glib-2.0)
96 Requires:      %{name} = %{version}
97
98 %description test
99 test program of csr-framework
100
101 %prep
102 %setup -q
103
104 %build
105
106 # define build architecture
107 %ifarch %{ix86}
108 %define test_target emulator
109 %else
110 %define test_target target
111 %endif
112
113 %cmake . \
114     -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}%{!?build_type:RELEASE} \
115     -DCMAKE_VERBOSE_MAKEFILE=ON \
116     -DCMAKE_INSTALL_PREFIX=%{_prefix} \
117     -DSERVICE_USER=%{service_user} \
118     -DSERVICE_GROUP=%{service_group} \
119     -DSERVICE_NAME=%{service_name} \
120     -DVERSION=%{version} \
121     -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \
122     -DBIN_DIR:PATH=%{bin_dir} \
123     -DSYSTEMD_UNIT_DIR=%{_unitdir} \
124     -DSYSTEMD_UNIT_USER_DIR=%{_unitdir_user} \
125     -DRO_DBSPACE:PATH=%{ro_db_dir} \
126     -DRW_DBSPACE:PATH=%{rw_db_dir} \
127     -DSAMPLE_ENGINE_RO_RES_DIR:PATH=%{sample_engine_ro_res_dir} \
128     -DSAMPLE_ENGINE_RW_WORKING_DIR:PATH=%{sample_engine_rw_working_dir} \
129     -DSAMPLE_ENGINE_DIR:PATH=%{sample_engine_dir} \
130     -DTEST_TARGET=%{test_target} \
131     -DTEST_DIR:PATH=%{test_dir} \
132 %if "%{platform_version}" == "3.0"
133     -DPLATFORM_VERSION_3:BOOL=ON
134 %else
135     -DPLATFORM_VERSION_3:BOOL=OFF
136 %endif
137
138 make %{?jobs:-j%jobs}
139
140 %install
141 %make_install
142 mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants
143 mkdir -p %{buildroot}%{_unitdir}/sockets.target.wants
144 ln -s ../%{service_name}.service %{buildroot}%{_unitdir}/multi-user.target.wants/%{service_name}.service
145 ln -s ../%{service_name}-cs.socket %{buildroot}%{_unitdir}/sockets.target.wants/%{service_name}-cs.socket
146 ln -s ../%{service_name}-wp.socket %{buildroot}%{_unitdir}/sockets.target.wants/%{service_name}-wp.socket
147 ln -s ../%{service_name}-admin.socket %{buildroot}%{_unitdir}/sockets.target.wants/%{service_name}-admin.socket
148 ln -s ../%{service_name}-popup.socket %{buildroot}%{_unitdir}/sockets.target.wants/%{service_name}-popup.socket
149
150 mkdir -p %{buildroot}%{ro_data_dir}/license
151 cp LICENSE %{buildroot}%{ro_data_dir}/license/%{name}
152 cp LICENSE.BSL-1.0 %{buildroot}%{ro_data_dir}/license/%{name}.BSL-1.0
153 cp LICENSE %{buildroot}%{ro_data_dir}/license/lib%{name}-client
154 cp LICENSE %{buildroot}%{ro_data_dir}/license/lib%{name}-common
155 cp LICENSE %{buildroot}%{ro_data_dir}/license/%{name}-test
156 cp LICENSE.BSL-1.0 %{buildroot}%{ro_data_dir}/license/%{name}-test.BSL-1.0
157
158 mkdir -p %{buildroot}%{ro_db_dir}
159 mkdir -p %{buildroot}%{rw_db_dir}
160 mkdir -p %{buildroot}%{sample_engine_ro_res_dir}
161 cp data/scripts/*.sql %{buildroot}%{ro_db_dir}
162
163 %post
164 systemctl daemon-reload
165 if [ $1 = 1 ]; then
166     systemctl start %{service_name}-cs.socket
167     systemctl start %{service_name}-wp.socket
168     systemctl start %{service_name}-admin.socket
169     systemctl start %{service_name}-popup.socket
170     systemctl start %{service_name}.service
171 fi
172
173 if [ $1 = 2 ]; then
174     systemctl restart %{service_name}-cs.socket
175     systemctl restart %{service_name}-wp.socket
176     systemctl restart %{service_name}-admin.socket
177     systemctl restart %{service_name}-popup.socket
178     systemctl restart %{service_name}.service
179 fi
180
181 %preun
182 if [ $1 = 0 ]; then
183     systemctl stop %{service_name}.service
184     systemctl stop %{service_name}-cs.socket
185     systemctl stop %{service_name}-wp.socket
186     systemctl stop %{service_name}-admin.socket
187     systemctl stop %{service_name}-popup.socket
188 fi
189
190 %postun
191 if [ $1 = 0 ]; then
192     systemctl daemon-reload
193 fi
194
195 %post -n lib%{name}-common -p %{sbin_dir}/ldconfig
196 %post -n lib%{name}-client -p %{sbin_dir}/ldconfig
197 %postun -n lib%{name}-common -p %{sbin_dir}/ldconfig
198 %postun -n lib%{name}-client -p %{sbin_dir}/ldconfig
199
200 %files
201 %defattr(-,root,root,-)
202 %manifest %{service_name}.manifest
203 %{ro_data_dir}/license/%{name}
204 %{ro_data_dir}/license/%{name}.BSL-1.0
205 %{bin_dir}/%{service_name}-server
206 %{bin_dir}/%{service_name}-popup
207 %{_unitdir}/multi-user.target.wants/%{service_name}.service
208 %{_unitdir}/%{service_name}.service
209 %{_unitdir}/%{service_name}-popup.service
210 %{_unitdir}/sockets.target.wants/%{service_name}-cs.socket
211 %{_unitdir}/sockets.target.wants/%{service_name}-wp.socket
212 %{_unitdir}/sockets.target.wants/%{service_name}-admin.socket
213 %{_unitdir}/sockets.target.wants/%{service_name}-popup.socket
214 %{_unitdir}/%{service_name}-cs.socket
215 %{_unitdir}/%{service_name}-wp.socket
216 %{_unitdir}/%{service_name}-admin.socket
217 %{_unitdir}/%{service_name}-popup.socket
218
219 %dir %{ro_data_dir}/%{service_name}
220 %dir %attr(-, %{service_user}, %{service_group}) %{rw_data_dir}/%{service_name}
221 %dir %{ro_db_dir}
222 %dir %attr(-, %{service_user}, %{service_group}) %{rw_db_dir}
223 %attr(444, %{service_user}, %{service_group}) %{ro_db_dir}/*.sql
224
225 # sample engine related files
226 %dir %{sample_engine_dir}
227 %dir %{sample_engine_ro_res_dir}
228 %dir %attr(775, %{service_user}, %{service_group}) %{sample_engine_rw_working_dir}
229 %{sample_engine_dir}/lib%{service_name}-cs-engine.so
230 %{sample_engine_dir}/lib%{service_name}-wp-engine.so
231 %attr(-, %{service_user}, %{service_group}) %{sample_engine_rw_working_dir}/*
232
233 %files -n lib%{name}-common
234 %defattr(-,root,root,-)
235 %manifest %{service_name}-common.manifest
236 %{ro_data_dir}/license/lib%{name}-common
237 %{_libdir}/lib%{service_name}-common.so.*
238
239 %files -n lib%{name}-client
240 %defattr(-,root,root,-)
241 %manifest %{service_name}-client.manifest
242 %{ro_data_dir}/license/lib%{name}-client
243 %{_libdir}/lib%{service_name}-client.so.*
244
245 %files devel
246 %defattr(-,root,root,-)
247 %{_includedir}/csr/content-screening.h
248 %{_includedir}/csr/content-screening-types.h
249 %{_includedir}/csr/web-protection.h
250 %{_includedir}/csr/web-protection-types.h
251 %{_includedir}/csr/error.h
252 %{_includedir}/csr/engine-manager.h
253 %{_libdir}/pkgconfig/%{service_name}.pc
254 %{_libdir}/lib%{service_name}-client.so
255 %{_libdir}/lib%{service_name}-common.so
256
257 %files engine-devel
258 %defattr(-,root,root,-)
259 %{_includedir}/csre/content-screening-engine-info.h
260 %{_includedir}/csre/content-screening.h
261 %{_includedir}/csre/content-screening-types.h
262 %{_includedir}/csre/error.h
263 %{_includedir}/csre/web-protection-engine-info.h
264 %{_includedir}/csre/web-protection.h
265 %{_includedir}/csre/web-protection-types.h
266 %{_libdir}/pkgconfig/%{service_name}-engine.pc
267
268 %files test
269 %defattr(-,root,root,-)
270 %manifest %{service_name}-test.manifest
271 %{ro_data_dir}/license/%{name}-test
272 %{ro_data_dir}/license/%{name}-test.BSL-1.0
273 %{_libdir}/lib%{service_name}-test-common.so
274 %attr(-, %{service_user}, %{service_group}) %{bin_dir}/%{service_name}-test
275 %attr(-, %{service_user}, %{service_group}) %{bin_dir}/%{service_name}-internal-test
276 %attr(-, %{service_user}, %{service_group}) %{bin_dir}/%{service_name}-popup-test
277 %attr(-, %{service_user}, %{service_group}) %{bin_dir}/%{service_name}-threadpool-test
278 # test resources
279 %dir %attr(-, %{service_user}, %{service_group}) %{test_dir}
280 %attr(-, %{service_user}, %{service_group}) %{test_dir}/*