mirror of
https://codeberg.org/guix/guix.git
synced 2026-01-25 20:15:25 -06:00
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
This commit is contained in:
parent
1f2f22800f
commit
d54d98ccc7
5 changed files with 107 additions and 134 deletions
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
;;; Copyright © 2018, 2020-2022 Marius Bakke <marius@gnu.org>
|
||||
;;; Copyright © 2018, 2020, 2021, 2022 Oleg Pykhalov <go.wigust@gmail.com>
|
||||
;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz>
|
||||
;;; Copyright © 2019-2025 Maxim Cournoyer <maxim@guixotic.coop>
|
||||
;;; Copyright © 2019-2026 Maxim Cournoyer <maxim@guixotic.coop>
|
||||
;;; Copyright © 2019 Vasile Dumitrascu <va511e@yahoo.com>
|
||||
;;; Copyright © 2019 Julien Lepiller <julien@lepiller.eu>
|
||||
;;; Copyright © 2019 Timotej Lazar <timotej.lazar@araneo.si>
|
||||
|
|
@ -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:
|
||||
;; <https://github.com/savoirfairelinux/opendht/issues/819#issuecomment-3701318124>)
|
||||
(("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:
|
||||
;; <https://github.com/savoirfairelinux/opendht/issues/819#issuecomment-3701318124>).
|
||||
(("test\\('Http', test_http)")
|
||||
"")
|
||||
;; The 'peerdiscovery' test fails even outside of the build
|
||||
;; environment (see:
|
||||
;; <https://github.com/savoirfairelinux/opendht/issues/819#issuecomment-3701328516>).
|
||||
(("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
|
||||
|
|
|
|||
32
gnu/packages/patches/opendht-meson-install-headers.patch
Normal file
32
gnu/packages/patches/opendht-meson-install-headers.patch
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
Upstream-status: <https://github.com/savoirfairelinux/opendht/pull/821>
|
||||
|
||||
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',
|
||||
26
gnu/packages/patches/opendht-meson-liburing.patch
Normal file
26
gnu/packages/patches/opendht-meson-liburing.patch
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
Upstream-status: <https://github.com/savoirfairelinux/opendht/pull/821>
|
||||
|
||||
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
|
||||
|
|
@ -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 <BaseTsd.h>
|
||||
|
||||
+#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 <stdlib.h>
|
||||
#include <stdatomic.h>
|
||||
#include <inttypes.h>
|
||||
+#include <time.h>
|
||||
|
||||
#include <getopt.h>
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
+#ifdef _WIN32
|
||||
+#include <windows.h>
|
||||
+#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;
|
||||
Loading…
Add table
Reference in a new issue