- add (bsc#1226183)

* make-reserve_diskspace-do-nothing-for-flattened-form.patch

OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/makedumpfile?expand=0&rev=180
This commit is contained in:
Petr Tesařík 2024-08-12 09:12:54 +00:00 committed by Git OBS Bridge
commit 845cd91ab9
13 changed files with 1650 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

View File

@ -0,0 +1,102 @@
From: Kazuhito Hagio <k-hagio-ab@nec.com>
Date: Thu, 30 May 2024 16:59:02 +0900
Subject: [PATCH] Fix failure of hugetlb pages exclusion on Linux 6.9 and later
Git-repo: https://github.com/makedumpfile/makedumpfile
Git-commit: 985e575253f1c2de8d6876cfe685c68a24ee06e1
Patch-mainline: 1.7.6
References: bsc#1228388
* Required for kernel 6.9
Kernel commit d99e3140a4d3 ("mm: turn folio_test_hugetlb into a
PageType") moved the PG_hugetlb flag from folio._flags_1 into
page._mapcount and introduced NUMBER(PAGE_HUGETLB_MAPCOUNT_VALUE) entry
into vmcoreinfo.
Without the patch, "makedumpfile -d 8" cannot exclude hugetlb pages.
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
makedumpfile.c | 22 ++++++++++++++++++++--
makedumpfile.h | 3 +++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/makedumpfile.c b/makedumpfile.c
index d7f1dd41d2ca..437ad916f816 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -2975,6 +2975,7 @@ read_vmcoreinfo(void)
READ_SRCFILE("pud_t", pud_t);
READ_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE);
+ READ_NUMBER("PAGE_HUGETLB_MAPCOUNT_VALUE", PAGE_HUGETLB_MAPCOUNT_VALUE);
READ_NUMBER("PAGE_OFFLINE_MAPCOUNT_VALUE", PAGE_OFFLINE_MAPCOUNT_VALUE);
READ_NUMBER("phys_base", phys_base);
READ_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE);
@@ -6510,6 +6511,9 @@ __exclude_unnecessary_pages(unsigned long mem_map,
_count = UINT(pcache + OFFSET(page._refcount));
mapping = ULONG(pcache + OFFSET(page.mapping));
+ if (OFFSET(page._mapcount) != NOT_FOUND_STRUCTURE)
+ _mapcount = UINT(pcache + OFFSET(page._mapcount));
+
compound_order = 0;
compound_dtor = 0;
/*
@@ -6520,6 +6524,22 @@ __exclude_unnecessary_pages(unsigned long mem_map,
if ((index_pg < PGMM_CACHED - 1) && isCompoundHead(flags)) {
unsigned char *addr = pcache + SIZE(page);
+ /*
+ * Linux 6.9 and later kernels use _mapcount value for hugetlb pages.
+ * See kernel commit d99e3140a4d3.
+ */
+ if (NUMBER(PAGE_HUGETLB_MAPCOUNT_VALUE) != NOT_FOUND_NUMBER) {
+ unsigned long _flags_1 = ULONG(addr + OFFSET(page.flags));
+ unsigned int PG_hugetlb = ~NUMBER(PAGE_HUGETLB_MAPCOUNT_VALUE);
+
+ compound_order = _flags_1 & 0xff;
+
+ if ((_mapcount & (PAGE_TYPE_BASE | PG_hugetlb)) == PAGE_TYPE_BASE)
+ compound_dtor = IS_HUGETLB;
+
+ goto check_order;
+ }
+
/*
* Linux 6.6 and later. Kernels that have PG_hugetlb should also
* have the compound order in the low byte of folio._flags_1.
@@ -6564,8 +6584,6 @@ check_order:
if (OFFSET(page.compound_head) != NOT_FOUND_STRUCTURE)
compound_head = ULONG(pcache + OFFSET(page.compound_head));
- if (OFFSET(page._mapcount) != NOT_FOUND_STRUCTURE)
- _mapcount = UINT(pcache + OFFSET(page._mapcount));
if (OFFSET(page.private) != NOT_FOUND_STRUCTURE)
private = ULONG(pcache + OFFSET(page.private));
diff --git a/makedumpfile.h b/makedumpfile.h
index 75b66ceaba21..f08c49fc73be 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -165,6 +165,8 @@ test_bit(int nr, unsigned long addr)
#define isAnon(mapping, flags) (((unsigned long)mapping & PAGE_MAPPING_ANON) != 0 \
&& !isSlab(flags))
+#define PAGE_TYPE_BASE (0xf0000000)
+
#define PTOB(X) (((unsigned long long)(X)) << PAGESHIFT())
#define BTOP(X) (((unsigned long long)(X)) >> PAGESHIFT())
@@ -2255,6 +2257,7 @@ struct number_table {
long PG_hugetlb;
long PAGE_BUDDY_MAPCOUNT_VALUE;
+ long PAGE_HUGETLB_MAPCOUNT_VALUE;
long PAGE_OFFLINE_MAPCOUNT_VALUE;
long SECTION_SIZE_BITS;
long MAX_PHYSMEM_BITS;
--
2.45.2

View File

@ -0,0 +1,132 @@
From: Kazuhito Hagio <k-hagio-ab@nec.com>
Date: Fri, 7 Jun 2024 15:34:05 +0900
Subject: [PATCH] Fix wrong exclusion of Slab pages on Linux 6.10-rc1 and later
Git-repo: https://github.com/makedumpfile/makedumpfile
Git-commit: bad2a7c4fa75d37a41578441468584963028bdda
Patch-mainline: 1.7.6
References: bsc#1228388
* Required for kernel 6.10
Kernel commit 46df8e73a4a3 ("mm: free up PG_slab") moved the PG_slab
flag from page.flags into page._mapcount (slab.__page_type), and
introduced NUMBER(PAGE_SLAB_MAPCOUNT_VALUE) entry into vmcoreinfo.
Without the patch, "makedumpfile -d 8" option wrongly excludes Slab
pages and crash cannot open the dumpfile with an error like this:
$ crash --kaslr auto vmlinux dumpfile
...
please wait... (gathering task table data)
crash: page excluded: kernel virtual address: ffff909980440270 type: "xa_node.slots[off]"
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
makedumpfile.c | 24 +++++++++++++++++++-----
makedumpfile.h | 6 +++---
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/makedumpfile.c b/makedumpfile.c
index 437ad916f816..5b347126db76 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -275,13 +275,26 @@ isHugetlb(unsigned long dtor)
&& (SYMBOL(free_huge_page) == dtor));
}
+static inline int
+isSlab(unsigned long flags, unsigned int _mapcount)
+{
+ /* Linux 6.10 and later */
+ if (NUMBER(PAGE_SLAB_MAPCOUNT_VALUE) != NOT_FOUND_NUMBER) {
+ unsigned int PG_slab = ~NUMBER(PAGE_SLAB_MAPCOUNT_VALUE);
+ if ((_mapcount & (PAGE_TYPE_BASE | PG_slab)) == PAGE_TYPE_BASE)
+ return TRUE;
+ }
+
+ return flags & (1UL << NUMBER(PG_slab));
+}
+
static int
isOffline(unsigned long flags, unsigned int _mapcount)
{
if (NUMBER(PAGE_OFFLINE_MAPCOUNT_VALUE) == NOT_FOUND_NUMBER)
return FALSE;
- if (flags & (1UL << NUMBER(PG_slab)))
+ if (isSlab(flags, _mapcount))
return FALSE;
if (_mapcount == (int)NUMBER(PAGE_OFFLINE_MAPCOUNT_VALUE))
@@ -2977,6 +2990,7 @@ read_vmcoreinfo(void)
READ_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE);
READ_NUMBER("PAGE_HUGETLB_MAPCOUNT_VALUE", PAGE_HUGETLB_MAPCOUNT_VALUE);
READ_NUMBER("PAGE_OFFLINE_MAPCOUNT_VALUE", PAGE_OFFLINE_MAPCOUNT_VALUE);
+ READ_NUMBER("PAGE_SLAB_MAPCOUNT_VALUE", PAGE_SLAB_MAPCOUNT_VALUE);
READ_NUMBER("phys_base", phys_base);
READ_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE);
@@ -6043,7 +6057,7 @@ static int
page_is_buddy_v3(unsigned long flags, unsigned int _mapcount,
unsigned long private, unsigned int _count)
{
- if (flags & (1UL << NUMBER(PG_slab)))
+ if (isSlab(flags, _mapcount))
return FALSE;
if (_mapcount == (int)NUMBER(PAGE_BUDDY_MAPCOUNT_VALUE))
@@ -6618,7 +6632,7 @@ check_order:
*/
else if ((info->dump_level & DL_EXCLUDE_CACHE)
&& is_cache_page(flags)
- && !isPrivate(flags) && !isAnon(mapping, flags)) {
+ && !isPrivate(flags) && !isAnon(mapping, flags, _mapcount)) {
pfn_counter = &pfn_cache;
}
/*
@@ -6626,7 +6640,7 @@ check_order:
*/
else if ((info->dump_level & DL_EXCLUDE_CACHE_PRI)
&& is_cache_page(flags)
- && !isAnon(mapping, flags)) {
+ && !isAnon(mapping, flags, _mapcount)) {
if (isPrivate(flags))
pfn_counter = &pfn_cache_private;
else
@@ -6638,7 +6652,7 @@ check_order:
* - hugetlbfs pages
*/
else if ((info->dump_level & DL_EXCLUDE_USER_DATA)
- && (isAnon(mapping, flags) || isHugetlb(compound_dtor))) {
+ && (isAnon(mapping, flags, _mapcount) || isHugetlb(compound_dtor))) {
pfn_counter = &pfn_user;
}
/*
diff --git a/makedumpfile.h b/makedumpfile.h
index f08c49fc73be..6b43a8b44f93 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -161,9 +161,8 @@ test_bit(int nr, unsigned long addr)
#define isSwapBacked(flags) test_bit(NUMBER(PG_swapbacked), flags)
#define isHWPOISON(flags) (test_bit(NUMBER(PG_hwpoison), flags) \
&& (NUMBER(PG_hwpoison) != NOT_FOUND_NUMBER))
-#define isSlab(flags) test_bit(NUMBER(PG_slab), flags)
-#define isAnon(mapping, flags) (((unsigned long)mapping & PAGE_MAPPING_ANON) != 0 \
- && !isSlab(flags))
+#define isAnon(mapping, flags, _mapcount) \
+ (((unsigned long)mapping & PAGE_MAPPING_ANON) != 0 && !isSlab(flags, _mapcount))
#define PAGE_TYPE_BASE (0xf0000000)
@@ -2259,6 +2258,7 @@ struct number_table {
long PAGE_BUDDY_MAPCOUNT_VALUE;
long PAGE_HUGETLB_MAPCOUNT_VALUE;
long PAGE_OFFLINE_MAPCOUNT_VALUE;
+ long PAGE_SLAB_MAPCOUNT_VALUE;
long SECTION_SIZE_BITS;
long MAX_PHYSMEM_BITS;
long HUGETLB_PAGE_DTOR;
--
2.45.2

BIN
eppic-21808c78596d6d80c67eeaa08a618570ae0d886d.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,42 @@
From: Jiri Bohac <jbohac@suse.cz>
Subject: make reserve_diskspace do nothing for flattened format
Git-commit: 0bcf67df2114ee932af7e0af3ccafa0b349e90c1
References: bsc#1226183
Acked-by: Jiri Bohac <jbohac@suse.cz>
reserve_diskspace() is called by write_elf_header() to make sure there is
always space to write the program header, even if writing other data fails
because of ENOSPC.
This is harmful when writing the flattened format to STDOUT for two reasons:
First, it actually wastes disk space, because first the block of zeroes is sent
to STDOUT by reserve_diskspace() and then the actual program header is sent,
meant to overwrite the zeroes when the flattened format is rearranged.
Second, the algorithm used to read flattened format directly by the crash
program does not cope with the flattened file containing two chunks meant for
the same offset. It uses a binary search on a sorted array of flat_data headers
to find the data in the flat file. It may return the zeroed chunk written by
reserve_diskspace() near the beginning of the file instead of the actual ELF
header located near the end of the flattened file.
Fixes: e39216fce9f73759509ec158e39c289e6c211125 ("Make the incomplete dumpfile generated by ENOSPC error analyzable.")
diff --git a/makedumpfile.c b/makedumpfile.c
index cadc596..9624c3f 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -5206,6 +5206,9 @@ reserve_diskspace(int fd, off_t start_offset, off_t end_offset, char *file_name)
int ret = FALSE;
+ if (info->flag_flatten)
+ return TRUE;
+
assert(start_offset < end_offset);
buf_size = end_offset - start_offset;
--
2.45.2

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0c53f1e5e11e75e4896197df795bee63b3d46b8821fbc3368f7a240861b543b5
size 210893

View File

@ -0,0 +1,26 @@
From: Petr Tesarik <ptesarik@suse.com>
Subject: Define PN_XNUM if missing
Upstream: never, build fix for old distros
Older elfutils did not define this constant.
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
elf_info.h | 4 ++++
1 file changed, 4 insertions(+)
Index: makedumpfile-1.7.1/elf_info.h
===================================================================
--- makedumpfile-1.7.1.orig/elf_info.h
+++ makedumpfile-1.7.1/elf_info.h
@@ -19,6 +19,10 @@
#include <elf.h>
#include <sys/types.h>
+#ifndef PN_XNUM
+#define PN_XNUM 0xffff
+#endif
+
#define KEXEC_CORE_NOTE_NAME "CORE"
#define KEXEC_CORE_NOTE_NAME_BYTES sizeof(KEXEC_CORE_NOTE_NAME)

View File

@ -0,0 +1,34 @@
From: Petr Tesarik <ptesarik@suse.com>
Subject: Allow to override the tinfo library used for eppic
Upstream: never; only needed for compatibility with older ncurses
Allow to override the "-ltinfo" linker option with a make variable.
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
Makefile | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Index: makedumpfile-1.7.1/Makefile
===================================================================
--- makedumpfile-1.7.1.orig/Makefile
+++ makedumpfile-1.7.1/Makefile
@@ -82,6 +82,8 @@ CFLAGS += -fsanitize=undefined
#CFLAGS += -fanalyzer
endif
+TINFOLIB = -ltinfo
+
LIBS := $(LIBS) -lpthread
try-run = $(shell set -e; \
@@ -120,7 +122,7 @@ makedumpfile: $(SRC_BASE) $(OBJ_PART) $(
$(VPATH)makedumpfile.conf.5.in > $(VPATH)makedumpfile.conf.5
eppic_makedumpfile.so: extension_eppic.c
- $(CC) $(CFLAGS) $(LDFLAGS) -shared -rdynamic -o $@ extension_eppic.c -fPIC -leppic -ltinfo
+ $(CC) $(CFLAGS) $(LDFLAGS) -shared -rdynamic -o $@ extension_eppic.c -fPIC -leppic ${TINFOLIB}
clean:
rm -f $(OBJ) $(OBJ_PART) $(OBJ_ARCH) makedumpfile makedumpfile.8 makedumpfile.conf.5

View File

@ -0,0 +1,53 @@
From: Petr Tesarik <ptesarik@suse.cz>
Subject: Use correct l3 index size with SLE15-SP1 ppc64le kernels
References: bsc#1123015
Upstream: never, SUSE-specific
SLE 15 SP1 backported commit c2b4d8b7417a ("powerpc/mm/hash64: Increase
the VA range"), to Linux 4.12, so let's check SUSE_PRODUCT_CODE.
diff -uprN makedumpfile-1.7.5.orig/arch/ppc64.c makedumpfile-1.7.5/arch/ppc64.c
--- makedumpfile-1.7.5.orig/arch/ppc64.c 2024-04-12 13:09:09.000000000 +0800
+++ makedumpfile-1.7.5/arch/ppc64.c 2024-05-16 14:19:46.846209221 +0800
@@ -261,7 +261,9 @@ ppc64_vmalloc_init(void)
if (info->kernel_version >= KERNEL_VERSION(4, 12, 0)) {
info->l2_index_size = PMD_INDEX_SIZE_L4_64K_4_12;
- if (info->kernel_version >= KERNEL_VERSION(4, 17, 0))
+ if (info->kernel_version >= KERNEL_VERSION(4, 17, 0) ||
+ ((NUMBER(SUSE_PRODUCT_CODE) & ~0xffL) == 0x010f0100) ||
+ ((NUMBER(SUSE_PRODUCT_CODE) & ~0xffL) == 0x010c0500))
info->l3_index_size = PUD_INDEX_SIZE_L4_64K_4_17;
else
info->l3_index_size = PUD_INDEX_SIZE_L4_64K_4_12;
diff -uprN makedumpfile-1.7.5.orig/makedumpfile.c makedumpfile-1.7.5/makedumpfile.c
--- makedumpfile-1.7.5.orig/makedumpfile.c 2024-04-12 13:09:09.000000000 +0800
+++ makedumpfile-1.7.5/makedumpfile.c 2024-05-16 14:16:42.897988141 +0800
@@ -2531,6 +2531,7 @@ write_vmcoreinfo_data(void)
WRITE_NUMBER_UNSIGNED("PHYS_OFFSET", PHYS_OFFSET);
WRITE_NUMBER_UNSIGNED("kimage_voffset", kimage_voffset);
#endif
+ WRITE_NUMBER("SUSE_PRODUCT_CODE", SUSE_PRODUCT_CODE);
if (info->phys_base)
fprintf(info->file_vmcoreinfo, "%s%lu\n", STR_NUMBER("phys_base"),
@@ -3002,6 +3003,7 @@ read_vmcoreinfo(void)
READ_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
READ_NUMBER("RADIX_MMU", RADIX_MMU);
+ READ_NUMBER("SUSE_PRODUCT_CODE", SUSE_PRODUCT_CODE);
return TRUE;
}
diff -uprN makedumpfile-1.7.5.orig/makedumpfile.h makedumpfile-1.7.5/makedumpfile.h
--- makedumpfile-1.7.5.orig/makedumpfile.h 2024-04-12 13:09:09.000000000 +0800
+++ makedumpfile-1.7.5/makedumpfile.h 2024-05-16 14:18:08.275376258 +0800
@@ -2283,6 +2283,9 @@ struct number_table {
unsigned long va_kernel_pa_offset;
#endif
+ /* Distro-specific */
+ long SUSE_PRODUCT_CODE;
+
unsigned long RADIX_MMU;
};

1
makedumpfile-rpmlintrc Normal file
View File

@ -0,0 +1 @@
addFilter("devel-file-in-non-devel-package .*/usr/share/makedumpfile-\d+\.\d+\.\d+/eppic_scripts/.*\.c")

1097
makedumpfile.changes Normal file

File diff suppressed because it is too large Load Diff

133
makedumpfile.spec Normal file
View File

@ -0,0 +1,133 @@
#
# spec file for package makedumpfile
#
# Copyright (c) 2024 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 https://bugs.opensuse.org/
#
%define build_eppic 1
%define eppic_commit 21808c78596d6d80c67eeaa08a618570ae0d886d
%if 0%{!?have_zstd:1}
%if 0%{?sle_version} >= 150200 || 0%{?suse_version} > 1500
%define have_zstd 1
%else
%define have_zstd 0
%endif
%endif
Name: makedumpfile
Version: 1.7.5
Release: 0
Summary: Partial kernel dump
License: GPL-2.0-only
Group: System/Kernel
URL: https://github.com/makedumpfile/makedumpfile
Source: https://github.com/makedumpfile/makedumpfile/releases/download/%{version}/%{name}-%{version}.tar.gz
Source1: https://github.com/lucchouina/eppic/archive/%{eppic_commit}.tar.gz#/eppic-%{eppic_commit}.tar.gz
Source99: %{name}-rpmlintrc
Patch0: %{name}-override-libtinfo.patch
Patch1: %{name}-ppc64-VA-range-SUSE.patch
Patch2: %{name}-PN_XNUM.patch
Patch3: 0001-PATCH-Fix-failure-of-hugetlb-pages-exclusion-on-Linu.patch
Patch4: 0002-PATCH-Fix-wrong-exclusion-of-Slab-pages-on-Linux-6.1.patch
Patch5: make-reserve_diskspace-do-nothing-for-flattened-form.patch
BuildRequires: libbz2-devel
BuildRequires: libdw-devel
BuildRequires: libelf-devel
BuildRequires: lzo-devel
BuildRequires: ncurses-devel
BuildRequires: snappy-devel
BuildRequires: xz-devel
BuildRequires: zlib-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-build
ExclusiveArch: %{ix86} x86_64 ia64 ppc ppc64 ppc64le riscv64 s390x %{arm} aarch64
%if %{have_zstd}
BuildRequires: libzstd-devel
%endif
%if %{build_eppic}
BuildRequires: bison
BuildRequires: flex
%endif
%description
makedumpfile is a dump program to shorten the size of dump file. It
copies only the necessary pages for analysis with various dump levels,
and can compress the page data. The obtained dump file can by analyzed
via gdb or crash utility.
%prep
%if %{build_eppic}
%autosetup -p1 -b1
%else
%autosetup -p1
%endif
%check
%build
export CFLAGS="%{optflags} -fcommon"
export USESNAPPY=on
%if %{have_zstd}
export USEZSTD=on
%endif
export USELZO=on
export LINKTYPE=dynamic
make %{?_smp_mflags} LDFLAGS="-Wl,-rpath,%{_libdir}/%{name}-%{version}"
%if %{build_eppic}
pushd ../eppic-%{eppic_commit}/libeppic
make
popd
export CFLAGS="-I../eppic-%{eppic_commit}/libeppic $CFLAGS"
export LDFLAGS="-L../eppic-%{eppic_commit}/libeppic $LDFLAGS"
make %{?_smp_mflags} eppic_makedumpfile.so %{?ncurses_make_opts}
%endif
%install
install -D -m 0755 makedumpfile %{buildroot}%{_bindir}/makedumpfile
install -D -m 0755 makedumpfile-R.pl %{buildroot}%{_bindir}/makedumpfile-R.pl
install -D -m 0644 makedumpfile.8 %{buildroot}%{_mandir}/man8/makedumpfile.8
install -D -m 0644 makedumpfile.conf.5 %{buildroot}%{_mandir}/man5/makedumpfile.conf.5
%if %{build_eppic}
install -D -m 0755 eppic_makedumpfile.so %{buildroot}%{_libdir}/%{name}-%{version}/eppic_makedumpfile.so
install -d -m 0755 %{buildroot}%{_datadir}/%{name}-%{version}/eppic_scripts
install -m 0644 -t %{buildroot}%{_datadir}/%{name}-%{version}/eppic_scripts/ eppic_scripts/*
%endif
# Compatibility cruft
# there is no %%license prior to SLE12
%if %{undefined _defaultlicensedir}
%define license %doc
%else
# filesystem before SLE12 SP3 lacks /usr/share/licenses
%if 0%(test ! -d %{_defaultlicensedir} && echo 1)
%define _defaultlicensedir %{_defaultdocdir}
%endif
%endif # End of compatibility cruft
%files
%defattr(-,root,root)
%license COPYING
%doc README IMPLEMENTATION
%{_mandir}/man?/*
%{_bindir}/*
%if %{build_eppic}
%dir %{_libdir}/%{name}-%{version}
%{_libdir}/%{name}-%{version}/eppic_makedumpfile.so
%dir %{_datadir}/%{name}-%{version}
%{_datadir}/%{name}-%{version}/eppic_scripts/
%endif
%changelog