[packages/log4cxx] - added libesmtp patch, enabled libesmtp by default (the issue was outdated internal API usage, not

qboosh qboosh at pld-linux.org
Thu Feb 9 22:17:06 CET 2023


commit d316c1c0312136ceef4006fe03acc4e667012d6f
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Thu Feb 9 22:18:32 2023 +0100

    - added libesmtp patch, enabled libesmtp by default (the issue was outdated internal API usage, not libesmtp API)

 log4cxx-libesmtp.patch | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++
 log4cxx.spec           | 11 ++++++--
 2 files changed, 85 insertions(+), 2 deletions(-)
---
diff --git a/log4cxx.spec b/log4cxx.spec
index c6d6ace..c904d68 100644
--- a/log4cxx.spec
+++ b/log4cxx.spec
@@ -1,5 +1,9 @@
-# TODO: our libesmtp is incompatible
+# TODO:
 # LOG4CXX_QT_SUPPORT
+#
+# Conditional build:
+%bcond_without	libesmtp	# (E)SMTP support via libesmtp
+
 Summary:	Log4cxx - a port to C++ of the log4j project
 Summary(pl.UTF-8):	Log4cxx - port projektu log4j dla C++
 Name:		log4cxx
@@ -9,6 +13,7 @@ License:	Apache v2.0
 Group:		Libraries
 Source0:	http://www.apache.org/dist/logging/log4cxx/%{version}/apache-%{name}-%{version}.tar.gz
 # Source0-md5:	2255f30cd968e2c1976081824e435bd5
+Patch0:		%{name}-libesmtp.patch
 URL:		http://logging.apache.org/log4cxx/
 BuildRequires:	apr-devel >= 1
 BuildRequires:	apr-util-devel >= 1
@@ -16,6 +21,7 @@ BuildRequires:	boost-devel
 BuildRequires:	cmake >= 3.13
 # for tests
 BuildRequires:	expat-devel >= 1.95
+%{?with_libesmtp:BuildRequires:	libesmtp-devel}
 BuildRequires:	libfmt-devel >= 7.1
 BuildRequires:	libstdc++-devel >= 6:7
 BuildRequires:	pkgconfig
@@ -52,12 +58,13 @@ Ten pakiet zawiera pliki nagłówkowe biblioteki log4cxx.
 
 %prep
 %setup -q -n apache-%{name}-%{version}
+%patch0 -p1
 
 %build
 %cmake -B build \
 	-DCMAKE_INSTALL_INCLUDEDIR=include \
 	-DCMAKE_INSTALL_LIBDIR=%{_lib} \
-	-DHAS_LIBESMTP=OFF
+	%{!?with_libesmtp:-DHAS_LIBESMTP=OFF}
 
 %{__make} -C build
 
diff --git a/log4cxx-libesmtp.patch b/log4cxx-libesmtp.patch
new file mode 100644
index 0000000..8ecded3
--- /dev/null
+++ b/log4cxx-libesmtp.patch
@@ -0,0 +1,76 @@
+--- apache-log4cxx-1.0.0/src/main/cpp/smtpappender.cpp.orig	2023-01-01 18:42:12.000000000 +0100
++++ apache-log4cxx-1.0.0/src/main/cpp/smtpappender.cpp	2023-02-09 20:39:33.462772023 +0100
+@@ -674,23 +674,23 @@ bool SMTPAppender::checkEntryConditions(
+ {
+ #if LOG4CXX_HAVE_LIBESMTP
+ 
+-	if ((to.empty() && cc.empty() && bcc.empty()) || from.empty() || smtpHost.empty())
++	if ((_priv->to.empty() && _priv->cc.empty() && _priv->bcc.empty()) || _priv->from.empty() || _priv->smtpHost.empty())
+ 	{
+-		errorHandler->error(LOG4CXX_STR("Message not configured."));
++		_priv->errorHandler->error(LOG4CXX_STR("Message not configured."));
+ 		return false;
+ 	}
+ 
+-	if (evaluator == 0)
++	if (_priv->evaluator == 0)
+ 	{
+-		errorHandler->error(LOG4CXX_STR("No TriggeringEventEvaluator is set for appender [") +
+-			name + LOG4CXX_STR("]."));
++		_priv->errorHandler->error(LOG4CXX_STR("No TriggeringEventEvaluator is set for appender [") +
++			_priv->name + LOG4CXX_STR("]."));
+ 		return false;
+ 	}
+ 
+ 
+-	if (layout == 0)
++	if (_priv->layout == 0)
+ 	{
+-		errorHandler->error(LOG4CXX_STR("No layout set for appender named [") + name + LOG4CXX_STR("]."));
++		_priv->errorHandler->error(LOG4CXX_STR("No layout set for appender named [") + _priv->name + LOG4CXX_STR("]."));
+ 		return false;
+ 	}
+ 
+@@ -749,22 +749,22 @@ void SMTPAppender::sendBuffer(Pool& p)
+ 	try
+ 	{
+ 		LogString sbuf;
+-		layout->appendHeader(sbuf, p);
++		_priv->layout->appendHeader(sbuf, p);
+ 
+-		int len = cb.length();
++		int len = _priv->cb.length();
+ 
+ 		for (int i = 0; i < len; i++)
+ 		{
+-			LoggingEventPtr event = cb.get();
+-			layout->format(sbuf, event, p);
++			LoggingEventPtr event = _priv->cb.get();
++			_priv->layout->format(sbuf, event, p);
+ 		}
+ 
+-		layout->appendFooter(sbuf, p);
++		_priv->layout->appendFooter(sbuf, p);
+ 
+-		SMTPSession session(smtpHost, smtpPort, smtpUsername, smtpPassword, p);
++		SMTPSession session(_priv->smtpHost, _priv->smtpPort, _priv->smtpUsername, _priv->smtpPassword, p);
+ 
+-		SMTPMessage message(session, from, to, cc,
+-			bcc, subject, sbuf, p);
++		SMTPMessage message(session, _priv->from, _priv->to, _priv->cc,
++			_priv->bcc, _priv->subject, sbuf, p);
+ 
+ 		session.send(p);
+ 
+--- apache-log4cxx-1.0.0/src/main/cpp/CMakeLists.txt.orig	2023-01-01 18:42:12.000000000 +0100
++++ apache-log4cxx-1.0.0/src/main/cpp/CMakeLists.txt	2023-02-09 21:23:28.838494968 +0100
+@@ -212,6 +212,9 @@ endif()
+ if(${ENABLE_FMT_LAYOUT})
+     target_link_libraries(log4cxx PUBLIC fmt::fmt)
+ endif()
++if(HAS_LIBESMTP)
++    target_link_libraries(log4cxx PRIVATE esmtp)
++endif()
+ 
+ if(LOG4CXX_ABI_CHECK)
+     message("Getting dependencies for ABI compatability check...")
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/log4cxx.git/commitdiff/d316c1c0312136ceef4006fe03acc4e667012d6f



More information about the pld-cvs-commit mailing list