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

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

Name:      crash-worker
Summary:    Crash-manager
Version:    4.0.4
Release:    1
Group:      Framework/system
License:    Apache-2.0
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:  cmake
BuildRequires:  pkgconfig(pkgmgr-info)

BuildRequires:  pkgconfig(libunwind-ptrace)
%if "%{TIZEN_FEATURE_PTRACE_CALLSTACK}" == "on"
BuildRequires:  libelf-devel libelf
BuildRequires:  libebl-devel libebl
BuildRequires:  libdw-devel libdw
%endif

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

Requires(post): coreutils
Requires(post): tar
Requires(post): gzip
Requires: zip
Requires: libelf
Requires: libdw
# If you need support for core dump files (see building below),
# you should add this dependency
# Requires: libebl

%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"
export CFLAGS+=" -DTIZEN_ENGINEER_MODE"
export CFLAGS+=" -DTIZEN_ENABLE_COREDUMP"

%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} \
	   -DTZ_SYS_ETC=%{TZ_SYS_ETC} \
	   -DTZ_SYS_BIN=%{TZ_SYS_BIN} \
	   -DCRASH_ROOT_PATH=%{crash_root_path} \
	   -DCRASH_PATH=%{crash_path} \
	   -DCRASH_TEMP=%{crash_temp} \
	   -DDEBUGMODE_PATH=%{debugmode_path} \
	   -DCRASH_PIPE_PATH=%{_libexecdir}/crash-pipe \
%if "%{TIZEN_FEATURE_PTRACE_CALLSTACK}" == "on"
	   -DCRASH_STACK_PATH=%{_libexecdir}/crash-stack \
%endif
	   -DCRASH_TESTS_PATH=%{_libdir}/crash-worker-tests \
	   -DSYS_ASSERT=%{on_off sys_assert} \
	   -DUPGRADE_SCRIPT_PATH=%{upgrade_script_path} \
	   -DTIZEN_FEATURE_PTRACE_CALLSTACK=%{TIZEN_FEATURE_PTRACE_CALLSTACK}

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(0644,system_fw,system_share) %{_unitdir}/log_dump.service
%{TZ_SYS_ETC}/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

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

%{_libexecdir}/crash-pipe
%if "%{TIZEN_FEATURE_PTRACE_CALLSTACK}" == "on"
%{_libexecdir}/crash-stack
%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