commit:     bc3e1cc11a179319bc34f903ea46a75117394734
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 14 11:28:25 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Dec 14 11:36:18 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bc3e1cc1

apache-2.eclass: add pcre2 support

Wire up a temporary eclass variable to allow older ebuilds to opt-in
to legacy PCRE1 usage so we can transition gradually to PCRE2 in ~arch
without affecting stable ebuilds.

Stable ebuilds should set GENTOO_USE_PCRE1=1.

Bug: https://bugs.gentoo.org/835151
Signed-off-by: Sam James <sam <AT> gentoo.org>

 eclass/apache-2.eclass | 82 ++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 63 insertions(+), 19 deletions(-)

diff --git a/eclass/apache-2.eclass b/eclass/apache-2.eclass
index 583657b35ffd..71fcb5428699 100644
--- a/eclass/apache-2.eclass
+++ b/eclass/apache-2.eclass
@@ -36,6 +36,12 @@ esac
 # INTERNAL VARIABLES
 # 
==============================================================================
 
+# @ECLASS_VARIABLE: GENTOO_USE_PCRE1
+# @DESCRIPTION:
+# Temporary variable to allow older Apache versions to force using legacy
+# dev-libs/libpcre.  This will be removed once ebuilds using dev-libs/libpcre2
+# ar stable.
+
 # @ECLASS_VARIABLE: GENTOO_PATCHNAME
 # @DESCRIPTION:
 # This internal variable contains the prefix for the patch tarball.
@@ -138,7 +144,6 @@ RDEPEND="
        dev-lang/perl
        >=dev-libs/apr-1.5.1:=
        =dev-libs/apr-util-1*:=[gdbm=,ldap?]
-       dev-libs/libpcre
        virtual/libcrypt:=
        apache2_modules_brotli? ( >=app-arch/brotli-0.6.0:= )
        apache2_modules_deflate? ( sys-libs/zlib )
@@ -166,6 +171,12 @@ RDEPEND="
        systemd? ( sys-apps/systemd )
 "
 
+if [[ -n ${GENTOO_USE_PCRE1} ]] ; then
+       RDEPEND+=" dev-libs/libpcre"
+else
+       RDEPEND+=" dev-libs/libpcre2"
+fi
+
 DEPEND="${RDEPEND}"
 BDEPEND="
        virtual/pkgconfig
@@ -517,20 +528,37 @@ apache-2_src_prepare() {
        # ${T} must be not group-writable, else grsec TPE will block it
        chmod g-w "${T}" || die
 
-       # This package really should upgrade to using pcre's .pc file.
-       cat <<-\EOF >"${T}"/pcre-config
-       #!/bin/bash
-       flags=()
-       for flag; do
-               if [[ ${flag} == "--version" ]]; then
-                       flags+=( --modversion )
-               else
-                       flags+=( "${flag}" )
-               fi
-       done
-       exec ${PKG_CONFIG} libpcre "${flags[@]}"
-       EOF
-       chmod a+x "${T}"/pcre-config || die
+       if [[ -n ${GENTOO_USE_PCRE1} ]] ; then
+               # This package really should upgrade to using pcre's .pc file.
+               cat <<-\EOF > "${T}"/pcre-config
+               #!/usr/bin/env bash
+               flags=()
+               for flag; do
+                       if [[ ${flag} == "--version" ]]; then
+                               flags+=( --modversion )
+                       else
+                               flags+=( "${flag}" )
+                       fi
+               done
+               exec ${PKG_CONFIG} libpcre "${flags[@]}"
+               EOF
+               chmod a+x "${T}"/pcre-config || die
+       else
+               # This package really should upgrade to using pcre's .pc file.
+               cat <<-\EOF > "${T}"/pcre2-config
+               #!/usr/bin/env bash
+               flags=()
+               for flag; do
+                       if [[ ${flag} == "--version" ]]; then
+                               flags+=( --modversion )
+                       else
+                               flags+=( "${flag}" )
+                       fi
+               done
+               exec ${PKG_CONFIG} libpcre2-8 "${flags[@]}"
+               EOF
+               chmod a+x "${T}"/pcre2-config || die
+       fi
 }
 
 # @FUNCTION: apache-2_src_configure
@@ -539,10 +567,11 @@ apache-2_src_prepare() {
 # MY_CONF
 apache-2_src_configure() {
        tc-export PKG_CONFIG
+       export ac_cv_path_PKGCONFIG="${PKG_CONFIG}"
 
        # Sanity check in case people have bad mounts/TPE settings. #500928
-       if ! "${T}"/pcre-config --help >/dev/null ; then
-               eerror "Could not execute ${T}/pcre-config; do you have bad 
mount"
+       if ! "${T}"/pcre-config --help >/dev/null && ! "${T}"/pcre2-config 
--help >/dev/null ; then
+               eerror "Could not execute ${T}/pcre-config (or pcre2-config); 
do you have bad mount"
                eerror "permissions in ${T} or have TPE turned on in your 
kernel?"
                die "check your runtime settings #500928"
        fi
@@ -567,13 +596,28 @@ apache-2_src_configure() {
                --with-mpm=${MY_MPM}
                --with-apr="${SYSROOT}${EPREFIX}"/usr
                --with-apr-util="${SYSROOT}${EPREFIX}"/usr
-               --with-pcre="${T}"/pcre-config
                --with-z="${EPREFIX}"/usr
                --with-port=80
                --with-program-name=apache2
                --enable-layout=Gentoo
        )
-       ac_cv_path_PKGCONFIG=${PKG_CONFIG} \
+
+       if [[ -n ${GENTOO_USE_PCRE1} ]] ; then
+               export ac_cv_prog_ac_ct_PCRE_CONFIG="${T}"/pcre-config
+
+               MY_CONF+=(
+                       --without-pcre2
+                       --with-pcre="${T}"/pcre-config
+               )
+       else
+               export ac_cv_prog_ac_ct_PCRE_CONFIG="${T}"/pcre2-config
+
+               MY_CONF+=(
+                       --without-pcre
+                       --with-pcre2="${T}"/pcre2-config
+               )
+       fi
+
        econf "${MY_CONF[@]}"
 
        sed -i -e 's:apache2\.conf:httpd.conf:' include/ap_config_auto.h || die

Reply via email to