From: jonas.licht@fem.tu-ilmenau.de
To: gentoo-dev@lists.gentoo.org
Cc: Jonas Licht <jonas.licht@fem.tu-ilmenau.de>
Subject: [gentoo-dev] [PATCH v2 2/3] Add nginx-module.eclass
Date: Sun, 28 Feb 2021 18:36:14 +0100 [thread overview]
Message-ID: <20210228173615.12685-3-jonas.licht@fem.tu-ilmenau.de> (raw)
In-Reply-To: <20210228173615.12685-1-jonas.licht@fem.tu-ilmenau.de>
From: Jonas Licht <jonas.licht@fem.tu-ilmenau.de>
Signed-off-by: Jonas Licht <jonas.licht@fem.tu-ilmenau.de>
---
eclass/nginx-module.eclass | 72 ++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
create mode 100644 eclass/nginx-module.eclass
diff --git a/eclass/nginx-module.eclass b/eclass/nginx-module.eclass
new file mode 100644
index 00000000000..d9f9bbdb89c
--- /dev/null
+++ b/eclass/nginx-module.eclass
@@ -0,0 +1,72 @@
+# Copyright 2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: nginx-module.eclass
+# @MAINTAINER:
+# Jonas Licht <jonas.licht@gmail.com>
+# @AUTHOR:
+# Jonas Licht <jonas.licht@gmail.com>
+# @BLURB: Provide a set of functions to build nginx dynamic modules.
+# @DESCRIPTION:
+# Eclass to make dynamic nginx modules.
+# As these modules are hardly build against one nginx version we use version cut to indicate the nginx version too.
+# The first three parts of the version must represent the nginx version,
+# the remaining part displays the module version.
+#
+# To build a nginx module the whole nginx source code is needed,
+# therfore we set the SRC_URI to the nginx source archive.
+# The module archive must be added with SRC_URI+=
+
+case ${EAPI:-0} in
+ 7) ;;
+ *) die "This eclass only supports EAPI 7" ;;
+esac
+
+# @ECLASS-VARIABLE: NGINX_PV
+# @DESCRIPTION:
+# Uses version cut of the first three parts of the version to determine the nginx version providing the module.
+# This version is used for SRC_URI, BDPEND and compiling process.
+NGINX_PV=$(ver_cut 1-3)
+
+# @ECLASS-VARIABLE: MODULE_PV
+# @DESCRIPTION:
+# Uses version cut to get the version of the module.
+# Variable can be used for SRC_URI of the nginx module.
+MODULE_PV=$(ver_cut 4-)
+
+BDPEND="=www-servers/nginx-${NGINX_PV}:="
+SRC_URI="https://nginx.org/download/nginx-${NGINX_PV}.tar.gz"
+
+S="${WORKDIR}/nginx-${NGINX_PV}"
+
+EXPORT_FUNCTIONS src_configure src_compile src_install
+
+# @FUNCTION: nginx-module_src_configure
+# @USAGE: [additional-args]
+# @DESCRIPTION:
+# Parses the configure from the original nginx binary by exicution 'nginx -V' and adds the package as dynamic module.
+nginx-module_src_configure() {
+ if [ $(grep -c "\.[[:space:]]auto/module" "${WORKDIR}/${PN}-${MODULE_PV}/config") -eq 0 ]; then
+ die "module uses old unsupported static config file syntax: https://www.nginx.com/resources/wiki/extending/converting/"
+ fi
+ #grep nginx configure from nginx -V add drop all other external modules
+ NGINX_ORIGIN_CONFIGURE=$(nginx -V 2>&1 | grep "configure arguments:" | cut -d: -f2 | sed "s/--add-module=\([^\s]\)*\s/ /")
+ ./configure ${NGINX_ORIGIN_CONFIGURE} --add-dynamic-module="../${PN}-${MODULE_PV}" "$@" || die "configure failed"
+}
+
+# @FUNCTION: nginx-module_src_compile
+# @USAGE: [additional-args]
+# @DESCRIPTION:
+# Runs 'make modules' to only build our package module.
+nginx-module_src_compile() {
+ emake modules "$@"
+}
+
+# @FUNCTION: nginx-module_src_install
+# @DESCRIPTION:
+# Parses the module config file to get the so file name and install the shared object file to '/usr/$(get_libdir)/nginx/modules'
+nginx-module_src_install() {
+ NGINX_MODULE_NAME=$(grep ${WORKDIR}/${PN}-${MODULE_PV}/config -e "ngx_addon_name" | cut -d= -f2)
+ exeinto /usr/$(get_libdir)/nginx/modules
+ doexe ${S}/objs/${NGINX_MODULE_NAME}.so
+}
--
2.26.2
next prev parent reply other threads:[~2021-02-28 17:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-14 16:20 [gentoo-dev] [PATCH 0/3] [RFC] www-nginx/ category and nginx-module.eclass jonas.licht
2021-02-14 16:20 ` [gentoo-dev] [PATCH 1/3] profiles/categories: add www-nginx jonas.licht
2021-02-14 16:20 ` [gentoo-dev] [PATCH 2/3] Add nginx-module.eclass jonas.licht
2021-02-14 17:56 ` Michał Górny
2021-02-14 16:20 ` [gentoo-dev] [PATCH 3/3] www-nginx/nginx-vod-module: add new package jonas.licht
2021-02-28 17:36 ` [gentoo-dev] [PATCH v2 0/3] Version 2 jonas.licht
2021-02-28 17:36 ` [gentoo-dev] [PATCH v2 1/3] profiles/categories: add www-nginx jonas.licht
2021-02-28 17:36 ` jonas.licht [this message]
2021-02-28 17:36 ` [gentoo-dev] [PATCH v2 3/3] www-nginx/nginx-vod-module: add new package jonas.licht
2021-12-13 21:12 ` [gentoo-dev] [PATCH v2 0/3] Version 2 Jonas Licht
2021-12-15 18:02 ` Joonas Niilola
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210228173615.12685-3-jonas.licht@fem.tu-ilmenau.de \
--to=jonas.licht@fem.tu-ilmenau.de \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox