%define on_off() %{expand:%%{?with_%{1}:ON}%%{!?with_%{1}:OFF}}
%define _with_tests on
+%define _with_regdumper on
%define _with_livedumper on
%define _with_bugreportservice on
%define _with_dumpsystemstateservice on
%bcond_with doc
%bcond_with tests
+%bcond_with regdumper
%bcond_with livedumper
%bcond_with bugreportservice
%bcond_with dumpsystemstateservice
-%if %{?_with_bugreportservice} == on
-%define _with_livedumper on
-%endif
-
# NOTE: To disable coredump set DumpCore=0 in configuration file
Name: crash-worker
Requires(post): coreutils
Requires(post): tar
Requires(post): gzip
-Requires: minicoredumper >= 2.1.0
+
+Requires: %{name}-dumpsystemstate-util = %{version}-%{release}
+%if %{with dumpsystemstateservice}
+Requires: %{name}-dumpsystemstate-service = %{version}-%{release}
+%endif
+%if %{with bugreportservice}
+Requires: bugreport-service = %{version}-%{release}
+%endif
+%if %{with regdumper}
+Requires: %{name}-support-regdump = %{version}-%{release}
+%endif
%description
%package dumpsystemstate-config
Summary: common configuration for dump_systemstate utility and bugreport-service
%description dumpsystemstate-config
-%package -n crash-manager-core
-Summary: package provides core crash-manager functionality - needed utilities and library
+%package dumpsystemstate-util
+Summary: dump_systemstate utility used for dumping basic system information
Requires: %{name}-dumpsystemstate-config = %{version}-%{release}
-Requires: zip
Requires: %{_bindir}/buxton2ctl
-%if %{with bugreportservice}
-Requires: %{name}-livedumper = %{version}-%{release}
+%description dumpsystemstate-util
+
+%if %{with dumpsystemstateservice}
+%package dumpsystemstate-service
+Summary: service provides dumpsys provider to system state information
+Requires: %{name}-dumpsystemstate-config = %{version}-%{release}
+%description dumpsystemstate-service
+%endif
+
+%if %{with regdumper}
+%package support-regdump
+Summary: package provides components needed to support kernel-invoked coredump handling
+Requires: %{name}-support-common = %{version}-%{release}
+Requires: minicoredumper >= 2.1.0
+%description support-regdump
+%endif
+
+%if %{with livedumper}
+%package support-livecoredump
+Summary: package provides components needed to support livecoredumps
+Requires: %{name}-support-common = %{version}-%{release}
+Provides: %{name}-livedumper = %{version}-%{release}
+%description support-livecoredump
%endif
-%description -n crash-manager-core
+%package support-common
+Summary: package provides common components needed to support both kernel-invoked coredump and livedump
+Requires: %{name}-dumpsystemstate-util = %{version}-%{release}
+Requires: zip
+%description support-common
%package -n libcrash-manager-devel
Summary: package provides headers needed to develop programs using libcrash-manager
%package -n bugreport-service
Summary: bugreport provides dumpsys provider for diagnostics data
+Requires: %{name}-dumpsystemstate-util = %{version}-%{release}
+%if %{with livedumper}
+Requires: %{name}-support-livecoredump = %{version}-%{release}
+%endif
%description -n bugreport-service
%package -n libbugreport-devel
Summary: package provides headers needed to develop programs using bugreport-service
%description -n libbugreport-devel
-%endif
-
-%if %{with dumpsystemstateservice}
-%package -n dumpsystemstate-service
-Summary: service provides dumpsys provider to system state information
-Requires: %{name}-dumpsystemstate-config = %{version}-%{release}
-%description -n dumpsystemstate-service
+%description -n libbugreport-devel
%endif
%if %{with doc}
%description tests
%endif
-%if %{with livedumper}
-%package livedumper
-Summary: Livedumper allows to dump core of live process
-%description livedumper
-%endif
-
%package system-tests
Summary: System tests for crash-worker components
Requires: diff
Requires: /usr/bin/mcookie
Requires: %{_sbindir}/minicoredumper
Requires: %{name}-system-tests-debuginfo = %{version}-%{release}
-Requires: %{name}
-Requires: %{name}-livecoredumper = %{version}-%{release}
+Requires: %{name}-support-livecoredump = %{version}-%{release}
+Requires: %{name}-support-regdump = %{version}-%{release}
%description system-tests
%prep
-DUPGRADE_SCRIPT_PATH=%{upgrade_script_path} \
-DLOGGER=dlog \
-DDLOG_LOG_LEVEL=DLOG_INFO \
+ -DTESTS=%{on_off tests} \
-DVERSION=%{version}
make %{?jobs:-j%jobs}
mkdir -p %{buildroot}%{crash_root_path}
mkdir -p %{buildroot}%{crash_path}
+%if ! %{with regdumper}
+rm -f %{buildroot}%{_prefix}/lib/sysctl.d/70-crash-manager.conf
+rm -f %{buildroot}%{_bindir}/crash-manager
+rm -f %{buildroot}%{_libexecdir}/crash-popup-launch
+rm -f %{buildroot}%{_libexecdir}/crash-notify-send
+rm -f %{buildroot}%{_prefix}/lib/debug/usr/bin/crash-manager.debug
+rm -f %{buildroot}%{_prefix}/lib/debug/usr/libexec/crash-notify-send.debug
+rm -f %{buildroot}%{_prefix}/lib/debug/usr/libexec/crash-popup-launch.debug
+%endif
+
+%if ! %{with livedumper}
+rm -f %{buildroot}%{_bindir}/livedumper
+rm -f %{buildroot}%{_prefix}/lib/debug/usr/bin/livedumper.debug
+%endif
+
+%if ! %{with regdumper} && ! %{with livedumper}
+rm -f %{buildroot}%{_libdir}/libcrash-manager.so*
+rm -f %{buildroot}%{_bindir}/crash-json2info
+rm -f %{buildroot}%{_libexecdir}/crash-stack
+rm -f %{buildroot}%{_sysconfdir}/crash-manager.conf
+rm -f %{buildroot}%{_sysconfdir}/crash-manager.conf.d/crash-manager.conf.example
+rm -f %{buildroot}%{_prefix}/lib/debug/usr/bin/crash-json2info.debug
+rm -f %{buildroot}%{_prefix}/lib/debug/usr/libexec/crash-stack.debug
+rm -f %{buildroot}%{_prefix}/lib/debug/usr/lib/libcrash-manager.so*
+rm -f %{buildroot}%{_includedir}/crash-manager.h
+rm -f %{buildroot}%{_prefix}/lib/pkgconfig/crash-manager.pc
+%endif
+
%post
chsmack -a "System" -t %{crash_root_path}
chsmack -a "System" -t %{crash_path}
%files
%license LICENSE
%manifest crash-worker.manifest
-%defattr(-,crash_worker,crash_worker,-)
%dir %{crash_root_path}
%attr(0775,crash_worker,crash_worker) %{crash_path}
-%attr(-,root,root) %{_prefix}/lib/sysctl.d/70-crash-manager.conf
-%attr(0750,crash_worker,crash_worker) %{_bindir}/crash-manager
%attr(-,root,root) %{upgrade_script_path}/500.crash-manager-upgrade.sh
+%files dumpsystemstate-util
+%manifest crash-worker.manifest
+%license LICENSE
+%attr(0750,crash_worker,crash_worker) %{_bindir}/dump_systemstate
+
+%if %{with dumpsystemstateservice}
+%files dumpsystemstate-service
+%license LICENSE
+%manifest crash-worker.manifest
+%attr(0750,crash_worker,crash_worker) %{_bindir}/dump_systemstate-service
+%attr(-,root,root) %{_unitdir}/dump_systemstate.service
+%attr(-,root,root) %{_datadir}/dbus-1/system-services/org.tizen.dumpsys.providers.org.tizen.systemstate.service
+%endif
+
%files dumpsystemstate-config
+%manifest crash-worker.manifest
%license LICENSE
%{_sysconfdir}/dump_systemstate.conf.d/files/*.conf*
%{_sysconfdir}/dump_systemstate.conf.d/programs/*.conf*
-%files -n crash-manager-core
+%if %{with regdumper}
+%files support-regdump
+%license LICENSE
+%manifest crash-worker.manifest
+%attr(-,root,root) %{_prefix}/lib/sysctl.d/70-crash-manager.conf
+%attr(0750,crash_worker,crash_worker) %{_bindir}/crash-manager
+%{_libexecdir}/crash-popup-launch
+%{_libexecdir}/crash-notify-send
+%endif
+
+%if %{with livedumper}
+%files support-livecoredump
+%license LICENSE
+%manifest crash-worker.manifest
+%manifest %{name}.manifest
+%{_bindir}/livedumper
+%endif
+
+%if %{with livedumper} || %{with regdumper}
+%files support-common
%license LICENSE LICENSE.BSD LICENSE.MIT
%manifest crash-worker.manifest
%{_libdir}/libcrash-manager.so.*
%{_bindir}/crash-json2info
-%attr(0750,crash_worker,crash_worker) %{_bindir}/dump_systemstate
%{_libexecdir}/crash-stack
-%{_libexecdir}/crash-popup-launch
-%{_libexecdir}/crash-notify-send
%{_sysconfdir}/crash-manager.conf
%{_sysconfdir}/crash-manager.conf.d/crash-manager.conf.example
%{_includedir}/crash-manager.h
%{_libdir}/libcrash-manager.so
%{_libdir}/pkgconfig/crash-manager.pc
+%endif
%if %{with bugreportservice}
%files -n bugreport-service
%{_libdir}/pkgconfig/bugreport.pc
%endif
-%if %{with dumpsystemstateservice}
-%files -n dumpsystemstate-service
-%license LICENSE
-%manifest crash-worker.manifest
-%attr(0750,crash_worker,crash_worker) %{_bindir}/dump_systemstate-service
-%attr(-,root,root) %{_unitdir}/dump_systemstate.service
-%attr(-,root,root) %{_datadir}/dbus-1/system-services/org.tizen.dumpsys.providers.org.tizen.systemstate.service
-%endif
-
%if %{with doc}
%files doc
%{_datadir}/doc/crash-worker
%{_libexecdir}/crash-worker/tests/tests_common.sh
%{_libexecdir}/crash-worker/tests/crash_common.sh
-%endif
-
-%if %{with livedumper}
-%files livedumper
-%manifest %{name}.manifest
-%{_bindir}/livedumper
-%endif
-
%files system-tests
%manifest %{name}.manifest
%{_bindir}/crash-worker-system-tests-run
%{_libexecdir}/crash-worker/system-tests/extra_script/extra_script.sh
%{_libexecdir}/crash-worker/system-tests/full_core/full_core.sh
%{_libexecdir}/crash-worker/system-tests/info_file/info_file.sh
+%if %{with bugreportservice}
%{_libexecdir}/crash-worker/system-tests/libbugreport-service/libbugreport-service.sh
%{_libexecdir}/crash-worker/system-tests/libbugreport-service_systemstate/libbugreport-service_systemstate.sh
+%endif
%{_libexecdir}/crash-worker/system-tests/log_file/log_file.sh
%{_libexecdir}/crash-worker/system-tests/output_param/output_param.sh
%{_libexecdir}/crash-worker/system-tests/report_basic/report_basic.sh
%if %{with livedumper}
%{_libexecdir}/crash-worker/system-tests/livedumper/livedumper.sh
%endif
+
+%endif