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