commit:     74e283b875a4253c03d202e9ea668c38b1d70b0b
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 16 10:10:01 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Dec 16 10:10:01 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=74e283b8

sys-apps/kbd: backport various fixes to 2.9.0

Closes: https://bugs.gentoo.org/964410
Signed-off-by: Sam James <sam <AT> gentoo.org>

 sys-apps/kbd/files/kbd-2.9.0-install-no-attr.patch |  55 +++++++++++
 sys-apps/kbd/files/kbd-2.9.0-install-posix.patch   |  41 ++++++++
 sys-apps/kbd/files/kbd-2.9.0-nullptr.patch         |  45 +++++++++
 sys-apps/kbd/files/kbd-2.9.0-time64.patch          |  54 ++++++++++
 sys-apps/kbd/files/kbd-2.9.0-uninit.patch          |  33 +++++++
 sys-apps/kbd/kbd-2.9.0-r1.ebuild                   | 109 +++++++++++++++++++++
 6 files changed, 337 insertions(+)

diff --git a/sys-apps/kbd/files/kbd-2.9.0-install-no-attr.patch 
b/sys-apps/kbd/files/kbd-2.9.0-install-no-attr.patch
new file mode 100644
index 000000000000..c3db405c28a6
--- /dev/null
+++ b/sys-apps/kbd/files/kbd-2.9.0-install-no-attr.patch
@@ -0,0 +1,55 @@
+https://github.com/legionus/kbd/commit/db82eb6f86e6c0b8ac4260e88b88d66e1cd7c077
+
+From db82eb6f86e6c0b8ac4260e88b88d66e1cd7c077 Mon Sep 17 00:00:00 2001
+From: Alexey Gladkov <[email protected]>
+Date: Wed, 10 Sep 2025 10:45:25 +0200
+Subject: [PATCH] Preserve only necessary metadata during install
+
+"cp -a" tries to preserve all attributes if possible. This implies
+preserving mode, any ACL, xattr permissions, and security context.
+
+In some cases (such as fakeroot), it is not possible to preserve that
+all attributes are preserved.
+
+  cp: failed to preserve ownership for 
/tmp/.pkgmk/pkg/usr/share/kbd/keymaps/i386/qwertz/sr-latin.map.gz: Operation 
not supported
+
+To avoid this, we will require that only the necessary attributes be
+preserved. It is important for us to preserve the simlinks.
+
+Signed-off-by: Alexey Gladkov <[email protected]>
+---
+ data/Makefile.am | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/data/Makefile.am b/data/Makefile.am
+index a730062b..4d2ae3d1 100644
+--- a/data/Makefile.am
++++ b/data/Makefile.am
+@@ -44,21 +44,21 @@ endif
+ 
+ install-consolefonts: $(SRC_FONTDIR) $(SRC_PARTIALDIR)
+       mkdir -p -m 755 -- $(DESTDIR)$(datadir)/$(FONTDIR)
+-      cp -a -- $(SRC_FONTDIR)/* $(DESTDIR)$(datadir)/$(FONTDIR)/
++      cp -dPR -- $(SRC_FONTDIR)/* $(DESTDIR)$(datadir)/$(FONTDIR)/
+       mkdir -p -m 755 -- $(DESTDIR)$(datadir)/$(FONTDIR)/$(PARTIALDIR)
+-      cp -a -- $(SRC_PARTIALDIR)/* 
$(DESTDIR)$(datadir)/$(FONTDIR)/$(PARTIALDIR)/
++      cp -dPR -- $(SRC_PARTIALDIR)/* 
$(DESTDIR)$(datadir)/$(FONTDIR)/$(PARTIALDIR)/
+ 
+ install-consoletrans:
+       mkdir -p -m 755 -- $(DESTDIR)$(datadir)/$(TRANSDIR)
+-      cp -a -- $(srcdir)/$(TRANSDIR)/* $(DESTDIR)$(datadir)/$(TRANSDIR)/
++      cp -dPR -- $(srcdir)/$(TRANSDIR)/* $(DESTDIR)$(datadir)/$(TRANSDIR)/
+ 
+ install-unimaps:
+       mkdir -p -m 755 -- $(DESTDIR)$(datadir)/$(UNIMAPDIR)
+-      cp -a -- $(srcdir)/$(UNIMAPDIR)/* $(DESTDIR)$(datadir)/$(UNIMAPDIR)/
++      cp -dPR -- $(srcdir)/$(UNIMAPDIR)/* $(DESTDIR)$(datadir)/$(UNIMAPDIR)/
+ 
+ install-keymaps: $(SRC_KEYMAPDIR)
+       mkdir -p -m 755 -- $(DESTDIR)$(datadir)/$(KEYMAPDIR)
+-      cp -ar -- $(SRC_KEYMAPDIR)/* $(DESTDIR)$(datadir)/$(KEYMAPDIR)/
++      cp -dPR -- $(SRC_KEYMAPDIR)/* $(DESTDIR)$(datadir)/$(KEYMAPDIR)/
+       cd "$(DESTDIR)$(datadir)/$(KEYMAPDIR)"; \
+         for f in $(IGNORE_KEYMAPS); do ! test -e "$$f" || rm -f -- "$$f"; done
+       rm -f $(DESTDIR)$(datadir)/$(KEYMAPDIR)/ppc
+

diff --git a/sys-apps/kbd/files/kbd-2.9.0-install-posix.patch 
b/sys-apps/kbd/files/kbd-2.9.0-install-posix.patch
new file mode 100644
index 000000000000..73e125d58437
--- /dev/null
+++ b/sys-apps/kbd/files/kbd-2.9.0-install-posix.patch
@@ -0,0 +1,41 @@
+https://github.com/legionus/kbd/commit/51ee1d95fae950323b62d3f31b14dc1e0e436762
+
+From 51ee1d95fae950323b62d3f31b14dc1e0e436762 Mon Sep 17 00:00:00 2001
+From: "Haelwenn (lanodan) Monnier" <[email protected]>
+Date: Fri, 31 Oct 2025 04:44:33 +0100
+Subject: [PATCH] data/Makefile.am: put `--` between end of option and mode
+
+POSIX comforming getopt(3) will stop parsing options at the mode argument
+(provided it doesn't starts with a dash).
+So prior to this change `--` would be taken as a file argument
+because getopt(3) already stopped.
+
+Signed-off-by: Haelwenn (lanodan) Monnier <[email protected]>
+---
+ data/Makefile.am | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/data/Makefile.am b/data/Makefile.am
+index 4d2ae3d1..8cd3610a 100644
+--- a/data/Makefile.am
++++ b/data/Makefile.am
+@@ -22,15 +22,15 @@ V_PACK_1 =
+ 
+ # compress data files - do not touch the distribution but copy first
+ $(SRC_KEYMAPDIR): $(KEYMAPDIR)
+-      $(V_PACK)cp -r -- "$<" "$@" && chmod -R u+w -- "$@" && \
++      $(V_PACK)cp -r -- "$<" "$@" && chmod -R -- u+w "$@" && \
+       $(srcdir)/compress.sh "$@"/*/*.map "$@"/*/*/*.map
+ 
+ $(SRC_FONTDIR): $(FONTDIR)
+-      $(V_PACK)cp -r -- "$<" "$@" && chmod -R u+w -- "$@" && \
++      $(V_PACK)cp -r -- "$<" "$@" && chmod -R -- u+w "$@" && \
+       $(srcdir)/compress.sh "$@"/*
+ 
+ $(SRC_PARTIALDIR): $(PARTIALDIR)
+-      $(V_PACK)cp -r -- "$<" "$@" && chmod -R u+w -- "$@" && \
++      $(V_PACK)cp -r -- "$<" "$@" && chmod -R -- u+w "$@" && \
+       $(srcdir)/compress.sh "$@"/*
+ 
+ # (not yet screenmaps - some other time)
+

diff --git a/sys-apps/kbd/files/kbd-2.9.0-nullptr.patch 
b/sys-apps/kbd/files/kbd-2.9.0-nullptr.patch
new file mode 100644
index 000000000000..cf10ac034dac
--- /dev/null
+++ b/sys-apps/kbd/files/kbd-2.9.0-nullptr.patch
@@ -0,0 +1,45 @@
+https://github.com/legionus/kbd/commit/c5473634bbb653f0b61bd237d0e4bdfc9cfe3650
+
+From c5473634bbb653f0b61bd237d0e4bdfc9cfe3650 Mon Sep 17 00:00:00 2001
+From: Bohai Li <[email protected]>
+Date: Wed, 19 Nov 2025 00:31:52 +0800
+Subject: [PATCH] Fix NULL reference in option parser
+
+If an option that needs an argument is given, but the argument is
+actually missing, the optind will increase by 1 and return, and if
+the option is the last option, a NULL reference occurs at
+setfont.c:290. This bug is fixed by returning '!' instead of '?' to
+main and process this condition separately.
+
+Signed-off-by: Bohai Li <[email protected]>
+---
+ src/setfont.c | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/src/setfont.c b/src/setfont.c
+index 18eb6386..dc336c18 100644
+--- a/src/setfont.c
++++ b/src/setfont.c
+@@ -158,8 +158,8 @@ kbd_getopt(int argc, char **argv, const struct kbd_option 
*opts)
+       return '?';
+ 
+ required_argument:
+-      kbd_warning(0, "option '%s' requires an argument", name);
+-      return '?';
++      optind--;
++      return '!';
+ }
+ 
+ int main(int argc, char *argv[])
+@@ -296,6 +296,10 @@ int main(int argc, char *argv[])
+                                       kbd_error(EX_USAGE, 0, _("Too many 
input files."));
+                               ifiles[ifilct++] = argv[optind++];
+                               break;
++                      case '!':
++                              kbd_warning(0, "option '%s' requires an 
argument", argv[optind]);
++                              usage(EX_USAGE, opthelp);
++                              break;
+               }
+       }
+ 
+

diff --git a/sys-apps/kbd/files/kbd-2.9.0-time64.patch 
b/sys-apps/kbd/files/kbd-2.9.0-time64.patch
new file mode 100644
index 000000000000..6618e0deb5d6
--- /dev/null
+++ b/sys-apps/kbd/files/kbd-2.9.0-time64.patch
@@ -0,0 +1,54 @@
+https://github.com/legionus/kbd/commit/2f9a4e56c2ef245fbe840677aad9d5932e17f50d
+
+From 2f9a4e56c2ef245fbe840677aad9d5932e17f50d Mon Sep 17 00:00:00 2001
+From: Alexey Gladkov <[email protected]>
+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 <[email protected]>
+Signed-off-by: Bernd Kuhls <[email protected]>
+Signed-off-by: Alexey Gladkov <[email protected]>
+---
+ 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 a0fd9e23..d3b8d5c9 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.
+

diff --git a/sys-apps/kbd/files/kbd-2.9.0-uninit.patch 
b/sys-apps/kbd/files/kbd-2.9.0-uninit.patch
new file mode 100644
index 000000000000..857c1c6ba242
--- /dev/null
+++ b/sys-apps/kbd/files/kbd-2.9.0-uninit.patch
@@ -0,0 +1,33 @@
+https://github.com/legionus/kbd/commit/7aa15f4c44b570a667b4911a2b6db0e6b9145da5
+
+From 7aa15f4c44b570a667b4911a2b6db0e6b9145da5 Mon Sep 17 00:00:00 2001
+From: Tommy-Zhang3759 <[email protected]>
+Date: Sat, 6 Dec 2025 05:18:43 +1100
+Subject: [PATCH] setfont: Initialize data pointer when resetting font
+
+When resetting the font to default, the `data` field in the
+`console_font_op` structure must be explicitly set to NULL.
+
+Previously, this field was left uninitialized. The kernel treats a
+non-NULL `data` pointer as a pointer to a font name string. This caused
+the ioctl to fail with -EFAULT (Bad address) because it attempted to
+read from a garbage address.
+
+Signed-off-by: Yutao Zhang <[email protected]>
+---
+ src/libkfont/kdfontop.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/libkfont/kdfontop.c b/src/libkfont/kdfontop.c
+index 8f132ff5..4f1f0d2a 100644
+--- a/src/libkfont/kdfontop.c
++++ b/src/libkfont/kdfontop.c
+@@ -46,6 +46,7 @@ kfont_restore_font(struct kfont_context *ctx, int fd)
+               return -1;
+ 
+       cfo.op = KD_FONT_OP_SET_DEFAULT;
++      cfo.data = NULL;
+ 
+       if (ioctl(fd, KDFONTOP, &cfo)) {
+               KFONT_ERR(ctx, "ioctl(KD_FONT_OP_SET_DEFAULT): %m");
+

diff --git a/sys-apps/kbd/kbd-2.9.0-r1.ebuild b/sys-apps/kbd/kbd-2.9.0-r1.ebuild
new file mode 100644
index 000000000000..39e22e346db7
--- /dev/null
+++ b/sys-apps/kbd/kbd-2.9.0-r1.ebuild
@@ -0,0 +1,109 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit autotools multiprocessing
+
+if [[ ${PV} == 9999 ]] ; then
+       inherit autotools git-r3
+       EGIT_REPO_URI="https://github.com/legionus/kbd.git 
https://git.kernel.org/pub/scm/linux/kernel/git/legion/kbd.git";
+       EGIT_BRANCH="master"
+else
+       if [[ $(ver_cut 3) -lt 90 ]] ; then
+               SRC_URI="https://www.kernel.org/pub/linux/utils/kbd/${P}.tar.xz";
+               KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips 
~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
+       else
+               inherit autotools
+               SRC_URI="https://github.com/legionus/kbd/archive/v${PV}.tar.gz 
-> ${P}.tar.gz"
+       fi
+fi
+
+DESCRIPTION="Keyboard and console utilities"
+HOMEPAGE="https://kbd-project.org/";
+
+LICENSE="GPL-2"
+SLOT="0"
+IUSE="bzip2 lzma nls selinux pam test zlib zstd"
+RESTRICT="!test? ( test )"
+
+DEPEND="
+       app-alternatives/gzip
+       bzip2? ( app-arch/bzip2 )
+       lzma? ( app-arch/xz-utils )
+       pam? (
+               !app-misc/vlock
+               sys-libs/pam
+       )
+       zlib? ( virtual/zlib:= )
+       zstd? ( app-arch/zstd:= )
+"
+RDEPEND="
+       ${DEPEND}
+       selinux? ( sec-policy/selinux-loadkeys )
+"
+BDEPEND="
+       sys-devel/flex
+       virtual/pkgconfig
+       test? ( dev-libs/check )
+"
+
+PATCHES=(
+       "${FILESDIR}"/${P}-install-no-attr.patch
+       "${FILESDIR}"/${P}-install-posix.patch
+       "${FILESDIR}"/${P}-nullptr.patch
+       "${FILESDIR}"/${P}-uninit.patch
+       "${FILESDIR}"/${P}-time64.patch
+)
+
+src_prepare() {
+       default
+
+       # Rename conflicting keymaps to have unique names, bug #293228
+       # See also https://github.com/legionus/kbd/issues/76.
+       pushd "${S}"/data/keymaps/i386 &> /dev/null || die
+       mv fgGIod/trf.map fgGIod/trf-fgGIod.map || die
+       mv olpc/es.map olpc/es-olpc.map || die
+       mv olpc/pt.map olpc/pt-olpc.map || die
+       mv qwerty/cz.map qwerty/cz-qwerty.map || die
+       popd &> /dev/null || die
+
+       #if [[ ${PV} == 9999 ]] || [[ $(ver_cut 3) -ge 90 ]] ; then
+       #       eautoreconf
+       #fi
+
+       # Drop after 2.9.0
+       eautoreconf
+}
+
+src_configure() {
+       # https://github.com/legionus/kbd/issues/121
+       unset LEX
+
+       local myeconfargs=(
+               --disable-werror
+               # No Valgrind for the testsuite
+               --disable-memcheck
+
+               $(use_enable nls)
+               $(use_enable pam vlock)
+               $(use_enable test tests)
+               $(use_with bzip2)
+               $(use_with lzma)
+               $(use_with zlib)
+               $(use_with zstd)
+       )
+
+       econf "${myeconfargs[@]}"
+}
+
+src_test() {
+       emake -Onone check TESTSUITEFLAGS="--jobs=$(get_makeopts_jobs)"
+}
+
+src_install() {
+       default
+
+       # USE="test" installs .la files
+       find "${ED}" -type f -name "*.la" -delete || die
+}

Reply via email to