Add crash manager API
[platform/core/system/crash-worker.git] / packaging / crash-worker.spec
1 # "on_off foo" wil turn into "ON" or "OFF"
2 %define on_off() %{expand:%%{?with_%{1}:ON}%%{!?with_%{1}:OFF}}
3
4 %define _with_tests on
5 %define _with_logdump on
6 %define _with_livedumper on
7 %define _with_crashservice on
8 %bcond_with doc
9 %bcond_with sys_assert
10 %bcond_with tests
11 %bcond_with logdump
12 %bcond_with livedumper
13 %bcond_with crashservice
14
15 # NOTE: To disable coredump set DumpCore=0 in configuration file
16
17 Name:      crash-worker
18 Summary:    Crash-manager
19 Version:    5.5.21
20 Release:    1
21 Group:      Framework/system
22 License:    Apache-2.0 and BSD
23 Source0:    %{name}-%{version}.tar.gz
24 Source1001:    crash-worker.manifest
25 BuildRequires:  pkgconfig(dlog)
26 BuildRequires:  pkgconfig(libtzplatform-config)
27 BuildRequires:  pkgconfig(iniparser)
28 BuildRequires:  pkgconfig(capi-system-info)
29 BuildRequires:  pkgconfig(glib-2.0)
30 BuildRequires:  pkgconfig(rpm)
31 BuildRequires:  cmake
32 BuildRequires:  pkgconfig(pkgmgr-info)
33
34 BuildRequires:  pkgconfig(libunwind-generic)
35 BuildRequires:  libelf-devel libelf
36 BuildRequires:  libebl-devel libebl
37 BuildRequires:  libdw-devel libdw
38
39 %if %{with doc}
40 BuildRequires:  doxygen
41 %endif
42
43 %if %{with livedumper}
44 BuildRequires:  boost-devel
45 %endif
46
47 Requires(post): coreutils
48 Requires(post): tar
49 Requires(post): gzip
50 Requires: zip
51 Requires: libelf
52 Requires: libdw
53 Requires: %{_sbindir}/minicoredumper
54 Requires: %{_bindir}/buxton2ctl
55
56 %description
57 crash-manager
58
59 %package devel
60 Requires: crash-worker
61 Summary:    Crash-manager development package
62 %description devel
63 This package provides library and header files.
64
65 %if %{with doc}
66 %package doc
67 Summary:       Documentation package for crash-worker
68 Group:         Framework/System
69
70 %description doc
71 This package provides development documentation for crash-worker.
72 %endif
73
74 %if %{with tests}
75 %package tests
76 Summary:        Package with binaries and data for crash-worker tests
77
78 %description tests
79 This package contains installable tests in Bash.
80 %endif
81
82 %if %{with livedumper}
83 %package livedumper
84 Summary:        Livedumper allows to dump core of live process
85
86 %description livedumper
87 %endif
88
89 %prep
90 %setup -q
91
92 #Path to store logs and coredump files
93 %define crash_root_path %{TZ_SYS_CRASH_ROOT}
94 %define crash_path      %{TZ_SYS_CRASH}
95 %define crash_temp      %{crash_root_path}/temp
96
97 #Debug mode path - existence of file at path below mean that core file should be generated
98 %define debugmode_path      %{TZ_SYS_ETC}/.debugmode
99
100 #Path for log_dump module
101 %define crash_all_log   %{TZ_SYS_ALLLOGS}
102 %define crash_dump_gen  %{TZ_SYS_DUMPGEN}
103
104 %define upgrade_script_path %{TZ_SYS_RO_SHARE}/upgrade/scripts
105
106 %build
107 cp %{SOURCE1001} .
108
109 export CFLAGS+=" -Werror"
110
111 %ifarch %{arm} aarch64
112         %define ARCH arm
113 %else
114         %define ARCH x86
115 %endif
116
117 %ifarch %{arm} %ix86
118         %define ARCH_BIT 32
119 %else
120         %define ARCH_BIT 64
121 %endif
122
123 %cmake . \
124            -DCMAKE_INSTALL_PREFIX=%{_prefix} \
125            -DTMP_FILES_DIR=%{_sysconfdir}/tmpfiles.d \
126            -DARCH=%{ARCH} \
127            -DARCH_BIT=%{ARCH_BIT} \
128            -DDUMP_SYSTEMSTATE_CONFIG_DIR_PATH=%{_sysconfdir}/dump_systemstate.conf.d \
129            -DCRASH_MANAGER_CONFIG_PATH=%{_sysconfdir}/crash-manager.conf \
130            -DCRASH_ROOT_PATH=%{crash_root_path} \
131            -DCRASH_PATH=%{crash_path} \
132            -DCRASH_TEMP=%{crash_temp} \
133            -DDEBUGMODE_PATH=%{debugmode_path} \
134            -DMINICOREDUMPER_BIN_PATH=%{_sbindir}/minicoredumper \
135            -DMINICOREDUMPER_CONFIG_PATH=%{_sysconfdir}/minicoredumper/minicoredumper.cfg.json \
136            -DLIVEDUMPER_BIN_PATH=%{_bindir}/livedumper \
137            -DLOG_DUMP_BIN_PATH=%{_bindir}/log_dump \
138            -DDUMP_SYSTEMSTATE_BIN_PATH=%{_bindir}/dump_systemstate \
139            -DCRASH_STACK_BIN_PATH=%{_libexecdir}/crash-stack \
140            -DCRASH_POPUP_BIN_PATH=%{_libexecdir}/crash-popup-launch \
141            -DCRASH_NOTIFY_BIN_PATH=%{_libexecdir}/crash-notify-send \
142            -DCRASH_TESTS_PATH=%{_libdir}/crash-worker-tests \
143            -DSYS_ASSERT=%{on_off sys_assert} \
144            -DLOG_DUMP=%{on_off logdump} \
145            -DLIVEDUMPER=%{on_off livedumper} \
146            -DCRASH_SERVICE=%{on_off crashservice} \
147            -DUPGRADE_SCRIPT_PATH=%{upgrade_script_path} \
148            -DLOGGER=dlog \
149            -DVERSION=%{version}
150
151 make %{?jobs:-j%jobs}
152 %if %{with doc}
153 make doc
154 %endif
155
156 %install
157 rm -rf %{buildroot}
158 %make_install
159 mkdir -p %{buildroot}%{crash_root_path}
160 mkdir -p %{buildroot}%{crash_path}
161 mkdir -p %{buildroot}%{crash_temp}
162
163 # log_dump dir
164 %if %{with logdump}
165 mkdir -p %{buildroot}%{crash_all_log}
166 mkdir -p %{buildroot}%{crash_dump_gen}
167 cp dump_scripts/* %{buildroot}%{crash_dump_gen}
168 chmod 755 %{buildroot}%{crash_dump_gen}/*
169 %endif
170
171 %post
172 %if %{with sys_assert}
173 if [ ! -d /.build ]; then
174         orig="%{_libdir}/libsys-assert.so"
175         pattern=$(echo $orig | sed -e 's|/|\\/|g')
176         ret=$(sed -n "/${pattern}/p"  %{_sysconfdir}/ld.so.preload)
177         if [ -z "$ret" ]; then
178                 echo "%{_libdir}/libsys-assert.so" >> %{_sysconfdir}/ld.so.preload
179         fi
180         chmod 644 %{_sysconfdir}/ld.so.preload
181 fi
182
183 /sbin/ldconfig
184 %endif
185
186 /usr/bin/chsmack -a "System" -t %{crash_path}
187 /usr/bin/chsmack -a "System" -t %{crash_temp}
188
189 %if %{with logdump}
190 /usr/bin/chsmack -a "System" -t %{crash_dump_gen}
191 /usr/bin/chsmack -a "System" -t %{crash_dump_gen}/module.d
192 /usr/bin/chsmack -a "System::Shared" -t %{crash_all_log}
193 /usr/bin/chsmack -a "_"  %{crash_dump_gen}/module.d/*
194 %endif
195
196 %postun
197 %if %{with sys_assert}
198 orig="%{_libdir}/libsys-assert.so"
199 pattern=$(echo $orig | sed -e 's|/|\\/|g')
200 sed -i "/${pattern}/D" %{_sysconfdir}/ld.so.preload
201 /sbin/ldconfig
202 %endif
203
204 %files
205 %license LICENSE LICENSE.BSD
206 %manifest crash-worker.manifest
207 %defattr(-,system_fw,system_fw,-)
208 %dir %{crash_root_path}
209 %dir %{crash_path}
210 %dir %{crash_temp}
211 %{_sysconfdir}/crash-manager.conf
212 %attr(-,root,root) %{_prefix}/lib/sysctl.d/70-crash-manager.conf
213 %attr(0750,system_fw,system_fw) %{_bindir}/crash-manager
214 %attr(0750,system_fw,system_fw) %{_bindir}/dump_systemstate
215 %{_sysconfdir}/dump_systemstate.conf.d/files/files.conf.example
216 %{_sysconfdir}/dump_systemstate.conf.d/programs/programs.conf.example
217 %{_libexecdir}/crash-stack
218 %{_libexecdir}/crash-popup-launch
219 %{_libexecdir}/crash-notify-send
220 %{_libdir}/libcrash-manager.so.*
221
222 %if %{with crashservice}
223 %attr(0750,system_fw,system_fw) %{_bindir}/crash-service
224 %attr(-,root,root) %{_unitdir}/crash-service.service
225 %attr(-,root,root) %{_sysconfdir}/dbus-1/system.d/crash-service.conf
226 %attr(-,root,root) %{_datadir}/dbus-1/system-services/org.tizen.system.crash.livedump.service
227 %{_libdir}/libcrash-service.so.*
228 %endif
229
230 %if %{with logdump}
231 %dir %{crash_all_log}
232 %{crash_dump_gen}/*
233 %attr(-,root,root) %{_unitdir}/log_dump.service
234 %attr(-,root,root) %{_sysconfdir}/dbus-1/system.d/log_dump.conf
235 %attr(-,root,root) %{_datadir}/dbus-1/system-services/org.tizen.system.crash.service
236 %attr(0750,system_fw,system_fw) %{_bindir}/log_dump
237 %endif
238
239 %if %{with sys_assert}
240 %{_libdir}/libsys-assert.so
241 %{_sysconfdir}/tmpfiles.d/sys-assert.conf
242 %endif
243
244 #upgrade script
245 %attr(-,root,root) %{upgrade_script_path}/500.crash-manager-upgrade.sh
246
247 %files devel
248 %{_includedir}/crash-manager.h
249 %{_libdir}/libcrash-manager.so
250 %{_datadir}/pkgconfig/crash-manager.pc
251 %if %{with crashservice}
252 %{_includedir}/libcrash-service.h
253 %{_libdir}/libcrash-service.so
254 %{_datadir}/pkgconfig/crash-service.pc
255 %endif
256
257 %if %{with doc}
258 %files doc
259 %{_datadir}/doc/crash-worker
260 %endif
261
262 %if %{with tests}
263 %files tests
264 %manifest %{name}.manifest
265 %defattr(-,root,root)
266 %{_libdir}/crash-worker-tests/test1-default-crash
267 %{_libdir}/crash-worker-tests/test1-default-sleep
268 %{_libdir}/crash-worker-tests/test1-default-ill
269 %{_libdir}/crash-worker-tests/test1-custom-crash
270 %{_libdir}/crash-worker-tests/test1-custom-sleep
271 %{_libdir}/crash-worker-tests/test1-custom-ill
272 %{_libdir}/crash-worker-tests/run_tests.sh
273 %{_libdir}/crash-worker-tests/tests_common.sh
274 %{_libdir}/crash-worker-tests/crash_common.sh
275
276 %endif
277
278 %if %{with livedumper}
279 %files livedumper
280 %manifest %{name}.manifest
281 %{_bindir}/livedumper
282 %endif