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