summaryrefslogtreecommitdiff
path: root/packaging/crash-worker.spec
blob: 904e238a7161e3da232a763163ec8f78397ba521 (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
# "on_off foo" wil turn into "ON" or "OFF"
%define on_off() %{expand:%%{?with_%{1}:ON}%%{!?with_%{1}:OFF}}

%define _with_tests on
%bcond_with doc
%bcond_with sys_assert
%bcond_with tests

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

Name:      crash-worker
Summary:    Crash-manager
Version:    5.5.6
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

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

%prep
%setup -q

#Path to store logs and coredump files
%define crash_root_path %{TZ_SYS_CRASH_ROOT}
%define crash_path      %{TZ_SYS_CRASH}
%define crash_temp      %{crash_root_path}/temp

#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 crash_dump_gen  %{TZ_SYS_DUMPGEN}

%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} \
	   -DCRASH_MANAGER_CONFIG_PATH=%{_sysconfdir}/crash-manager.conf \
	   -DCRASH_ROOT_PATH=%{crash_root_path} \
	   -DCRASH_PATH=%{crash_path} \
	   -DCRASH_TEMP=%{crash_temp} \
	   -DDEBUGMODE_PATH=%{debugmode_path} \
	   -DMINICOREDUMPER_BIN_PATH=%{_sbindir}/minicoredumper \
	   -DMINICOREDUMPER_CONFIG_PATH=%{_sysconfdir}/minicoredumper/minicoredumper.cfg.json \
	   -DCRASH_STACK_PATH=%{_libexecdir}/crash-stack \
	   -DCRASH_TESTS_PATH=%{_libdir}/crash-worker-tests \
	   -DSYS_ASSERT=%{on_off sys_assert} \
	   -DUPGRADE_SCRIPT_PATH=%{upgrade_script_path} \

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

%install
rm -rf %{buildroot}
%make_install
mkdir -p %{buildroot}%{crash_root_path}
mkdir -p %{buildroot}%{crash_path}
mkdir -p %{buildroot}%{crash_temp}

# log_dump dir
mkdir -p %{buildroot}%{crash_all_log}
mkdir -p %{buildroot}%{crash_dump_gen}
cp dump_scripts/* %{buildroot}%{crash_dump_gen}
chmod 755 %{buildroot}%{crash_dump_gen}/*

%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}
/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/*

%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
%manifest crash-worker.manifest
%defattr(-,system_fw,system_fw,-)
%dir %{crash_root_path}
%dir %{crash_path}
%dir %{crash_temp}
%dir %{crash_all_log}
%{crash_dump_gen}/*
%attr(0750,system_fw,system_fw) %{_bindir}/*
%attr(-,root,root) %{_unitdir}/log_dump.service
%{_sysconfdir}/crash-manager.conf
%attr(-,root,root) %{_sysconfdir}/dbus-1/system.d/log_dump.conf
%attr(-,root,root) %{_prefix}/lib/sysctl.d/99-crash-manager.conf
%attr(-,root,root) %{_datadir}/dbus-1/system-services/org.tizen.system.crash.service
%{_libexecdir}/crash-stack
%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