mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-11-23 11:17:21 -08:00
33d3f76d5dfc7a168b019edc1385af39aed75840
This adds a generic eclass for building, testing and installing NGINX
distributions (F5's NGINX, freenginx, etc).
This is a complete revamp of the way NGINX is packaged in Gentoo.
The problem
===========
NGINX has not been maintained for almost 2 years, since June 5 2022
(commit 9061b2f231: "*/*: reassign whissi's packages"). In its current
state, NGINX has 16 open bugs, with the oldest being reported more than
10 years ago (471106, 496318 and a few more). Moreover, each NGINX
ebuild is over 1100 lines of code and 40 kilobytes in size, with
enormous amounts of code being copied over with each version bump.
Currently, these are some of the most obvious issues.
There is another major problem: the www-servers/nginx package bundles
25 third party modules. This inflexible approach has its own issues:
* version pinning (of the external modules).
* no trivial way to add other external modules (for the end user).
The actual code is very old, has inconsistent USE flag choices
(http{2,3} being USE flags on their own rather than NGINX_MODULES_HTTP
USE_EXPAND flags, the same goes for the ssl USE flag, etc.), outright
useless USE flags that do nothing at all (pcre-jit and ktls), outdated
dependencies (libpcre instead of libpcre2 by default), mixed shell
constructs ('[' somewhere and '[[' elsewhere). The ebuild adds the
default include paths to CFLAGS and LDFLAGS for no reason and has
warnings about the versions as old as 1.10 (released in January
2017); the ebuild configures NGINX to store its temporary files in
/var/lib, instead of /var/tmp and so on...
Although this does not intend to cover all the flaws of the current
state of NGINX in the Gentoo tree, it is blatant that the quality of the
NGINX ebuilds are quite poor and that they are overall particularly
messy and clunky.
So, I deemed "repackaging" NGINX from the ground up an easier task (than
fixing the current NGINX ebuild in-place) and went on with it.
The solution
============
This eclass aims to fully cover as much of what is in common between
different NGINX versions and distributions as possible, which by itself
requires a high degree of flexibility in an eclass. The nginx.eclass
does not intend to move the aforementioned complexity to a one place,
but rather to *get rid* of it entirely. It achieves this by requiring
the inheriting ebuilds to provide the "specification" of their version.
The specification is really simple and is comprised of 4 variables:
* NGINX_MODULES, that defines available modules, i.e "http_perl",
"http_geoip", "http_ssl", "http_v3", "mail_imap", etc.
* NGINX_SUBSYSTEMS, that defines individual available NGINX servers:
"http", "stream" and "mail".
* NGINX_TESTS_COMMIT, that defines a partcular commit of NGINX
tests.
* NGINX_UPDATE_STREAM, that corresponds to the NGINX version type as
defined upstream. Currently, it is either "mainline", "stable" or
"live" for the Git version. SLOT is derived from this
variable.
And 1 optional variable:
* NGINX_MISC_FILES, that specifies files in FILESDIR, e.g. NGINX
main configuration file, NGINX systemd service file, etc. They are
installed into specific locations based on their file extension.
The nginx.eclass takes care of all the other aspects. This eclass:
1. Sets the default value for DESCRITPION, HOMEPAGE, LICENSE,
SRC_URI. SLOT is set to ${NGINX_UPDATE_STREAM}/${PV}.
2. Populates IUSE, based on the NGINX_MODULES and NGINX_SUBSYSTEMS
variables.
3. Fills BDEPEND, DEPEND and RDEPEND with general NGINX
dependencies.
4. Sets blocks on all possible update streams (that are expressed as
SLOT) apart from the current one, in order to disallow installing
multiple NGINX versions at once.
5. Sets REQUIRED_USE for inter-module dependencies, unless
OVERRIDE_NGINX_MOD_REQUIRED_USE is set.
6. Sets BDEPEND, DEPEND and RDEPEND for external module
dependencies, unless OVERRIDE_NGINX_MOD_DEPEND is set.
7. Sets BDEPEND for module test dependencies, unless
OVERRIDE_NGINX_MOD_TEST_DEPEND is set.
(points 5-7: the nginx.eclass comes with a default list for such
dependencies; the REQUIRED_USE and *DEPEND variables are only set
for the modules that are present in NGINX_MODULES).
8. Unpacks the sources or clones the Git repository.
9. Configures NGINX, obviously.
10. Compiles NGINX.
11. Tests the compiled binary. The test dependencies have also been
brought in line with what tests actually depend on.
12. Installs NGINX, complying with the FHS. The files specified in
NGINX_MISC_FILES are installed in their respective directories.
If "modules" use flag is enabled, indicating dynamic modules
support, NGINX build system is installed into /usr/src/nginx and
NGINX headers are installed into /usr/include/nginx.
The nginx.eclass also installs Portage set
@nginx-modules-rebuild. It groups all the NGINX dynamic modules
and is mainly of use for those who install the "live" version.
A considerable part of the eclass parses the ebuild variables, the
actual phase function code constitues roughly 240 LoC (out of 790
total). Every part of the eclass is thoroughly annotated and documented.
The nginx.eclass sets up the infrastructure for resolving the following
bugs:
* 886537 - "drop support for obsolete dev-libs/libpcre":
_ngx_set_mod_depend() makes the http_rewrite module depend only
on dev-libs/libpcre2.
* 578658 - "silently ignoring USE=http":
nginx.eclass introduces the "http" USE flag, which is a master
switch for the whole http subsystem.
* 573710 - "Add support for external 3rd party modules":
nginx.eclass acts as a foundation for such support. The actual
support for building dynamic modules will be in a separate
eclass - nginx-module.eclass.
* 735020 - "missing a USE flag for building --with-stream only":
nginx.eclass adds the "stream" flag to IUSE, allowing the
subsystem to be enabled without requiring to alter the
NGINX_MODULES_STREAM variable.
* 700866 - "use default log names":
this eclass uses the default {access,error}.log filenames,
instead of {access,error}_log.
* 925098 - "www-servers/freenginx - new package":
with this eclass, adding freenginx to the Gentoo tree is as
simple as setting the aforementioned NGINX_* variables,
inheriting nginx.eclass and setting the proper HOMEPAGE,
DESCRITPION and SRC_URI. It is crucial to also add block on
www-servers/nginx, so that the two packages are not installed
simultaneously. Nonetheless, the procedure desribed above is not
comprehensive; freenginx will not be regarded by the package
manager as a drop-in replacement of F5's NGINX for external
modules. To achieve this, a separate virtual/nginx ebuild must
be created.
Bug: https://bugs.gentoo.org/886537
Bug: https://bugs.gentoo.org/578658
Bug: https://bugs.gentoo.org/573710
Bug: https://bugs.gentoo.org/735020
Bug: https://bugs.gentoo.org/700866
Bug: https://bugs.gentoo.org/925098
Signed-off-by: Zurab Kvachadze <zurabid2016@gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/37590
Signed-off-by: Sam James <sam@gentoo.org>
…
…
…
…
…
…
…
Description
No description provided
9.8 GiB
Languages
Shell
97.9%
Roff
1.4%
Emacs Lisp
0.2%
C
0.1%