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