sys-apps/keyutils: Sync with Gentoo

It's from Gentoo commit 0e727a3a16bc2abfd39386f10821d3e5ce89c45a.
This commit is contained in:
Krzesimir Nowak 2025-04-03 15:19:14 +02:00
parent b677163275
commit 327f06ecde
4 changed files with 114 additions and 44 deletions

View File

@ -1,3 +0,0 @@
We keep this package in overlay, because we install the keyutils
config file in /usr instead of /etc, and then establish some symlinks
during installation and with systemd's tmpfiles.d utility.

View File

@ -0,0 +1,76 @@
https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git/commit/?id=c076dff259e99d84d3822b4d2ad7f3f66532f411
From c076dff259e99d84d3822b4d2ad7f3f66532f411 Mon Sep 17 00:00:00 2001
From: Pavel Reichl <preichl@redhat.com>
Date: Tue, 20 Dec 2022 14:13:29 +0100
Subject: test: Fix test expectation based on kernel config
Some test results are dependent on the kernel configuration option
CONFIG_SYSTEM_BLACKLIST_AUTH_UPDATE.
Check the kernel configuration file for its presence and expect appropriate
test results.
Function has_kernel_config is based on its xfstsests counterpart.
Signed-off-by: Pavel Reichl <preichl@redhat.com>
Signed-off-by: David Howells <dhowells@redhat.com>
--- a/tests/features/builtin_trusted/runtest.sh
+++ b/tests/features/builtin_trusted/runtest.sh
@@ -33,7 +33,11 @@ expect_error EACCES
create_key --fail user a a $stk
expect_error EOPNOTSUPP
create_key --fail user a a $blk
-expect_error EACCES
+if has_kernel_config "CONFIG_SYSTEM_BLACKLIST_AUTH_UPDATE"; then
+ expect_error EOPNOTSUPP
+else
+ expect_error EACCES
+fi
# Try adding a key to the keyrings
marker "TRY ADDING ASYMMETRIC KEYS"
@@ -89,7 +93,11 @@ expect_error EACCES
create_key --fail -x asymmetric "" "$x509" $stk
expect_error ENOKEY
create_key --fail -x asymmetric "" "$x509" $blk
-expect_error EACCES
+if has_kernel_config "CONFIG_SYSTEM_BLACKLIST_AUTH_UPDATE"; then
+ expect_error EOPNOTSUPP
+else
+ expect_error EACCES
+fi
echo "++++ FINISHED TEST: $result" >>$OUTPUTFILE
--- a/tests/prepare.inc.sh
+++ b/tests/prepare.inc.sh
@@ -4,6 +4,26 @@
includes=${BASH_SOURCE[0]}
includes=${includes%/*}/
+# Check if currently running kernel has option set
+function has_kernel_config()
+{
+ local option=$1
+ local uname=$(uname -r)
+ local config_list="$KCONFIG_PATH
+ /lib/modules/$uname/build/.config
+ /boot/config-$uname
+ /lib/kernel/config-$uname"
+
+ for config in $config_list; do
+ [ ! -f $config ] && continue
+ grep -qE "^${option}=[my]" $config
+ return
+ done
+
+ echo "Failed to find kernel configuration file"
+ return false
+}
+
# --- need to run in own session keyring
watch_fd=0
if [ "$1" != "--inside-test-session" ]
--
cgit 1.2.3-korg

View File

@ -1,3 +0,0 @@
L /etc/request-key.conf - - - - ../usr/share/keyutils/request-key.conf
d /etc/request-key.d - - - - -
d /etc/keyutils - - - - -

View File

@ -1,10 +1,9 @@
# Copyright 1999-2023 Gentoo Authors # Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=7 EAPI=7
TMPFILES_OPTIONAL=1 inherit toolchain-funcs linux-info multilib-minimal
inherit toolchain-funcs linux-info multilib-minimal usr-ldscript systemd tmpfiles
DESCRIPTION="Linux Key Management Utilities" DESCRIPTION="Linux Key Management Utilities"
HOMEPAGE="https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git" HOMEPAGE="https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git"
@ -12,7 +11,7 @@ SRC_URI="https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git/s
LICENSE="GPL-2 LGPL-2.1" LICENSE="GPL-2 LGPL-2.1"
SLOT="0/1.9" SLOT="0/1.9"
KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ~ppc ppc64 ~riscv ~s390 ~sparc x86 ~amd64-linux ~x86-linux" KEYWORDS="~alpha amd64 arm arm64 hppa ~loong ~m68k ~mips ~ppc ppc64 ~riscv ~s390 ~sparc x86 ~amd64-linux ~x86-linux"
IUSE="static static-libs test" IUSE="static static-libs test"
RESTRICT="!test? ( test )" RESTRICT="!test? ( test )"
@ -24,10 +23,9 @@ PATCHES=(
"${FILESDIR}"/${PN}-1.5.10-disable-tests.patch #519062 #522050 "${FILESDIR}"/${PN}-1.5.10-disable-tests.patch #519062 #522050
"${FILESDIR}"/${PN}-1.5.9-header-extern-c.patch "${FILESDIR}"/${PN}-1.5.9-header-extern-c.patch
"${FILESDIR}"/${PN}-1.6.3-fix-rpmspec-check.patch "${FILESDIR}"/${PN}-1.6.3-fix-rpmspec-check.patch
"${FILESDIR}"/${P}-tests.patch
) )
MAKEOPTS+=" ETCDIR=/usr/share/keyutils"
pkg_setup() { pkg_setup() {
# To prevent a failure in test phase and false positive bug reports # To prevent a failure in test phase and false positive bug reports
# we are enforcing the following options because testsuite expects # we are enforcing the following options because testsuite expects
@ -72,30 +70,38 @@ src_prepare() {
multilib_copy_sources multilib_copy_sources
} }
multilib_src_compile() { mymake() {
tc-export AR CC CXX local args=(
sed -i \ PREFIX="${EPREFIX}/usr"
-e "1iRPATH = $(usex static -static '')" \ ETCDIR="${EPREFIX}/etc"
-e '/^C.*FLAGS/s|:=|+=|' \ BINDIR="${EPREFIX}/bin"
-e 's:-Werror::' \ SBINDIR="${EPREFIX}/sbin"
-e '/^BUILDFOR/s:=.*:=:' \ SHAREDIR="${EPREFIX}/usr/share/keyutils"
-e "/^LIBDIR/s:=.*:= /usr/$(get_libdir):" \ MANDIR="${EPREFIX}/usr/share/man"
-e '/^USRLIBDIR/s:=.*:=$(LIBDIR):' \ INCLUDEDIR="${EPREFIX}/usr/include"
-e "s: /: ${EPREFIX}/:g" \ LIBDIR="${EPREFIX}/usr/$(get_libdir)"
-e '/^NO_ARLIB/d' \ USRLIBDIR="${EPREFIX}/usr/$(get_libdir)"
Makefile || die CFLAGS="${CFLAGS}"
CXXFLAGS="${CXXFLAGS}"
# We need the static lib in order to statically link programs. RPATH=$(usex static -static '')
if use static ; then BUILDFOR=
export NO_ARLIB=0 NO_ARLIB="${NO_ARLIB}"
# Hack the progs to depend on the static lib instead. )
sed -i \ if use static; then
-e '/^.*:.*[$](DEVELLIB)$/s:$(DEVELLIB):$(ARLIB) $(SONAME):' \ args+=( LIB_DEPENDENCY='$(ARLIB)' )
Makefile || die
else
export NO_ARLIB=$(usex static-libs 0 1)
fi fi
emake emake "${args[@]}" "$@"
}
multilib_src_compile() {
local NO_ARLIB
if use static; then
NO_ARLIB=0
else
NO_ARLIB=$(usex static-libs 0 1)
fi
tc-export AR CC CXX
mymake
} }
multilib_src_test() { multilib_src_test() {
@ -103,19 +109,13 @@ multilib_src_test() {
# older versions already installed in the system. # older versions already installed in the system.
LD_LIBRARY_PATH=${BUILD_DIR} \ LD_LIBRARY_PATH=${BUILD_DIR} \
PATH="${BUILD_DIR}:${PATH}" \ PATH="${BUILD_DIR}:${PATH}" \
emake test mymake test
} }
multilib_src_install() { multilib_src_install() {
dotmpfiles "${FILESDIR}/tmpfiles.d/keyutils.conf"
# Possibly undo the setting for USE=static (see src_compile). # Possibly undo the setting for USE=static (see src_compile).
export NO_ARLIB=$(usex static-libs 0 1) local NO_ARLIB=$(usex static-libs 0 1)
mymake DESTDIR="${D}" install
default
use static || gen_usr_ldscript -a keyutils
dosym ../usr/share/keyutils/request-key.conf /etc/request-key.conf
dodir /etc/request-key.d
dodir /etc/keyutils
} }
multilib_src_install_all() { multilib_src_install_all() {