commit:     7354829ce09740d0d515ed7a5ec17cde83a7b4ab
Author:     Christopher Byrne <salah.coronya <AT> gmail <DOT> com>
AuthorDate: Fri Feb 28 07:26:18 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 26 20:01:57 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7354829c

sys-libs/libnbd: add 1.22.2

Dropped test dependency on sys-block/nbd. The only dependency required
for test is sys-block/ndbkit. However, it will test sys-block/nbd and
app-emulation/qemu, if present.
The examples were automagically added, so made that a seperate use flag
Add Python 3.13 support
Add support for compiling rust binding
If support for a particular for a partical feature wasn't enabled, 0 tests
would be run for that, which while not fatal, produces a QA warning. Worked
around it by removing what isn't select in the top-level Makefile.am with
sed
Test calls certtool, go net-libs/gnutls[tools] required to test.

Closes: https://bugs.gentoo.org/884245
Closes: https://bugs.gentoo.org/884247
Closes: https://bugs.gentoo.org/926647
Closes: https://bugs.gentoo.org/938348
Closes: https://bugs.gentoo.org/938349
Closes: https://bugs.gentoo.org/946553
Closes: https://bugs.gentoo.org/952745
Closes: https://bugs.gentoo.org/955251

Signed-off-by: Christopher Byrne <salah.coronya <AT> gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/40808
Signed-off-by: Sam James <sam <AT> gentoo.org>

 sys-libs/libnbd/Manifest                           |   1 +
 ...ile.am-Conditionally-compile-some-SUBDIRS.patch |  79 +++++++++++
 ...ld-Remove-automagic-compiling-of-examples.patch | 149 +++++++++++++++++++++
 sys-libs/libnbd/libnbd-1.22.2.ebuild               |  98 ++++++++++++++
 sys-libs/libnbd/metadata.xml                       |   3 +
 5 files changed, 330 insertions(+)

diff --git a/sys-libs/libnbd/Manifest b/sys-libs/libnbd/Manifest
index c36bf4f22618..e7d55c4fd950 100644
--- a/sys-libs/libnbd/Manifest
+++ b/sys-libs/libnbd/Manifest
@@ -1 +1,2 @@
 DIST libnbd-1.18.1.tar.gz 1482736 BLAKE2B 
d3f0b2993fa1392df93b0bbc5d63805489ad1a82cf5bcc5eb5c3b5b7e7e6c40095471ab8fc964cc0e5c7a99affa7150f7be38cc16c42f27fc4cdc16bd0ca0359
 SHA512 
f4262666be55d580550e053355f14f80d352bf869ae7241e9fa032a9b5cd9e027eb89a536871c1206422413fc7ed745da7d612b3e1413f76ec17168705fbf12c
+DIST libnbd-1.22.1.tar.gz 1565817 BLAKE2B 
f06ab0002b21a2960614fa2f704f007dc90713994c8a9dd8dd769d8ef02a451e45a84c8ed9b59c8d9334ab8c4ba4fa0339afa88bc0b959ea280d1d8fecd07e0a
 SHA512 
3f265ed59020c394c5e1f46c51d0ae7f3e7e54461739da964ac92b5c4c8bc98ea9813b93342e025f5f770b688d16d155d6e74d715beab482a040115df6be5afa

diff --git 
a/sys-libs/libnbd/files/libnbd-1.22.2-Makefile.am-Conditionally-compile-some-SUBDIRS.patch
 
b/sys-libs/libnbd/files/libnbd-1.22.2-Makefile.am-Conditionally-compile-some-SUBDIRS.patch
new file mode 100644
index 000000000000..ef4988c62641
--- /dev/null
+++ 
b/sys-libs/libnbd/files/libnbd-1.22.2-Makefile.am-Conditionally-compile-some-SUBDIRS.patch
@@ -0,0 +1,79 @@
+From 2934e26841b88604ed1bf23e3728d7b69d018c72 Mon Sep 17 00:00:00 2001
+From: Christopher Byrne <[email protected]>
+Date: Sat, 14 Jun 2025 21:26:24 -0500
+Subject: [PATCH 2/2] Makefile.am: Conditionally compile some SUBDIRS
+
+Otherwise, the Makefile will try to compile them. The correct machinery
+is in configure.ac, so just add the conditions to Makefile.am
+---
+ Makefile.am | 41 ++++++++++++++++++++++++++++++-----------
+ 1 file changed, 30 insertions(+), 11 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index f31e067..1d00ebd 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -42,30 +42,49 @@ SUBDIRS = \
+       common/utils \
+       lib \
+       docs \
+-      examples \
+       valgrind \
+       . \
+       tests \
+-      python \
+-      sh \
+       info \
+       copy \
+       dump \
+-      fuse \
+-      ublk \
+-      ocaml \
+-      ocaml/examples \
+-      ocaml/tests \
+-      golang \
+-      golang/examples \
+-      rust \
+       interop \
+       fuzzing \
+       bash-completion \
+       $(NULL)
+ 
++if HAVE_FUSE
++SUBDIRS += fuse
++endif
++
++if HAVE_UBLK
++SUBDIRS += ublk
++endif
++
++if HAVE_GOLANG
++SUBDIRS += golang
++endif
++
++if HAVE_OCAML
++SUBDIRS += ocaml ocaml/tests
++endif
++
++if HAVE_PYTHON
++SUBDIRS += python sh
++endif
++
++if HAVE_RUST
++SUBDIRS += rust
++endif
++
+ if BUILD_EXAMPLES 
+ SUBDIRS += examples
++if HAVE_OCAML
++SUBDIRS += ocaml/examples
++endif
++if HAVE_GOLANG
++SUBDIRS += golang/examples
++endif
+ endif
+ 
+ noinst_SCRIPTS = run
+-- 
+2.49.0
+

diff --git 
a/sys-libs/libnbd/files/libnbd-1.22.2-build-Remove-automagic-compiling-of-examples.patch
 
b/sys-libs/libnbd/files/libnbd-1.22.2-build-Remove-automagic-compiling-of-examples.patch
new file mode 100644
index 000000000000..6bd9cd09fea5
--- /dev/null
+++ 
b/sys-libs/libnbd/files/libnbd-1.22.2-build-Remove-automagic-compiling-of-examples.patch
@@ -0,0 +1,149 @@
+From 53e0ade7f46525e048cea7bd321cdf370800e18a Mon Sep 17 00:00:00 2001
+From: Christopher Byrne <[email protected]>
+Date: Sat, 14 Jun 2025 21:01:17 -0500
+Subject: [PATCH 1/2] build: Remove automagic compiling of examples
+
+---
+ Makefile.am  |  4 +++
+ configure.ac | 93 +++++++++++++++++++++++++++++-----------------------
+ 2 files changed, 56 insertions(+), 41 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index 129e393..f31e067 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -64,6 +64,10 @@ SUBDIRS = \
+       bash-completion \
+       $(NULL)
+ 
++if BUILD_EXAMPLES 
++SUBDIRS += examples
++endif
++
+ noinst_SCRIPTS = run
+ 
+ # Check no files are missing from EXTRA_DIST rules, and that all
+diff --git a/configure.ac b/configure.ac
+index 84ec09d..d27a605 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -308,57 +308,67 @@ AS_IF([test "$with_libxml2" != "no"],[
+ ])
+ AM_CONDITIONAL([HAVE_LIBXML2], [test "x$LIBXML2_LIBS" != "x"])
+ 
++dnl Examples
++AC_ARG_ENABLE([examples],
++    [AS_HELP_STRING([--disable-examples],
++                    [disable building of glib and libev examples 
@<:@default=check@:>@])],
++    [],
++    [with_examples=check])
++
++AS_IF([test "$enable_examples" != "no"],[
+ dnl glib2 main loop for examples that interoperate with the glib main loop.
+-PKG_CHECK_MODULES([GLIB], [glib-2.0], [
+-    printf "glib2 version is "; $PKG_CONFIG --modversion glib-2.0
+-    AC_SUBST([GLIB_CFLAGS])
+-    AC_SUBST([GLIB_LIBS])
+-],[
+-    AC_MSG_WARN([glib2 not found, some examples will not be compiled])
+-])
+-AM_CONDITIONAL([HAVE_GLIB], [test "x$GLIB_LIBS" != "x"])
++    PKG_CHECK_MODULES([GLIB], [glib-2.0], [
++         printf "glib2 version is "; $PKG_CONFIG --modversion glib-2.0
++         AC_SUBST([GLIB_CFLAGS])
++         AC_SUBST([GLIB_LIBS])
++    ], [
++        AC_MSG_WARN([glib2 not found, some examples will not be compiled])
++    ])
+ 
+ dnl libev support for examples that interoperate with libev event loop.
+-PKG_CHECK_MODULES([LIBEV], [libev], [
+-    printf "libev version is "; $PKG_CONFIG --modversion libev
+-    AC_SUBST([LIBEV_CFLAGS])
+-    AC_SUBST([LIBEV_LIBS])
+-],[
+-    dnl no pkg-config for libev, searching manually:
+-    AC_CHECK_HEADERS([ev.h], [
+-        AC_CHECK_LIB([ev], [ev_time], [
+-            AC_SUBST([LIBEV_LIBS], ["-lev"])
+-        ],
+-        [
+-            AC_MSG_WARN([libev not found, some examples will not be compiled])
+-        ])
+-    ],[
+-        AC_MSG_WARN([ev.h not found, some examples will not be compiled])
++    PKG_CHECK_MODULES([LIBEV], [libev], [
++         printf "libev version is "; $PKG_CONFIG --modversion libev
++         AC_SUBST([LIBEV_CFLAGS])
++         AC_SUBST([LIBEV_LIBS])
++         ],[
++dnl no pkg-config for libev, searching manually:
++         AC_CHECK_HEADERS([ev.h], [
++             AC_CHECK_LIB([ev], [ev_time], [
++                 AC_SUBST([LIBEV_LIBS], ["-lev"])
++             ],
++             [
++                 AC_MSG_WARN([libev not found, some examples will not be 
compiled])
++             ])
++         ],[
++              AC_MSG_WARN([ev.h not found, some examples will not be 
compiled])
++         ])
+     ])
+-])
+ 
+-AS_IF([test "x$LIBEV_LIBS" != "x"], [
+-    old_CFLAGS="$CFLAGS"
+-    CFLAGS="$CFLAGS $LIBEV_CFLAGS -Werror=strict-aliasing -O2"
+-    AC_MSG_CHECKING([if the compiler is new enough for good aliasing rules])
+-    AC_COMPILE_IFELSE([
+-        AC_LANG_PROGRAM([
+-            #include <ev.h>
+-
+-            static void cb (struct ev_loop *l, ev_timer *t, int e) { }
+-            static ev_timer timer;
++    AS_IF([test "x$LIBEV_LIBS" != "x"], [
++        old_CFLAGS="$CFLAGS"
++        CFLAGS="$CFLAGS $LIBEV_CFLAGS -Werror=strict-aliasing -O2"
++        AC_MSG_CHECKING([if the compiler is new enough for good aliasing 
rules])
++        AC_COMPILE_IFELSE([
++            AC_LANG_PROGRAM([
++                #include <ev.h>
++
++                static void cb (struct ev_loop *l, ev_timer *t, int e) { }
++                static ev_timer timer;
++            ], [
++                ev_timer_init (&timer, cb, 0, .1);
++            ])
+         ], [
+-            ev_timer_init (&timer, cb, 0, .1);
++            AC_MSG_RESULT([yes])
++        ], [
++            AC_MSG_RESULT([no])
++            LIBEV_CFLAGS="$LIBEV_CFLAGS -Wno-strict-aliasing"
+         ])
+-    ], [
+-        AC_MSG_RESULT([yes])
+-    ], [
+-        AC_MSG_RESULT([no])
+-        LIBEV_CFLAGS="$LIBEV_CFLAGS -Wno-strict-aliasing"
++        CFLAGS="$old_CFLAGS"
+     ])
+-    CFLAGS="$old_CFLAGS"
+ ])
++AM_CONDITIONAL([HAVE_GLIB], [test "x$GLIB_LIBS" != "x"]) 
+ AM_CONDITIONAL([HAVE_LIBEV], [test "x$LIBEV_LIBS" != "x"])
++AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$enable_examples" != "xno" ])
+ 
+ dnl FUSE 3 is optional to build the nbdfuse program.
+ AC_ARG_ENABLE([fuse],
+@@ -378,6 +388,7 @@ AS_IF([test "x$enable_fuse" != "xno"],[
+ ])
+ AM_CONDITIONAL([HAVE_FUSE],[test "x$enable_fuse" != "xno"])
+ 
++
+ dnl libublksrv is optional to build the nbdublk program.
+ AC_ARG_ENABLE([ublk],
+     AS_HELP_STRING([--disable-ublk], [disable ublk (nbdublk) support]),
+-- 
+2.49.0
+

diff --git a/sys-libs/libnbd/libnbd-1.22.2.ebuild 
b/sys-libs/libnbd/libnbd-1.22.2.ebuild
new file mode 100644
index 000000000000..1aa213a6484b
--- /dev/null
+++ b/sys-libs/libnbd/libnbd-1.22.2.ebuild
@@ -0,0 +1,98 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+RUST_OPTIONAL=1
+RUST_REQ_USE="rustfmt"
+PYTHON_COMPAT=( python3_{10..13} )
+
+inherit autotools bash-completion-r1 python-single-r1 rust
+
+MY_PV_1="$(ver_cut 1-2)"
+MY_PV_2="$(ver_cut 2)"
+[[ $(( ${MY_PV_2} % 2 )) -eq 0 ]] && SD="stable" || SD="development"
+
+DESCRIPTION="NBD client library in userspace"
+HOMEPAGE="https://gitlab.com/nbdkit/libnbd";
+SRC_URI="https://download.libguestfs.org/libnbd/${MY_PV_1}-${SD}/${P}.tar.gz";
+
+LICENSE="LGPL-2.1+"
+SLOT="0"
+KEYWORDS="~amd64 ~ppc64 ~sparc ~x86"
+IUSE="examples fuse gnutls go ocaml python rust test"
+
+REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
+RESTRICT="!test? ( test )"
+
+# libxml2 - URI support
+RDEPEND="
+       dev-libs/libxml2
+       examples? (     dev-libs/glib
+                       dev-libs/libev )
+       fuse? ( sys-fs/fuse:3 )
+       gnutls? ( net-libs/gnutls:= )
+       go? ( dev-lang/go )
+       ocaml? ( >=dev-lang/ocaml-4.03:=[ocamlopt] )
+       python? ( ${PYTHON_DEPS} )
+"
+DEPEND="
+       ${RDEPEND}
+       test? ( sys-block/nbdkit[gnutls?]
+               net-libs/gnutls:=[tools]
+               ocaml? ( dev-ml/findlib[ocamlopt] )
+)
+"
+BDEPEND="dev-lang/perl
+       rust? ( ${RUST_DEPEND} )"
+
+PATCHES=(
+       
"${FILESDIR}/${PN}-1.22.2-build-Remove-automagic-compiling-of-examples.patch"
+       
"${FILESDIR}/${PN}-1.22.2-Makefile.am-Conditionally-compile-some-SUBDIRS.patch"
+       )
+
+pkg_setup() {
+       if use rust; then
+               rust_pkg_setup
+       fi
+       if use python; then
+               python_setup
+       fi
+}
+
+src_prepare() {
+       default
+
+       # Broken under sandbox.
+       cat <<-EOF > lib/test-fork-safe-execvpe.sh || die
+       #!/bin/sh
+       :
+       EOF
+
+       eautoreconf
+}
+
+src_configure() {
+       local myeconfargs=(
+               $(use_enable examples)
+               $(use_enable fuse)
+               $(use_enable go golang)
+               $(use_enable ocaml)
+               $(use_enable python)
+               $(use_enable rust)
+               $(use_with gnutls)
+               --disable-ublk # Not in portage
+               --with-libxml2
+       )
+
+       export bashcompdir="$(get_bashcompdir)"
+
+       econf "${myeconfargs[@]}"
+}
+
+src_install() {
+       default
+
+       find "${ED}" -name '*.la' -delete || die
+       use python && python_optimize
+}

diff --git a/sys-libs/libnbd/metadata.xml b/sys-libs/libnbd/metadata.xml
index 67433ebdc158..7f4fe7c56247 100644
--- a/sys-libs/libnbd/metadata.xml
+++ b/sys-libs/libnbd/metadata.xml
@@ -15,5 +15,8 @@
                <flag name="go">
                        Build bindings for <pkg>dev-lang/go</pkg>
                </flag>
+               <flag name="rust">
+                       Build bindings for <pkg>dev-lang/rust</pkg>
+               </flag>
        </use>
 </pkgmetadata>

Reply via email to