Fix build issue for unittest
[platform/core/api/app-manager.git] / packaging / capi-appfw-app-manager.spec
1 Name:       capi-appfw-app-manager
2 Summary:    Application Manager API
3 Version:    0.13.6
4 Release:    1
5 Group:      Application Framework/API
6 License:    Apache-2.0
7 Source0:    %{name}-%{version}.tar.gz
8 BuildRequires:  cmake
9 BuildRequires:  pkgconfig(dlog)
10 BuildRequires:  pkgconfig(vconf)
11 BuildRequires:  pkgconfig(aul)
12 BuildRequires:  pkgconfig(pkgmgr)
13 BuildRequires:  pkgconfig(pkgmgr-info)
14 BuildRequires:  pkgconfig(capi-base-common)
15 BuildRequires:  pkgconfig(glib-2.0)
16 BuildRequires:  pkgconfig(cynara-client)
17 BuildRequires:  pkgconfig(gmock)
18
19 Requires(post): /sbin/ldconfig
20 Requires(postun): /sbin/ldconfig
21
22 %if 0%{?gcov:1}
23 BuildRequires:  lcov
24 BuildRequires:  zip
25 %endif
26
27 %description
28 The Application Manager API provides functions to get information about running applications.
29
30 %package devel
31 Summary:  Application Manager API (Development)
32 Group:    Application Framework/Libraries
33 Requires: %{name} = %{version}
34
35 %description devel
36 The Application Manager API provides functions to get information about running applications. (DEV)
37
38 %package unittests
39 Summary:    GTest for app-manager API
40 Group:      Development/Libraries
41 Requires:   %{name}
42
43 %description unittests
44 GTest for app-manager API
45
46 %if 0%{?gcov:1}
47 %package gcov
48 Summary:  Application Manager API(gcov)
49 Group:    Application Framework/API
50
51 %description gcov
52 gcov objects for an application manager library
53 %endif
54
55 %prep
56 %setup -q
57
58
59 %build
60 %if 0%{?gcov:1}
61 export CFLAGS+=" -fprofile-arcs -ftest-coverage"
62 export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
63 export FFLAGS+=" -fprofile-arcs -ftest-coverage"
64 export LDFLAGS+=" -lgcov"
65 %endif
66
67 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
68 %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
69 %__make %{?jobs:-j%jobs}
70
71 %check
72 export LD_LIBRARY_PATH="../../src"
73 ctest --verbose %{?_smp_mflags}
74 %if 0%{?gcov:1}
75 lcov -c --ignore-errors mismatch,graph,unused --no-external -q -d . -o app-manager.info
76 genhtml app-manager.info -o app-manager.out
77 zip -r app-manager.zip app-manager.out
78 install -m 0644 app-manager.zip %{buildroot}%{_datadir}/gcov/
79 %endif
80
81 %install
82 rm -rf %{buildroot}
83 %make_install
84
85 %if 0%{?gcov:1}
86 builddir=$(basename $PWD)
87 gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir"
88 mkdir -p "$gcno_obj_dir"
89 find . -name '*.gcno' -exec cp --parents '{}' "$gcno_obj_dir" ';'
90 %endif
91
92 cat << EOF > run-unittest.sh
93 #!/bin/sh
94 GCOV_PATH="/tmp/home/abuild/rpmbuild/BUILD"
95 PAKCAGE="%{name}-%{version}"
96
97 set_perm() {
98     ## Sets the permission for applications
99     /usr/bin/find /tmp/home/ -print | /usr/bin/xargs -n1 /usr/bin/chsmack -a "System::Run" &> /dev/null
100     /usr/bin/find /tmp/home/ -print | /usr/bin/xargs -n1 /usr/bin/chsmack -a "System::Run" -t &> /dev/null
101     /usr/bin/chmod -R 777 /tmp/home/
102 }
103
104 setup() {
105     echo "setup start"
106     /usr/bin/mkdir -p "${GCOV_PATH}/${PACKAGE}"
107     set_perm
108 }
109
110 test_main() {
111     echo "test_main start"
112     export "GCOV_PREFIX=/tmp"
113     /usr/bin/app-manager_unittests
114 }
115
116 teardown() {
117     echo "teardown start"
118     set_perm
119 }
120
121 main() {
122     setup
123     test_main
124     teardown
125 }
126
127 main "\$*"
128 EOF
129
130 mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name}
131 install -m 0755 run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}/
132
133 %post -p /sbin/ldconfig
134
135 %postun -p /sbin/ldconfig
136
137
138 %files
139 %{_libdir}/libcapi-appfw-app-manager.so.*
140 %{_bindir}/appmgr_tool
141 %manifest %{name}.manifest
142 %license LICENSE
143
144 %files devel
145 %{_includedir}/appfw/*.h
146 %{_libdir}/libcapi-appfw-app-manager.so
147 %{_libdir}/pkgconfig/*.pc
148
149 %files unittests
150 %{_bindir}/app-manager_unittests
151 %{_bindir}/tizen-unittests/%{name}/run-unittest.sh
152
153 %if 0%{?gcov:1}
154 %files gcov
155 %{_datadir}/gcov/*
156 %endif