diff --git a/databases/proxysql/Makefile b/databases/proxysql/Makefile index c7ab2e52215b..183c97b9f739 100644 --- a/databases/proxysql/Makefile +++ b/databases/proxysql/Makefile @@ -1,78 +1,79 @@ PORTNAME= proxysql PORTVERSION= 3.0.10 +PORTREVISION= 1 DISTVERSIONPREFIX= v CATEGORIES= databases MAINTAINER= zi@FreeBSD.org COMMENT= High performance, high availability, protocol-aware proxy for MySQL WWW= https://www.proxysql.com/ LICENSE= GPLv3 LICENSE_FILE= ${WRKSRC}/LICENSE BUILD_DEPENDS= bash:shells/bash \ cmake:devel/cmake-core \ ggrep:textproc/gnugrep \ libgcrypt>0:security/libgcrypt \ libevent>0:devel/libevent \ gnutls>0:security/gnutls LIB_DEPENDS= libuuid.so:misc/libuuid RUN_DEPENDS= libgcrypt>0:security/libgcrypt \ gnutls>0:security/gnutls USES= autoreconf:build bison:build compiler:c++11-lang gmake \ libtool perl5 pkgconfig python:build ssl USE_CSTD= gnu11 USE_PERL5= build USE_GCC= yes MAKE_ENV= GIT_VERSION_BASE="${PORTVERSION}" SOURCE_DATE_EPOCH="$$(date +%s)" USE_GITHUB= yes ALL_TARGET= build_deps default LDFLAGS+= -L${LOCALBASE}/lib BINARY_ALIAS= python3=${PYTHON_CMD} USE_RC_SUBR= ${PORTNAME} USERS= ${PORTNAME} GROUPS= ${PORTNAME} GH_ACCOUNT= sysown post-patch: @${REINPLACE_CMD} -e 's,/etc/,${ETCDIR}/,g' ${WRKSRC}/lib/ProxySQL_GloVars.cpp @${REINPLACE_CMD} \ -e 's,/var/lib,/var/db,g' \ -e '7s/^/errorlog="\/var\/log\/proxysql\/proxysql-error.log"\n\n/g' \ -e '7s/^/pidfile="\/var\/run\/${PORTNAME}\/${PORTNAME}.pid"\n/g' \ ${WRKSRC}/src/proxysql.cfg @${REINPLACE_CMD} \ -e '/^GIT_VERSION_BASE := /d' \ -e 's,grep -P,g&,' \ -e '/ export C/d' \ -e 's,PROXYSQLCLICKHOUSE=1 ,,g' \ -e '/cd curl/s,$${MAKE},${GMAKE},' \ -e '/cd libmicrohttpd/s,$${MAKE},${GMAKE},' \ -e '/cd lz4/s,$${MAKE},${GMAKE},' \ -e '/cd libhttpserver.*MAKE/s,CC,MAKE=${GMAKE} CC,' \ -e '/cd libhttpserver/s,$${MAKE},${GMAKE},' \ -e '/get_result_from_pgconn/s,-p0,-p0 -l,' \ -e 's,without-readline,without-readline --without-icu,g' \ -e 's,--enable-fastopen=false ,--enable-fastopen=false --enable-shared=no ,g' \ ${WRKSRC}/Makefile ${WRKSRC}/deps/Makefile @${REINPLACE_CMD} -e 's,grep -oP,ggrep -oP,g' ${WRKSRC}/common_mk/*.mk @${REINPLACE_CMD} -e 's,ENABLE_EPOLL := -DENABLE_EPOLL,ENABLE_EPOLL :=,g' \ ${WRKSRC}/lib/Makefile do-install: ${INSTALL_PROGRAM} ${WRKSRC}/src/proxysql ${STAGEDIR}${LOCALBASE}/sbin post-install: ${MKDIR} ${STAGEDIR}${ETCDIR} ${STAGEDIR}/var/db/${PORTNAME} \ ${STAGEDIR}/var/run/${PORTNAME} \ ${STAGEDIR}${PREFIX}/etc/newsyslog.conf.d \ ${STAGEDIR}/var/log/${PORTNAME} ${INSTALL_DATA} ${FILESDIR}/proxysql.conf-newsyslog \ ${STAGEDIR}${PREFIX}/etc/newsyslog.conf.d/proxysql.conf.sample ${INSTALL_DATA} ${WRKSRC}/src/proxysql.cfg \ ${STAGEDIR}${ETCDIR}/proxysql.cfg.sample .include diff --git a/databases/proxysql/files/patch-lib_ProxySQL__Admin__Stats.cpp b/databases/proxysql/files/patch-lib_ProxySQL__Admin__Stats.cpp new file mode 100644 index 000000000000..44c1f698d87e --- /dev/null +++ b/databases/proxysql/files/patch-lib_ProxySQL__Admin__Stats.cpp @@ -0,0 +1,51 @@ +--- lib/ProxySQL_Admin_Stats.cpp.orig 2026-07-30 16:48:30 UTC ++++ lib/ProxySQL_Admin_Stats.cpp +@@ -27,6 +27,11 @@ + // for reference) so no header from those moved sets is needed. + #include + ++#if defined(__FreeBSD__) ++#include ++#include ++#endif ++ + #define SAFE_SQLITE3_STEP(_stmt) do {\ + do {\ + rc=(*proxy_sqlite3_step)(_stmt);\ +@@ -86,6 +91,19 @@ void ProxySQL_Admin::p_update_metrics() { + * @return On success, the number of currently opened file descriptors, '-1' otherwise. + */ + int32_t get_open_fds() { ++#if defined(__FreeBSD__) ++ // FreeBSD's procfs implementation does not provide /proc/self/fd ++ int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_NFDS, 0 }; ++ int nfds = 0; ++ size_t len = sizeof(nfds); ++ ++ if (sysctl(mib, 4, &nfds, &len, NULL, 0) == -1) { ++ proxy_error("'sysctl(KERN_PROC_NFDS)' failed with error: '%d'\n", errno); ++ return -1; ++ } ++ ++ return static_cast(nfds); ++#else + DIR* dir = opendir("/proc/self/fd"); + if (dir == NULL) { + proxy_error("'opendir()' failed with error: '%d'\n", errno); +@@ -93,6 +111,8 @@ int32_t get_open_fds() { + } + + struct dirent* dp = nullptr; ++ // Start at '-3' to discount the '.' and '..' entries, plus the fd ++ // opened by 'opendir()' itself. + int32_t count = -3; + + while ((dp = readdir(dir)) != NULL) { +@@ -102,6 +122,7 @@ int32_t get_open_fds() { + closedir(dir); + + return count; ++#endif + } + +