From d54d98ccc77a3669a69b2a5d08061a574e3aeb3e Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Wed, 31 Dec 2025 11:21:54 +0900 Subject: [PATCH] gnu: opendht: Modernize and build with liburing. * gnu/packages/networking.scm (opendht) [source]: Apply patches. [build-system]: Switch to meson-build-system. [#:modules]: Adjust accordingly. Add (ice-9 ftw) and (srfi srfi-26). [#:configure-flags]: Migrate to Meson options. [#:phases] {disable-problematic-tests}: Update phase. {fix-python-installation-prefix}: Delete. {specify-runpath-for-python-module}: Likewise. {pkgconfig-disable-iouring, check, delete-autogen.sh}: Likewise. {move-and-wrap-tools}: Rename to move-tools and adjust. {move-python-bindings}: Add. [native-inputs]: Remove autoconf, automake and libtool. [inputs]: Delete python. [propagated-inputs]: Add liburing. Remove llhttp. * gnu/packages/patches/opendht-nanosleep.patch: Delete file. * gnu/packages/patches/opendht-meson-liburing.patch: New file. * gnu/packages/patches/opendht-meson-install-headers.patch: Likewise. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. Change-Id: I015e9422dd534106150f2a4a2a89777c47fb5507 --- gnu/local.mk | 3 +- gnu/packages/networking.scm | 119 +++++++----------- .../opendht-meson-install-headers.patch | 32 +++++ .../patches/opendht-meson-liburing.patch | 26 ++++ gnu/packages/patches/opendht-nanosleep.patch | 61 --------- 5 files changed, 107 insertions(+), 134 deletions(-) create mode 100644 gnu/packages/patches/opendht-meson-install-headers.patch create mode 100644 gnu/packages/patches/opendht-meson-liburing.patch delete mode 100644 gnu/packages/patches/opendht-nanosleep.patch diff --git a/gnu/local.mk b/gnu/local.mk index ca6fd1571a2..500a50f575c 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1973,7 +1973,8 @@ dist_patch_DATA = \ %D%/packages/patches/openboardview-use-system-mpc.patch \ %D%/packages/patches/openbox-add-fix-for-glib2-exposed-segfault.patch \ %D%/packages/patches/openbox-python3.patch \ - %D%/packages/patches/opendht-nanosleep.patch \ + %D%/packages/patches/opendht-meson-install-headers.patch \ + %D%/packages/patches/opendht-meson-liburing.patch \ %D%/packages/patches/openexr-2-gcc-14.patch \ %D%/packages/patches/openfst-for-vosk-fix-unique-ptr.patch \ %D%/packages/patches/openjdk-currency-time-bomb.patch \ diff --git a/gnu/packages/networking.scm b/gnu/packages/networking.scm index e0cf3fe93b5..502114f85fa 100644 --- a/gnu/packages/networking.scm +++ b/gnu/packages/networking.scm @@ -26,7 +26,7 @@ ;;; Copyright © 2018, 2020-2022 Marius Bakke ;;; Copyright © 2018, 2020, 2021, 2022 Oleg Pykhalov ;;; Copyright © 2018 Pierre Neidhardt -;;; Copyright © 2019-2025 Maxim Cournoyer +;;; Copyright © 2019-2026 Maxim Cournoyer ;;; Copyright © 2019 Vasile Dumitrascu ;;; Copyright © 2019 Julien Lepiller ;;; Copyright © 2019 Timotej Lazar @@ -4193,31 +4193,43 @@ and targeted primarily for asynchronous processing of HTTP-requests.") (file-name (git-file-name name version)) (sha256 (base32 - "1v8miwsslqlqlpp7p210jhxwkblqyc69cgxaq680qhg7h1sf3y2i")))) + "1v8miwsslqlqlpp7p210jhxwkblqyc69cgxaq680qhg7h1sf3y2i")) + (patches (search-patches "opendht-meson-install-headers.patch" + "opendht-meson-liburing.patch")))) (outputs '("out" "python" "tools" "debug")) - (build-system gnu-build-system) + (build-system meson-build-system) (arguments (list - #:imported-modules `((guix build python-build-system) ;for site-packages - ,@%default-gnu-imported-modules) - #:modules '(((guix build python-build-system) #:prefix python:) - (guix build gnu-build-system) - (guix build utils)) + #:modules '((guix build meson-build-system) + (guix build utils) + (ice-9 ftw) + (srfi srfi-26)) #:configure-flags - #~(list "--disable-static" ;to reduce size - "--enable-tests" - "--enable-proxy-server" - "--enable-push-notifications" - "--enable-proxy-server-identity" - "--enable-proxy-client") + #~(list "-Dproxy_client=enabled" + "-Dproxy_server=enabled" + "-Dpush_notifications=enabled") #:phases #~(modify-phases %standard-phases (add-after 'unpack 'disable-problematic-tests (lambda _ - ;; The dhtrunnertester test suite includes 'testListen', which - ;; is sensitive to the performance/load of the machine it runs - ;; on, introducing nondeterminism (see: - ;; https://github.com/savoirfairelinux/opendht/issues/626). + (substitute* "meson.build" + ;; The 'proxy' test fails with "killed by signal 6 SIGABRT" + ;; inside the build environment (see: + ;; ) + (("test\\('(DhtProxy)', test_proxy)") + "") + ;; The 'http' test fails due to liburing not being + ;; functional inside build environment, causing + ;; "io_uring_queue_init: Cannot allocate memory" errors + ;; (see: + ;; ). + (("test\\('Http', test_http)") + "") + ;; The 'peerdiscovery' test fails even outside of the build + ;; environment (see: + ;; ). + (("test\\('PeerDiscovery', test_peerdiscovery)") + "")) (substitute* "tests/Makefile.am" (("\\bdhtrunnertester\\.(h|cpp)\\b") "")))) @@ -4229,51 +4241,23 @@ and targeted primarily for asynchronous processing of HTTP-requests.") (substitute* "tests/httptester.cpp" (("std::chrono::seconds\\(10)") "std::chrono::seconds(30)")))) - (add-after 'unpack 'fix-python-installation-prefix - ;; Specify the installation prefix for the compiled Python module - ;; that would otherwise attempt to installs itself to Python's own - ;; site-packages directory. - (lambda _ - (substitute* "python/Makefile.am" - (("--root=\\$\\(DESTDIR)/") - (string-append "--root=/ --single-version-externally-managed " - "--prefix=" #$output:python))))) - (add-after 'unpack 'specify-runpath-for-python-module - (lambda _ - (substitute* "python/setup.py.in" - (("extra_link_args=\\[(.*)\\]" _ args) - (string-append "extra_link_args=[" args - ", '-Wl,-rpath=" #$output "/lib']"))))) - ;; TODO: build with liburing, requires cmake or meson. - (add-after 'unpack 'pkgconfig-disable-iouring - (lambda _ - ;; This one causes configure error in dhtnet. - (substitute* "opendht.pc.in" - (("@iouring_lib@") - "")))) - (replace 'check - (lambda* (#:key tests? #:allow-other-keys) - (when tests? - (invoke "tests/opendht_unit_tests")))) - (add-before 'bootstrap 'delete-autogen.sh - (lambda _ - ;; The autogen.sh script lacks a shebang, cannot be executed - ;; directly. Let the bootstrap phase invoke autoreconf itself. - (delete-file "autogen.sh"))) - (add-after 'install 'move-and-wrap-tools + (add-after 'install 'move-tools (lambda* (#:key inputs outputs #:allow-other-keys) - (let* ((tools (assoc-ref outputs "tools")) - (dhtcluster (string-append tools "/bin/dhtcluster")) - (site-packages (python:site-packages inputs outputs))) + (let* ((tools #$output:tools)) (mkdir tools) (rename-file (string-append #$output "/bin") - (string-append tools "/bin")) - ;; TODO: Contribute a patch to python/Makefile.am to - ;; automate this. - (copy-file "python/tools/dhtcluster.py" dhtcluster) - (chmod dhtcluster #o555) - (wrap-program dhtcluster - `("GUIX_PYTHONPATH" prefix (,site-packages))))))))) + (string-append tools "/bin"))))) + (add-after 'install 'move-python-bindings + (lambda _ + (let* ((python-dir (car + (scandir (string-append #$output "/lib") + (cut string-prefix? "python" <>)))) + (dest (string-append #$output:python "/lib/" + python-dir))) + (mkdir-p (dirname dest)) + (rename-file (string-append #$output "/lib/" python-dir) + dest))))))) + (native-inputs (list cppunit pkg-config python python-cython)) (inputs (list bash-minimal fmt @@ -4281,24 +4265,15 @@ and targeted primarily for asynchronous processing of HTTP-requests.") (propagated-inputs (list msgpack-cxx ;included in several installed headers restinio ;included in opendht/http.h - ;; The following are listed in the 'Requires.private' field of - ;; opendht.pc: + ;; The following are listed in the Requires/Requires.private + ;; field of opendht.pc: argon2 gnutls jsoncpp - llhttp + liburing nettle openssl ;required for the DHT proxy - python simdutf)) - (native-inputs - (list autoconf - automake - pkg-config - python - python-cython - libtool - cppunit)) (home-page "https://github.com/savoirfairelinux/opendht/") (synopsis "Lightweight Distributed Hash Table (DHT) library") (description "OpenDHT provides an easy to use distributed in-memory data diff --git a/gnu/packages/patches/opendht-meson-install-headers.patch b/gnu/packages/patches/opendht-meson-install-headers.patch new file mode 100644 index 00000000000..8090e383a42 --- /dev/null +++ b/gnu/packages/patches/opendht-meson-install-headers.patch @@ -0,0 +1,32 @@ +Upstream-status: + +diff --git a/meson.build b/meson.build +index d3c4a500..8d1ed563 100644 +--- a/meson.build ++++ b/meson.build +@@ -116,6 +116,13 @@ opendht = library( + install: true, + ) + ++# Install library headers. ++install_subdir( ++ 'include', ++ install_dir: get_option('includedir'), ++ strip_directory: true ++) ++ + conf_data.set('VERSION', meson.project_version()) + conf_data.set('prefix', get_option('prefix')) + conf_data.set('exec_prefix', get_option('prefix')) +@@ -145,6 +152,11 @@ if get_option('c').enabled() + install: true, + ) + ++ install_headers( ++ 'c/opendht_c.h', ++ subdir: 'opendht' ++ ) ++ + configure_file( + input: 'opendht-c.pc.in', + output: 'opendht-c.pc', diff --git a/gnu/packages/patches/opendht-meson-liburing.patch b/gnu/packages/patches/opendht-meson-liburing.patch new file mode 100644 index 00000000000..ef57639ca72 --- /dev/null +++ b/gnu/packages/patches/opendht-meson-liburing.patch @@ -0,0 +1,26 @@ +Upstream-status: + +diff --git a/meson.build b/meson.build +index 7d7c5e0a..d3c4a500 100644 +--- a/meson.build ++++ b/meson.build +@@ -208,12 +208,18 @@ if get_option('tools').enabled() + install: true, + ) + if llhttp.found() ++ durl_deps = [msgpack, openssl] ++ ++ if io_uring.found() ++ durl_deps += io_uring ++ endif ++ + durl = executable( + 'durl', + 'tools/durl.cpp', + include_directories: opendht_interface_inc, + link_with: opendht, +- dependencies: [msgpack, openssl], ++ dependencies: durl_deps, + ) + endif + endif diff --git a/gnu/packages/patches/opendht-nanosleep.patch b/gnu/packages/patches/opendht-nanosleep.patch deleted file mode 100644 index 42b1b24c34d..00000000000 --- a/gnu/packages/patches/opendht-nanosleep.patch +++ /dev/null @@ -1,61 +0,0 @@ -Upstream-status: merged with commit ccec6c2f6770484278b25c3335d4bd8882bc4c87 - -diff --git a/configure.ac b/configure.ac -index b54d5b49..584b0179 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -83,6 +83,7 @@ case "${host_os}" in - ;; - linux*) - SYS=linux -+ CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200809L" - ;; - darwin*) - SYS=darwin -diff --git a/src/compat/msvc/unistd.h b/src/compat/msvc/unistd.h -index d43d4796..abcc1c61 100644 ---- a/src/compat/msvc/unistd.h -+++ b/src/compat/msvc/unistd.h -@@ -50,4 +50,6 @@ - typedef int mode_t; - #include - -+#define nanosleep(x) Sleep((x) / 1000000) -+ - #endif -diff --git a/tools/dhtcnode.c b/tools/dhtcnode.c -index cdb04714..f78a7f7f 100644 ---- a/tools/dhtcnode.c -+++ b/tools/dhtcnode.c -@@ -24,12 +24,17 @@ - #include - #include - #include -+#include - - #include - #include - #include - #include - -+#ifdef _WIN32 -+#include -+#endif -+ - struct op_context { - dht_runner* runner; - atomic_bool stop; -@@ -287,7 +292,12 @@ int main(int argc, char **argv) - - // Wait until shutdown callback is called - while (!atomic_load(&ctx.stop)) { -- usleep(10000); -+#ifdef _WIN32 -+ Sleep(10); // 10ms -+#else -+ struct timespec ts = {0, 10000000}; // 10ms -+ nanosleep(&ts, NULL); -+#endif - } - dht_runner_delete(runner); - return EXIT_SUCCESS;