Hi,

I'd like to extend the nginx functionality with nginx javascript
module, so here's the patch to add the module to the www/nginx
port.
Please let me know your thoughts.

Thank you.

-- 
Sergey A. Osokin
Index: Makefile
===================================================================
RCS file: /cvs/ports/www/nginx/Makefile,v
retrieving revision 1.165
diff -u -p -r1.165 Makefile
--- Makefile	17 Apr 2023 17:36:58 -0000	1.165
+++ Makefile	24 May 2023 16:07:23 -0000
@@ -11,6 +11,7 @@ COMMENT-ldap_auth=	nginx LDAP authentica
 COMMENT-lua=		nginx lua scripting module
 COMMENT-headers_more=	nginx module for setting/adding/clearing headers
 COMMENT-perl=		nginx perl scripting module
+COMMENT-njs=		nginx javascript scripting module
 COMMENT-passenger=	nginx passenger (ruby/python/nodejs) integration module
 COMMENT-rtmp=		nginx module for RTMP streaming
 COMMENT-securelink=	nginx HMAC secure link module
@@ -18,7 +19,9 @@ COMMENT-securelink=	nginx HMAC secure li
 VERSION=	1.24.0
 DISTNAME=	nginx-${VERSION}
 CATEGORIES=	www
+REVISION=	0
 
+VERSION-njs=	0.7.12
 VERSION-rtmp=	1.2.1
 
 PKGNAME-main=		${DISTNAME}
@@ -32,6 +35,7 @@ PKGNAME-ldap_auth=	nginx-ldap_auth-${VER
 PKGNAME-lua=		nginx-lua-${VERSION}
 PKGNAME-headers_more=	nginx-headers-more-${VERSION}
 PKGNAME-perl=		nginx-perl-${VERSION}
+PKGNAME-njs=		nginx-njs-${VERSION}
 PKGNAME-passenger=	nginx-passenger-${VERSION}
 PKGNAME-rtmp=		nginx-rtmp-${VERSION}
 PKGNAME-securelink=	nginx-securelink-${VERSION}
@@ -51,6 +55,7 @@ _GH_MODS=	\
 	nbs-system	naxsi				d714f1636ea49a9a9f4f06dba14aee003e970834 \
 	kvspb		nginx-auth-ldap			83c059b73566c2ee9cbda920d91b66657cf120b7 \
 	arut		nginx-rtmp-module		v${VERSION-rtmp} \
+	nginx		njs				${VERSION-njs} \
 	simpl		ngx_devel_kit			v0.3.0 \
 	leev		ngx_http_geoip2_module		3.3 \
 	nginx-modules	ngx_http_hmac_secure_link_module 48c4625fbbf51ed5a95bfec23fa444f6c3702e50
@@ -70,7 +75,7 @@ MULTI_PACKAGES =	-main -naxsi -perl ${MO
 
 MODULE_PACKAGES =	-image_filter -geoip2 -xslt -mailproxy -stream \
 			-passenger -headers_more -ldap_auth -lua -rtmp \
-			-securelink
+			-securelink -njs
 
 FLAVOR ?=
 PSEUDO_FLAVORS =	no_lua no_passenger
@@ -85,6 +90,7 @@ WANTLIB-stream=
 WANTLIB-image_filter=	gd
 WANTLIB-geoip2=		maxminddb
 WANTLIB-rtmp=
+WANTLIB-njs=		pcre2-8 crypto ssl xml2 z
 WANTLIB-xslt=		exslt xml2 xslt
 WANTLIB-naxsi=
 WANTLIB-ldap_auth=	ldap
@@ -103,6 +109,8 @@ LIB_DEPENDS-ldap_auth=	databases/openlda
 LIB_DEPENDS-lua=	${MODLUA_LIB_DEPENDS}
 LIB_DEPENDS-rtmp=
 LIB_DEPENDS-securelink=
+LIB_DEPENDS-njs=	devel/pcre2 \
+			textproc/libxml
 
 MODLUA_RUNDEP=		No
 RUN_DEPENDS=		www/nginx,-main=${VERSION}
@@ -150,6 +158,10 @@ CONFIGURE_ARGS+=	--add-dynamic-module=${
 CONFIGURE_ARGS+=	--add-dynamic-module=${WRKDIR}/nginx-rtmp-module-${VERSION-rtmp}/
 .endif
 
+.if ${BUILD_PACKAGES:M-njs}
+CONFIGURE_ARGS+=	--add-dynamic-module=${WRKSRC}/njs/nginx
+.endif
+
 CONFIGURE_ARGS+=	--prefix=${NGINX_DIR} \
 			--conf-path=${SYSCONFDIR}/nginx/nginx.conf \
 			--sbin-path=${PREFIX}/sbin/nginx \
@@ -193,7 +205,7 @@ NO_TEST=		Yes
 ALL_TARGET=
 
 pre-patch:
-.for i in headers-more-nginx-module lua-nginx-module naxsi \
+.for i in headers-more-nginx-module lua-nginx-module naxsi njs \
 	nginx-auth-ldap ngx_devel_kit ngx_http_geoip2_module \
 	ngx_http_hmac_secure_link_module
 	cd ${WRKSRC} && mv ../$i-* $i
Index: distinfo
===================================================================
RCS file: /cvs/ports/www/nginx/distinfo,v
retrieving revision 1.80
diff -u -p -r1.80 distinfo
--- distinfo	17 Apr 2023 17:36:58 -0000	1.80
+++ distinfo	24 May 2023 16:07:23 -0000
@@ -8,6 +8,7 @@ SHA256 (nginx-rtmp-module-v1.2.1.tar.gz)
 SHA256 (ngx_devel_kit-v0.3.0.tar.gz) = iOBamainQZBm9a51lm+x78QJutRSLRSYbaB0VUrmFhk=
 SHA256 (ngx_http_geoip2_module-3.3.tar.gz) = QTeEOMgz4xOhiGnQxKcnBLSDXDCsr3/WgBOrZzL/eKc=
 SHA256 (ngx_http_hmac_secure_link_module-48c4625fbbf51ed5a95bfec23fa444f6c3702e50.tar.gz) = ZXpA2rODS1enIREzlD1OqWwpWcv3NOUXH4eUOgOAmqg=
+SHA256 (njs-0.7.12.tar.gz) = enWjkCLftY2/RhBTkDoHzEjdSUL32CpGYBgZwbAHdoc=
 SIZE (headers-more-nginx-module-v0.34.tar.gz) = 28827
 SIZE (lua-nginx-module-v0.10.11.tar.gz) = 616653
 SIZE (naxsi-d714f1636ea49a9a9f4f06dba14aee003e970834.tar.gz) = 237272
@@ -18,3 +19,4 @@ SIZE (nginx-rtmp-module-v1.2.1.tar.gz) =
 SIZE (ngx_devel_kit-v0.3.0.tar.gz) = 66455
 SIZE (ngx_http_geoip2_module-3.3.tar.gz) = 8509
 SIZE (ngx_http_hmac_secure_link_module-48c4625fbbf51ed5a95bfec23fa444f6c3702e50.tar.gz) = 6159
+SIZE (njs-0.7.12.tar.gz) = 662554
--- /dev/null	Wed May 24 11:08:50 2023
+++ patches/patch-njs_auto_make	Wed May 24 11:06:56 2023
@@ -0,0 +1,22 @@
+https://github.com/nginx/njs/commit/e9d814a0a8c1857f78fdc85ed1461cb9101ebf4e
+
+Index: njs/auto/make
+--- njs/auto/make.orig
++++ njs/auto/make
+@@ -320,11 +320,11 @@ cat << END >> $NJS_MAKEFILE
+ pc: $NJS_BUILD_DIR/njs.pc
+ 
+ $NJS_BUILD_DIR/njs.pc: $NJS_BUILD_DIR/njs_auto_config.h
+-	sed -e "s,@PREFIX@,$(pwd)/$NJS_BUILD_DIR," \\
+-		-e "s,@LIBDIR@,$(pwd)/$NJS_BUILD_DIR," \\
+-		-e "s,@CFLAGS@,-I$(pwd)/$NJS_BUILD_DIR -I$(pwd)/src," \\
+-		-e "s,@VERSION@,\$(NJS_VER)," \\
+-		-e "s,@EXTRA_LIBS@,-lm $NJS_LIBS $NJS_LIB_AUX_LIBS," \\
++	sed -e "s|@PREFIX@|$(pwd)/$NJS_BUILD_DIR|" \\
++		-e "s|@LIBDIR@|$(pwd)/$NJS_BUILD_DIR|" \\
++		-e "s|@CFLAGS@|-I$(pwd)/$NJS_BUILD_DIR -I$(pwd)/src|" \\
++		-e "s|@VERSION@|\$(NJS_VER)|" \\
++		-e "s|@EXTRA_LIBS@|-lm $NJS_LIBS $NJS_LIB_AUX_LIBS|" \\
+ 		src/njs.pc.in > \$@
+ END
+ 
--- /dev/null	Wed May 24 11:09:01 2023
+++ patches/patch-njs_external_njs_fs_module_c	Wed May 24 11:06:34 2023
@@ -0,0 +1,16 @@
+https://github.com/nginx/njs/commit/8a03334e27393fc2031f071830f9605f4373b0be
+
+Index: njs/external/njs_fs_module.c
+--- njs/external/njs_fs_module.c.orig
++++ njs/external/njs_fs_module.c
+@@ -3297,8 +3297,8 @@ njs_fs_to_stat(njs_stat_t *dst, struct stat *st)
+     dst->st_mtim.tv_nsec = st->st_mtimespec.tv_nsec;
+     dst->st_ctim.tv_sec = st->st_ctimespec.tv_sec;
+     dst->st_ctim.tv_nsec = st->st_ctimespec.tv_nsec;
+-    dst->st_birthtim.tv_sec = st->st_birthtimespec.tv_sec;
+-    dst->st_birthtim.tv_nsec = st->st_birthtimespec.tv_nsec;
++    dst->st_birthtim.tv_sec = st->__st_birthtimespec.tv_sec;
++    dst->st_birthtim.tv_nsec = st->__st_birthtimespec.tv_nsec;
+ 
+ #elif (NJS_HAVE_STAT_ATIM)
+ 
--- /dev/null	Wed May 24 11:09:13 2023
+++ pkg/DESCR-njs	Tue May 23 20:55:43 2023
@@ -0,0 +1,2 @@
+The NGINX Javascript module is a subset of the JavaScript language
+that allows extending nginx functionality.
--- /dev/null	Wed May 24 11:09:21 2023
+++ pkg/PLIST-njs	Tue May 23 20:55:07 2023
@@ -0,0 +1,3 @@
+@comment $OpenBSD$
+@so ngx_http_js_module.so
+@so ngx_stream_js_module.so

Reply via email to