git: 298c90f57071 - main - sysutils/fusefs-httpfs: build with https support

From: Eugene Grosbein <eugen_at_FreeBSD.org>
Date: Tue, 07 Jun 2022 05:38:30 UTC
The branch main has been updated by eugen:

URL: https://cgit.FreeBSD.org/ports/commit/?id=298c90f57071c723c2c9fbbeba5e08cabf7519bd

commit 298c90f57071c723c2c9fbbeba5e08cabf7519bd
Author:     Eugene Grosbein <eugen@FreeBSD.org>
AuthorDate: 2022-06-07 05:35:45 +0000
Commit:     Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2022-06-07 05:35:45 +0000

    sysutils/fusefs-httpfs: build with https support
    
    The software has https support via GNUTLS
    but the port did not enable it.
    
    Add new port option GNUTLS and enable it by default.
    While here, add LICENSE (GPLv2+).
    Pet portlint. Bump PORTREVISION.
---
 sysutils/fusefs-httpfs/Makefile              | 29 +++++++++++++++++++--
 sysutils/fusefs-httpfs/files/patch-Makefile  | 39 +++++++++++++++++++++-------
 sysutils/fusefs-httpfs/files/patch-httpfs2.c | 25 ++++++++++++++----
 3 files changed, 77 insertions(+), 16 deletions(-)

diff --git a/sysutils/fusefs-httpfs/Makefile b/sysutils/fusefs-httpfs/Makefile
index 4975a1b74497..4bb9ac0cd4d2 100644
--- a/sysutils/fusefs-httpfs/Makefile
+++ b/sysutils/fusefs-httpfs/Makefile
@@ -2,6 +2,7 @@
 
 PORTNAME=	httpfs
 PORTVERSION=	2.${VERSION}
+PORTREVISION=	1
 PORTEPOCH=	1
 CATEGORIES=	sysutils www
 MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}2/
@@ -11,15 +12,39 @@ DISTNAME=	${PORTNAME}2-${VERSION}
 MAINTAINER=	ports@FreeBSD.org
 COMMENT=	Fuse-based http filesystem
 
-WRKSRC=		${WRKDIR}/${PORTNAME}2-${VERSION}
+LICENSE=	GPLv2+
+LICENSE_FILE=	${WRKSRC}/debian/copyright
 
-VERSION=	0.1.5
 USES=		fuse pkgconfig gmake
+
+WRKSRC=		${WRKDIR}/${PORTNAME}2-${VERSION}
+VERSION=	0.1.5
 CFLAGS+=	-D__BSD_VISIBLE
 ALL_TARGET=	httpfs2
 PLIST_FILES=	bin/httpfs2
 
+CERT_STORE=	${LOCALBASE}/share/certs/ca-root-nss.crt
+MAKE_ENV+=	CERT_STORE=${CERT_STORE}
+ALL_TARGET=	full
+
+OPTIONS_DEFINE=		GNUTLS
+OPTIONS_DEFAULT=	GNUTLS
+
+GNUTLS_LIB_DEPENDS=	libgnutls.so:security/gnutls
+GNUTLS_RUN_DEPENDS=	${CERT_STORE}:security/ca_root_nss
+
 do-install:
 	${INSTALL_PROGRAM} ${WRKSRC}/httpfs2 ${STAGEDIR}${PREFIX}/bin
 
+.include <bsd.port.options.mk>
+
+.if ${PORT_OPTIONS:MGNUTLS}
+PLIST_FILES+=	bin/httpfs2-mt bin/httpfs2-ssl bin/httpfs2-ssl-mt
+.endif
+
+do-install-GNUTLS-on:
+	cd ${WRKSRC} && \
+	    ${INSTALL_PROGRAM} httpfs2-mt httpfs2-ssl httpfs2-ssl-mt \
+	    ${STAGEDIR}${PREFIX}/bin
+
 .include <bsd.port.mk>
diff --git a/sysutils/fusefs-httpfs/files/patch-Makefile b/sysutils/fusefs-httpfs/files/patch-Makefile
index f64302e6aa5d..4e2252a2840b 100644
--- a/sysutils/fusefs-httpfs/files/patch-Makefile
+++ b/sysutils/fusefs-httpfs/files/patch-Makefile
@@ -1,5 +1,5 @@
---- Makefile.orig	2012-09-03 16:58:02.000000000 +0200
-+++ Makefile	2013-02-19 18:03:41.000000000 +0100
+--- Makefile.orig	2012-09-03 14:58:02 UTC
++++ Makefile
 @@ -1,5 +1,5 @@
  MAIN_CFLAGS :=  -g -Os -Wall $(shell pkg-config fuse --cflags)
 -MAIN_CPPFLAGS := -Wall -Wno-unused-function -Wconversion -Wtype-limits -DUSE_AUTH -D_XOPEN_SOURCE=700 -D_ISOC99_SOURCE
@@ -7,19 +7,41 @@
  THR_CPPFLAGS := -DUSE_THREAD
  THR_LDFLAGS := -lpthread
  MAIN_LDFLAGS := $(shell pkg-config fuse --libs | sed -e s/-lrt// -e s/-ldl// -e s/-pthread// -e "s/  / /g")
-@@ -45,7 +45,7 @@
+@@ -10,7 +10,7 @@ ifeq ($(shell pkg-config --atleast-version 2.10 gnutls
+ 
+     variants += -ssl -ssl-mt
+ 
+-    CERT_STORE := /etc/ssl/certs/ca-certificates.crt
++#   CERT_STORE := /etc/ssl/certs/ca-certificates.crt
+     SSL_CPPFLAGS := -DUSE_SSL $(shell pkg-config gnutls --cflags) -DCERT_STORE=\"$(CERT_STORE)\"
+     SSL_LDFLAGS := $(shell pkg-config gnutls --libs)
+ endif
+@@ -23,7 +23,8 @@ manpages = $(addsuffix .1,$(binaries))
+ 
+ intermediates += $(addsuffix .xml,$(manpages))
+ 
+-targets = $(binaries) $(manpages)
++#targets = $(binaries) $(manpages)
++targets = $(binaries)
+ 
+ full:
+ 	$(MAKE) all $(addprefix all,$(variants))
+@@ -44,8 +45,8 @@ clean-recursive:
+ %-full:
  	$(MAKE) $* $(addprefix $*,$(variants))
  
- %.1: %.1.txt
+-%.1: %.1.txt
 -	a2x -f manpage $<
-+	a2x -L -f manpage $<
++#%.1: %.1.txt
++#	a2x -f manpage $<
  
  %-ssl: $*
  	$(MAKE) CPPFLAGS='$(CPPFLAGS) $(SSL_CPPFLAGS)' LDFLAGS='$(LDFLAGS) $(SSL_LDFLAGS)' binsuffix=-ssl$(binsuffix) $*
-@@ -61,20 +61,6 @@
+@@ -60,20 +61,6 @@ clean-recursive:
+ 	$(MAKE) CPPFLAGS='$(CPPFLAGS) -DRETRY_ON_RESET' binsuffix=-rst$(binsuffix) $*
  
  # Rules to automatically make a Debian package
- 
+-
 -package = $(shell dpkg-parsechangelog | grep ^Source: | sed -e s,'^Source: ',,)
 -version = $(shell dpkg-parsechangelog | grep ^Version: | sed -e s,'^Version: ',, -e 's,-.*,,')
 -revision = $(shell dpkg-parsechangelog | grep ^Version: | sed -e -e 's,.*-,,')
@@ -33,7 +55,6 @@
 -pkg_deb_bin = $(pkg_deb_dir)/$(package)_$(version)-$(revision)_$(architecture).changes
 -
 -deb_pkg_key = CB8C5858
--
+ 
  debclean:
  	rm -rf $(pkg_deb_dir)
- 
diff --git a/sysutils/fusefs-httpfs/files/patch-httpfs2.c b/sysutils/fusefs-httpfs/files/patch-httpfs2.c
index 512f4eb6d4e7..c18b96efd4a4 100644
--- a/sysutils/fusefs-httpfs/files/patch-httpfs2.c
+++ b/sysutils/fusefs-httpfs/files/patch-httpfs2.c
@@ -1,5 +1,5 @@
---- httpfs2.c.orig	2013-02-19 15:45:06.000000000 +0100
-+++ httpfs2.c	2013-02-19 15:48:43.000000000 +0100
+--- httpfs2.c.orig	2012-09-03 14:58:02 UTC
++++ httpfs2.c
 @@ -35,7 +35,7 @@
  #include <assert.h>
  #include <ctype.h>
@@ -9,7 +9,7 @@
  #include <sys/types.h>
  #include <sys/time.h>
  #include <sys/socket.h>
-@@ -188,7 +188,7 @@
+@@ -188,7 +188,7 @@ static char * b64_encode(unsigned const char* ptr, lon
  
  static int httpfs_stat(fuse_ino_t ino, struct stat *stbuf)
  {
@@ -18,7 +18,7 @@
      switch (ino) {
          case 1:
              stbuf->st_mode = S_IFDIR | 0755;
-@@ -257,7 +257,7 @@
+@@ -257,7 +257,7 @@ static void dirbuf_add(fuse_req_t req, struct dirbuf *
      b->size += fuse_add_direntry(req, NULL, 0, name, NULL, 0);
      b->p = (char *) realloc(b->p, b->size);
      memset(&stbuf, 0, sizeof(stbuf));
@@ -27,7 +27,7 @@
      fuse_add_direntry(req, b->p + oldsize, b->size - oldsize, name, &stbuf,
              (off_t) b->size);
  }
-@@ -667,7 +667,7 @@
+@@ -667,11 +667,12 @@ static char * url_encode(char * path) {
  
  static int init_url(struct_url* url)
  {
@@ -36,3 +36,18 @@
      url->sock_type = SOCK_CLOSED;
      url->timeout = TIMEOUT;
  #ifdef USE_SSL
+-    url->cafile = CERT_STORE;
++    if ((url->cafile = getenv("CERT_STORE")) == NULL)
++	url->cafile = CERT_STORE;
+ #endif
+     return 0;
+ }
+@@ -911,7 +912,7 @@ int main(int argc, char *argv[])
+         return 3;
+     }
+ #ifdef USE_SSL
+-    else {
++    else if(main_url.ss != NULL) {
+         print_ssl_info(main_url.ss);
+     }
+ #endif