diff --git a/packages/libknot/build.sh b/packages/libknot/build.sh new file mode 100644 index 0000000000..3711c82ee8 --- /dev/null +++ b/packages/libknot/build.sh @@ -0,0 +1,13 @@ +TERMUX_PKG_HOMEPAGE=https://www.knot-dns.cz/ +TERMUX_PKG_DESCRIPTION="Knot DNS libraries" +TERMUX_PKG_LICENSE="GPL-3.0" +TERMUX_PKG_MAINTAINER="@termux" +TERMUX_PKG_VERSION=3.2.4 +TERMUX_PKG_SRCURL=https://secure.nic.cz/files/knot-dns/knot-${TERMUX_PKG_VERSION}.tar.xz +TERMUX_PKG_SHA256=299e8de918f9fc7ecbe625b41cb085e47cdda542612efbd51cd5ec60deb9dd13 +TERMUX_PKG_DEPENDS="libgnutls, liblmdb" +TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" +--disable-daemon +--disable-modules +--enable-utilities +" diff --git a/packages/libknot/fix-hardcoded-paths.patch b/packages/libknot/fix-hardcoded-paths.patch new file mode 100644 index 0000000000..e2bd9f858a --- /dev/null +++ b/packages/libknot/fix-hardcoded-paths.patch @@ -0,0 +1,11 @@ +--- a/src/utils/common/resolv.c ++++ b/src/utils/common/resolv.c +@@ -24,7 +24,7 @@ + #include "libknot/libknot.h" + #include "contrib/ucw/lists.h" + +-#define RESOLV_FILE "/etc/resolv.conf" ++#define RESOLV_FILE "@TERMUX_PREFIX@/etc/resolv.conf" + + srv_info_t* parse_nameserver(const char *str, const char *def_port) + { diff --git a/packages/libknot/knot-utils.subpackage.sh b/packages/libknot/knot-utils.subpackage.sh new file mode 100644 index 0000000000..75503374eb --- /dev/null +++ b/packages/libknot/knot-utils.subpackage.sh @@ -0,0 +1,6 @@ +TERMUX_SUBPKG_DESCRIPTION="Knot DNS utilities" +TERMUX_SUBPKG_INCLUDE=" +bin/ +share/man/man1/ +" +TERMUX_SUBPKG_DEPENDS="libedit, libidn2, libnghttp2, resolv-conf" diff --git a/packages/libknot/pthread_cancel.patch b/packages/libknot/pthread_cancel.patch new file mode 100644 index 0000000000..7aef2bc794 --- /dev/null +++ b/packages/libknot/pthread_cancel.patch @@ -0,0 +1,92 @@ +--- a/src/contrib/conn_pool.c ++++ b/src/contrib/conn_pool.c +@@ -63,10 +63,26 @@ + return fd; + } + ++#ifdef __ANDROID__ ++static void thread_signal_handler(int signum) ++{ ++ pthread_exit(0); ++} ++#endif ++ + static void *closing_thread(void *_arg) + { + conn_pool_t *pool = _arg; + ++#ifdef __ANDROID__ ++ struct sigaction actions; ++ memset(&actions, 0, sizeof(actions)); ++ sigemptyset(&actions.sa_mask); ++ actions.sa_flags = 0; ++ actions.sa_handler = thread_signal_handler; ++ sigaction(SIGUSR2, &actions, NULL); ++#endif ++ + while (true) { + knot_time_t now = knot_time(), next = 0; + knot_timediff_t timeout = conn_pool_timeout(pool, 0); +@@ -117,7 +133,11 @@ + void conn_pool_deinit(conn_pool_t *pool) + { + if (pool != NULL) { ++#ifndef __ANDROID__ + pthread_cancel(pool->closing_thread); ++#else ++ pthread_kill(pool->closing_thread, SIGUSR2); ++#endif + pthread_join(pool->closing_thread, NULL); + + int fd; +--- a/src/knot/common/stats.c ++++ b/src/knot/common/stats.c +@@ -249,8 +249,24 @@ + free(file_name); + } + ++#ifdef __ANDROID__ ++static void thread_signal_handler(int signum) ++{ ++ pthread_exit(0); ++} ++#endif ++ + static void *dumper(void *data) + { ++#ifdef __ANDROID__ ++ struct sigaction actions; ++ memset(&actions, 0, sizeof(actions)); ++ sigemptyset(&actions.sa_mask); ++ actions.sa_flags = 0; ++ actions.sa_handler = thread_signal_handler; ++ sigaction(SIGUSR2, &actions, NULL); ++#endif ++ + while (true) { + assert(stats.timer > 0); + sleep(stats.timer); +@@ -291,7 +307,11 @@ + } + // Stop current dumping. + } else if (stats.active_dumper) { ++#ifndef __ANDROID__ + pthread_cancel(stats.dumper); ++#else ++ pthread_kill(stats.dumper, SIGUSR2); ++#endif + pthread_join(stats.dumper, NULL); + stats.active_dumper = false; + } +@@ -300,7 +320,11 @@ + void stats_deinit(void) + { + if (stats.active_dumper) { ++#ifndef __ANDROID__ + pthread_cancel(stats.dumper); ++#else ++ pthread_kill(stats.dumper, SIGUSR2); ++#endif + pthread_join(stats.dumper, NULL); + } +