Add engine APIs and sample engine & tests
[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 Requires:      lib%{name}-common = %{version}-%{release}
13 %{?systemd_requires}
14
15 %description
16 General purpose content screening and reputation solution. Can scan
17 file contents and checking url to prevent malicious items.
18
19 %global service_name              csr
20 %global bin_dir                   %{_bindir}
21 %global sbin_dir                  /sbin
22 %global ro_data_dir               %{_datadir}
23 %global sample_engine_working_dir /opt/share/%{service_name}/engine
24 %global sample_engine_dir         %{_libdir}
25 %global test_dir                  /opt/share/%{service_name}-test
26
27 %package -n lib%{name}-common
28 Summary: Common library package for %{name}
29 License: Apache-2.0
30 Group:   Security/Libraries
31 Requires: %{sbin_dir}/ldconfig
32 Requires: %{sbin_dir}/ldconfig
33
34 %description -n lib%{name}-common
35 csr-framework common library package.
36
37 %package -n lib%{name}-client
38 Summary: Client library package for %{name}
39 License: Apache-2.0
40 Group:   Security/Libraries
41 BuildRequires: pkgconfig(capi-base-common)
42 Requires: %{name} = %{version}-%{release}
43 Requires: %{sbin_dir}/ldconfig
44 Requires: %{sbin_dir}/ldconfig
45
46 %description -n lib%{name}-client
47 csr-framework client library package.
48
49 %package devel
50 Summary: Development files for %{name}
51 LICENSE: Apache-2.0
52 Group:   Security/Development
53 BuildRequires: pkgconfig(capi-base-common)
54 Requires:      %{name} = %{version}-%{release}
55
56 %description devel
57 csr-framework developemnt files including headers and pkgconfig file.
58
59 %package test
60 Summary: test program for %{name}
61 License: Apache-2.0 and BSL-1.0
62 Group:   Security/Testing
63 BuildRequires: boost-devel
64 Requires:      %{name} = %{version}
65
66 %description test
67 test program of csr-framework
68
69 %prep
70 %setup -q
71
72 %build
73 %cmake . \
74     -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}%{!?build_type:RELEASE} \
75     -DCMAKE_VERBOSE_MAKEFILE=ON \
76     -DCMAKE_INSTALL_PREFIX=%{_prefix} \
77     -DSERVICE_NAME=%{service_name} \
78     -DVERSION=%{version} \
79     -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \
80     -DBIN_DIR:PATH=%{bin_dir} \
81     -DSYSTEMD_UNIT_DIR=%{_unitdir} \
82     -DSAMPLE_ENGINE_WORKING_DIR:PATH=%{sample_engine_working_dir} \
83     -DSAMPLE_ENGINE_DIR:PATH=%{sample_engine_dir} \
84     -DTEST_DIR:PATH=%{test_dir}
85
86 make %{?jobs:-j%jobs}
87
88 %install
89 %make_install
90 mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants
91 mkdir -p %{buildroot}%{_unitdir}/sockets.target.wants
92 ln -s ../%{service_name}.service %{buildroot}%{_unitdir}/multi-user.target.wants/%{service_name}.service
93 ln -s ../%{service_name}.socket %{buildroot}%{_unitdir}/sockets.target.wants/%{service_name}.socket
94
95 mkdir -p %{buildroot}%{ro_data_dir}/license
96 cp LICENSE %{buildroot}%{ro_data_dir}/license/%{name}
97 cp LICENSE.BSL-1.0 %{buildroot}%{ro_data_dir}/license/%{name}.BSL-1.0
98 cp LICENSE %{buildroot}%{ro_data_dir}/license/lib%{name}-client
99 cp LICENSE %{buildroot}%{ro_data_dir}/license/lib%{name}-common
100 cp LICENSE %{buildroot}%{ro_data_dir}/license/%{name}-test
101 cp LICENSE.BSL-1.0 %{buildroot}%{ro_data_dir}/license/%{name}-test.BSL-1.0
102
103 %post
104 systemctl daemon-reload
105 if [ $1 = 1 ]; then
106     systemctl start %{service_name}.socket
107     systemctl start %{service_name}.service
108 fi
109
110 if [ $1 = 2 ]; then
111     systemctl restart %{service_name}.socket
112     systemctl restart %{service_name}.service
113 fi
114
115 %preun
116 if [ $1 = 0 ]; then
117     systemctl stop %{service_name}.service
118     systemctl stop %{service_name}.socket
119 fi
120
121 %postun
122 if [ $1 = 0 ]; then
123     systemctl daemon-reload
124 fi
125
126 %post -n lib%{name}-common -p %{sbin_dir}/ldconfig
127 %post -n lib%{name}-client -p %{sbin_dir}/ldconfig
128 %postun -n lib%{name}-common -p %{sbin_dir}/ldconfig
129 %postun -n lib%{name}-client -p %{sbin_dir}/ldconfig
130
131 %files
132 %defattr(-,root,root,-)
133 %manifest %{service_name}.manifest
134 %{ro_data_dir}/license/%{name}
135 %{ro_data_dir}/license/%{name}.BSL-1.0
136 %{bin_dir}/%{service_name}-server
137 %{_unitdir}/multi-user.target.wants/%{service_name}.service
138 %{_unitdir}/%{service_name}.service
139 %{_unitdir}/sockets.target.wants/%{service_name}.socket
140 %{_unitdir}/%{service_name}.socket
141
142 # sample engine related files
143 %{sample_engine_dir}/lib%{service_name}-cs-engine.so
144 %{sample_engine_dir}/lib%{service_name}-wp-engine.so
145 %{sample_engine_working_dir}
146
147 %files -n lib%{name}-common
148 %defattr(-,root,root,-)
149 %manifest %{service_name}-common.manifest
150 %{ro_data_dir}/license/lib%{name}-common
151 %{_libdir}/lib%{service_name}-common.so.*
152
153 %files -n lib%{name}-client
154 %defattr(-,root,root,-)
155 %manifest %{service_name}-client.manifest
156 %{ro_data_dir}/license/lib%{name}-client
157 %{_libdir}/lib%{service_name}-client.so.*
158
159 %files devel
160 %defattr(-,root,root,-)
161 %{_includedir}/csr/csr/content-screening.h
162 %{_includedir}/csr/csr/content-screening-types.h
163 %{_includedir}/csr/csr/web-protection.h
164 %{_includedir}/csr/csr/web-protection-types.h
165 %{_includedir}/csr/csr/error.h
166 %{_includedir}/csr/csr/engine-manager.h
167 %{_libdir}/pkgconfig/%{service_name}.pc
168 %{_libdir}/lib%{service_name}-client.so
169 %{_libdir}/lib%{service_name}-common.so
170
171 %files test
172 %defattr(-,root,root,-)
173 %manifest %{service_name}-test.manifest
174 %{ro_data_dir}/license/%{name}-test
175 %{ro_data_dir}/license/%{name}-test.BSL-1.0
176 %{bin_dir}/%{service_name}-test
177 # test resources
178 %{test_dir}