summaryrefslogtreecommitdiff
path: root/packaging/crash-worker.spec
blob: 292fd74871b554395c1bd16c3ff49e3d1c52d79f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# "on_off foo" wil turn into "ON" or "OFF"
%define on_off() %{expand:%%{?with_%{1}:ON}%%{!?with_%{1}:OFF}}

%define _with_tests on
%define _with_logdump on
%define _with_livedumper on
%bcond_with doc
%bcond_with sys_assert
%bcond_with tests
%bcond_with logdump
%bcond_with livedumper

# NOTE: To disable coredump set DumpCore=0 in configuration file

Name:      crash-worker
Summary:    Crash-manager
Version:    5.5.19
Release:    1
Group:      Framework/system
License:    Apache-2.0 and BSD
Source0:    %{name}-%{version}.tar.gz
Source1001:    crash-worker.manifest
BuildRequires:  pkgconfig(dlog)
BuildRequires:  pkgconfig(libtzplatform-config)
BuildRequires:  pkgconfig(iniparser)
BuildRequires:  pkgconfig(capi-system-info)
BuildRequires:  pkgconfig(glib-2.0)
BuildRequires:  pkgconfig(rpm)
BuildRequires:  cmake
BuildRequires:  pkgconfig(pkgmgr-info)

BuildRequires:  pkgconfig(libunwind-generic)
BuildRequires:  libelf-devel libelf
BuildRequires:  libebl-devel libebl
BuildRequires:  libdw-devel libdw

%if %{with doc}
BuildRequires:  doxygen
%endif

%if %{with livedumper}
BuildRequires:  boost-devel
%endif

Requires(post): coreutils
Requires(post): tar
Requires(post): gzip
Requires: zip
Requires: libelf
Requires: libdw
Requires: %{_sbindir}/minicoredumper
Requires: %{_bindir}/buxton2ctl

%description
crash-manager

%if %{with doc}
%package doc
Summary:       Documentation package for crash-worker
Group:         Framework/System

%description doc
This package provides development documentation for crash-worker.
%endif

%if %{with tests}
%package tests
Summary:	Package with binaries and data for crash-worker tests

%description tests
This package contains installable tests in Bash.
%endif

%if %{with livedumper}
%package livedumper
Summary:	Livedumper allows to dump core of live process

%description livedumper
%endif

%prep
%setup -q

#Path to store logs and coredump files
%define crash_root_path %{TZ_SYS_CRASH_ROOT}

#Debug mode path - existence of file at path below mean that core file should be generated
%define debugmode_path      %{TZ_SYS_ETC}/.debugmode

#Path for log_dump module
%define crash_all_log   %{TZ_SYS_ALLLOGS}

%define upgrade_script_path %{TZ_SYS_RO_SHARE}/upgrade/scripts

%build
cp %{SOURCE1001} .

export CFLAGS+=" -Werror"

%ifarch %{arm} aarch64
	%define ARCH arm
%else
	%define ARCH x86
%endif

%ifarch %{arm} %ix86
	%define ARCH_BIT 32
%else
	%define ARCH_BIT 64
%endif

%cmake . \
	   -DCMAKE_INSTALL_PREFIX=%{_prefix} \
	   -DTMP_FILES_DIR=%{_sysconfdir}/tmpfiles.d \
	   -DARCH=%{ARCH} \
	   -DARCH_BIT=%{ARCH_BIT} \
	   -DDUMP_SYSTEMSTATE_CONFIG_DIR_PATH=%{_sysconfdir}/dump_systemstate.conf.d \
	   -DCRASH_MANAGER_CONFIG_PATH=%{_sysconfdir}/crash-manager.conf \
	   -DCRASH_ROOT_PATH=%{crash_root_path} \
	   -DDEBUGMODE_PATH=%{debugmode_path} \
	   -DMINICOREDUMPER_BIN_PATH=%{_sbindir}/minicoredumper \
	   -DMINICOREDUMPER_CONFIG_PATH=%{_sysconfdir}/minicoredumper/minicoredumper.cfg.json \
	   -DLIVEDUMPER_BIN_PATH=%{_bindir}/livedumper \
	   -DLOG_DUMP_BIN_PATH=%{_bindir}/log_dump \
	   -DLOG_DUMP_SCRIPTS_PATH=%{_sysconfdir}/dump.d \
	   -DDUMP_SYSTEMSTATE_BIN_PATH=%{_bindir}/dump_systemstate \
	   -DCRASH_STACK_BIN_PATH=%{_libexecdir}/crash-stack \
	   -DCRASH_POPUP_BIN_PATH=%{_libexecdir}/crash-popup-launch \
	   -DCRASH_NOTIFY_BIN_PATH=%{_libexecdir}/crash-notify-send \
	   -DCRASH_TESTS_PATH=%{_libdir}/crash-worker-tests \
	   -DSYS_ASSERT=%{on_off sys_assert} \
	   -DLOG_DUMP=%{on_off logdump} \
	   -DLIVEDUMPER=%{on_off livedumper} \
	   -DUPGRADE_SCRIPT_PATH=%{upgrade_script_path} \
	   -DLOGGER=dlog

make %{?jobs:-j%jobs}
%if %{with doc}
make doc
%endif

%install
rm -rf %{buildroot}
%make_install
mkdir -p %{buildroot}%{crash_root_path}/{dump,livedump,temp,log}

# log_dump dir
%if %{with logdump}
mkdir -p %{buildroot}%{crash_all_log}
mkdir -p %{buildroot}%{_sysconfdir}/dump.d
install -m755 dump_scripts/* %{buildroot}%{_sysconfdir}/dump.d
%endif

%post
%if %{with sys_assert}
if [ ! -d /.build ]; then
	orig="%{_libdir}/libsys-assert.so"
	pattern=$(echo $orig | sed -e 's|/|\\/|g')
	ret=$(sed -n "/${pattern}/p"  %{_sysconfdir}/ld.so.preload)
	if [ -z "$ret" ]; then
		echo "%{_libdir}/libsys-assert.so" >> %{_sysconfdir}/ld.so.preload
	fi
	chmod 644 %{_sysconfdir}/ld.so.preload
fi

/sbin/ldconfig
%endif

/usr/bin/chsmack -a "System" -t %{crash_path}
/usr/bin/chsmack -a "System" -t %{crash_temp}

%if %{with logdump}
/usr/bin/chsmack -a "System" -t %{crash_dump_gen}
/usr/bin/chsmack -a "System" -t %{crash_dump_gen}/module.d
/usr/bin/chsmack -a "System::Shared" -t %{crash_all_log}
/usr/bin/chsmack -a "_"  %{crash_dump_gen}/module.d/*
%endif

%postun
%if %{with sys_assert}
orig="%{_libdir}/libsys-assert.so"
pattern=$(echo $orig | sed -e 's|/|\\/|g')
sed -i "/${pattern}/D" %{_sysconfdir}/ld.so.preload
/sbin/ldconfig
%endif

%files
%license LICENSE LICENSE.BSD
%manifest crash-worker.manifest
%defattr(-,system_fw,system_fw,-)
%dir %{crash_root_path}
%dir %{crash_path}
%dir %{crash_temp}
%{_sysconfdir}/crash-manager.conf
%attr(-,root,root) %{_prefix}/lib/sysctl.d/70-crash-manager.conf
%attr(0750,system_fw,system_fw) %{_bindir}/crash-manager
%attr(0750,system_fw,system_fw) %{_bindir}/dump_systemstate
%{_sysconfdir}/dump_systemstate.conf.d/files/files.conf.example
%{_sysconfdir}/dump_systemstate.conf.d/programs/programs.conf.example
%{_libexecdir}/crash-stack
%{_libexecdir}/crash-popup-launch
%{_libexecdir}/crash-notify-send

%if %{with logdump}
%dir %{crash_all_log}
%{_sysconfdir}/dump.d/module_log.sh
%{_sysconfdir}/dump.d/move_dump.sh
%{_sysconfdir}/dump.d/system_log.sh
%{_sysconfdir}/dump.d/zz_legacy.sh
%attr(-,root,root) %{_unitdir}/log_dump.service
%attr(-,root,root) %{_sysconfdir}/dbus-1/system.d/log_dump.conf
%attr(-,root,root) %{_datadir}/dbus-1/system-services/org.tizen.system.crash.service
%attr(0750,system_fw,system_fw) %{_bindir}/log_dump
%endif

%if %{with sys_assert}
%{_libdir}/libsys-assert.so
%{_sysconfdir}/tmpfiles.d/sys-assert.conf
%endif

#upgrade script
%attr(-,root,root) %{upgrade_script_path}/500.crash-manager-upgrade.sh

%if %{with doc}
%files doc
%{_datadir}/doc/crash-worker
%endif

%if %{with tests}
%files tests
%manifest %{name}.manifest
%defattr(-,root,root)
%{_libdir}/crash-worker-tests/test1-default-crash
%{_libdir}/crash-worker-tests/test1-default-sleep
%{_libdir}/crash-worker-tests/test1-default-ill
%{_libdir}/crash-worker-tests/test1-custom-crash
%{_libdir}/crash-worker-tests/test1-custom-sleep
%{_libdir}/crash-worker-tests/test1-custom-ill
%{_libdir}/crash-worker-tests/run_tests.sh
%{_libdir}/crash-worker-tests/tests_common.sh
%{_libdir}/crash-worker-tests/crash_common.sh

%endif

%if %{with livedumper}
%files livedumper
%manifest %{name}.manifest
%{_bindir}/livedumper
%endif