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