Control: tags -1 + patch sid trixie
Please find attached a patch which I admit I could not test properly.
This package is fairly specialized and I'm absolutely unfamiliar with
it. It requires some extra knowledge and right configuration in order
to expose the functionality that has to be tested. Also, some of the
affected plugins fail to load due to #1020989.
The testsuite passes, and the server runs and loads some of the
pcre-based global plugins. I also tested loading of the remap plugins
with a hack to workaround #1020989 (I'll follow-up there with more
details).
Description: Port to PCRE2.
Bug-Debian: https://bugs.debian.org/bug=38
Bug: https://github.com/apache/trafficserver/issues/8780
Author: Yavor Doganov
Forwarded: no
Last-Update: 2023-12-29
---
--- trafficserver-9.2.3+ds.orig/build/pcre.m4
+++ trafficserver-9.2.3+ds/build/pcre.m4
@@ -45,12 +45,12 @@
fi
],
[
- AC_CHECK_PROG(PCRE_CONFIG, pcre-config, pcre-config)
+ AC_CHECK_PROG(PCRE_CONFIG, pcre2-config, pcre2-config)
if test "x$PCRE_CONFIG" != "x"; then
enable_pcre=yes
pcre_base_dir="`$PCRE_CONFIG --prefix`"
pcre_include="`$PCRE_CONFIG --cflags | sed -es/-I//`"
-pcre_ldflags="`$PCRE_CONFIG --libs | sed -es/-lpcre// -es/-L//`"
+pcre_ldflags="`$PCRE_CONFIG --libs8 | sed -es/-lpcre2-8// -es/-L//`"
fi
])
@@ -58,7 +58,7 @@
AC_MSG_CHECKING([for pcre location])
AC_CACHE_VAL(ats_cv_pcre_dir,[
for dir in /usr/local /usr ; do
-if test -d $dir && ( test -f $dir/include/pcre.h || test -f
$dir/include/pcre/pcre.h ); then
+if test -d $dir && ( test -f $dir/include/pcre2.h ); then
ats_cv_pcre_dir=$dir
break
fi
@@ -76,7 +76,7 @@
fi
else
AC_MSG_CHECKING(for pcre headers in $pcre_include)
- if test -d $pcre_include && test -d $pcre_ldflags && ( test -f
$pcre_include/pcre.h || test -f $pcre_include/pcre/pcre.h ); then
+ if test -d $pcre_include && test -d $pcre_ldflags && ( test -f
$pcre_include/pcre2.h ); then
AC_MSG_RESULT([ok])
else
AC_MSG_RESULT([not found])
@@ -93,14 +93,15 @@
TS_ADDTO(LDFLAGS, [-L${pcre_ldflags}])
TS_ADDTO_RPATH(${pcre_ldflags})
fi
- AC_CHECK_LIB([pcre], [pcre_exec], [pcre_have_libs=1])
+ AC_CHECK_LIB([pcre2-8], [pcre2_match_8], [pcre_have_libs=1])
if test "$pcre_have_libs" != "0"; then
-AC_CHECK_HEADERS(pcre.h, [pcre_have_headers=1])
-AC_CHECK_HEADERS(pcre/pcre.h, [pcre_have_headers=1])
+AC_CHECK_HEADERS([pcre2.h], [pcre_have_headers=1], [], [[
+#define PCRE2_CODE_UNIT_WIDTH 8
+]])
fi
if test "$pcre_have_headers" != "0"; then
AC_DEFINE(HAVE_LIBPCRE,1,[Compiling with pcre support])
-AC_SUBST(LIBPCRE, [-lpcre])
+AC_SUBST(LIBPCRE, [-lpcre2-8])
else
enable_pcre=no
CPPFLAGS=$saved_cppflags
--- trafficserver-9.2.3+ds.orig/include/tscore/Regex.h
+++ trafficserver-9.2.3+ds/include/tscore/Regex.h
@@ -30,11 +30,8 @@
#include "tscore/ink_config.h"
-#ifdef HAVE_PCRE_PCRE_H
-#include
-#else
-#include
-#endif
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include
/// Match flags for regular expression evaluation.
enum REFlags {
@@ -94,8 +91,7 @@
int get_capture_count();
private:
- pcre *regex = nullptr;
- pcre_extra *regex_extra = nullptr;
+ pcre2_code *regex = nullptr;
};
/** Deterministic Finite state Automata container.
--- trafficserver-9.2.3+ds.orig/include/tscore/ink_memory.h
+++ trafficserver-9.2.3+ds/include/tscore/ink_memory.h
@@ -22,6 +22,7 @@
*/
#pragma once
+#ifdef __cplusplus
#include
#include
#include
@@ -29,6 +30,7 @@
#include
#include
#include
+#endif
#include "tscore/ink_config.h"
@@ -56,6 +58,9 @@
#include
#endif // ! TS_HAS_JEMALLOC
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include
+
#ifndef MADV_NORMAL
#define MADV_NORMAL 0
#endif
@@ -80,18 +85,9 @@
extern "C" {
#endif /* __cplusplus */
-struct IOVec : public iovec {
- IOVec()
- {
-iov_base = nullptr;
-iov_len = 0;
- }
- IOVec(void *base, size_t len)
- {
-iov_base = base;
-iov_len = len;
- }
-};
+extern pcre2_general_context *gen_ctxt;
+extern pcre2_compile_context *comp_ctxt;
+extern pcre2_match_context *match_ctxt;
void *ats_malloc(size_t size);
void *ats_calloc(size_t nelem, size_t elsize);
@@ -100,6 +96,10 @@
void ats_free(void *ptr);
void *ats_free_null(void *ptr);
+void pcre_init(void);
+void *pcre_malloc(PCRE2_SIZE size, void *data);
+void pcre_free(void *ptr, void *data);
+
int ats_msync(caddr_t addr, size_t len, caddr_t end, int flags);
int ats_madvise(caddr_t addr, size_t len, int flags);
int ats_mlock(caddr_t addr, size_t len);
@@ -142,6 +142,19 @@
#include
+struct IOVec : public iovec {
+ IOVec()
+ {
+iov_base = nullptr;
+iov_len = 0;
+ }
+ IOVec(void *base, size_t len)
+ {
+iov_base = base;
+iov_len = len;
+ }
+};
+
// this is to help with migration to a std::string issue with older code that
// expects char* being copied. As more code moves to std::string, this can be
//