Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[gentoo-dev] [PATCH v3 2/3] Add nginx-module.eclass

3 views
Skip to first unread message

Adrian Schollmeyer

unread,
Jan 24, 2023, 11:00:03 AM1/24/23
to
From: Jonas Licht <jonas...@fem.tu-ilmenau.de>

Signed-off-by: Adrian Schollmeyer <nex+...@nexadn.de>
Signed-off-by: Jonas Licht <jonas...@fem.tu-ilmenau.de>
---
eclass/nginx-module.eclass | 90 ++++++++++++++++++++++++++++++++++++++
1 file changed, 90 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..aa25977cdc5
--- /dev/null
+++ b/eclass/nginx-module.eclass
@@ -0,0 +1,90 @@
+# Copyright 2021-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: nginx-module.eclass
+# @MAINTAINER:
+# Jonas Licht <jonas...@gmail.com>
+# @AUTHOR:
+# Jonas Licht <jonas...@gmail.com>
+# @BLURB: Provide a set of functions to build nginx dynamic modules.
+# @DESCRIPTION:
+# Eclass to make dynamic nginx modules.
+# As these modules are built against one particular nginx version.
+# The nginx version is encoded in PV as the first three version components,
+# while the rest of PV represent's the module's upstream version.
+#
+# To build an nginx module the whole nginx source code is needed.
+# Therefore SRC_URI is set to the nginx source archive.
+# Ebuilds using this eclass thus must use SRC_URI+= instead of
+# SRC_URI=.
+
+case ${EAPI:-0} in
+ 7|8) ;;
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+inherit toolchain-funcs
+
+# @ECLASS_VARIABLE: NGINX_PV
+# @PRE_INHERIT
+# @DESCRIPTION:
+# Version of www-apps/nginx to build against.
+# Default is the first three components of PV.
+: "${NGINX_PV:=$(ver_cut 1-3)}"
+
+# @ECLASS_VARIABLE: MODULE_PV
+# @PRE_INHERIT
+# @DESCRIPTION:
+# Module version minus the www-apps/nginx version.
+# Default is all components of PV starting with the 4th component.
+: "${MODULE_PV=$(ver_cut 4-)}"
+
+# @ECLASS_VARIABLE: MODULE_SOURCE
+# @DESCRIPTION:
+# Path to the unpacked source directory of the module.
+# Defaults to '${WORKDIR}/${PN}-${MODULE_PV}', mimicking the default value of S.
+: "${MODULE_SOURCE:="${WORKDIR}/${PN}-${MODULE_PV}"}"
+
+BDEPEND="~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 executing 'nginx -V' and
+# adds the package as dynamic module.
+nginx-module_src_configure() {
+ if [ "$(grep -c "\.[[:space:]]auto/module" "${MODULE_SOURCE}/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/ /")
+ # shellcheck disable=SC2086
+ ./configure ${NGINX_ORIGIN_CONFIGURE} --add-dynamic-module="${MODULE_SOURCE}" "$@" || 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() {
+ # https://bugs.gentoo.org/286772
+ export LANG=C LC_ALL=C
+ emake modules "$@" CC="$(tc-getCC)" LINK="$(tc-getCC) ${LDFLAGS}" OTHERLDFLAGS="${LDFLAGS}"
+}
+
+# @FUNCTION: nginx-module_src_install
+# @DESCRIPTION:
+# Parses the module config file to get the shared object file name and install the file to the nginx module directory.
+nginx-module_src_install() {
+ einstalldocs
+
+ local NGINX_MODULE_NAME
+ NGINX_MODULE_NAME=$(grep "${MODULE_SOURCE}/config" -e "ngx_addon_name" | cut -d= -f2)
+ exeinto /usr/$(get_libdir)/nginx/modules
+ doexe objs/${NGINX_MODULE_NAME}.so
+}
--
2.38.2

Adrian Schollmeyer

unread,
Jan 24, 2023, 11:00:03 AM1/24/23
to
From: Jonas Licht <jonas...@fem.tu-ilmenau.de>

Bug: https://bugs.gentoo.org/648334
Signed-off-by: Adrian Schollmeyer <nex+...@nexadn.de>
Signed-off-by: Jonas Licht <jonas...@fem.tu-ilmenau.de>
---
www-nginx/nginx-vod-module/Manifest | 2 ++
www-nginx/nginx-vod-module/metadata.xml | 15 +++++++++++++
.../nginx-vod-module-1.23.2.1.30.ebuild | 21 +++++++++++++++++++
3 files changed, 38 insertions(+)
create mode 100644 www-nginx/nginx-vod-module/Manifest
create mode 100644 www-nginx/nginx-vod-module/metadata.xml
create mode 100644 www-nginx/nginx-vod-module/nginx-vod-module-1.23.2.1.30.ebuild

diff --git a/www-nginx/nginx-vod-module/Manifest b/www-nginx/nginx-vod-module/Manifest
new file mode 100644
index 00000000000..e6aa72eb74a
--- /dev/null
+++ b/www-nginx/nginx-vod-module/Manifest
@@ -0,0 +1,2 @@
+DIST nginx-1.23.2.tar.gz 1108243 BLAKE2B 0a6a556afe93c4326247e879e3bb2ad377cd734a572f471b52c91b1b2901a243a848cd74fea587bda5afa0ee91dec9635b5d2a468cb95abc7f361c42a32c9598 SHA512 4a5413c0ec251c02fb73dfb4d351045f857a36d45ebb7ae2c29f4a4f320a6543d0a049b147b08318de0b7b0406773c329dbf43bf98bb088f76e506ea532cd8ef
+DIST nginx-vod-module-1.30.tar.gz 470262 BLAKE2B 26b20aa2d1b7104280b904ba1d16ea9dc569973a437d14183b0366037e9a1c2868e553d1db0ca5918f58d3cf0d7f47c001bb2362241e399f5bb1bdc8e9b3167c SHA512 23bc21d1f841b1ebddec53836d9df64ed1bd3ae5d16f966f940ba617072a28f6a85cc0d32ad6ad06ff60185d2d2b4509fffd8470045b5e211f57aed0d2e6505e
diff --git a/www-nginx/nginx-vod-module/metadata.xml b/www-nginx/nginx-vod-module/metadata.xml
new file mode 100644
index 00000000000..c7c79d4c4b0
--- /dev/null
+++ b/www-nginx/nginx-vod-module/metadata.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <email>jonas...@gmail.com</email>
+ <name>Jonas Licht</name>
+ </maintainer>
+ <maintainer type="project">
+ <email>proxy...@gentoo.org</email>
+ <name>Proxy Maintainers</name>
+ </maintainer>
+ <upstream>
+ <remote-id type="github">kaltura/nginx-vod-module</remote-id>
+ </upstream>
+</pkgmetadata>
diff --git a/www-nginx/nginx-vod-module/nginx-vod-module-1.23.2.1.30.ebuild b/www-nginx/nginx-vod-module/nginx-vod-module-1.23.2.1.30.ebuild
new file mode 100644
index 00000000000..2b69c44b0de
--- /dev/null
+++ b/www-nginx/nginx-vod-module/nginx-vod-module-1.23.2.1.30.ebuild
@@ -0,0 +1,21 @@
+# Copyright 2020-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit nginx-module
+
+DESCRIPTION="NGINX-based MP4 Repackager"
+HOMEPAGE="https://github.com/kaltura/nginx-vod-module"
+SRC_URI+=" https://github.com/kaltura/nginx-vod-module/archive/${MODULE_PV}.tar.gz -> ${PN}-${MODULE_PV}.tar.gz"
+
+LICENSE="AGPL-3"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+
+DEPEND="
+ dev-libs/libxml2:=
+ media-video/ffmpeg:=
+ sys-libs/zlib:=
+"
+RDEPEND="${DEPEND}"
--
2.38.2

Adrian Schollmeyer

unread,
Jan 24, 2023, 11:00:03 AM1/24/23
to
From: Jonas Licht <jonas...@fem.tu-ilmenau.de>

Signed-off-by: Adrian Schollmeyer <nex+...@nexadn.de>
Signed-off-by: Jonas Licht <jonas...@fem.tu-ilmenau.de>
---
profiles/categories | 1 +
www-nginx/metadata.xml | 7 +++++++
2 files changed, 8 insertions(+)
create mode 100644 www-nginx/metadata.xml

diff --git a/profiles/categories b/profiles/categories
index 64963f1467a..4b4ff07cb35 100644
--- a/profiles/categories
+++ b/profiles/categories
@@ -155,6 +155,7 @@ www-apache
www-apps
www-client
www-misc
+www-nginx
www-plugins
www-servers
x11-apps
diff --git a/www-nginx/metadata.xml b/www-nginx/metadata.xml
new file mode 100644
index 00000000000..340ce767d0e
--- /dev/null
+++ b/www-nginx/metadata.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE catmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<catmetadata>
+ <longdescription lang="en">
+ The www-nginx category contains modules for the Nginx Webserver.
+ </longdescription>
+</catmetadata>
--
2.38.2

Adrian Schollmeyer

unread,
Jan 24, 2023, 11:00:03 AM1/24/23
to
Hey there,

a while back Jonas Licht (Cc) wrote an eclass for Nginx dynamic modules.
For a few years now, Nginx supports building third party dynamic modules
outside of the Nginx source tree with the help of Nginx's build system.
Since this involves quite some work to obtain information from the Nginx
build configuration and using Nginx's build system to actually build the
module, an eclass was written. The last RFC didn't make it into
::gentoo, since the requested changes haven't been applied.

However, we have been working on the eclass again and applied all the
requested changes, made it EAPI=8 compatible and were able to use it
successfully to package a third party Nginx module in ::fem-overlay [0].

This patchset contains the reworked nginx-module.eclass for building
third party modules using Nginx's build system as separate packages.
Furthermore the category www-nginx is added where these third party
modules shall be put. Lastly, www-nginx/nginx-vod-module is added as a
first package using this eclass.

The patchset is also available as PR #16053 on GitHub [1]. If this
patchset is applied, the other PR for adding nginx-vod-module [2]
probably becomes obsolete [2].

Best regards
Adrian and Jonas

[0] https://gitlab.fem-net.de/gentoo/fem-overlay/-/tree/master/www-nginx/nginx-vod-module
[1] https://github.com/gentoo/gentoo/pull/16053
[2] https://github.com/gentoo/gentoo/pull/11043

Michał Górny

unread,
Jan 24, 2023, 12:20:03 PM1/24/23
to
On Tue, 2023-01-24 at 16:51 +0100, Adrian Schollmeyer wrote:
> Hey there,
>
> a while back Jonas Licht (Cc) wrote an eclass for Nginx dynamic modules.
> For a few years now, Nginx supports building third party dynamic modules
> outside of the Nginx source tree with the help of Nginx's build system.
> Since this involves quite some work to obtain information from the Nginx
> build configuration and using Nginx's build system to actually build the
> module, an eclass was written. The last RFC didn't make it into
> ::gentoo, since the requested changes haven't been applied.
>
> However, we have been working on the eclass again and applied all the
> requested changes, made it EAPI=8 compatible and were able to use it
> successfully to package a third party Nginx module in ::fem-overlay [0].
>
> This patchset contains the reworked nginx-module.eclass for building
> third party modules using Nginx's build system as separate packages.
> Furthermore the category www-nginx is added where these third party
> modules shall be put. Lastly, www-nginx/nginx-vod-module is added as a
> first package using this eclass.
>
> The patchset is also available as PR #16053 on GitHub [1]. If this
> patchset is applied, the other PR for adding nginx-vod-module [2]
> probably becomes obsolete [2].
>

How many packages do you expect to add to this new category? It's not
customary to create a new category for one package.

--
Best regards,
Michał Górny

Anna (cybertailor) Vyalkova

unread,
Jan 24, 2023, 2:00:03 PM1/24/23
to
On 2023-01-24 18:11, Michał Górny wrote:
> How many packages do you expect to add to this new category? It's not
> customary to create a new category for one package.

Look at www-servers/nginx package, it's huge! Lots of modules
(many of them are 3rd-party) could be separate packages.

Adrian Schollmeyer

unread,
Jan 24, 2023, 2:10:03 PM1/24/23
to
Hi,

Am Dienstag, dem 24.01.2023 um 18:11 +0100 schrieb Michał Górny:
> How many packages do you expect to add to this new category?  It's
> not customary to create a new category for one package.
We currently have 24 third party modules in www-apps/nginx pulled in
conditionally via USE flags. With nginx-module.eclass we should be
able to migrate all of them to separate packages, reducing extra
compile overhead for users wanting to install one of those modules and
reducing the ebuild size and complexity of www-apps/nginx.

Best regards
Adrian
signature.asc
0 new messages