git: 38e8d9ecc4fb - main - www/angie: replace with more comprehensive port

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Sun, 06 Aug 2023 12:43:28 UTC
The branch main has been updated by fuz:

URL: https://cgit.FreeBSD.org/ports/commit/?id=38e8d9ecc4fba0264bfc094f6d8984135ac02940

commit 38e8d9ecc4fba0264bfc094f6d8984135ac02940
Author:     Oleg A. Mamontov <oleg@mamontov.net>
AuthorDate: 2023-08-05 12:25:34 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-08-06 12:42:48 +0000

    www/angie: replace with more comprehensive port
    
    Replace port with a version that supports modules as slave ports.
    
    PR:             270933
    Approved by:    wen
    Differential Revision:  https://reviews.freebsd.org/D39868
---
 www/angie/Makefile                     | 194 ++++++++++++++++++++++++++++++---
 www/angie/distinfo                     |   4 +-
 www/angie/files/angie.conf.sample.in   |  41 +++++++
 www/angie/files/angie.in               |  73 +++++++++++++
 www/angie/files/default.conf.sample.in |  49 +++++++++
 www/angie/files/example.conf.sample.in |  24 ++++
 www/angie/files/pkg-message.in         |  13 +++
 www/angie/pkg-descr                    |   8 +-
 www/angie/pkg-plist                    |  47 ++++----
 9 files changed, 411 insertions(+), 42 deletions(-)

diff --git a/www/angie/Makefile b/www/angie/Makefile
index 2b47a5e90f2a..5da3b942df7a 100644
--- a/www/angie/Makefile
+++ b/www/angie/Makefile
@@ -1,25 +1,187 @@
-PORTNAME=	angie
-PORTVERSION=	1.2.0
-CATEGORIES=	www
-MASTER_SITES=	https://download.angie.software/files/
+PORTNAME?=		angie
+PORTVERSION=		1.2.0
+PORTREVISION=		1
+CATEGORIES+=		www
+MASTER_SITES+=		https://download.angie.software/files/:angie
+DISTNAME=		angie-${DISTVERSIONFULL}
+DISTFILES+=		${DISTNAME}${EXTRACT_SUFX}:angie
 
-MAINTAINER=	wen@FreeBSD.org
-COMMENT=	Efficient, powerful and scalable web server
-WWW=		https://angie.software/en/
+MAINTAINER?=		oleg@mamontov.net
+COMMENT?=		Efficient, powerful and scalable reverse proxy and web server
+WWW?=			https://angie.software/en/
 
-LICENSE=	BSD2CLAUSE
-LICENSE_FILE=	${WRKSRC}/LICENSE
+LICENSE?=		BSD2CLAUSE
+.if ${PORTNAME} == angie
+LICENSE_FILE=		${WRKSRC}/LICENSE
+.else
+LICENSE_FILE?=		${WRKSRC_module}/LICENSE
+.endif
 
-LIB_DEPENDS=	libpcre2-8.so:devel/pcre2
+.if ${PORTNAME} == angie
+LIB_DEPENDS=		libpcre2-8.so:devel/pcre2
+.else
+BUILD_DEPENDS+=		pcre2>=0:devel/pcre2
+RUN_DEPENDS+=		angie==${PKGVERSION}:www/angie
+.endif
 
-USES=		gmake ssl
+USES+=			ssl
+USE_GITHUB=		nodefault
 
-HAS_CONFIGURE=	yes
-ALL_TARGET=
+HAS_CONFIGURE?=		yes
 
-CONFIGURE_ARGS=	--with-openssl=${LOCALBASE}
+.if ${PORTNAME} == angie
+ALL_TARGET=		build
+SUB_FILES=		angie.conf.sample \
+			default.conf.sample \
+			example.conf.sample \
+			pkg-message
+USE_RC_SUBR=		angie
+.else
+ALL_TARGET?=		modules
+CONFIGURE_ADD?=		--add-dynamic-module=${WRKSRC_module}
+.endif
 
-post-install:
-	${STRIP_CMD} ${STAGEDIR}${PREFIX}/angie/sbin/angie
+# modules always have their own assets
+PATCHDIR?=		${.CURDIR}/files
+FILESDIR?=		${.CURDIR}/files
+SCRIPTDIR?=		${.CURDIR}/scripts
+PKGDIR?=		${.CURDIR}
+
+# angie-specific variables
+CACHEDIR=		/var/cache/angie
+LOGDIR=			/var/log/angie
+MODDIR=			${PREFIX}/libexec/angie
+RUNDIR=			/var/run
+WRKSRC_DEBUG=		${WRKSRC}-debug
+
+PLIST_SUB+=		CACHEDIR=${CACHEDIR} \
+			LOGDIR=${LOGDIR} \
+			MODDIR=${MODDIR} \
+			RUNDIR=${RUNDIR}
+
+SUB_LIST+=		CACHEDIR=${CACHEDIR} \
+			LOGDIR=${LOGDIR} \
+			MODDIR=${MODDIR} \
+			RUNDIR=${RUNDIR} \
+			WWWOWN=${WWWOWN}
+
+SUB_FILES?=		pkg-message
+
+OPTIONS_SUB=		yes
+
+CONFIGURE_ARGS=		--prefix=${PREFIX}/etc/angie \
+			--conf-path=${PREFIX}/etc/angie/angie.conf \
+			--error-log-path=${LOGDIR}/error.log \
+			--http-log-path=${LOGDIR}/access.log \
+			--lock-path=${RUNDIR}/angie.lock \
+			--modules-path=${MODDIR} \
+			--pid-path=${RUNDIR}/angie.pid \
+			--sbin-path=${PREFIX}/sbin/angie \
+			--http-client-body-temp-path=${CACHEDIR}/client_temp \
+			--http-fastcgi-temp-path=${CACHEDIR}/fastcgi_temp \
+			--http-proxy-temp-path=${CACHEDIR}/proxy_temp \
+			--http-scgi-temp-path=${CACHEDIR}/scgi_temp \
+			--http-uwsgi-temp-path=${CACHEDIR}/uwsgi_temp \
+			--user=${WWWOWN} \
+			--group=${WWWGRP} \
+			--with-file-aio \
+			--with-http_addition_module \
+			--with-http_auth_request_module \
+			--with-http_dav_module \
+			--with-http_flv_module \
+			--with-http_gunzip_module \
+			--with-http_gzip_static_module \
+			--with-http_mp4_module \
+			--with-http_random_index_module \
+			--with-http_realip_module \
+			--with-http_secure_link_module \
+			--with-http_slice_module \
+			--with-http_ssl_module \
+			--with-http_stub_status_module \
+			--with-http_sub_module \
+			--with-http_v2_module \
+			--with-http_v3_module \
+			--with-mail \
+			--with-mail_ssl_module \
+			--with-stream \
+			--with-stream_realip_module \
+			--with-stream_ssl_module \
+			--with-stream_ssl_preread_module \
+			--with-threads \
+			--with-cc-opt="-I ${LOCALBASE}/include" \
+			--with-ld-opt="-L ${LOCALBASE}/lib" \
+			${CONFIGURE_ADD}
+
+OPTIONS_DEFINE?=	DEBUG
+OPTIONS_DEFAULT?=	DEBUG
+DEBUG_DESC?=		Include debug version
+
+
+.include <bsd.port.options.mk>
+
+post-patch-DEBUG-on:
+	@${CP} -Rp ${WRKSRC} ${WRKSRC_DEBUG}
+
+post-configure-DEBUG-on:
+	@(cd ${WRKSRC_DEBUG} && \
+	    ${SET_LATE_CONFIGURE_ARGS} \
+	    if ! ${SETENV} CC="${CC}" CPP="${CPP}" CXX="${CXX}" \
+	        CFLAGS="${CFLAGS} -g" CPPFLAGS="${CPPFLAGS}" CXXFLAGS="${CXXFLAGS}" \
+	        LDFLAGS="${LDFLAGS}" LIBS="${LIBS}" \
+	        INSTALL="/usr/bin/install -c" \
+	        INSTALL_DATA="${INSTALL_DATA}" \
+	        INSTALL_LIB="${INSTALL_LIB}" \
+	        INSTALL_PROGRAM="${INSTALL_PROGRAM}" \
+	        INSTALL_SCRIPT="${INSTALL_SCRIPT}" \
+	        ${CONFIGURE_ENV} ${CONFIGURE_CMD} ${CONFIGURE_ARGS} --with-debug; then \
+	        ${ECHO_MSG} "===>  Script \"${CONFIGURE_SCRIPT}\" failed unexpectedly."; \
+	        (${ECHO_CMD} ${CONFIGURE_FAIL_MESSAGE}) | ${FMT_80} ; \
+	        ${FALSE}; \
+	    fi \
+	)
+
+post-build-DEBUG-on:
+	@(cd ${WRKSRC_DEBUG} && ${DO_MAKE_BUILD} ${ALL_TARGET})
+
+.if ${PORTNAME} == angie
+do-install:
+	${MKDIR} ${STAGEDIR}${CACHEDIR}
+	${MKDIR} ${STAGEDIR}${DOCSDIR}
+	${MKDIR} ${STAGEDIR}${ETCDIR}/http.d
+	${MKDIR} ${STAGEDIR}${ETCDIR}/stream.d
+	${MKDIR} ${STAGEDIR}${LOGDIR}
+	${MKDIR} ${STAGEDIR}${MODDIR}
+	${MKDIR} ${STAGEDIR}${WWWDIR}/html
+
+	${RLN} ${STAGEDIR}${MODDIR} ${STAGEDIR}${ETCDIR}/modules
+
+	${INSTALL_PROGRAM} ${WRKSRC}/objs/angie \
+	    ${STAGEDIR}${PREFIX}/sbin/angie-nodebug
+
+	${LN} -fs angie-nodebug ${STAGEDIR}${PREFIX}/sbin/angie
+
+	${INSTALL_MAN} ${WRKSRC}/objs/angie.8 ${STAGEDIR}${MAN8PREFIX}/man/man8
+.for i in CHANGES CHANGES.ru README.rst
+	${INSTALL_MAN} ${WRKSRC}/${i} ${STAGEDIR}${DOCSDIR}
+.endfor
+
+.for i in fastcgi.conf fastcgi_params mime.types scgi_params uwsgi_params
+	${INSTALL_DATA} ${WRKSRC}/conf/${i} ${STAGEDIR}${ETCDIR}/${i}.sample
+.endfor
+	${INSTALL_DATA} ${WRKDIR}/angie.conf.sample \
+	    ${STAGEDIR}${ETCDIR}
+	${INSTALL_DATA} ${WRKDIR}/default.conf.sample \
+	    ${STAGEDIR}${ETCDIR}/http.d
+	${INSTALL_DATA} ${WRKDIR}/example.conf.sample \
+	    ${STAGEDIR}${ETCDIR}/stream.d
+
+.for i in 50x.html index.html
+	${INSTALL_DATA} ${WRKSRC}/html/${i} ${STAGEDIR}${WWWDIR}/html/${i}.sample
+.endfor
+
+do-install-DEBUG-on:
+	${INSTALL} ${COPY} -m ${BINMODE} ${WRKSRC_DEBUG}/objs/angie \
+	    ${STAGEDIR}${PREFIX}/sbin/angie-debug
+.endif
 
 .include <bsd.port.mk>
diff --git a/www/angie/distinfo b/www/angie/distinfo
index cd0d20e57762..1dc90fd2b9df 100644
--- a/www/angie/distinfo
+++ b/www/angie/distinfo
@@ -1,3 +1,5 @@
-TIMESTAMP = 1686140577
+TIMESTAMP = 1690816224
 SHA256 (angie-1.2.0.tar.gz) = 82f23115c2e8ebf00d5429622ad96e8c7e785e87bc298b292246660cc61e2cff
 SIZE (angie-1.2.0.tar.gz) = 1510159
+SHA256 (leev-ngx_http_geoip2_module-3.4_GH0.tar.gz) = ad72fc23348d715a330994984531fab9b3606e160483236737f9a4a6957d9452
+SIZE (leev-ngx_http_geoip2_module-3.4_GH0.tar.gz) = 8877
diff --git a/www/angie/files/angie.conf.sample.in b/www/angie/files/angie.conf.sample.in
new file mode 100644
index 000000000000..85f812c7d357
--- /dev/null
+++ b/www/angie/files/angie.conf.sample.in
@@ -0,0 +1,41 @@
+user  %%WWWOWN%%;
+worker_processes  auto;
+worker_rlimit_nofile 65536;
+
+error_log  %%LOGDIR%%/error.log notice;
+pid        %%RUNDIR%%/angie.pid;
+
+events {
+    worker_connections  65536;
+}
+
+http {
+    include       %%ETCDIR%%/mime.types;
+    default_type  application/octet-stream;
+
+    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
+                      '$status $body_bytes_sent "$http_referer" '
+                      '"$http_user_agent" "$http_x_forwarded_for"';
+
+    log_format extended '$remote_addr - $remote_user [$time_local] "$request" '
+                        '$status $body_bytes_sent "$http_referer" rt="$request_time" '
+                        '"$http_user_agent" "$http_x_forwarded_for" '
+                        'h="$host" sn="$server_name" ru="$request_uri" u="$uri" '
+                        'ucs="$upstream_cache_status" ua="$upstream_addr" us="$upstream_status" '
+                        'uct="$upstream_connect_time" urt="$upstream_response_time"';
+
+    access_log  %%LOGDIR%%/access.log  main;
+
+    sendfile        on;
+    #tcp_nopush     on;
+
+    keepalive_timeout  65;
+
+    #gzip  on;
+
+    include %%ETCDIR%%/http.d/*.conf;
+}
+
+#stream {
+#    include %%ETCDIR%%/stream.d/*.conf;
+#}
diff --git a/www/angie/files/angie.in b/www/angie/files/angie.in
new file mode 100644
index 000000000000..3a55a858e685
--- /dev/null
+++ b/www/angie/files/angie.in
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+# PROVIDE: angie
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+
+# Add these lines to /etc/rc.conf.local or /etc/rc.conf
+# to enable the service:
+#
+# angie_enable (bool):  Set to "NO" by default.
+#                       Set it to "YES" to enable angie.
+#
+# angie_flags (str):    Set to "" by default.
+#                       Extra flags passed to start command.
+
+. /etc/rc.subr
+
+name=angie
+rcvar=angie_enable
+
+command=%%PREFIX%%/sbin/${name}
+pidfile=%%RUNDIR%%/${name}.pid
+required_files=%%ETCDIR%%/${name}.conf
+
+extra_commands="configtest reload upgrade"
+
+configtest_cmd=angie_config_check
+upgrade_cmd="angie_upgrade"
+
+reload_precmd=angie_config_check
+restart_precmd=angie_config_check
+start_precmd=angie_config_check
+
+load_rc_config $name
+
+: ${angie_enable:=NO}
+: ${angie_flags:=}
+: ${angie_config_valid:=""}
+
+angie_config_check() {
+	[ -n "${angie_config_valid}" ] && return 0
+
+	echo "Checking config validity:"
+	eval ${command} ${angie_flags} -t || return 1
+
+	angie_config_valid=yes
+}
+
+angie_upgrade() {
+	if [ ! -s ${pidfile} ]; then
+		echo "No running ${name} found."
+		return 1
+	fi
+
+	angie_config_check || return 1
+
+	echo "Starting new ${name}."
+	kill -USR2 $(cat ${pidfile})
+
+	for i in $(seq 5); do
+		sleep 1
+		if [ -f ${pidfile} -a -f ${pidfile}.oldbin ]; then
+			echo "Shutting down old ${name}."
+			kill -QUIT $(cat ${pidfile}.oldbin)
+			return 0
+		fi
+	done
+
+	echo "Upgrade failed!"
+	return 1
+}
+
+run_rc_command "$1"
diff --git a/www/angie/files/default.conf.sample.in b/www/angie/files/default.conf.sample.in
new file mode 100644
index 000000000000..9ba47bde12b2
--- /dev/null
+++ b/www/angie/files/default.conf.sample.in
@@ -0,0 +1,49 @@
+server {
+    listen       80;
+    server_name  localhost;
+
+    #access_log  %%LOGDIR%%/host.access.log  main;
+
+    location / {
+        root   %%WWWDIR%%/html;
+        index  index.html index.htm;
+    }
+
+    location /status/ {
+        api     /status/;
+        allow   127.0.0.1;
+        deny    all;
+    }
+
+    #error_page  404              /404.html;
+
+    # redirect server error pages to the static page /50x.html
+    #
+    error_page   500 502 503 504  /50x.html;
+    location = /50x.html {
+        root   %%WWWDIR%%/html;
+    }
+
+    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
+    #
+    #location ~ \.php$ {
+    #    proxy_pass   http://127.0.0.1;
+    #}
+
+    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
+    #
+    #location ~ \.php$ {
+    #    root           html;
+    #    fastcgi_pass   127.0.0.1:9000;
+    #    fastcgi_index  index.php;
+    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
+    #    include        fastcgi_params;
+    #}
+
+    # deny access to .htaccess files, if Apache's document root
+    # concurs with angie's one
+    #
+    #location ~ /\.ht {
+    #    deny  all;
+    #}
+}
diff --git a/www/angie/files/example.conf.sample.in b/www/angie/files/example.conf.sample.in
new file mode 100644
index 000000000000..b4beadd44310
--- /dev/null
+++ b/www/angie/files/example.conf.sample.in
@@ -0,0 +1,24 @@
+#upstream stream_backend {
+#    server backend1.example.com:12345 weight=5;
+#    server backend2.example.com:12345 max_fails=2 fail_timeout=30s;
+#    server backend3.example.com:12345 max_conns=3;
+#}
+#
+#upstream dns_servers {
+#    least_conn;
+#    server 192.168.136.130:53;
+#    server 192.168.136.131:53;
+#    server 192.168.136.132:53;
+#}
+#
+#server {
+#    listen        12345;
+#    proxy_pass    stream_backend;
+#    proxy_timeout 3s;
+#    proxy_connect_timeout 1s;
+#}
+#
+#server {
+#    listen     53 udp;
+#    proxy_pass dns_servers;
+#}
diff --git a/www/angie/files/pkg-message.in b/www/angie/files/pkg-message.in
new file mode 100644
index 000000000000..1a9c28c17f9b
--- /dev/null
+++ b/www/angie/files/pkg-message.in
@@ -0,0 +1,13 @@
+[
+{ type: install
+  message: <<EOM
+
+
+Thanks for using Angie!
+
+Please find the official documentation for Angie here:
+* https://angie.software/en/
+
+EOM
+}
+]
diff --git a/www/angie/pkg-descr b/www/angie/pkg-descr
index affbbd24752a..13b710d3a5e9 100644
--- a/www/angie/pkg-descr
+++ b/www/angie/pkg-descr
@@ -1,6 +1,2 @@
-Angie is an efficient, powerful and scalable web server, that was forked from
-nginx by some of its former core devs, with intention to extend functionality
-far beyond original version.
-
-Angie is a drop-in replacement for nginx, so you can use existing nginx
-configuration without major changes.
+Actively developing fork of nginx aiming to keep it great
+with brand new extra functionality.
diff --git a/www/angie/pkg-plist b/www/angie/pkg-plist
index 22dc59363791..8ee62936b6a9 100644
--- a/www/angie/pkg-plist
+++ b/www/angie/pkg-plist
@@ -1,19 +1,28 @@
-angie/conf/angie.conf
-angie/conf/angie.conf.default
-angie/conf/fastcgi.conf
-angie/conf/fastcgi.conf.default
-angie/conf/fastcgi_params
-angie/conf/fastcgi_params.default
-angie/conf/koi-utf
-angie/conf/koi-win
-angie/conf/mime.types
-angie/conf/mime.types.default
-angie/conf/scgi_params
-angie/conf/scgi_params.default
-angie/conf/uwsgi_params
-angie/conf/uwsgi_params.default
-angie/conf/win-utf
-angie/html/50x.html
-angie/html/index.html
-angie/sbin/angie
-@dir angie/logs
+@dir %%ETCDIR%%/http.d
+@dir %%ETCDIR%%/stream.d
+@dir %%CACHEDIR%%
+@dir %%LOGDIR%%
+@dir %%MODDIR%%
+
+%%ETCDIR%%/modules
+
+sbin/angie-nodebug
+sbin/angie
+%%DEBUG%%sbin/angie-debug
+
+man/man8/angie.8.gz
+%%DOCSDIR%%/CHANGES
+%%DOCSDIR%%/CHANGES.ru
+%%DOCSDIR%%/README.rst
+
+@sample %%ETCDIR%%/angie.conf.sample
+@sample %%ETCDIR%%/fastcgi.conf.sample
+@sample %%ETCDIR%%/fastcgi_params.sample
+@sample %%ETCDIR%%/mime.types.sample
+@sample %%ETCDIR%%/scgi_params.sample
+@sample %%ETCDIR%%/uwsgi_params.sample
+@sample %%ETCDIR%%/http.d/default.conf.sample
+@sample %%ETCDIR%%/stream.d/example.conf.sample
+
+@sample %%WWWDIR%%/html/50x.html.sample
+@sample %%WWWDIR%%/html/index.html.sample