diff mbox series

kbd: use zlib to decompress files

Message ID 20260112085422.683754-1-hongxu.jia@windriver.com
State New
Headers show
Series kbd: use zlib to decompress files | expand

Commit Message

Hongxu Jia Jan. 12, 2026, 8:54 a.m. UTC
Upstream used zlib to decompress files [1], add PACKAGECONFIG
zlib to avoid host contamination.

Backport a patch from upstream [2] to fix compile failure while
zlib is used

[1] https://git.kernel.org/pub/scm/linux/kernel/git/legion/kbd.git/commit/?id=7fdd8debe37ae52812b77d82e08713bd62c607f4
[2] https://github.com/legionus/kbd/commit/2f9a4e56c2ef245fbe840677aad9d5932e17f50d

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 ...x-problem-with-undeclared-sym_gzopen.patch | 57 +++++++++++++++++++
 meta/recipes-core/kbd/kbd_2.9.0.bb            |  3 +
 2 files changed, 60 insertions(+)
 create mode 100644 meta/recipes-core/kbd/kbd/0001-libkbdfile-Fix-problem-with-undeclared-sym_gzopen.patch
diff mbox series

Patch

diff --git a/meta/recipes-core/kbd/kbd/0001-libkbdfile-Fix-problem-with-undeclared-sym_gzopen.patch b/meta/recipes-core/kbd/kbd/0001-libkbdfile-Fix-problem-with-undeclared-sym_gzopen.patch
new file mode 100644
index 0000000000..84d273c19a
--- /dev/null
+++ b/meta/recipes-core/kbd/kbd/0001-libkbdfile-Fix-problem-with-undeclared-sym_gzopen.patch
@@ -0,0 +1,57 @@ 
+From 2f9a4e56c2ef245fbe840677aad9d5932e17f50d Mon Sep 17 00:00:00 2001
+From: Alexey Gladkov <legion@kernel.org>
+Date: Mon, 8 Dec 2025 11:28:24 +0100
+Subject: [PATCH] libkbdfile: Fix problem with undeclared sym_gzopen
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+A compile error occurs on certain systems:
+
+kbdfile-zlib.c: In function 'dlopen_note':
+elf-note.h:27:30: error: 'sym_gzopen' undeclared (first use in this function); did you mean 'sym_gzopen64'?
+   27 | #define DLSYM_ARG(symbol__) &sym_##symbol__, STRINGIFY(symbol__),
+
+kbdfile-zlib.c: In function 'kbdfile_decompressor_zlib': kbdfile-zlib.c:61:15: error: implicit declaration of function 'sym_gzopen'; did you mean 'sym_gzopen64'?
+ [-Wimplicit-function-declaration]
+   61 |         gzf = sym_gzopen(file->pathname, "rb");
+
+The problem arises because if -D_FILE_OFFSET_BITS=64 is specified, which
+in zlib ultimately makes gzopen a macro that expands to gzopen64.
+DECLARE_SYM(gzopen) from elf-note.h then expands gzopen to gzopen64,
+resulting in sym_gzopen64 declared. That's why no sym_gzopen exists.
+
+Link: https://github.com/legionus/kbd/pull/150
+Suggested-by: Jan Čermák <sairon@sairon.cz>
+Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
+Signed-off-by: Alexey Gladkov <legion@kernel.org>
+
+Upstream-Status: Backport [https://github.com/legionus/kbd/commit/2f9a4e56c2ef245fbe840677aad9d5932e17f50d]
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+---
+ src/libkbdfile/elf-note.h | 5 +----
+ 1 file changed, 1 insertion(+), 4 deletions(-)
+
+diff --git a/src/libkbdfile/elf-note.h b/src/libkbdfile/elf-note.h
+index a0fd9e2..d3b8d5c 100644
+--- a/src/libkbdfile/elf-note.h
++++ b/src/libkbdfile/elf-note.h
+@@ -26,14 +26,11 @@ int dlsym_many(void **dlp, const char *filename, ...);
+  */
+ #define DLSYM_ARG(symbol__) &sym_##symbol__, STRINGIFY(symbol__),
+ 
+-/* For symbols being dynamically loaded */
+-#define DECLARE_DLSYM(symbol) static typeof(symbol) *sym_##symbol
+-
+ /*
+  * Helper defines, to be done locally before including this header to switch between
+  * implementations
+  */
+-#define DECLARE_SYM(sym__) DECLARE_DLSYM(sym__);
++#define DECLARE_SYM(sym__) static typeof(sym__) *sym_##sym__;
+ 
+ /*
+  * Originally from systemd codebase.
+-- 
+2.49.0
+
diff --git a/meta/recipes-core/kbd/kbd_2.9.0.bb b/meta/recipes-core/kbd/kbd_2.9.0.bb
index ae07979733..79b011e529 100644
--- a/meta/recipes-core/kbd/kbd_2.9.0.bb
+++ b/meta/recipes-core/kbd/kbd_2.9.0.bb
@@ -25,6 +25,7 @@  RCONFLICTS:${PN} = "console-tools"
 
 SRC_URI = "${KERNELORG_MIRROR}/linux/utils/${BPN}/${BP}.tar.xz \
            file://0001-Preserve-only-necessary-metadata-during-install.patch \
+           file://0001-libkbdfile-Fix-problem-with-undeclared-sym_gzopen.patch \
            "
 
 SRC_URI[sha256sum] = "fb3197f17a99eb44d22a3a1a71f755f9622dd963e66acfdea1a45120951b02ed"
@@ -32,9 +33,11 @@  SRC_URI[sha256sum] = "fb3197f17a99eb44d22a3a1a71f755f9622dd963e66acfdea1a4512095
 # 'gzip -n' is set due to https://github.com/legionus/kbd/issues/124
 EXTRA_OECONF = "--disable-tests --enable-compress='gzip -n'"
 PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)} \
+                   zlib \
                   "
 
 PACKAGECONFIG[pam] = "--enable-vlock, --disable-vlock, libpam,"
+PACKAGECONFIG[zlib] = "--with-zlib=yes, --with-zlib=no, zlib"
 
 PACKAGES += "${PN}-consolefonts ${PN}-keymaps-pine ${PN}-keymaps ${PN}-unimaps ${PN}-consoletrans"