File kdump.spec of Package kdump

#
# spec file for package kdump
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


%define dracutlibdir %{_prefix}/lib/dracut

%if 0%{?suse_version} > 1220
%define uses_systemd 1
%else
%define uses_systemd 0
%endif

%{!?_udevdir: %global _udevdir %(pkg-config --variable=udevdir udev)}
%if "%{_udevdir}" == ""
%if 0%{?suse_version} >= 1230
%global _udevdir /usr/lib/udev
%else
%global _udevdir /lib/udev
%endif
%endif
%define _udevrulesdir %{_udevdir}/rules.d

Url:            https://github.com/ptesarik/kdump

Name:           kdump
Version:        0.8.15
Release:        0
Requires:       curl
Requires:       makedumpfile
Requires:       openssh
Summary:        Script for kdump
License:        GPL-2.0+
Group:          System/Kernel
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:  pkg-config
BuildRequires:  udev
BuildRequires:  zlib-devel
#!BuildIgnore:  fop
%if %{uses_systemd}
BuildRequires:  systemd
%endif
PreReq:         %insserv_prereq %fillup_prereq
%if 0%{?suse_version} > 1310
PreReq:         dracut
%else
PreReq:         mkinitrd
%endif
Source:         %{name}-%{version}.tar.bz2
Source2:        %{name}-rpmlintrc
Patch0:         0001-multipath-Write-proper-regex-into-multipath-conf.patch
Patch1:         %{name}-use-fstab-device.patch
Patch2:         %{name}-count-framebuffer.patch
Patch3:         %{name}-count-const-slabs.patch
Patch4:         %{name}-remove-root-and-resume.patch
Patch5:         %{name}-systemd-support.patch
Patch6:         %{name}-calibrate-systemd-runtime.patch
Patch7:         %{name}-calibrate-systemd-initramfs.patch
Patch8:         %{name}-get-multipath-wwid-from-sysfs.patch
Patch9:         %{name}-split-kdump_default_netdev.patch
Patch10:        %{name}-move-network-setup-to-module-setup.patch
Patch11:        %{name}-add-IPv6-KDUMP_NETCONFIG-modes.patch
Patch12:        %{name}-enable-fadump-ppc64le.patch
Patch13:        %{name}-fadump-bootloader-always.patch
Patch14:        %{name}-bootloader-grub2.patch
Patch15:        %{name}-fadump-keep-sysroot.patch
Patch16:        %{name}-device-timeout.patch
Patch17:        %{name}-no-xen-secondary-kernel.patch
Patch18:        %{name}-always-pass-kernelver-to-dracut.patch
Patch19:        %{name}-root-parameter.patch
Patch20:        %{name}-keep-dracut-fstab-generator.patch
Patch21:        %{name}-add-requires-mounts-for-into-systemd-unit.patch
Patch22:        %{name}-remove-unnecessary-systemd-dependencies.patch
Patch23:        %{name}-pre-generate-mount-units.patch
Patch24:        %{name}-fix-extractKernelConfigELF.patch
Patch25:        %{name}-relocatable-check-config.patch
Patch26:        %{name}-systemd-integration.patch
Patch27:        %{name}-x86_64-kexec-file-syscall.patch
Patch28:        %{name}-udev-skip-restart-if-not-loaded.patch
Patch29:        %{name}-fate318842-0001-use-proc-iomem.patch
Patch30:        %{name}-fate318842-0002-revert-getMemorySize.patch
Patch31:        %{name}-fate318842-0003-change-output-format.patch
Patch32:        %{name}-fate318842-0004-print-total.patch
Patch33:        %{name}-fate318842-0005-calculate-low-high-min-max.patch
Patch34:        %{name}-fate318842-0006-improve-small-x86_64.patch
Patch35:        %{name}-udev-reload-only-once.patch
Patch36:        %{name}-fix-mkdumprd-regenerate.patch
Patch37:        %{name}-limit-max-udev-workers.patch
Patch38:        %{name}-always-create-multipath.conf.patch
Patch39:        %{name}-fadump-message-on-load.patch
Patch40:        %{name}-fadump-umount.patch
Patch41:        %{name}-fadump-reboot.patch
Patch42:        %{name}-move-SFTP-to-own-file.patch
Patch43:        %{name}-sftppacket.patch
Patch50:        %{name}-SFTPTransfer-base.patch
Patch51:        %{name}-drop-KSFTPErrorCode-libssh2-dep.patch
Patch52:        %{name}-sftp-init-session.patch
Patch53:        %{name}-sftp-mkpath.patch
Patch54:        %{name}-sftp-file-create.patch
Patch55:        %{name}-sftp-data-transfer.patch
Patch56:        %{name}-openssh-files-in-kdumprd.patch
Patch57:        %{name}-drop-libssh2-dep.patch
Patch58:        %{name}-netcheck-0001-routable-class.patch
Patch59:        %{name}-netcheck-0002-netlink-timeout.patch
Patch60:        %{name}-netcheck-0003-target-check.patch
Patch61:        %{name}-calibrate-boot-requirements.patch
Patch62:        %{name}-calibrate-initdata.patch
Patch63:        %{name}-calibrate-top-down.patch
Patch64:        %{name}-calibrate-swiotlb.patch
Patch65:        %{name}-bind-mount-sysroot.patch
Patch66:        %{name}-large-phdrs.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
# rename "kdump-helpers" (10.3) -> "kdump" (11.0/SP2)
Provides:       kdump-helpers = %{version}
Obsoletes:      kdump-helpers < %{version}
# update should detect the split-off from kexec-tools
Provides:       kexec-tools:/etc/init.d/kdump
Requires:       kexec-tools
%if %{uses_systemd}
%systemd_requires
%endif
Recommends:     nfs-client cifs-utils
PreReq:         coreutils sed
ExcludeArch:    s390 ppc

%description
kdump is a package that includes several scripts for kdump, including
the init script /etc/init.d/kdump and the configuration file for kdump.

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.

Authors:
--------
    Bernhard Walle <bwalle@suse.de>

%prep
%setup
%patch0 -p1
%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
chmod +x tests/testsftppacket.sh
%patch50 -p1
%patch51 -p1
%patch52 -p1
%patch53 -p1
%patch54 -p1
%patch55 -p1
%patch56 -p1
%patch57 -p1
%patch58 -p1
%patch59 -p1
%patch60 -p1
%patch61 -p1
%patch62 -p1
%patch63 -p1
%patch64 -p1
%patch65 -p1
%patch66 -p1

%build
export CFLAGS="%optflags"
export CXXFLAGS="%optflags"
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} ..
make
cd -

%check
cd build
make test

%install
cd build
make DESTDIR=$RPM_BUILD_ROOT install
cd -
# move udev rules
mkdir -p $RPM_BUILD_ROOT/%{_udevrulesdir}
mv $RPM_BUILD_ROOT/%{_sysconfdir}/udev/rules.d/* $RPM_BUILD_ROOT/%{_udevrulesdir}/
# remove executable bit from non-binaries
chmod -x $RPM_BUILD_ROOT/lib/kdump/setup-kdump.functions
# empty directory
mkdir $RPM_BUILD_ROOT/var/crash
%if 0%{?suse_version} > 1310
rm -r $RPM_BUILD_ROOT/lib/mkinitrd
%endif

# symlink for init script
%if %{uses_systemd}
rm %{buildroot}/etc/init.d/boot.kdump
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rckdump
%else
rm %{buildroot}/usr/lib/systemd/system/kdump.service
ln -s ../..%{_initddir}/boot.kdump %{buildroot}%{_sbindir}/rckdump
%endif

%if %{uses_systemd}
%pre
%service_add_pre kdump.service
%endif

%post
# change only permission if the file exists before /etc/sysconfig/kdump
# has been created from /var/adm/fillup-templates/sysconfig.kdump
change_permission=0
if [ ! -f /etc/sysconfig/kdump ] ; then
    change_permission=1
fi
%if %{uses_systemd}
%{fillup_only -n kdump}
%service_add_post kdump.service
%else
%{fillup_and_insserv -n kdump boot.kdump}
%endif
if (( $change_permission )) ; then
    chmod 0600 /etc/sysconfig/kdump
fi
# if /var/log/dump is empty, make it a symlink to /var/crash
if test -d /var/log/dump && rmdir /var/log/dump &>/dev/null ||
        ! test -d /var/log/dump ; then
    ln -snf /var/crash /var/log/dump
fi

%preun
echo "Stopping kdump ..."
%if %{uses_systemd}
%service_del_preun kdump.service
%else
%stop_on_removal boot.kdump
%endif

%postun
# force regeneration of kdumprd
touch /etc/sysconfig/kdump
# delete symbolic link
rm /var/log/dump &>/dev/null || true
%if %{uses_systemd}
%service_del_postun kdump.service
%else
%restart_on_update boot.kdump
%{insserv_cleanup}
%endif

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc ChangeLog COPYING README NEWS
%{_sbindir}/kdumptool
%{_sbindir}/mkdumprd
%{_sbindir}/kdump-bootloader.pl
%{_mandir}/man5/kdump.5.gz
%{_mandir}/man7/kdump.7.gz
%{_mandir}/man8/kdumptool.8.gz
%{_mandir}/man8/mkdumprd.8.gz
/var/adm/fillup-templates/sysconfig.kdump
%if 0%{?suse_version} <= 1310
/lib/mkinitrd/scripts/*-kdump.sh
/lib/mkinitrd/scripts/setup-kdumpfs.sh
/lib/mkinitrd/scripts/setup-mkdumprd.sh
%endif
%dir %{dracutlibdir}
%dir %{dracutlibdir}/modules.d
%{dracutlibdir}/modules.d/99kdump/
%dir /lib/kdump
/lib/kdump/*
%{_udevrulesdir}/70-kdump.rules
%if %{uses_systemd}
%{_unitdir}/kdump.service
%else
%{_sysconfdir}/init.d/boot.kdump
%endif
%{_sbindir}/rckdump

%changelog
openSUSE Build Service is sponsored by