The build system of this package automagically enables HMAC support
based on SSL functionality being enabled in the installed NGINX.

In order to enable this support independently, via a USE flag, a "hack"
is applied: only if GENTOO_USE_HMAC environmental variable and
preprocessor definition are defined, HMAC support is enabled.

Signed-off-by: Zurab Kvachadze <zurabid2...@gmail.com>
---
 www-nginx/ngx-set-misc/Manifest               |  1 +
 .../ngx-set-misc}/metadata.xml                |  9 ++--
 .../ngx-set-misc/ngx-set-misc-0.33.ebuild     | 50 +++++++++++++++++++
 3 files changed, 55 insertions(+), 5 deletions(-)
 create mode 100644 www-nginx/ngx-set-misc/Manifest
 copy {app-containers/apptainer => www-nginx/ngx-set-misc}/metadata.xml (54%)
 create mode 100644 www-nginx/ngx-set-misc/ngx-set-misc-0.33.ebuild

diff --git a/www-nginx/ngx-set-misc/Manifest b/www-nginx/ngx-set-misc/Manifest
new file mode 100644
index 000000000000..34be9e483747
--- /dev/null
+++ b/www-nginx/ngx-set-misc/Manifest
@@ -0,0 +1 @@
+DIST ngx-set-misc-0.33.tar.gz 30084 BLAKE2B 
1aabf47e86946054d128a10290c36829152d427cf415378f5042e00e428baaf94a91e1d8ee1037b8a40197637c721492b01a82c800064decb9471149ad47bcff
 SHA512 
1ff4c947538a5bd5f9d6adcd87b37f2702f5cc90e3342bc08359cbe8f290b705a3a2daa3dedfb1df3ce4bc19478c8fcac07081c4a53a804fc2862d50078278dc
diff --git a/app-containers/apptainer/metadata.xml 
b/www-nginx/ngx-set-misc/metadata.xml
similarity index 54%
copy from app-containers/apptainer/metadata.xml
copy to www-nginx/ngx-set-misc/metadata.xml
index c461d956342a..4a396a61a564 100644
--- a/app-containers/apptainer/metadata.xml
+++ b/www-nginx/ngx-set-misc/metadata.xml
@@ -2,11 +2,10 @@
 <!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd";>
 <pkgmetadata>
        <!-- maintainer-needed -->
-       <use>
-               <flag name="network">Install network plug-ins</flag>
-               <flag name="suid">Install SUID helper binary</flag>
-       </use>
        <upstream>
-               <remote-id type="github">apptainer/apptainer</remote-id>
+               <remote-id 
type="github">openresty/set-misc-nginx-module</remote-id>
        </upstream>
+       <use>
+               <flag name="hmac">Enable support for generating HMAC digests 
using <pkg>dev-libs/openssl</pkg></flag>
+       </use>
 </pkgmetadata>
diff --git a/www-nginx/ngx-set-misc/ngx-set-misc-0.33.ebuild 
b/www-nginx/ngx-set-misc/ngx-set-misc-0.33.ebuild
new file mode 100644
index 000000000000..9869cf207c11
--- /dev/null
+++ b/www-nginx/ngx-set-misc/ngx-set-misc-0.33.ebuild
@@ -0,0 +1,50 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+DESCRIPTION="An NGINX module that adds various set_xxx directives to NGINX's 
rewrite module"
+HOMEPAGE="https://github.com/openresty/set-misc-nginx-module";
+
+SRC_URI="
+       
https://github.com/openresty/set-misc-nginx-module/archive/refs/tags/v${PV}.tar.gz
 -> ${P}.tar.gz
+"
+LICENSE="BSD-2"
+
+SLOT=0
+
+MY_PN="set-misc-nginx-module"
+
+inherit nginx-module
+
+NGINX_MOD_S="${WORKDIR}/${MY_PN}-${PV}"
+
+IUSE="+hmac"
+
+DEPEND="
+       www-nginx/ngx_devel_kit
+       hmac? ( dev-libs/openssl )
+"
+RDEPEND="${DEPEND}"
+
+src_prepare() {
+       sed -E -i 's/USE_OPENSSL|MAIL_SSL/GENTOO_USE_HMAC/g' \
+               "${NGINX_MOD_S}/config" || die "sed failed"
+       sed -i 's/NGX_OPENSSL/GENTOO_USE_HMAC/g' \
+               "${NGINX_MOD_S}/src/ngx_http_set_misc_module.c" || die "sed 
failed"
+       if use hmac; then
+               sed -E -i 's/^(\s*ngx_module_libs)=$/\1=-lcrypto/' \
+                       "${NGINX_MOD_S}/config" || die "sed failed"
+       fi
+       nginx-module_src_prepare
+}
+
+src_configure() {
+       append-cflags -DNDK
+       export NDK_SRCS="ndk.c"
+       export GENTOO_USE_HMAC=NO
+       if use hmac; then
+               export GENTOO_USE_HMAC=YES
+               append-cflags -DGENTOO_USE_HMAC=1
+       fi
+       nginx-module_src_configure
+}
-- 
2.44.2


Reply via email to