Fix gcov path
[platform/upstream/csr-framework.git] / packaging / csr-framework.spec
index 8ffadf9..8b3955c 100644 (file)
 %define with_detailed_base_url 0
 %define detailed_base_url %nil
 
-%define with_sample_engine 0
+%define with_sample_engine 1
 
 Summary: A general purpose content screening and reputation solution
 Name: csr-framework
-Version: 2.1.0
+Version: 2.3.7
 Release: 0
 Source: %{name}-%{version}.tar.gz
 License: Apache-2.0 and BSL-1.0
@@ -31,7 +31,7 @@ URL: http://tizen.org
 BuildRequires: cmake
 BuildRequires: gettext-tools
 BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(libsystemd-daemon)
+BuildRequires: pkgconfig(libsystemd)
 BuildRequires: pkgconfig(vconf)
 BuildRequires: pkgconfig(sqlite3)
 BuildRequires: pkgconfig(pkgmgr)
@@ -41,11 +41,8 @@ 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}
 
@@ -66,38 +63,25 @@ file contents and checking url to prevent malicious items.
 %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}
-%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: Common library package for %{name}
+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
-csr-framework common library package.
+Content Screening and Reputation framework package (common library)
 
 %package -n lib%{name}-client
-Summary: Client library package for %{name}
+Summary: CSR framework (client library)
 License: Apache-2.0
 Group:   Security/Libraries
 BuildRequires: pkgconfig(capi-base-common)
@@ -105,37 +89,51 @@ Requires: %{name} = %{version}-%{release}
 Requires: %{sbin_dir}/ldconfig
 
 %description -n lib%{name}-client
-csr-framework client library package.
+Content Screening and Reputation framework package (client library)
 
 %package devel
-Summary: Development files for %{name}
+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
-csr-framework development files including headers and pkgconfig file.
+Content Screening and Reputation framework development files like headers and pkgconfigs
 
 %package engine-devel
-Summary: Development files for %{name} engine
+Summary: CSR framework (engine development files)
 LICENSE: Apache-2.0
 Group:   Security/Development
 
 %description engine-devel
-csr-framework engine development files including headers and pkgconfig file.
+Content Screening and Reputation framework engine development files like headers and
+pkgconfigs
 
 %package test
-Summary: test program for %{name}
+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:      boost-test
 Requires:      %{name} = %{version}
 
 %description test
-test program of csr-framework
+Content Screening and Reputation framework (test program)
+
+%if 0%{?gcov:1}
+%package gcov
+Summary: CSR framework (gcov)
+Group:   Security/Testing
+BuildRequires: lcov
+
+%description gcov
+Content Screening and Reputation framework (gcov)
+%endif
 
 %prep
 %setup -q
@@ -149,6 +147,13 @@ test program of csr-framework
 %define test_target target
 %endif
 
+%if 0%{?gcov:1}
+export CFLAGS+=" -fprofile-arcs -ftest-coverage"
+export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
+export FFLAGS+=" -fprofile-arcs -ftest-coverage"
+export LDFLAGS+=" -lgcov"
+%endif
+
 %cmake . \
     -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}%{!?build_type:RELEASE} \
     -DCMAKE_VERBOSE_MAKEFILE=ON \
@@ -182,31 +187,24 @@ test program of csr-framework
 %else
     -DWITH_SAMPLE_ENGINE:BOOL=OFF \
 %endif
-%if "%{?tizen_version}" == "3.0"
-    -DPLATFORM_VERSION_3:BOOL=ON
-%else
-    -DPLATFORM_VERSION_3:BOOL=OFF
-%endif
+    -DTZ_SYS_STORAGE=%TZ_SYS_STORAGE \
+    -DTZ_SYS_RW_APP=%TZ_SYS_RW_APP \
+    -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP \
+    -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0}
 
 make %{?jobs:-j%jobs}
 
+%if 0%{?gcov:1}
+mkdir -p gcov-obj
+find . -name '*.gcno' -exec cp '{}' gcov-obj ';'
+%endif
+
 %install
 %make_install
-mkdir -p %{buildroot}%{_unitdir}/sockets.target.wants
-mkdir -p %{buildroot}%{popup_unitdir}/sockets.target.wants
-ln -s ../%{service_name}-cs.socket %{buildroot}%{_unitdir}/sockets.target.wants/%{service_name}-cs.socket
-ln -s ../%{service_name}-wp.socket %{buildroot}%{_unitdir}/sockets.target.wants/%{service_name}-wp.socket
-ln -s ../%{service_name}-admin.socket %{buildroot}%{_unitdir}/sockets.target.wants/%{service_name}-admin.socket
-ln -s ../%{service_name}-popup.socket %{buildroot}%{popup_unitdir}/sockets.target.wants/%{service_name}-popup.socket
-
-mkdir -p %{buildroot}%{ro_data_dir}/license
-cp LICENSE %{buildroot}%{ro_data_dir}/license/%{name}
-cp LICENSE.BSL-1.0 %{buildroot}%{ro_data_dir}/license/%{name}.BSL-1.0
-cp LICENSE %{buildroot}%{ro_data_dir}/license/lib%{name}-client
-cp LICENSE %{buildroot}%{ro_data_dir}/license/lib%{name}-common
-
-cp LICENSE %{buildroot}%{ro_data_dir}/license/%{name}-test
-cp LICENSE.BSL-1.0 %{buildroot}%{ro_data_dir}/license/%{name}-test.BSL-1.0
+%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}
@@ -215,6 +213,13 @@ cp data/scripts/*.sql %{buildroot}%{ro_db_dir}
 mkdir -p %{buildroot}%{engine_dir}
 mkdir -p %{buildroot}%{engine_rw_working_dir}
 
+%find_lang %{service_name}
+
+%if 0%{?gcov:1}
+mkdir -p %{buildroot}%{_datadir}/gcov/obj
+install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj/%{name}
+%endif
+
 %post
 rm -f %{rw_db_dir}/.%{service_name}.db*
 
@@ -223,33 +228,29 @@ 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}-popup.socket
-
     systemctl start %{service_name}.service
-    systemctl start %{service_name}-popup.service
-fi
 
-if [ $1 = 2 ]; then
+    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 stop %{service_name}-popup.socket
-
-    systemctl stop %{service_name}-popup.service
-    systemctl stop %{service_name}.service
-
     systemctl restart %{service_name}.service
-    systemctl restart %{service_name}-popup.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}-popup.service
-    systemctl stop %{service_name}.service
     systemctl stop %{service_name}-cs.socket
     systemctl stop %{service_name}-wp.socket
     systemctl stop %{service_name}-admin.socket
-    systemctl stop %{service_name}-popup.socket
+    systemctl stop %{service_name}.service
+
+    systemctl --user stop %{service_name}-popup.socket
+    systemctl --user stop %{service_name}-popup.service
 fi
 
 %postun
@@ -264,12 +265,28 @@ fi
 
 %post -n %{name}-test
 chsmack -a "_" %{test_dir}/test_dir/dir1
+%if 0%{?with_sample_engine}
+systemctl stop %{service_name}-cs.socket
+systemctl stop %{service_name}-wp.socket
+systemctl stop %{service_name}-admin.socket
+systemctl restart %{service_name}.service
+
+touch %{engine_rw_working_dir}/csret_cs_virus_signatures
+touch %{engine_rw_working_dir}/csret_wp_risky_urls
+%endif
 
-%files
+%if 0%{?gcov:1}
+chmod 777 -R /tmp/home/abuild/rpmbuild/BUILD/csr-framework-*
+su - owner -c %{bin_dir}/%{service_name}-test
+%{bin_dir}/%{service_name}-internal-test
+%{bin_dir}/%{service_name}-threadpool-test
+%endif
+
+%files -f %{service_name}.lang
 %defattr(-,root,root,-)
 %manifest %{service_name}.manifest
-%{ro_data_dir}/license/%{name}
-%{ro_data_dir}/license/%{name}.BSL-1.0
+%license LICENSE
+%license LICENSE.BSL-1.0
 %{bin_dir}/%{service_name}-server
 %{bin_dir}/%{service_name}-popup
 %{_unitdir}/%{service_name}.service
@@ -282,7 +299,6 @@ chsmack -a "_" %{test_dir}/test_dir/dir1
 %{popup_unitdir}/%{service_name}-popup.socket
 %{popup_unitdir}/sockets.target.wants/%{service_name}-popup.socket
 %{popup_unitdir}/%{service_name}-popup.service
-%{ro_data_dir}/locale/*
 %{ro_res_dir}/default-icon.png
 
 %dir %{ro_data_dir}/%{service_name}
@@ -297,13 +313,13 @@ chsmack -a "_" %{test_dir}/test_dir/dir1
 %files -n lib%{name}-common
 %defattr(-,root,root,-)
 %manifest %{service_name}-common.manifest
-%{ro_data_dir}/license/lib%{name}-common
+%license LICENSE
 %{_libdir}/lib%{service_name}-common.so.*
 
 %files -n lib%{name}-client
 %defattr(-,root,root,-)
 %manifest %{service_name}-client.manifest
-%{ro_data_dir}/license/lib%{name}-client
+%license LICENSE
 %{_libdir}/lib%{service_name}-client.so.*
 
 %files devel
@@ -332,8 +348,8 @@ chsmack -a "_" %{test_dir}/test_dir/dir1
 %files test
 %defattr(-,root,root,-)
 %manifest %{service_name}-test.manifest
-%{ro_data_dir}/license/%{name}-test
-%{ro_data_dir}/license/%{name}-test.BSL-1.0
+%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
@@ -341,11 +357,11 @@ chsmack -a "_" %{test_dir}/test_dir/dir1
 %attr(-, %{test_user}, %{service_group}) %{bin_dir}/%{service_name}-threadpool-test
 
 # test resources
-%dir %attr(777, %{test_user}, %{service_group}) %{test_dir}
-%attr(777, %{test_user}, %{service_group}) %{test_dir}/*
+%dir %attr(-, %{test_user}, %{service_group}) %{test_dir}
+%attr(-, %{test_user}, %{service_group}) %{test_dir}/*
 
-%dir %attr(777, %{test_user}, %{service_group}) %{test_res_dir}
-%attr(777, %{test_user}, %{service_group}) %{test_res_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}
@@ -353,3 +369,8 @@ chsmack -a "_" %{test_dir}/test_dir/dir1
 %{engine_dir}/lib%{service_name}-wp-engine.so
 %attr(-, %{service_user}, %{service_group}) %{engine_rw_working_dir}/*
 %endif
+
+%if 0%{?gcov:1}
+%files gcov
+%{_datadir}/gcov/obj/*
+%endif