File kdump.spec of Package kdump.21347

# spec file for package kdump
# Copyright (c) 2020 SUSE LLC
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

# on systemd distros, rpm-build requires systemd-rpm-macros,
# which in turn defines %%systemd_requires
%define systemd_present %{defined systemd_requires}

#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
  %define _fillupdir %{_localstatedir}/adm/fillup-templates

%define dracutlibdir %{_prefix}/lib/dracut

Name:           kdump
Version:        0.9.0
Release:        0
Summary:        Script for kdump
License:        GPL-2.0-or-later
Group:          System/Kernel
Source:         %{name}-%{version}.tar.bz2
Source2:        %{name}-rpmlintrc
Patch1:         %{name}-fillupdir-fixes.patch
Patch2:         %{name}-block-initrd-parse-etc.service.patch
Patch3:         %{name}-fadump-avoid-multipath-optimizations.patch
Patch4:         %{name}-split-cmdline-purpose-wise.patch
Patch5:         %{name}-fadump-fix-network-bring-up.patch
Patch6:         %{name}-fadump-add-udev-support.patch
Patch7:         %{name}-turn-off-NUMA-in-kdump-kernel.patch
Patch8:         %{name}-remove-noefi-and-acpi_rsdp-for-efi-firmware.patch
Patch9:         %{name}-use-pbl.patch
Patch10:        %{name}-on-error-option-yesno.patch
Patch11:        %{name}-Restore-only-static-routes-in-kdump-initrd.patch
Patch12:        %{name}-fallback-re-register-fadump-from-userspace.patch
Patch13:        %{name}-recover-from-missing-CRASHTIME.patch
Patch14:        %{name}-fix-multipath-user_friendly_names.patch
Patch15:        %{name}-Add-skip_balance-option-to-BTRFS-mounts.patch
Patch16:        %{name}-kdumprd-Look-for-boot-image-and-boot-Image.patch
Patch17:        %{name}-savedump-search-also-for-vmlinux.xz.patch
Patch18:        %{name}-preserve-white-space.patch
Patch19:        %{name}-Clean-up-the-use-of-current-vs-boot-network-iface.patch
Patch20:        %{name}-Use-a-custom-namespace-for-physical-NICs.patch
Patch21:        %{name}-clean-up-kdump-mount-points.patch
Patch22:        %{name}-skip-mounts-if-no-proc-vmcore.patch
Patch23:        %{name}-nss-modules.patch
Patch24:        %{name}-Add-force-option-to-KDUMP_NETCONFIG.patch
Patch25:        %{name}-Add-fence_kdump_send-when-fence-agents-installed.patch
Patch26:        %{name}-FENCE_KDUMP_SEND-variable.patch
Patch27:        %{name}-Document-fence_kdump_send.patch
Patch28:        %{name}-powerpc-no-reload-on-CPU-removal.patch
Patch29:        %{name}-prefer-by-path-and-device-mapper.patch
Patch30:        %{name}-calibrate-Update-values.patch
Patch31:        %{name}-activate-udev-rules-late-during-boot.patch
Patch32:        %{name}-make-sure-that-the-udev-runtime-directory-exists.patch
Patch33:        %{name}-do-not-add-rd.neednet.patch
Patch34:        %{name}-remove-console-hvc0-from-commandline.patch
Patch35:        %{name}-set-serial-console-from-Xen-cmdline.patch
Patch36:        %{name}
Patch37:        %{name}-query-systemd-network.service.patch
Patch38:        %{name}-check-explicit-ip-options.patch
Patch39:        %{name}-avoid-endless-loop-EAI_AGAIN.patch
Patch40:        %{name}-install-etc-resolv.conf-using-resolved-path.patch
Patch41:        %{name}-Add-bootdev-to-dracut-command-line.patch
Patch42:        %{name}-fix-incorrect-exit-code-checking.patch
Patch43:        %{name}-do-not-iterate-past-end-of-string.patch
BuildRequires:  asciidoc
BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  libblkid-devel
BuildRequires:  libcurl-devel
BuildRequires:  libelf-devel
BuildRequires:  libesmtp-devel
BuildRequires:  libopenssl-devel
BuildRequires:  libxslt
BuildRequires:  pkgconfig
BuildRequires:  zlib-devel
BuildRequires:  pkgconfig(udev)
#!BuildIgnore:  fop
Requires:       curl
Requires:       kexec-tools
Requires:       makedumpfile
Requires:       openssh
# FIXME: use proper Requires(pre/post/preun/...)
PreReq:         %fillup_prereq
PreReq:         coreutils
PreReq:         dracut
PreReq:         sed
Recommends:     cifs-utils
Recommends:     nfs-client
# update should detect the split-off from kexec-tools
Provides:       kexec-tools:%{_initddir}/kdump
ExcludeArch:    s390 ppc
%if %{systemd_present}
BuildRequires:  pkgconfig(systemd)
# FIXME: use proper Requires(pre/post/preun/...)
PreReq:         %insserv_prereq
%if %{systemd_present}

kdump is a package that includes several scripts for kdump, including
the kdump service and configuration files

The kernel package and this package are all that are required for a
crash dump to occur. However, if you wish to debug the crash dump
yourself you will need several debugging packages installed for each
kernel flavor and release you wish to debug.

For example, if you are debugging kernel-default, you will need:
- kernel-default-debuginfo
- kernel-default-devel
- kernel-default-devel-debuginfo

These packages are not needed to create the dump and can be installed
after a crash dump has occured.

%setup -q
%if 0%{?suse_version} >= 1330
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch28 -p1
%patch29 -p1
%patch30 -p1
%patch31 -p1
%patch32 -p1
%patch33 -p1
%patch34 -p1
%patch35 -p1
%patch36 -p1
%patch37 -p1
%patch38 -p1
%patch39 -p1
%patch40 -p1
%patch41 -p1
%patch42 -p1
%patch43 -p1

export CFLAGS="%{optflags}"
export CXXFLAGS="%{optflags} -std=gnu++98"
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} ..
make %{?_smp_mflags}

cd build
ctest --output-on-failure --force-new-ctest-process %{?_smp_mflags} 

DESTDIR=%{buildroot} make -C build %{?_smp_mflags} install
# remove executable bit from non-binaries
chmod -x %{buildroot}/lib/kdump/setup-kdump.functions
# empty directory
mkdir -p %{buildroot}%{_localstatedir}/crash

# symlink for init script
%if %{systemd_present}
rm %{buildroot}%{_initddir}/boot.kdump
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rckdump
rm %{buildroot}%{_prefix}/lib/systemd/system/kdump.service
rm %{buildroot}%{_prefix}/lib/systemd/system/kdump-early.service
ln -s ../..%{_initddir}/boot.kdump %{buildroot}%{_sbindir}/rckdump

%if %{systemd_present}
%service_add_pre kdump.service
%service_add_pre kdump-early.service

# change only permission if the file exists before /etc/sysconfig/kdump
# has been created from %%{_fillupdir}/sysconfig.kdump
if [ ! -f %{_sysconfdir}/sysconfig/kdump ] ; then
%if %{systemd_present}
%{fillup_only -n kdump}
%service_add_post kdump.service
%service_add_post kdump-early.service
# ensure newly added kdump-early.service is-enabled matches prior state
if [ -x %{_bindir}/systemctl ] && %{_bindir}/systemctl is-enabled kdump.service &>/dev/null ; then
	%{_bindir}/systemctl reenable kdump.service || :
%{fillup_and_insserv -n kdump boot.kdump}
if [ "$change_permission" = 1 ]; then
    chmod 0600 %{_sysconfdir}/sysconfig/kdump
# if /var/log/dump is empty, make it a symlink to /var/crash
if test -d %{_localstatedir}/log/dump && rmdir %{_localstatedir}/log/dump >/dev/null 2>&1 ||
        ! test -d %{_localstatedir}/log/dump ; then
    ln -snf %{_localstatedir}/crash %{_localstatedir}/log/dump

echo "Stopping kdump ..."
%if %{systemd_present}
%service_del_preun kdump.service
%service_del_preun kdump-early.service
%stop_on_removal boot.kdump

# force regeneration of kdumprd
touch %{_sysconfdir}/sysconfig/kdump
# delete symbolic link
rm %{_localstatedir}/log/dump >/dev/null 2>&1 || true
%if %{systemd_present}
%service_del_postun kdump.service
%service_del_postun kdump-early.service
%restart_on_update boot.kdump

# Compatibility cruft
# there is no %%license prior to SLE12
%if %{undefined _defaultlicensedir}
%define license %doc
# filesystem before SLE12 SP3 lacks /usr/share/licenses
%if 0%(test ! -d %{_defaultlicensedir} && echo 1)
%define _defaultlicensedir %{_defaultdocdir}
# End of compatibility cruft

%license COPYING
%doc ChangeLog README NEWS
%dir %{dracutlibdir}
%dir %{dracutlibdir}/modules.d
%dir /lib/kdump
%dir /usr/lib/kdump
%if %{systemd_present}

openSUSE Build Service is sponsored by