Skip to contentSkip to conversation

package/makedumpfile: new package

PATCH Superseded Alexander Egorenkov 2 participants 3 messages Aug 29, 2020 – Aug 30, 2020

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/makedumpfile: new package

---
 package/Config.in                             |  1 +
 .../0001-Cross-compilation-fixes.patch        | 13 +++++++
 package/makedumpfile/0002-gcc10-fixes.patch   | 35 +++++++++++++++++++
 package/makedumpfile/Config.in                | 11 ++++++
 package/makedumpfile/makedumpfile.hash        |  3 ++
 package/makedumpfile/makedumpfile.mk          | 23 ++++++++++++
 6 files changed, 86 insertions(+)
 create mode 100644 package/makedumpfile/0001-Cross-compilation-fixes.patch
 create mode 100644 package/makedumpfile/0002-gcc10-fixes.patch
 create mode 100644 package/makedumpfile/Config.in
 create mode 100644 package/makedumpfile/makedumpfile.hash
 create mode 100644 package/makedumpfile/makedumpfile.mk
package/Config.in +1 -0
index d7e79f4795..10cb1f94d1 100644
@@ -2374,6 +2374,7 @@ menu "System tools"
 	source "package/kvmtool/Config.in"
 	source "package/libostree/Config.in"
 	source "package/lxc/Config.in"
+	source "package/makedumpfile/Config.in"
 	source "package/mender/Config.in"
 	source "package/mender-grubenv/Config.in"
 	source "package/mfoc/Config.in"
package/makedumpfile/0001-Cross-compilation-fixes.patch new file +13 -0
new file mode 100644
index 0000000000..ebe495d89d
@@ -0,0 +1,13 @@
+Index: makedumpfile-1.6.7/Makefile
+===================================================================
+--- makedumpfile-1.6.7.orig/Makefile
++++ makedumpfile-1.6.7/Makefile
+@@ -8,7 +8,7 @@ ifeq ($(strip $CC),)
+ CC	= gcc
+ endif
+ 
+-CFLAGS_BASE := $(CFLAGS) -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \
++CFLAGS_BASE := $(EXTRA_CFLAGS) -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \
+ 		-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
+ CFLAGS      := $(CFLAGS_BASE) -DVERSION='"$(VERSION)"' -DRELEASE_DATE='"$(DATE)"'
+ CFLAGS_ARCH := $(CFLAGS_BASE)
package/makedumpfile/0002-gcc10-fixes.patch new file +35 -0
new file mode 100644
index 0000000000..10c4bf72c7
@@ -0,0 +1,35 @@
+--- a/makedumpfile.h	2020-08-28 20:08:00.308241301 +0200
++++ b/makedumpfile.h	2020-08-28 20:08:10.484310117 +0200
+@@ -1262,7 +1262,9 @@
+ 	mdf_pfn_t		end_pfn;
+ 	off_t			offset_eraseinfo;
+ 	unsigned long		size_eraseinfo;
+-} splitting_info_t;
++};
++
++typedef struct splitting_info splitting_info_t;
+ 
+ struct parallel_info {
+ 	int			fd_memory;
+@@ -1275,7 +1277,9 @@
+ #ifdef USELZO
+ 	lzo_bytep		wrkmem;
+ #endif
+-} parallel_info_t;
++};
++
++typedef struct parallel_info parallel_info_t;
+ 
+ struct ppc64_vmemmap {
+ 	unsigned long		phys;
+@@ -2006,8 +2010,8 @@
+ };
+ 
+ #define CRASH_RESERVED_MEM_NR   8
+-struct memory_range crash_reserved_mem[CRASH_RESERVED_MEM_NR];
+-int crash_reserved_mem_nr;
++extern struct memory_range crash_reserved_mem[CRASH_RESERVED_MEM_NR];
++extern int crash_reserved_mem_nr;
+ 
+ unsigned long read_vmcoreinfo_symbol(char *str_symbol);
+ int readmem(int type_addr, unsigned long long addr, void *bufptr, size_t size);
package/makedumpfile/Config.in new file +11 -0
new file mode 100644
index 0000000000..6751282ea6
@@ -0,0 +1,11 @@
+config BR2_PACKAGE_MAKEDUMPFILE
+	bool "makedumpfile"
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on !BR2_STATIC_LIBS # dlopen
+	select BR2_PACKAGE_ELFUTILS
+	select BR2_PACKAGE_ZLIB
+	select BR2_PACKAGE_BZIP2
+	select BR2_PACKAGE_LZO
+	select BR2_PACKAGE_XZ
+	help
+	  Makes a small dumpfile of kdump.
package/makedumpfile/makedumpfile.hash new file +3 -0
new file mode 100644
index 0000000000..6cf882e3e5
@@ -0,0 +1,3 @@
+# Locally computed:
+sha256  e702fbdf62b4cd829a76e46f3e24eb3fc7501918b85ebdcd8baef4f53d6ee2c8  makedumpfile-1.6.7.tar.gz
+sha256  ab15fd526bd8dd18a9e77ebc139656bf4d33e97fc7238cd11bf60e2b9b8666c6  COPYING
package/makedumpfile/makedumpfile.mk new file +23 -0
new file mode 100644
index 0000000000..b240944eaf
@@ -0,0 +1,23 @@
+################################################################################
+#
+# makedumpfile
+#
+################################################################################
+
+MAKEDUMPFILE_VERSION = 1.6.7
+MAKEDUMPFILE_SITE = https://github.com/makedumpfile/makedumpfile/releases/download/Released-$(subst .,-,$(MAKEDUMPFILE_VERSION))
+MAKEDUMPFILE_DEPENDENCIES = zlib xz lzo
+MAKEDUMPFILE_LICENSE = GPL-2.0
+MAKEDUMPFILE_LICENSE_FILES = COPYING
+
+define MAKEDUMPFILE_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) CC="$(TARGET_CC)" \
+		EXTRA_CFLAGS="$(TARGET_CFLAGS)" TARGET=$(BR2_ARCH) USELZO=on LINKTYPE=dynamic
+endef
+
+define MAKEDUMPFILE_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS) install \
+		DESTDIR="$(TARGET_DIR)"
+endef
+
+$(eval $(generic-package))
Signature · 1 line
2.28.0
#1 lore raw

PATCH 1/1 package/makedumpfile: new package

Hello Alexander,

Quoted 1 line · On Sat, 29 Aug 2020 09:59:01 +0200 Alexander Egorenkov…

Thanks for your contribution! See below for a number of comments.

Quoted 7 lines
 package/Config.in                             |  1 +
 .../0001-Cross-compilation-fixes.patch        | 13 +++++++
 package/makedumpfile/0002-gcc10-fixes.patch   | 35 +++++++++++++++++++
 package/makedumpfile/Config.in                | 11 ++++++
 package/makedumpfile/makedumpfile.hash        |  3 ++
 package/makedumpfile/makedumpfile.mk          | 23 ++++++++++++
 6 files changed, 86 insertions(+)

For all new packages, we need an entry to be added to the DEVELOPERS file so we know who is in charge of which package, and you will receive e-mail notifications when this package fails to build or needs to be updated.

package/makedumpfile/0001-Cross-compilation-fixes.patch

Quoted 6 lines
package/makedumpfile/0001-Cross-compilation-fixes.patch new file +0 -0
new file mode 100644
index 0000000000..ebe495d89d
@@ -0,0 +1,13 @@

We need all patches to have a description and Signed-off-by line, and be generated using "git format-patch -N" when the upstream project uses git.

package/makedumpfile/0001-Cross-compilation-fixes.patch line 10

Quoted 10 lines
package/makedumpfile/0001-Cross-compilation-fixes.patch new file +10 -0
+Index: makedumpfile-1.6.7/Makefile
+===================================================================
+--- makedumpfile-1.6.7.orig/Makefile
++++ makedumpfile-1.6.7/Makefile
+@@ -8,7 +8,7 @@ ifeq ($(strip $CC),)
+ CC	= gcc
+ endif
+ 
+-CFLAGS_BASE := $(CFLAGS) -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \
++CFLAGS_BASE := $(EXTRA_CFLAGS) -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \

It's not clear to me why you need this change though. I think the intention of this code is that if you pass CFLAGS in the environment of make and not as an option, it will do the right thing. Quick demo:

$ cat toto.mk 
CFLAGS_BASE := $(CFLAGS) -foobar
CFLAGS := $(CFLAGS_BASE) -barfoo

all:

	@echo $(CFLAGS)

$

$ make -f toto.mk CFLAGS=-baz
-baz
$ CFLAGS=-baz make -f toto.mk
-baz -foobar -barfoo

package/makedumpfile/0002-gcc10-fixes.patch

Quoted 9 lines
package/makedumpfile/0001-Cross-compilation-fixes.patch new file +3 -0
+ 		-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
+ CFLAGS      := $(CFLAGS_BASE) -DVERSION='"$(VERSION)"' -DRELEASE_DATE='"$(DATE)"'
+ CFLAGS_ARCH := $(CFLAGS_BASE)
package/makedumpfile/0002-gcc10-fixes.patch new file +0 -0
new file mode 100644
index 0000000000..10c4bf72c7
@@ -0,0 +1,35 @@

Again, we need this to have a proper description and Signed-off-by. Also, could you submit it upstream ?

package/makedumpfile/Config.in line 4

Quoted 10 lines
package/makedumpfile/Config.in new file +4 -0
new file mode 100644
index 0000000000..6751282ea6
@@ -0,0 +1,11 @@
+config BR2_PACKAGE_MAKEDUMPFILE
+	bool "makedumpfile"
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on !BR2_STATIC_LIBS # dlopen

elfutils has plenty more dependencies that you need to replicate:

depends on BR2_USE_WCHAR
depends on !BR2_STATIC_LIBS
# Only glibc and uClibc implement the myriad of required GNUisms depends on BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC

package/makedumpfile/Config.in line 11

Quoted 7 lines
package/makedumpfile/Config.in new file +7 -0
+	select BR2_PACKAGE_ELFUTILS
+	select BR2_PACKAGE_ZLIB
+	select BR2_PACKAGE_BZIP2
+	select BR2_PACKAGE_LZO
+	select BR2_PACKAGE_XZ
+	help
+	  Makes a small dumpfile of kdump.

You need to add the upstream URL of the project in the Config.in help text, look at other packages for example.

Also, you need to add a comment about the Config.in dependencies. Look at other packages for direction on how to do this. For example, in package/elfutils/Config.in, we have:

comment "elfutils needs a uClibc or glibc toolchain w/ wchar, dynamic library"

        depends on !BR2_USE_WCHAR || BR2_STATIC_LIBS \
                || !(BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC)

package/makedumpfile/Config.in

Quoted 3 lines
package/makedumpfile/Config.in new file +3 -0
+MAKEDUMPFILE_VERSION = 1.6.7
+MAKEDUMPFILE_SITE = https://github.com/makedumpfile/makedumpfile/releases/download/Released-$(subst .,-,$(MAKEDUMPFILE_VERSION))
+MAKEDUMPFILE_DEPENDENCIES = zlib xz lzo

Your Config.in file also selects bzip2 and elfutils... so it seems odd they are not needed at build time. Could you confirm this ?

In any case, make sure you can run this:

$ make clean
$ make makedumpfile

if that doesn't work, you forgot some build dependencies.

Also, run:

$ cat > snippet.cfg<<EOF
BR2_PACKAGE_MAKEDUMPFILE=y
EOF
$ ./utils/test-pkg -c snippet.cfg -p makedumpfile

package/makedumpfile/Config.in

Quoted 6 lines
package/makedumpfile/Config.in new file +6 -0
+MAKEDUMPFILE_LICENSE = GPL-2.0
+MAKEDUMPFILE_LICENSE_FILES = COPYING
+
+define MAKEDUMPFILE_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) CC="$(TARGET_CC)" \
+		EXTRA_CFLAGS="$(TARGET_CFLAGS)" TARGET=$(BR2_ARCH) USELZO=on LINKTYPE=dynamic

Could you instead pass TARGET_CONFIGURE_OPTS in the environment, like this:

	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D) \
		TARGET=$(BR2_ARCH) USELZO=on LINKTYPE=dynamic

TARGET=$(BR2_ARCH): did you check it builds with all CPU architectures supported by Buildroot? In the above proposed test with test-pkg, I'd suggest doing one run with the -a option to check with all toolchains supported by Buildroot.

Also, USELZO=on indicates that the LZO dependency, could you make it optional? I.e, drop the select BR2_PACKAGE_LZO from Config.in, and in the .mk file, do something like:

ifeq ($(BR2_PACKAGE_LZO),y)
MAKEDUMPFILE_DEPENDENCIES += lzo
MAKEDUMPFILE_MAKE_OPTS += USELZO=on
endif

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

PATCH 1/1 package/makedumpfile: new package

Quoted 5 lines

For all new packages, we need an entry to be added to the DEVELOPERS file so we know who is in charge of which package, and you will receive e-mail notifications when this package fails to build or needs to be updated.

Fixed.

Quoted 5 lines

We need all patches to have a description and Signed-off-by line, and be generated using "git format-patch -N" when the upstream project uses git.

Fixed.

Quoted 8 lines

It's not clear to me why you need this change though. I think the intention of this code is that if you pass CFLAGS in the environment of make and not as an option, it will do the right thing. Quick demo:

$ cat toto.mk 
CFLAGS_BASE := $(CFLAGS) -foobar
CFLAGS := $(CFLAGS_BASE) -barfoo
Quoted 10 lines

all:

	@echo $(CFLAGS)

$

$ make -f toto.mk CFLAGS=-baz
-baz
$ CFLAGS=-baz make -f toto.mk
-baz -foobar -barfoo

Fixed. Thanks for pointing out.

Quoted 3 lines

Again, we need this to have a proper description and Signed-off-by. Also, could you submit it upstream ?

The fix is already upstream but there is no release yet. Anyways, i took the official patch now.

Quoted 7 lines

elfutils has plenty more dependencies that you need to replicate:

depends on BR2_USE_WCHAR
depends on !BR2_STATIC_LIBS
# Only glibc and uClibc implement the myriad of required GNUisms depends on BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC

Fixed.

Quoted 4 lines

You need to add the upstream URL of the project in the Config.in help text, look at other packages for example.

Quoted 8 lines

Also, you need to add a comment about the Config.in dependencies. Look at other packages for direction on how to do this. For example, in package/elfutils/Config.in, we have:

comment "elfutils needs a uClibc or glibc toolchain w/ wchar, dynamic library"

        depends on !BR2_USE_WCHAR || BR2_STATIC_LIBS \
                || !(BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC)

Fixed.

Quoted 8 lines

Your Config.in file also selects bzip2 and elfutils... so it seems odd they are not needed at build time. Could you confirm this ?

In any case, make sure you can run this:

$ make clean
$ make makedumpfile

Done. It works.

Quoted 9 lines

if that doesn't work, you forgot some build dependencies.

Also, run:

$ cat > snippet.cfg<<EOF
BR2_PACKAGE_MAKEDUMPFILE=y
EOF
$ ./utils/test-pkg -c snippet.cfg -p makedumpfile
$ ./utils/test-pkg -c snippet.cfg -p makedumpfile
                             br-arm-full [1/6]: FAILED
                  br-arm-cortex-a9-glibc [2/6]: OK
                   br-arm-cortex-m4-full [3/6]: SKIPPED
                          br-x86-64-musl [4/6]: SKIPPED
                      br-arm-full-static [5/6]: SKIPPED
                            sourcery-arm [6/6]: OK
6 builds, 3 skipped, 1 build failed, 0 legal-info failed

/home/egorenar/br-test-pkg/br-arm-full/host/bin/arm-linux-gcc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -g -O2 -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__arm __ -U__x86_64__ -c -o ./arch/x86_64.o arch/x86_64.c
elf_info.c: In function ?get_elf64_phnum?:
elf_info.c:1050:23: error: ?PN_XNUM? undeclared (first use in this function)

   if (ehdr->e_phnum == PN_XNUM) {
                        ^

elf_info.c:1050:23: note: each undeclared identifier is reported only once for each function it appears in
/home/egorenar/br-test-pkg/br-arm-full/host/bin/arm-linux-gcc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -g -O2 -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__arm __ -U__x86_64__ -c -o ./arch/ia64.o arch/ia64.c
make[1]: *** [Makefile:90: elf_info.o] Error 1

Not sure what is going on, because PN_XNUM is defined in elfutils/libelf/elf.h

Quoted 11 lines

Could you instead pass TARGET_CONFIGURE_OPTS in the environment, like this:

	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D) \
		TARGET=$(BR2_ARCH) USELZO=on LINKTYPE=dynamic

TARGET=$(BR2_ARCH): did you check it builds with all CPU architectures supported by Buildroot? In the above proposed test with test-pkg, I'd suggest doing one run with the -a option to check with all toolchains supported by Buildroot.

Quoted 8 lines

Also, USELZO=on indicates that the LZO dependency, could you make it optional? I.e, drop the select BR2_PACKAGE_LZO from Config.in, and in the .mk file, do something like:

ifeq ($(BR2_PACKAGE_LZO),y)
MAKEDUMPFILE_DEPENDENCIES += lzo
MAKEDUMPFILE_MAKE_OPTS += USELZO=on
endif

Fixed.

Regards
Alex