Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: Jonas Licht <jonas.licht@××××××××××××××.de>
Subject: Re: [gentoo-dev] [PATCH 2/3] Add nginx-module.eclass
Date: Sun, 14 Feb 2021 17:56:38
Message-Id: 6edb60da73d53a7e04f1b76dc4c16cba5e042d43.camel@gentoo.org
In Reply to: [gentoo-dev] [PATCH 2/3] Add nginx-module.eclass by jonas.licht@fem.tu-ilmenau.de
1 On Sun, 2021-02-14 at 17:20 +0100, jonas.licht@××××××××××××××.de wrote:
2 > From: Jonas Licht <jonas.licht@××××××××××××××.de>
3 >
4 > Signed-off-by: Jonas Licht <jonas.licht@××××××××××××××.de>
5 > ---
6 >  eclass/nginx-module.eclass | 73 ++++++++++++++++++++++++++++++++++++++
7 >  1 file changed, 73 insertions(+)
8 >  create mode 100644 eclass/nginx-module.eclass
9 >
10 > diff --git a/eclass/nginx-module.eclass b/eclass/nginx-module.eclass
11 > new file mode 100644
12 > index 00000000000..178982af285
13 > --- /dev/null
14 > +++ b/eclass/nginx-module.eclass
15 > @@ -0,0 +1,73 @@
16 > +# Copyright 2021 Gentoo Authors
17 > +# Distributed under the terms of the GNU General Public License v2
18 > +
19 > +# @ECLASS: nginx-module.eclass
20 > +# @MAINTAINER:
21 > +# Jonas Licht <jonas.licht@×××××.com>
22 > +# @AUTHOR:
23 > +# Jonas Licht <jonas.licht@×××××.com>
24 > +# @BLURB: Provide a set of functions to build nginx dynamic modules.
25 > +# @DESCRIPTION:
26 > +# Eclass to make dynamic nginx modules.
27 > +# As these modules are hardly build against one nginx version we use version cut to indicate the nginx version too.
28 > +# The first three parts of the version must represent the nginx version,
29 > +# the remaining part displays the module version.
30 > +#
31 > +# To build a nginx module the whole nginx source code is needed,
32 > +# therfore we set the SRC_URI to the nginx source archive.
33 > +# The module archive must be added with SRC_URI+=
34 > +
35 > +case ${EAPI:-0} in
36 > + 7) ;;
37 > + *) die "This eclass only supports EAPI 7" ;;
38 > +esac
39 > +
40 > +# @ECLASS-VARIABLE: NGX_PV
41
42 It seems you've used tab instead of space here.
43
44 Also is there any reason to use 'NGX' instead of 'NGINX'? This doesn't
45 seem to save much.
46
47 > +# @DESCRIPTION:
48 > +# Uses version cut of the first three parts of the version to determine the proposed nginx version.
49
50 'proposed nginx version' sounds weird. Maybe 'nginx version providing
51 the module' or sth like that.
52
53 > +# This version is used for SRC_URI, BDPEND and compiling process.
54 > +NGX_PV=$(ver_cut 1-3)
55 > +
56 > +# @ECLASS-VARIABLE: MODULE_PV
57 > +# @DESCRIPTION:
58 > +# Uses version cut to get the version of the module.
59 > +# Variable can uses for SRC_URI.
60
61 This seems to entirely miss the point that it's used pretty much
62 everywhere.
63
64 > +MODULE_PV=$(ver_cut 4-)
65 > +
66 > +BDPEND="=www-servers/nginx-${NGX_PV}:="
67 > +SRC_URI="https://nginx.org/download/nginx-${NGX_PV}.tar.gz
68 > + "
69 Why the extra newline + indent?
70
71 > +
72 > +S="${WORKDIR}/nginx-${NGX_PV}"
73 > +
74 > +EXPORT_FUNCTIONS src_configure src_compile src_install
75 > +
76 > +# @FUNCTION: nginx-module_src_configure
77 > +# @USAGE: [additional-args]
78 > +# @DESCRIPTION:
79 > +# Parses the configure from the original nginx binary by exicution 'nginx -V' and adds the package as dynamic module.
80 > +nginx-module_src_configure() {
81 > + if [ `grep -c "\.[[:space:]]auto/module" ${WORKDIR}/${PN}-${MODULE_PV}/config` -eq 0 ]; then
82
83 Use $() instead of ``, quote ${WORKDIR}.
84
85
86 > + die "module uses old unsupported static config file syntax: https://www.nginx.com/resources/wiki/extending/converting/"
87 > + fi
88 > + #grep nginx configure from nginx -V add drop all other external modules
89 > + NGX_ORIGIN_CONFIGURE=`nginx -V 2>&1 | grep "configure arguments:" | cut -d: -f2 | sed "s/--add-module=\([^\s]\)*\s/ /"`
90 > + ./configure ${NGX_ORIGIN_CONFIGURE} --add-dynamic-module="../${PN}-${MODULE_PV}" "$@" || die "configure failed"
91 > +}
92 > +
93 > +# @FUNCTION: nginx-module_src_compile
94 > +# @USAGE: [additional-args]
95 > +# @DESCRIPTION:
96 > +# Runs 'make modules' to only build our package module.
97 > +nginx-module_src_compile() {
98 > + emake modules "$@"
99 > +}
100 > +
101 > +# @FUNCTION: nginx-module_src_install
102 > +# @DESCRIPTION:
103 > +# Parses the module config file to get the so file name and install the shared object file to '/usr/$(get_libdir)/nginx/modules'
104 > +nginx-module_src_install() {
105 > + NGX_MODULE_NAME=`grep ${WORKDIR}/${PN}-${MODULE_PV}/config -e "ngx_addon_name" | cut -d= -f2`
106 > + exeinto /usr/$(get_libdir)/nginx/modules
107 > + doexe ${S}/objs/${NGX_MODULE_NAME}.so
108 > +}
109
110 --
111 Best regards,
112 Michał Górny