Name: pkgmgr-info
Summary: Packager Manager infomation api for package
-Version: 0.22.7
+Version: 0.23.2
Release: 1
Group: Application Framework/Package Management
License: Apache-2.0
BuildRequires: pkgconfig(cynara-client-async)
BuildRequires: pkgconfig(cynara-session)
BuildRequires: pkgconfig(cynara-creds-socket)
+BuildRequires: pkgconfig(capi-system-resource)
+BuildRequires: pkgconfig(tizen-database)
%if 0%{?gcov:1}
BuildRequires: lcov
%description common-devel
Dev package for libpkgmgr_common
+%if 0%{?asan} != 1
+%package unittests
+Summary: %{name} unittests binary
+
+%description unittests
+unittest binary
+%endif
+
%prep
%setup -q
cp %{SOURCE1001} .
%endif
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DUNITDIR=%{_unitdir}
+%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DUNITDIR=%{_unitdir} \
+%if 0%{?asan} != 1
+ -DASAN_ENABLED=FALSE
+%else
+ -DASAN_ENABLED=TRUE
+%endif
%__make %{?jobs:-j%jobs}
-%if 0%{?gcov:1}
-mkdir -p gcov-obj
-find . -name '*.gcno' ! -path './gcov-obj/*' -exec cp '{}' gcov-obj ';'
-%endif
-
%check
export LD_LIBRARY_PATH=../../src/:../../src/server:../../parser
ctest -V
%if 0%{?gcov:1}
-lcov -c --ignore-errors graph --no-external -q -d . -o pkgmgr-info.info
-genhtml pkgmgr-info.info -o pkgmgr-info.out
-zip -r pkgmgr-info.zip pkgmgr-info.out
-install -m 0644 pkgmgr-info.zip %{buildroot}%{_datadir}/gcov/
+lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.info
+genhtml %{name}.info -o out --legend --show-details
%endif
%install
%make_install
+%if 0%{?gcov:1}
+builddir=$(basename $PWD)
+gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir"
+mkdir -p "$gcno_obj_dir"
+find . -name '*.gcno' -exec cp --parents '{}' "$gcno_obj_dir" ';'
+%endif
+
+%if 0%{?asan} != 1
+cat << EOF > run-unittest.sh
+#!/bin/sh
+
+setup() {
+ echo "setup start"
+}
+
+test_main() {
+ echo "test_main start"
+ /usr/bin/pkgmgr-info-unit-test
+}
+
+teardown() {
+ echo "teardown start"
+}
+
+main() {
+ setup
+ test_main
+ teardown
+}
+
+main "\$*"
+EOF
+
+mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name}
+install -m 0755 run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}/
+%endif
+
mkdir -p %{buildroot}%{_unitdir}/basic.target.wants
ln -sf ../pkg-db-recovery.service %{buildroot}%{_unitdir}/basic.target.wants/pkg-db-recovery.service
ln -s ../%{name}.service %{buildroot}%{_unitdir}/basic.target.wants/%{name}.service
ln -sf ../%{name}.socket %{buildroot}%{_unitdir}/sockets.target.wants/%{name}.socket
-%if 0%{?gcov:1}
-mkdir -p %{buildroot}%{_datadir}/gcov/obj/%{name}
-install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj/%{name}
-%endif
-
%post
/sbin/ldconfig
%if 0%{?gcov:1}
%files gcov
%defattr(-,root,root,-)
-%{_datadir}/gcov/*
+%{_datadir}/gcov/obj/*
+%endif
+
+%if 0%{?asan} != 1
+%files unittests
+%{_bindir}/pkgmgr-info-unit-test
+%{_bindir}/tizen-unittests/%{name}/run-unittest.sh
%endif