This directory layout allows for more flexible dynamic module management. nginx-module.eclass generates `load_module` .conf stubs for every module and installs them into /etc/nginx/modules-available. Then, modules can be enabled or disabled by adding or removing symlinks from /etc/nginx/modules-enabled to /etc/nginx/modules-available, potentially with an eselect module. See bug 967022 for background information.
This commit adds a new eclass variable NGINX_SUPPORT_MODULE_STUBS that must be turned on to create the directories and add the include into shipped nginx.conf. Also, the latest NGINX versions are bumped with the variable set. Bug: https://bugs.gentoo.org/967022 Signed-off-by: Zurab Kvachadze <[email protected]> --- eclass/nginx.eclass | 21 +++++++++++++++++++ .../files/{nginx-r4.conf => nginx-r5.conf} | 3 ++- ...x-1.28.1.ebuild => nginx-1.28.1-r1.ebuild} | 5 +++-- ...x-1.29.4.ebuild => nginx-1.29.4-r1.ebuild} | 3 ++- www-servers/nginx/nginx-9999.ebuild | 5 +++-- 5 files changed, 31 insertions(+), 6 deletions(-) copy www-servers/nginx/files/{nginx-r4.conf => nginx-r5.conf} (94%) copy www-servers/nginx/{nginx-1.28.1.ebuild => nginx-1.28.1-r1.ebuild} (89%) copy www-servers/nginx/{nginx-1.29.4.ebuild => nginx-1.29.4-r1.ebuild} (92%) diff --git a/eclass/nginx.eclass b/eclass/nginx.eclass index a67da18edef8..05576be94a42 100644 --- a/eclass/nginx.eclass +++ b/eclass/nginx.eclass @@ -221,6 +221,14 @@ has "${NGINX_UPDATE_STREAM}" "${NGX_UPDATE_STREAMS_LIST[@]}" || # automatically fill the BDEPEND variable with module test dependencies. # For details, see _ngx_set_mod_test_depend() function description below. +# @ECLASS_VARIABLE: NGINX_SUPPORT_MODULE_STUBS +# @DEFAULT_UNSET +# @DESCRIPTION: +# Set this to a non-empty value before calling nginx_src_install() to create +# /etc/nginx/modules-{available,enabled} and to make the default config load +# .conf stubs from /etc/nginx/modules-enabled. See nginx_src_install() for +# details. + #-----> ebuild setup <----- # NGINX does not guarantee ABI stability (required by dynamic modules), SLOT is @@ -850,6 +858,12 @@ nginx_src_install() { perl_fix_packlist fi + # If not using modules, do not 'include modules-enabled/*.conf;'. Also, just + # in case, remove the line if NGINX_SUPPORT_MODULE_STUBS is unset. + if use !modules || [[ -z ${NGINX_SUPPORT_MODULE_STUBS} ]]; then + sed -i '/^@GENTOO_MODULES_INCLUDE@$/d' "${ED}"/etc/nginx/nginx.conf + fi + # For the rationale of the following, see nginx-module.eclass. if use modules; then # Install the headers into /usr/include/nginx. @@ -906,6 +920,13 @@ nginx_src_install() { variable = BDEPEND includes = ${CATEGORY}/${PN} EOF + + if [[ -n ${NGINX_SUPPORT_MODULE_STUBS} ]]; then + keepdir /etc/nginx/modules-{available,enabled} + + sed -i 's|^@GENTOO_MODULES_INCLUDE@$|include modules-enabled/*.conf;|' \ + "${ED}"/etc/nginx/nginx.conf + fi fi } diff --git a/www-servers/nginx/files/nginx-r4.conf b/www-servers/nginx/files/nginx-r5.conf similarity index 94% copy from www-servers/nginx/files/nginx-r4.conf copy to www-servers/nginx/files/nginx-r5.conf index 1144af3d7ceb..5c8aae56f380 100644 --- a/www-servers/nginx/files/nginx-r4.conf +++ b/www-servers/nginx/files/nginx-r5.conf @@ -1,5 +1,6 @@ user nginx nginx; worker_processes auto; +@GENTOO_MODULES_INCLUDE@ events { # NGINX refuses to start if the 'events' section is not present. Yet, @@ -10,7 +11,7 @@ http { # Maximum hash table size is increased to accommodate for a large # mime.types file that is shipped on Gentoo. types_hash_max_size 4096; - include /etc/nginx/mime.types.nginx; + include mime.types.nginx; sendfile on; diff --git a/www-servers/nginx/nginx-1.28.1.ebuild b/www-servers/nginx/nginx-1.28.1-r1.ebuild similarity index 89% copy from www-servers/nginx/nginx-1.28.1.ebuild copy to www-servers/nginx/nginx-1.28.1-r1.ebuild index 40c88269b812..11667dcd7851 100644 --- a/www-servers/nginx/nginx-1.28.1.ebuild +++ b/www-servers/nginx/nginx-1.28.1-r1.ebuild @@ -1,4 +1,4 @@ -# Copyright 1999-2025 Gentoo Authors +# Copyright 1999-2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 @@ -22,8 +22,9 @@ NGINX_MODULES=( NGINX_UPDATE_STREAM=stable NGINX_TESTS_COMMIT=0fccfcef1278263416043e0bbb3e0116b84026e4 NGINX_MISC_FILES=( - nginx-{r2.logrotate,r2.service,r4.conf,r6.initd,r1.confd,r1.tmpfiles} + nginx-{r2.logrotate,r2.service,r5.conf,r6.initd,r1.confd,r1.tmpfiles} ) +NGINX_SUPPORT_MODULE_STUBS=1 inherit nginx diff --git a/www-servers/nginx/nginx-1.29.4.ebuild b/www-servers/nginx/nginx-1.29.4-r1.ebuild similarity index 92% copy from www-servers/nginx/nginx-1.29.4.ebuild copy to www-servers/nginx/nginx-1.29.4-r1.ebuild index 1125173d95c7..4b0219c19b76 100644 --- a/www-servers/nginx/nginx-1.29.4.ebuild +++ b/www-servers/nginx/nginx-1.29.4-r1.ebuild @@ -22,8 +22,9 @@ NGINX_MODULES=( NGINX_UPDATE_STREAM=mainline NGINX_TESTS_COMMIT=51e17e709ede6d4a75737e98d12e775fb4fc424a NGINX_MISC_FILES=( - nginx-{r2.logrotate,r2.service,r4.conf,r6.initd,r1.confd,r1.tmpfiles} + nginx-{r2.logrotate,r2.service,r5.conf,r6.initd,r1.confd,r1.tmpfiles} ) +NGINX_SUPPORT_MODULE_STUBS=1 inherit nginx diff --git a/www-servers/nginx/nginx-9999.ebuild b/www-servers/nginx/nginx-9999.ebuild index a2f13adffc00..dd446c87d26c 100644 --- a/www-servers/nginx/nginx-9999.ebuild +++ b/www-servers/nginx/nginx-9999.ebuild @@ -1,4 +1,4 @@ -# Copyright 1999-2025 Gentoo Authors +# Copyright 1999-2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 @@ -22,8 +22,9 @@ NGINX_MODULES=( NGINX_UPDATE_STREAM=live NGINX_TESTS_COMMIT=live NGINX_MISC_FILES=( - nginx-{r2.logrotate,r2.service,r4.conf,r6.initd,r1.confd,r1.tmpfiles} + nginx-{r2.logrotate,r2.service,r5.conf,r6.initd,r1.confd,r1.tmpfiles} ) +NGINX_SUPPORT_MODULE_STUBS=1 inherit nginx -- 2.52.0
