changeset 9:4746e1c5cb56

Build of libpromhttp for version 0.1.3. It needs the separate prometheus-client-c-libpromhttp and libmicrohttpd packages.
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 18 Mar 2025 18:17:59 +0100
parents
children 40cf179a620e
files .hgignore Makefile distinfo files/patch-promhttp_src_promhttp.c pkg-descr pkg-plist
diffstat 6 files changed, 89 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Tue Mar 18 18:17:59 2025 +0100
@@ -0,0 +1,3 @@
+syntax: regexp
+
+^work(-[^/]+)?/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile	Tue Mar 18 18:17:59 2025 +0100
@@ -0,0 +1,32 @@
+PORTNAME=	prometheus-client-c-libpromhttp
+DISTVERSION=	0.1.3
+CATEGORIES=	net-mgmt
+
+MAINTAINER=	freebsd-dev@dom66.de
+COMMENT=	This is libpromhttp -- a C-client library for Prometheus
+WWW=		https://github.com/digitalocean/prometheus-client-c
+
+LICENSE=	APACHE20
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+USES=		cmake:noninja compiler:c11
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	digitalocean
+GH_PROJECT=	prometheus-client-c
+GH_TAGNAME=	v${DISTVERSION}
+
+LIB_DEPENDS=	libprom.so:net-mgmt/prometheus-client-c-libprom \
+		libmicrohttpd.so:www/libmicrohttpd
+
+# Currently compilation errors on incompatible types with clang
+USE_GCC=	yes
+USE_LDCONFIG=	yes
+
+CMAKE_SOURCE_PATH=	${WRKSRC}/promhttp
+
+do-install:
+	(cd ${CMAKE_SOURCE_PATH}/include && ${COPYTREE_SHARE} . ${STAGEDIR}${PREFIX}/include)
+	${INSTALL_LIB} ${BUILD_WRKSRC}/libpromhttp.so ${STAGEDIR}${PREFIX}/lib/libpromhttp.so
+
+.include <bsd.port.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distinfo	Tue Mar 18 18:17:59 2025 +0100
@@ -0,0 +1,3 @@
+TIMESTAMP = 1742306323
+SHA256 (digitalocean-prometheus-client-c-0.1.3-v0.1.3_GH0.tar.gz) = 3a82e302a5bdbbd5f699cf21bee97217c0386b5076d878cab724d5f672ef5092
+SIZE (digitalocean-prometheus-client-c-0.1.3-v0.1.3_GH0.tar.gz) = 1038300
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/files/patch-promhttp_src_promhttp.c	Tue Mar 18 18:17:59 2025 +0100
@@ -0,0 +1,40 @@
+--- promhttp/src/promhttp.c.orig	2020-12-08 07:38:13 UTC
++++ promhttp/src/promhttp.c
+@@ -29,32 +29,32 @@ void promhttp_set_active_collector_registry(prom_colle
+   }
+ }
+ 
+-int promhttp_handler(void *cls, struct MHD_Connection *connection, const char *url, const char *method,
++enum MHD_Result promhttp_handler(void *cls, struct MHD_Connection *connection, const char *url, const char *method,
+                      const char *version, const char *upload_data, size_t *upload_data_size, void **con_cls) {
+   if (strcmp(method, "GET") != 0) {
+     char *buf = "Invalid HTTP Method\n";
+     struct MHD_Response *response = MHD_create_response_from_buffer(strlen(buf), (void *)buf, MHD_RESPMEM_PERSISTENT);
+-    int ret = MHD_queue_response(connection, MHD_HTTP_BAD_REQUEST, response);
++    enum MHD_Result ret = MHD_queue_response(connection, MHD_HTTP_BAD_REQUEST, response);
+     MHD_destroy_response(response);
+     return ret;
+   }
+   if (strcmp(url, "/") == 0) {
+     char *buf = "OK\n";
+     struct MHD_Response *response = MHD_create_response_from_buffer(strlen(buf), (void *)buf, MHD_RESPMEM_PERSISTENT);
+-    int ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
++    enum MHD_Result ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
+     MHD_destroy_response(response);
+     return ret;
+   }
+   if (strcmp(url, "/metrics") == 0) {
+     const char *buf = prom_collector_registry_bridge(PROM_ACTIVE_REGISTRY);
+     struct MHD_Response *response = MHD_create_response_from_buffer(strlen(buf), (void *)buf, MHD_RESPMEM_MUST_FREE);
+-    int ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
++    enum MHD_Result ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
+     MHD_destroy_response(response);
+     return ret;
+   }
+   char *buf = "Bad Request\n";
+   struct MHD_Response *response = MHD_create_response_from_buffer(strlen(buf), (void *)buf, MHD_RESPMEM_PERSISTENT);
+-  int ret = MHD_queue_response(connection, MHD_HTTP_BAD_REQUEST, response);
++  enum MHD_Result ret = MHD_queue_response(connection, MHD_HTTP_BAD_REQUEST, response);
+   MHD_destroy_response(response);
+   return ret;
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkg-descr	Tue Mar 18 18:17:59 2025 +0100
@@ -0,0 +1,9 @@
+Tis is libpromhttp -- a C-client library for Prometheus
+from https://github.com/digitalocean/prometheus-client-c.
+
+This project provides this shared library for instrumenting software via
+Prometheus.
+
+  libpromhttp: Provides a simple web handler to expose Prometheus
+               metrics for scraping. This library has a dependency on
+               libmicrohttpd.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkg-plist	Tue Mar 18 18:17:59 2025 +0100
@@ -0,0 +1,2 @@
+include/promhttp.h
+lib/libpromhttp.so