sys-apps/kbd: backport various fixes to 2.9.0

Closes: https://bugs.gentoo.org/964410
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Sam James 2025-12-16 10:10:01 +00:00
parent cc35cf664b
commit 74e283b875
No known key found for this signature in database
GPG Key ID: 738409F520DF9190
6 changed files with 337 additions and 0 deletions

View File

@ -0,0 +1,55 @@
https://github.com/legionus/kbd/commit/db82eb6f86e6c0b8ac4260e88b88d66e1cd7c077
From db82eb6f86e6c0b8ac4260e88b88d66e1cd7c077 Mon Sep 17 00:00:00 2001
From: Alexey Gladkov <legion@kernel.org>
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 <legion@kernel.org>
---
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

View File

@ -0,0 +1,41 @@
https://github.com/legionus/kbd/commit/51ee1d95fae950323b62d3f31b14dc1e0e436762
From 51ee1d95fae950323b62d3f31b14dc1e0e436762 Mon Sep 17 00:00:00 2001
From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
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 <contact@hacktivis.me>
---
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)

View File

@ -0,0 +1,45 @@
https://github.com/legionus/kbd/commit/c5473634bbb653f0b61bd237d0e4bdfc9cfe3650
From c5473634bbb653f0b61bd237d0e4bdfc9cfe3650 Mon Sep 17 00:00:00 2001
From: Bohai Li <lbhlbhlbh2002@icloud.com>
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 <lbhlbhlbh2002@icloud.com>
---
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;
}
}

View File

@ -0,0 +1,54 @@
https://github.com/legionus/kbd/commit/2f9a4e56c2ef245fbe840677aad9d5932e17f50d
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>
---
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.

View File

@ -0,0 +1,33 @@
https://github.com/legionus/kbd/commit/7aa15f4c44b570a667b4911a2b6db0e6b9145da5
From 7aa15f4c44b570a667b4911a2b6db0e6b9145da5 Mon Sep 17 00:00:00 2001
From: Tommy-Zhang3759 <tommyzhang4707@outlook.com>
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 <tommyzhang4707@outlook.com>
---
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");

View File

@ -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
}