tizen 2.3 release
[kernel/api/system-resource.git] / packaging / system-resource.spec
1 Name:       system-resource
2 Summary:    System Resource Information
3 Version:    0.2.86
4 Release:    0
5 VCS:        magnolia/kernel/api/system-resource#submit/master/20131010.041510-19-gcf6121a4bcce9c122d4ea05fa9974ec7bac227d8
6 Group:      System/Libraries
7 License:    Apache License, Version 2.0
8 Source0:    %{name}-%{version}.tar.gz
9 Source1:    resourced.service
10 Source2:    resourced-zram.service
11 Source5:    resourced_swapoff.service
12 Source6:    resourced-cpucgroup.service
13 Source8:    resourced-logging.service
14
15 %define powertop_state OFF
16 %define cpu_module ON
17 %define vip_agent_module ON
18 %define timer_slack ON
19 %define logging_module OFF
20 %define logging_memory OFF
21 %define logging_cpu OFF
22 %define memory_module ON
23 %define memory_cgroup OFF
24
25 %if "%{?tizen_profile_name}" == "mobile"
26         %define swap_module OFF
27         %define network_state ON
28         %define network_service OFF
29         %define telephony_feature OFF
30         %define tethering_feature OFF
31
32 %endif
33
34 %if "%{?tizen_profile_name}" == "wearable"
35         %define swap_module OFF
36         %define network_state ON
37         %define network_service OFF
38         %define telephony_feature OFF
39
40 %endif
41
42 %if 0%{?tizen_build_binary_release_type_eng}
43         %define memory_eng ON
44 %else
45         %define memory_eng OFF
46 %endif
47
48 %define exclude_list_file_name resourced_proc_exclude.ini
49 %define exclude_list_full_path /usr/etc/%{exclude_list_file_name}
50 %define exclude_list_opt_full_path /opt/usr/etc/%{exclude_list_file_name}
51 %define database_full_path /opt/usr/dbspace/.resourced-datausage.db
52
53 BuildRequires:  cmake
54 BuildRequires:  pkgconfig(glib-2.0)
55 BuildRequires:  pkgconfig(dlog)
56 BuildRequires:  pkgconfig(sqlite3)
57 BuildRequires:  pkgconfig(vconf)
58 BuildRequires:  pkgconfig(vconf-internal-keys)
59 BuildRequires:  pkgconfig(ecore)
60 BuildRequires:  pkgconfig(ecore-file)
61 BuildRequires:  pkgconfig(eina)
62 BuildRequires:  pkgconfig(edbus)
63 BuildRequires:  pkgconfig(capi-network-connection)
64 BuildRequires:  pkgconfig(libsystemd-daemon)
65 BuildRequires:  pkgconfig(journal)
66
67 Requires(post): /sbin/ldconfig
68 Requires(postun): /sbin/ldconfig
69 Requires: system-resource-resourced = %{version}-%{release}
70 Requires: libresourced = %{version}-%{release}
71
72 %if %{?logging_module} == ON
73 BuildRequires:  pkgconfig(libsystemd-journal)
74 %endif
75
76 %description
77
78 %package resourced
79 Summary: Resource Daemon
80 Group:   System/Libraries
81 Requires:   %{name} = %{version}-%{release}
82
83 %description resourced
84 Resource Daemon
85
86 %package -n libresourced
87 Summary: Resource Daemon Library
88 Group:   System/Libraries
89 Requires:   %{name} = %{version}-%{release}
90
91 %description -n libresourced
92 Resource Daemon Library
93
94 %package -n libresourced-devel
95 Summary: Resource Daemon Library (Development)
96 Group:   System/Libraries
97 Requires:   %{name} = %{version}-%{release}
98
99 %description -n libresourced-devel
100 Resource Daemon Library (Development)
101
102 %prep
103 %setup -q
104
105 %build
106 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
107 MINORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $2}'`
108 PATCHVER=`echo %{version} | awk 'BEGIN {FS="."}{print $3}'`
109 echo "\
110 /* That file was generated automaticaly. Don't edit it */
111 #define MINOR_VERSION ${MINORVER}
112 #define MAJOR_VERSION ${MAJORVER}
113 #define PATCH_VERSION ${PATCHVER}" > src/common/version.h
114
115 %if 0%{?tizen_build_binary_release_type_eng}
116         CFLAGS+=" -DTIZEN_ENGINEER_MODE"
117 %endif
118
119 export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
120 export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
121 export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
122
123 cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DCMAKE_BUILD_TYPE=Release \
124         -DEXCLUDE_LIST_FILE_NAME=%{exclude_list_file_name} \
125         -DEXCLUDE_LIST_FULL_PATH=%{exclude_list_full_path} -DDATABASE_FULL_PATH=%{database_full_path} \
126         -DEXCLUDE_LIST_OPT_FULL_PATH=%{exclude_list_opt_full_path} -DNETWORK_MODULE=%{network_state} -DNETWORK_SERVICE=%{network_service} \
127         -DSWAP_MODULE=%{swap_module} -DPOWERTOP_MODULE=%{powertop_state} -DCPU_MODULE=%{cpu_module}\
128         -DMEMORY_ENG=%{memory_eng} -DVIP_AGENT=%{vip_agent_module} -DTELEPHONY_FEATURE=%{telephony_feature} \
129         -DTIMER_SLACK=%{timer_slack} -DLOGGING_MODULE=%{logging_module} -DLOGGING_MEMORY=%{logging_memory} \
130         -DLOGGING_CPU=%{logging_cpu} -DDATAUSAGE_TYPE=NFACCT -DMEMORY_MODULE=%{memory_module} -DMEMORY_CGROUP=%{memory_cgroup}  \
131         -DTETHERING_FEATURE=%{tethering_feature}
132
133 make %{?jobs:-j%jobs}
134
135 %install
136 rm -rf %{buildroot}
137 mkdir -p %{buildroot}/usr/share/license
138 cp -f LICENSE %{buildroot}/usr/share/license/%{name}
139 cp -f LICENSE %{buildroot}/usr/share/license/%{name}-resourced
140 cp -f LICENSE %{buildroot}/usr/share/license/libresourced
141
142 %make_install
143
144 %if %{?network_state} == ON
145         mkdir -p %{buildroot}/opt/usr/dbspace
146         sqlite3 %{buildroot}%{database_full_path} < %{buildroot}/usr/share/traffic_db.sql
147         rm %{buildroot}/usr/share/traffic_db.sql
148 %endif
149
150 mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants
151 %if %{?swap_module} == ON
152 install -m 0644 %SOURCE1 %{buildroot}%{_libdir}/systemd/system/resourced.service
153 ln -s ../resourced.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/resourced.service
154
155 mkdir -p %{buildroot}%{_libdir}/systemd/system/graphical.target.wants
156 install -m 0644 %SOURCE2 %{buildroot}%{_libdir}/systemd/system/resourced-zram.service
157 ln -s ../resourced-zram.service %{buildroot}%{_libdir}/systemd/system/graphical.target.wants/resourced-zram.service
158 %else
159 install -m 0644 %SOURCE5 %{buildroot}%{_libdir}/systemd/system/resourced.service
160 ln -s ../resourced.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/resourced.service
161 %endif
162
163 %if %{?cpu_module} == OFF
164 mkdir -p %{buildroot}%{_libdir}/systemd/system/graphical.target.wants
165 install -m 0644 %SOURCE6 %{buildroot}%{_libdir}/systemd/system/resourced-cpucgroup.service
166 ln -s ../resourced-cpucgroup.service %{buildroot}%{_libdir}/systemd/system/graphical.target.wants/resourced-cpucgroup.service
167 %endif
168
169 #powertop-wrapper part
170 %if %{?powertop_state} == ON
171 mkdir -p %{buildroot}/usr/share/powertop-wrapper/
172 cp -p %_builddir/%name-%version/src/powertop-wrapper/header.html %{buildroot}/usr/share/powertop-wrapper
173 %endif
174
175 %if %{?logging_module} == ON
176 #logging service file
177 mkdir -p %{buildroot}%{_libdir}/systemd/system/graphical.target.wants
178 install -m 0644 %SOURCE8 %{buildroot}%{_libdir}/systemd/system/resourced-logging.service
179 ln -s ../resourced-logging.service %{buildroot}%{_libdir}/systemd/system/graphical.target.wants/resourced-logging.service
180 %endif
181
182 %pre resourced
183 if [ "$1" = "2" ]; then # upgrade begins
184         systemctl stop resourced.service
185 fi
186
187 %post -p /sbin/ldconfig
188
189 %post resourced
190
191 init_vconf()
192 {
193         vconftool set -t bool db/private/resourced/wifi_statistics 1 -i -f -s resourced
194         vconftool set -t bool db/private/resourced/datacall 1 -i -f -s resourced
195         vconftool set -t bool db/private/resourced/datacall_logging 1 -i -f -s resourced
196         vconftool set -t int db/private/resourced/datausage_timer 60 -i -f -s resourced
197         vconftool set -t string db/private/resourced/new_limit "" -u 5000 -f -s resourced
198         vconftool set -t string db/private/resourced/delete_limit "" -u 5000 -f -s resourced
199 }
200
201 %if %{?network_state} == ON
202         init_vconf
203 %endif
204 #install init.d script
205 mkdir -p /opt/usr/etc
206 #make empty dynamic exclude list for first installation
207 touch %{exclude_list_opt_full_path}
208
209 if [ "$1" = "2" ]; then # upgrade begins
210         systemctl start resourced.service
211 fi
212
213 %postun -p /sbin/ldconfig
214
215 %files
216 /usr/share/license/%{name}
217 %manifest system-resource.manifest
218 %files resourced
219 /usr/share/license/%{name}-resourced
220 %attr(-,root, root) %{_bindir}/resourced
221 %if %{?network_state} == ON
222         %config(noreplace) %attr(660,root,app) %{database_full_path}
223         %config(noreplace) %attr(660,root,app) %{database_full_path}-journal
224         /usr/bin/datausagetool
225         %manifest resourced.manifest
226 %else
227 %manifest resourced_nodb.manifest
228 %endif
229 %config %{_sysconfdir}/dbus-1/system.d/resourced.conf
230 %{_libdir}/systemd/system/resourced.service
231 %{_libdir}/systemd/system/multi-user.target.wants/resourced.service
232 /etc/resourced/memory.conf
233 %if %{?cpu_module} == ON
234 /etc/resourced/cpu.conf
235 %else
236 %{_bindir}/resourced-cpucgroup.sh
237 %{_libdir}/systemd/system/resourced-cpucgroup.service
238 %{_libdir}/systemd/system/graphical.target.wants/resourced-cpucgroup.service
239 %endif
240 %if %{?swap_module} == ON
241 %{_libdir}/systemd/system/resourced-zram.service
242 %{_libdir}/systemd/system/graphical.target.wants/resourced-zram.service
243 %{_bindir}/resourced-zram.sh
244 %endif
245 %if %{?logging_module} == ON
246 %{_libdir}/systemd/system/resourced-logging.service
247 %{_libdir}/systemd/system/graphical.target.wants/resourced-logging.service
248 %endif
249 %if %{?vip_agent_module} == ON
250 /etc/resourced/vip-process.conf
251 %attr(-,root, root) %{_bindir}/vip-release-agent
252 %endif
253 %if %{?timer_slack} == ON
254 /etc/resourced/timer-slack.conf
255 %endif
256 %{exclude_list_full_path}
257 %if %{?powertop_state} == ON
258 /usr/share/powertop-wrapper/header.html
259 %endif
260
261 #memps
262 %attr(-,root, root) %{_bindir}/memps
263
264 %files -n libresourced
265 %manifest libresourced.manifest
266 %defattr(-,root,root,-)
267 /usr/share/license/libresourced
268 #proc-stat part
269 %{_libdir}/libproc-stat.so.*
270 #network part
271 %if %{?network_state} == ON
272 %{_libdir}/libresourced.so.*
273 %{_libdir}/librd-network.so.*
274 %endif
275 #powertop-wrapper part
276 %if %{?powertop_state} == ON
277 %{_libdir}/libpowertop-wrapper.so.*
278 %endif
279
280 %files -n libresourced-devel
281 %defattr(-,root,root,-)
282 %{_libdir}/pkgconfig/*.pc
283 %{_includedir}/system/resourced.h
284 #proc-stat part
285 %{_includedir}/system/proc_stat.h
286 %{_libdir}/libproc-stat.so
287 #network part
288 %if %{?network_state} != OFF
289 %{_includedir}/system/data_usage.h
290 %{_includedir}/system/rd-network.h
291 %{_libdir}/libresourced.so
292 %{_libdir}/librd-network.so
293 /etc/resourced/network.conf
294 %endif
295 #powertop-wrapper part
296 %if %{?powertop_state} == ON
297 %{_includedir}/system/powertop-dapi.h
298 %{_libdir}/libpowertop-wrapper.so
299 %endif