From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 647C01382C5 for ; Sun, 28 Feb 2021 17:36:59 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7EA25E08F4; Sun, 28 Feb 2021 17:36:34 +0000 (UTC) Received: from smail.fem.tu-ilmenau.de (smail.fem.tu-ilmenau.de [141.24.220.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id ECC97E0885 for ; Sun, 28 Feb 2021 17:36:33 +0000 (UTC) Received: from localhost.localdomain (unknown [185.122.87.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smail.fem.tu-ilmenau.de (Postfix) with ESMTPSA id 7CFDD200AD; Sun, 28 Feb 2021 18:36:31 +0100 (CET) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=fem.tu-ilmenau.de; s=30012001; t=1614533791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VhetHzc2qA6xP7z9cog4tdjiAd8rmstHx1Pk3RbYfCk=; b=xXNHoGgkzKToj3RnY8noZ/LqMP+BBvfVyCCQiPWzySPovKZUH/QlLYPqxFo6bK4dxX/pKL UHRJw1Fk/K4Rp3Cw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fem.tu-ilmenau.de; s=30012002; t=1614533791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VhetHzc2qA6xP7z9cog4tdjiAd8rmstHx1Pk3RbYfCk=; b=rLKQKqACrCb25JMomlTmuHw0vkU8o+8SBeuBF3/h3VOnsK9ymM+U8Rn8WGfbUl1eIXWkX/ YBYCkBZojNOdgiMPBSeEmDy8+8y2kwK3LfW2XUUh94O/EJ0EwBHrCswpJ0jJ0wopwbHt4E Va4qriKPKVo77Ff+0NY+LLhdvDQ9Brrgs0XJVTMQgmoc95W/Wi1DpuWkDqRuUYqILwjo+L XGJpdNV/gfM7i1PqHfonPQSBSUKewOMRZJRQqGtX4JzSrqtilYFotE4V5L1QXD0Iy1R5hJ uPbUroQN0aohKaX+9urwZCZFUdNGBPqByUpqXmQKbYZXWLYGL1cc+xPoI4Mr8Q== From: jonas.licht@fem.tu-ilmenau.de To: gentoo-dev@lists.gentoo.org Cc: Jonas Licht Subject: [gentoo-dev] [PATCH v2 2/3] Add nginx-module.eclass Date: Sun, 28 Feb 2021 18:36:14 +0100 Message-Id: <20210228173615.12685-3-jonas.licht@fem.tu-ilmenau.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210228173615.12685-1-jonas.licht@fem.tu-ilmenau.de> References: <20210214162035.16786-1-jonas.licht@fem.tu-ilmenau.de> <20210228173615.12685-1-jonas.licht@fem.tu-ilmenau.de> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: 838060bd-a2bd-466c-9e4e-f30bfd70a85c X-Archives-Hash: f9246cd58da1488be43466c6fdcf0425 From: Jonas Licht Signed-off-by: Jonas Licht --- eclass/nginx-module.eclass | 72 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 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..d9f9bbdb89c --- /dev/null +++ b/eclass/nginx-module.eclass @@ -0,0 +1,72 @@ +# Copyright 2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: nginx-module.eclass +# @MAINTAINER: +# Jonas Licht +# @AUTHOR: +# Jonas Licht +# @BLURB: Provide a set of functions to build nginx dynamic modules. +# @DESCRIPTION: +# Eclass to make dynamic nginx modules. +# As these modules are hardly build against one nginx version we use version cut to indicate the nginx version too. +# The first three parts of the version must represent the nginx version, +# the remaining part displays the module version. +# +# To build a nginx module the whole nginx source code is needed, +# therfore we set the SRC_URI to the nginx source archive. +# The module archive must be added with SRC_URI+= + +case ${EAPI:-0} in + 7) ;; + *) die "This eclass only supports EAPI 7" ;; +esac + +# @ECLASS-VARIABLE: NGINX_PV +# @DESCRIPTION: +# Uses version cut of the first three parts of the version to determine the nginx version providing the module. +# This version is used for SRC_URI, BDPEND and compiling process. +NGINX_PV=$(ver_cut 1-3) + +# @ECLASS-VARIABLE: MODULE_PV +# @DESCRIPTION: +# Uses version cut to get the version of the module. +# Variable can be used for SRC_URI of the nginx module. +MODULE_PV=$(ver_cut 4-) + +BDPEND="=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 exicution 'nginx -V' and adds the package as dynamic module. +nginx-module_src_configure() { + if [ $(grep -c "\.[[:space:]]auto/module" "${WORKDIR}/${PN}-${MODULE_PV}/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/ /") + ./configure ${NGINX_ORIGIN_CONFIGURE} --add-dynamic-module="../${PN}-${MODULE_PV}" "$@" || 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() { + emake modules "$@" +} + +# @FUNCTION: nginx-module_src_install +# @DESCRIPTION: +# Parses the module config file to get the so file name and install the shared object file to '/usr/$(get_libdir)/nginx/modules' +nginx-module_src_install() { + NGINX_MODULE_NAME=$(grep ${WORKDIR}/${PN}-${MODULE_PV}/config -e "ngx_addon_name" | cut -d= -f2) + exeinto /usr/$(get_libdir)/nginx/modules + doexe ${S}/objs/${NGINX_MODULE_NAME}.so +} -- 2.26.2