Gentoo Archives: gentoo-dev

From: jonas.licht@××××××××××××××.de
To: gentoo-dev@l.g.o
Cc: Jonas Licht <jonas.licht@××××××××××××××.de>
Subject: [gentoo-dev] [PATCH 2/3] Add nginx-module.eclass
Date: Sun, 14 Feb 2021 16:22:01
Message-Id: 20210214162035.16786-3-jonas.licht@fem.tu-ilmenau.de
In Reply to: [gentoo-dev] [PATCH 0/3] [RFC] www-nginx/ category and nginx-module.eclass by jonas.licht@fem.tu-ilmenau.de
1 From: Jonas Licht <jonas.licht@××××××××××××××.de>
2
3 Signed-off-by: Jonas Licht <jonas.licht@××××××××××××××.de>
4 ---
5 eclass/nginx-module.eclass | 73 ++++++++++++++++++++++++++++++++++++++
6 1 file changed, 73 insertions(+)
7 create mode 100644 eclass/nginx-module.eclass
8
9 diff --git a/eclass/nginx-module.eclass b/eclass/nginx-module.eclass
10 new file mode 100644
11 index 00000000000..178982af285
12 --- /dev/null
13 +++ b/eclass/nginx-module.eclass
14 @@ -0,0 +1,73 @@
15 +# Copyright 2021 Gentoo Authors
16 +# Distributed under the terms of the GNU General Public License v2
17 +
18 +# @ECLASS: nginx-module.eclass
19 +# @MAINTAINER:
20 +# Jonas Licht <jonas.licht@×××××.com>
21 +# @AUTHOR:
22 +# Jonas Licht <jonas.licht@×××××.com>
23 +# @BLURB: Provide a set of functions to build nginx dynamic modules.
24 +# @DESCRIPTION:
25 +# Eclass to make dynamic nginx modules.
26 +# As these modules are hardly build against one nginx version we use version cut to indicate the nginx version too.
27 +# The first three parts of the version must represent the nginx version,
28 +# the remaining part displays the module version.
29 +#
30 +# To build a nginx module the whole nginx source code is needed,
31 +# therfore we set the SRC_URI to the nginx source archive.
32 +# The module archive must be added with SRC_URI+=
33 +
34 +case ${EAPI:-0} in
35 + 7) ;;
36 + *) die "This eclass only supports EAPI 7" ;;
37 +esac
38 +
39 +# @ECLASS-VARIABLE: NGX_PV
40 +# @DESCRIPTION:
41 +# Uses version cut of the first three parts of the version to determine the proposed nginx version.
42 +# This version is used for SRC_URI, BDPEND and compiling process.
43 +NGX_PV=$(ver_cut 1-3)
44 +
45 +# @ECLASS-VARIABLE: MODULE_PV
46 +# @DESCRIPTION:
47 +# Uses version cut to get the version of the module.
48 +# Variable can uses for SRC_URI.
49 +MODULE_PV=$(ver_cut 4-)
50 +
51 +BDPEND="=www-servers/nginx-${NGX_PV}:="
52 +SRC_URI="https://nginx.org/download/nginx-${NGX_PV}.tar.gz
53 + "
54 +
55 +S="${WORKDIR}/nginx-${NGX_PV}"
56 +
57 +EXPORT_FUNCTIONS src_configure src_compile src_install
58 +
59 +# @FUNCTION: nginx-module_src_configure
60 +# @USAGE: [additional-args]
61 +# @DESCRIPTION:
62 +# Parses the configure from the original nginx binary by exicution 'nginx -V' and adds the package as dynamic module.
63 +nginx-module_src_configure() {
64 + if [ `grep -c "\.[[:space:]]auto/module" ${WORKDIR}/${PN}-${MODULE_PV}/config` -eq 0 ]; then
65 + die "module uses old unsupported static config file syntax: https://www.nginx.com/resources/wiki/extending/converting/"
66 + fi
67 + #grep nginx configure from nginx -V add drop all other external modules
68 + NGX_ORIGIN_CONFIGURE=`nginx -V 2>&1 | grep "configure arguments:" | cut -d: -f2 | sed "s/--add-module=\([^\s]\)*\s/ /"`
69 + ./configure ${NGX_ORIGIN_CONFIGURE} --add-dynamic-module="../${PN}-${MODULE_PV}" "$@" || die "configure failed"
70 +}
71 +
72 +# @FUNCTION: nginx-module_src_compile
73 +# @USAGE: [additional-args]
74 +# @DESCRIPTION:
75 +# Runs 'make modules' to only build our package module.
76 +nginx-module_src_compile() {
77 + emake modules "$@"
78 +}
79 +
80 +# @FUNCTION: nginx-module_src_install
81 +# @DESCRIPTION:
82 +# Parses the module config file to get the so file name and install the shared object file to '/usr/$(get_libdir)/nginx/modules'
83 +nginx-module_src_install() {
84 + NGX_MODULE_NAME=`grep ${WORKDIR}/${PN}-${MODULE_PV}/config -e "ngx_addon_name" | cut -d= -f2`
85 + exeinto /usr/$(get_libdir)/nginx/modules
86 + doexe ${S}/objs/${NGX_MODULE_NAME}.so
87 +}
88 --
89 2.26.2

Replies

Subject Author
Re: [gentoo-dev] [PATCH 2/3] Add nginx-module.eclass "Michał Górny" <mgorny@g.o>