public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-apps/kmod/files/, sys-apps/kmod/
Date: Sat,  2 Mar 2024 00:15:31 +0000 (UTC)	[thread overview]
Message-ID: <1709338483.7e18d8b8c3d468754790010cc157cc8eaff3d5b5.sam@gentoo> (raw)

commit:     7e18d8b8c3d468754790010cc157cc8eaff3d5b5
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Mar  2 00:13:33 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Mar  2 00:14:43 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7e18d8b8

sys-apps/kmod: drop Python bindings, fix musl-1.2.5 compat (modern C porting)

* Drop Python bindings for weird double install issue (bug #925568).

  This is a somewhat extreme response, but it turns out upstream have dropped
  the bindings upstream anyway in https://github.com/kmod-project/kmod/commit/594f102cf575b0d5c01ebff22aae450c8a204d45
  for the next release.

* Fix musl-1.2.5 compat wrt POSIX vs GNU basename.

  Would segfault at runtime otherwise on a non-strict C compiler.

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

 sys-apps/kmod/files/kmod-31-musl-basename.patch    | 113 +++++++++++++++++++++
 .../kmod/{kmod-9999.ebuild => kmod-31-r1.ebuild}   | 102 +++----------------
 sys-apps/kmod/kmod-9999.ebuild                     | 102 +++----------------
 3 files changed, 145 insertions(+), 172 deletions(-)

diff --git a/sys-apps/kmod/files/kmod-31-musl-basename.patch b/sys-apps/kmod/files/kmod-31-musl-basename.patch
new file mode 100644
index 000000000000..f4839dad2474
--- /dev/null
+++ b/sys-apps/kmod/files/kmod-31-musl-basename.patch
@@ -0,0 +1,113 @@
+https://github.com/kmod-project/kmod/pull/32
+
+From 721ed6040c7aa47070faf6378c433089e178bd43 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sat, 9 Dec 2023 17:35:59 -0800
+Subject: [PATCH] Use portable implementation for basename API
+
+musl has removed the non-prototype declaration of basename from
+string.h [1] which now results in build errors with clang-17+ compiler
+
+Implement GNU basename behavior using strchr which is portable across libcs
+
+Fixes
+../git/tools/kmod.c:71:19: error: call to undeclared function 'basename'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
+71 | "Commands:\n", basename(argv[0]));
+| ^
+
+[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7
+
+Suggested-by: Rich Felker
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+--- a/libkmod/libkmod-config.c
++++ b/libkmod/libkmod-config.c
+@@ -794,7 +794,7 @@ static int conf_files_insert_sorted(struct kmod_ctx *ctx,
+ 	bool is_single = false;
+ 
+ 	if (name == NULL) {
+-		name = basename(path);
++		name = gnu_basename(path);
+ 		is_single = true;
+ 	}
+ 
+--- a/shared/util.c
++++ b/shared/util.c
+@@ -172,9 +172,9 @@ char *modname_normalize(const char *modname, char buf[static PATH_MAX], size_t *
+ 
+ char *path_to_modname(const char *path, char buf[static PATH_MAX], size_t *len)
+ {
+-	char *modname;
++	const char *modname;
+ 
+-	modname = basename(path);
++	modname = gnu_basename(path);
+ 	if (modname == NULL || modname[0] == '\0')
+ 		return NULL;
+ 
+--- a/shared/util.h
++++ b/shared/util.h
+@@ -5,6 +5,7 @@
+ #include <stdbool.h>
+ #include <stdlib.h>
+ #include <stdio.h>
++#include <string.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <time.h>
+@@ -76,6 +77,12 @@ do {						\
+ 	__p->__v = (val);			\
+ } while(0)
+ 
++static _always_inline_ const char *gnu_basename(const char *s)
++{
++  const char *p = strrchr(s, '/');
++  return p ? p+1 : s;
++}
++
+ static _always_inline_ unsigned int ALIGN_POWER2(unsigned int u)
+ {
+ 	return 1 << ((sizeof(u) * 8) - __builtin_clz(u - 1));
+--- a/testsuite/testsuite.c
++++ b/testsuite/testsuite.c
+@@ -70,7 +70,7 @@ static void help(void)
+ 
+ 	printf("Usage:\n"
+ 	       "\t%s [options] <test>\n"
+-	       "Options:\n", basename(progname));
++	       "Options:\n", gnu_basename(progname));
+ 
+ 	for (itr = options, itr_short = options_short;
+ 				itr->name != NULL; itr++, itr_short++)
+--- a/tools/depmod.c
++++ b/tools/depmod.c
+@@ -762,7 +762,7 @@ static int cfg_files_insert_sorted(struct cfg_file ***p_files, size_t *p_n_files
+ 	if (name != NULL)
+ 		namelen = strlen(name);
+ 	else {
+-		name = basename(dir);
++		name = gnu_basename(dir);
+ 		namelen = strlen(name);
+ 		dirlen -= namelen + 1;
+ 	}
+--- a/tools/kmod.c
++++ b/tools/kmod.c
+@@ -68,7 +68,7 @@ static int kmod_help(int argc, char *argv[])
+ 			"Options:\n"
+ 			"\t-V, --version     show version\n"
+ 			"\t-h, --help        show this help\n\n"
+-			"Commands:\n", basename(argv[0]));
++			"Commands:\n", gnu_basename(argv[0]));
+ 
+ 	for (i = 0; i < ARRAY_SIZE(kmod_cmds); i++) {
+ 		if (kmod_cmds[i]->help != NULL) {
+@@ -156,7 +156,7 @@ static int handle_kmod_compat_commands(int argc, char *argv[])
+ 	const char *cmd;
+ 	size_t i;
+ 
+-	cmd = basename(argv[0]);
++	cmd = gnu_basename(argv[0]);
+ 
+ 	for (i = 0; i < ARRAY_SIZE(kmod_compat_cmds); i++) {
+ 		if (streq(kmod_compat_cmds[i]->name, cmd))
+

diff --git a/sys-apps/kmod/kmod-9999.ebuild b/sys-apps/kmod/kmod-31-r1.ebuild
similarity index 61%
copy from sys-apps/kmod/kmod-9999.ebuild
copy to sys-apps/kmod/kmod-31-r1.ebuild
index a67cecf3e9af..d0de1d663e3e 100644
--- a/sys-apps/kmod/kmod-9999.ebuild
+++ b/sys-apps/kmod/kmod-31-r1.ebuild
@@ -3,9 +3,10 @@
 
 EAPI=8
 
-PYTHON_COMPAT=( python3_{10..11} )
+inherit autotools libtool bash-completion-r1
 
-inherit autotools libtool bash-completion-r1 python-r1
+DESCRIPTION="Library and tools for managing linux kernel modules"
+HOMEPAGE="https://git.kernel.org/?p=utils/kernel/kmod/kmod.git"
 
 if [[ ${PV} == 9999* ]]; then
 	EGIT_REPO_URI="https://git.kernel.org/pub/scm/utils/kernel/${PN}/${PN}.git"
@@ -15,12 +16,9 @@ else
 	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
 fi
 
-DESCRIPTION="library and tools for managing linux kernel modules"
-HOMEPAGE="https://git.kernel.org/?p=utils/kernel/kmod/kmod.git"
-
 LICENSE="LGPL-2"
 SLOT="0"
-IUSE="debug doc +lzma pkcs7 python static-libs +tools +zlib +zstd"
+IUSE="debug doc +lzma pkcs7 static-libs +tools +zlib +zstd"
 
 # Upstream does not support running the test suite with custom configure flags.
 # I was also told that the test suite is intended for kmod developers.
@@ -31,15 +29,16 @@ IUSE="debug doc +lzma pkcs7 python static-libs +tools +zlib +zstd"
 # - >=zlib-1.2.6 required because of bug #427130
 # - Block systemd below 217 for -static-nodes-indicate-that-creation-of-static-nodes-.patch
 # - >=zstd-1.5.2-r1 required for bug #771078
-RDEPEND="!sys-apps/module-init-tools
+RDEPEND="
+	!sys-apps/module-init-tools
 	!sys-apps/modutils
 	!<sys-apps/openrc-0.13.8
 	!<sys-apps/systemd-216-r3
 	lzma? ( >=app-arch/xz-utils-5.0.4-r1 )
-	python? ( ${PYTHON_DEPS} )
 	pkcs7? ( >=dev-libs/openssl-1.1.0:= )
 	zlib? ( >=sys-libs/zlib-1.2.6 )
-	zstd? ( >=app-arch/zstd-1.5.2-r1:= )"
+	zstd? ( >=app-arch/zstd-1.5.2-r1:= )
+"
 DEPEND="${RDEPEND}"
 BDEPEND="
 	doc? (
@@ -47,20 +46,15 @@ BDEPEND="
 		dev-build/gtk-doc-am
 	)
 	lzma? ( virtual/pkgconfig )
-	python? (
-		dev-python/cython[${PYTHON_USEDEP}]
-		virtual/pkgconfig
-	)
 	zlib? ( virtual/pkgconfig )
 "
 if [[ ${PV} == 9999* ]]; then
-	BDEPEND="${BDEPEND}
-		dev-libs/libxslt"
+	BDEPEND+=" dev-libs/libxslt"
 fi
 
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-DOCS=( NEWS README.md TODO )
+PATCHES=(
+	"${FILESDIR}"/${PN}-31-musl-basename.patch
+)
 
 src_prepare() {
 	default
@@ -89,8 +83,9 @@ src_configure() {
 		--enable-shared
 		--with-bashcompletiondir="$(get_bashcompdir)"
 		--with-rootlibdir="${EPREFIX}/$(get_libdir)"
+		--disable-python
 		$(use_enable debug)
-		$(usex doc '--enable-gtk-doc' '')
+		$(usev doc '--enable-gtk-doc')
 		$(use_enable static-libs static)
 		$(use_enable tools)
 		$(use_with lzma xz)
@@ -99,76 +94,11 @@ src_configure() {
 		$(use_with zstd)
 	)
 
-	local ECONF_SOURCE="${S}"
-
-	kmod_configure() {
-		mkdir -p "${BUILD_DIR}" || die
-		run_in_build_dir econf "${myeconfargs[@]}" "$@"
-	}
-
-	BUILD_DIR="${WORKDIR}/build"
-	kmod_configure --disable-python
-
-	if use python; then
-		python_foreach_impl kmod_configure --enable-python
-	fi
-}
-
-src_compile() {
-	emake -C "${BUILD_DIR}"
-
-	if use python; then
-		local native_builddir="${BUILD_DIR}"
-
-		python_compile() {
-			emake -C "${BUILD_DIR}" -f Makefile -f - python \
-				VPATH="${native_builddir}:${S}" \
-				native_builddir="${native_builddir}" \
-				libkmod_python_kmod_{kmod,list,module,_util}_la_LIBADD='$(PYTHON_LIBS) $(native_builddir)/libkmod/libkmod.la' \
-				<<< 'python: $(pkgpyexec_LTLIBRARIES)'
-		}
-
-		python_foreach_impl python_compile
-	fi
-}
-
-src_test() {
-	python_test() {
-		mkdir "${T}/test-${EPYTHON}" || die
-		emake -C "${BUILD_DIR}" DESTDIR="${T}/test-${EPYTHON}" \
-				VPATH="${native_builddir}:${S}" \
-				install-pkgpyexecLTLIBRARIES \
-				install-dist_pkgpyexecPYTHON
-
-		# Smoke test based on https://bugs.gentoo.org/891975#c5
-		local -x PYTHONPATH="${T}/test-${EPYTHON}/usr/lib/${EPYTHON}/site-packages:${PYTHONPATH}"
-		${EPYTHON} -c 'import kmod; km = kmod.Kmod(); print([(m.name, m.size) for m in km.loaded()])' || die
-		rm -r "${T}/test-${EPYTHON}" || die
-	}
-
-	if use python; then
-		python_foreach_impl python_test
-	fi
+	econf "${myeconfargs[@]}"
 }
 
 src_install() {
-	emake -C "${BUILD_DIR}" DESTDIR="${D}" install
-
-	einstalldocs
-
-	if use python; then
-		local native_builddir="${BUILD_DIR}"
-
-		python_install() {
-			emake -C "${BUILD_DIR}" DESTDIR="${D}" \
-				VPATH="${native_builddir}:${S}" \
-				install-pkgpyexecLTLIBRARIES \
-				install-dist_pkgpyexecPYTHON
-			python_optimize
-		}
-
-		python_foreach_impl python_install
-	fi
+	default
 
 	find "${ED}" -type f -name "*.la" -delete || die
 

diff --git a/sys-apps/kmod/kmod-9999.ebuild b/sys-apps/kmod/kmod-9999.ebuild
index a67cecf3e9af..d0de1d663e3e 100644
--- a/sys-apps/kmod/kmod-9999.ebuild
+++ b/sys-apps/kmod/kmod-9999.ebuild
@@ -3,9 +3,10 @@
 
 EAPI=8
 
-PYTHON_COMPAT=( python3_{10..11} )
+inherit autotools libtool bash-completion-r1
 
-inherit autotools libtool bash-completion-r1 python-r1
+DESCRIPTION="Library and tools for managing linux kernel modules"
+HOMEPAGE="https://git.kernel.org/?p=utils/kernel/kmod/kmod.git"
 
 if [[ ${PV} == 9999* ]]; then
 	EGIT_REPO_URI="https://git.kernel.org/pub/scm/utils/kernel/${PN}/${PN}.git"
@@ -15,12 +16,9 @@ else
 	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
 fi
 
-DESCRIPTION="library and tools for managing linux kernel modules"
-HOMEPAGE="https://git.kernel.org/?p=utils/kernel/kmod/kmod.git"
-
 LICENSE="LGPL-2"
 SLOT="0"
-IUSE="debug doc +lzma pkcs7 python static-libs +tools +zlib +zstd"
+IUSE="debug doc +lzma pkcs7 static-libs +tools +zlib +zstd"
 
 # Upstream does not support running the test suite with custom configure flags.
 # I was also told that the test suite is intended for kmod developers.
@@ -31,15 +29,16 @@ IUSE="debug doc +lzma pkcs7 python static-libs +tools +zlib +zstd"
 # - >=zlib-1.2.6 required because of bug #427130
 # - Block systemd below 217 for -static-nodes-indicate-that-creation-of-static-nodes-.patch
 # - >=zstd-1.5.2-r1 required for bug #771078
-RDEPEND="!sys-apps/module-init-tools
+RDEPEND="
+	!sys-apps/module-init-tools
 	!sys-apps/modutils
 	!<sys-apps/openrc-0.13.8
 	!<sys-apps/systemd-216-r3
 	lzma? ( >=app-arch/xz-utils-5.0.4-r1 )
-	python? ( ${PYTHON_DEPS} )
 	pkcs7? ( >=dev-libs/openssl-1.1.0:= )
 	zlib? ( >=sys-libs/zlib-1.2.6 )
-	zstd? ( >=app-arch/zstd-1.5.2-r1:= )"
+	zstd? ( >=app-arch/zstd-1.5.2-r1:= )
+"
 DEPEND="${RDEPEND}"
 BDEPEND="
 	doc? (
@@ -47,20 +46,15 @@ BDEPEND="
 		dev-build/gtk-doc-am
 	)
 	lzma? ( virtual/pkgconfig )
-	python? (
-		dev-python/cython[${PYTHON_USEDEP}]
-		virtual/pkgconfig
-	)
 	zlib? ( virtual/pkgconfig )
 "
 if [[ ${PV} == 9999* ]]; then
-	BDEPEND="${BDEPEND}
-		dev-libs/libxslt"
+	BDEPEND+=" dev-libs/libxslt"
 fi
 
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-DOCS=( NEWS README.md TODO )
+PATCHES=(
+	"${FILESDIR}"/${PN}-31-musl-basename.patch
+)
 
 src_prepare() {
 	default
@@ -89,8 +83,9 @@ src_configure() {
 		--enable-shared
 		--with-bashcompletiondir="$(get_bashcompdir)"
 		--with-rootlibdir="${EPREFIX}/$(get_libdir)"
+		--disable-python
 		$(use_enable debug)
-		$(usex doc '--enable-gtk-doc' '')
+		$(usev doc '--enable-gtk-doc')
 		$(use_enable static-libs static)
 		$(use_enable tools)
 		$(use_with lzma xz)
@@ -99,76 +94,11 @@ src_configure() {
 		$(use_with zstd)
 	)
 
-	local ECONF_SOURCE="${S}"
-
-	kmod_configure() {
-		mkdir -p "${BUILD_DIR}" || die
-		run_in_build_dir econf "${myeconfargs[@]}" "$@"
-	}
-
-	BUILD_DIR="${WORKDIR}/build"
-	kmod_configure --disable-python
-
-	if use python; then
-		python_foreach_impl kmod_configure --enable-python
-	fi
-}
-
-src_compile() {
-	emake -C "${BUILD_DIR}"
-
-	if use python; then
-		local native_builddir="${BUILD_DIR}"
-
-		python_compile() {
-			emake -C "${BUILD_DIR}" -f Makefile -f - python \
-				VPATH="${native_builddir}:${S}" \
-				native_builddir="${native_builddir}" \
-				libkmod_python_kmod_{kmod,list,module,_util}_la_LIBADD='$(PYTHON_LIBS) $(native_builddir)/libkmod/libkmod.la' \
-				<<< 'python: $(pkgpyexec_LTLIBRARIES)'
-		}
-
-		python_foreach_impl python_compile
-	fi
-}
-
-src_test() {
-	python_test() {
-		mkdir "${T}/test-${EPYTHON}" || die
-		emake -C "${BUILD_DIR}" DESTDIR="${T}/test-${EPYTHON}" \
-				VPATH="${native_builddir}:${S}" \
-				install-pkgpyexecLTLIBRARIES \
-				install-dist_pkgpyexecPYTHON
-
-		# Smoke test based on https://bugs.gentoo.org/891975#c5
-		local -x PYTHONPATH="${T}/test-${EPYTHON}/usr/lib/${EPYTHON}/site-packages:${PYTHONPATH}"
-		${EPYTHON} -c 'import kmod; km = kmod.Kmod(); print([(m.name, m.size) for m in km.loaded()])' || die
-		rm -r "${T}/test-${EPYTHON}" || die
-	}
-
-	if use python; then
-		python_foreach_impl python_test
-	fi
+	econf "${myeconfargs[@]}"
 }
 
 src_install() {
-	emake -C "${BUILD_DIR}" DESTDIR="${D}" install
-
-	einstalldocs
-
-	if use python; then
-		local native_builddir="${BUILD_DIR}"
-
-		python_install() {
-			emake -C "${BUILD_DIR}" DESTDIR="${D}" \
-				VPATH="${native_builddir}:${S}" \
-				install-pkgpyexecLTLIBRARIES \
-				install-dist_pkgpyexecPYTHON
-			python_optimize
-		}
-
-		python_foreach_impl python_install
-	fi
+	default
 
 	find "${ED}" -type f -name "*.la" -delete || die
 


             reply	other threads:[~2024-03-02  0:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-02  0:15 Sam James [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-01-04  4:32 [gentoo-commits] repo/gentoo:master commit in: sys-apps/kmod/files/, sys-apps/kmod/ Sam James
2021-05-21  7:06 Lars Wendler
2021-01-08 14:15 Lars Wendler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1709338483.7e18d8b8c3d468754790010cc157cc8eaff3d5b5.sam@gentoo \
    --to=sam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox