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