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