syncevolution.org binaries: work with both libneon and libneon-gnutls

When --enable-neon-compatibility is used, libneon.so.27 and
libneon-gnutls.so.27 are opened dynamically instead of linking against
them. The Debian package specifies that it depends on one of these two
libs in this case. Don't use --enable-neon-compatibility when not
enabling WebDAV to avoid this dependency.

This change is necessary for Debian Testing, which no longer has
libneon.so.27 at all. Note that the very latest Debian Testing also
has another problem because libnotify1 was dropped in favor of
libnotify4.
This commit is contained in:
Patrick Ohly 2011-08-17 09:57:50 +00:00
parent 1af59c855f
commit 6099214016
5 changed files with 71 additions and 11 deletions

View File

@ -92,7 +92,14 @@ TYPE_rpm = -R
# Dependency calculation is intentionally incomplete:
# - don't force dependency on specific EDS libs via backends, their versions change too much (handled via --enable-evolution-compatibility and dynamic loading of the backends)
# - ignore client-test dependencies (because users typically don't run it)
REQUIRES_deb = --requires="'$(shell set -x; cd dist; LD_LIBRARY_PATH=$(distdir)/usr/lib:$(distdir)/usr/lib/syncevolution dpkg-shlibdeps -L$(srcdir)/src/shlibs.local --ignore-missing-info -O $$(for i in $$(find $(distdir) -type f -perm /u+x | grep -v -e client-test -e lib/syncevolution/sync); do if file $$i | grep ELF >/dev/null; then echo $$i; fi; done) | sed -e 's/[^=]*=//')'"
REQUIRES_deb = --requires="'$(shell set -x; cd dist; LD_LIBRARY_PATH=$(distdir)/usr/lib:$(distdir)/usr/lib/syncevolution dpkg-shlibdeps -L$(srcdir)/src/shlibs.local --ignore-missing-info -O $$(for i in $$(find $(distdir) -type f -perm /u+x | grep -v -e client-test -e lib/syncevolution/sync); do if file $$i | grep ELF >/dev/null; then echo $$i; fi; done) | sed -e 's/[^=]*=//')$(REQUIRES_deb_neon)'"
if NEON_COMPATIBILITY
# --enable-neon-compatibility in src/backends/webdav:
# replace dependencies from linking with hard-coded dlopen() dependencies
REQUIRES_deb_neon = , libneon27 (>= 0.29.0) | libneon27-gnutls (>= 0.29.0)
else
REQUIRES_deb_neon =
endif
VERSION_deb = 1:$(STABLE_VERSION)$(VERSION)
VERSION_rpm = `echo $(VERSION) | sed -e s/-/_/g`
RELEASE = 2

View File

@ -835,6 +835,17 @@ Request::~Request()
ne_request_destroy(m_req);
}
#ifdef NEON_COMPATIBILITY
/**
* wrapper needed to allow lazy resolution of the ne_accept_2xx() function when needed
* instead of when loaded
*/
static int ne_accept_2xx(void *userdata, ne_request *req, const ne_status *st)
{
return ::ne_accept_2xx(userdata, req, st);
}
#endif
bool Request::run()
{
int error;

View File

@ -9,6 +9,9 @@
#ifdef ENABLE_UNIT_TESTS
#include "test.h"
#endif
#ifdef NEON_COMPATIBILITY
#include <dlfcn.h>
#endif
#include <boost/bind.hpp>
#include <boost/tokenizer.hpp>
@ -21,6 +24,28 @@ static SyncSource *createSource(const SyncSourceParams &params)
SourceType sourceType = SyncSource::getSourceType(params.m_nodes);
bool isMe;
// Backend is enabled if a suitable libneon can be found. In
// binary compatibility mode, libneon was not linked against.
// Instead we dlopen() it and don't care whether that is
// libneon.so.27 or libneon-gnutls.so.27. Debian Testing only has
// the later.
#ifdef NEON_COMPATIBILITY
static bool enabled;
if (!enabled) {
// try libneon.so.27 first because it seems to be a bit more
// common and upstream seems to use OpenSSL
void *dl = dlopen("libneon.so.27", RTLD_LAZY|RTLD_GLOBAL);
if (!dl) {
dl = dlopen("libneon-gnutls.so.27", RTLD_LAZY|RTLD_GLOBAL);
}
if (dl) {
enabled = true;
}
}
#else
static bool enabled = true;
#endif
isMe = sourceType.m_backend == "CalDAV";
if (isMe) {
if (sourceType.m_format == "" ||
@ -28,12 +53,13 @@ static SyncSource *createSource(const SyncSourceParams &params)
sourceType.m_format == "text/x-calendar" ||
sourceType.m_format == "text/x-vcalendar") {
#ifdef ENABLE_DAV
boost::shared_ptr<Neon::Settings> settings;
boost::shared_ptr<SubSyncSource> sub(new CalDAVSource(params, settings));
return new MapSyncSource(params, sub);
#else
return RegisterSyncSource::InactiveSource;
if (enabled) {
boost::shared_ptr<Neon::Settings> settings;
boost::shared_ptr<SubSyncSource> sub(new CalDAVSource(params, settings));
return new MapSyncSource(params, sub);
}
#endif
return RegisterSyncSource::InactiveSource;
}
}
@ -43,11 +69,12 @@ static SyncSource *createSource(const SyncSourceParams &params)
sourceType.m_format == "text/x-vcard" ||
sourceType.m_format == "text/vcard") {
#ifdef ENABLE_DAV
boost::shared_ptr<Neon::Settings> settings;
return new CardDAVSource(params, settings);
#else
return RegisterSyncSource::InactiveSource;
if (enabled) {
boost::shared_ptr<Neon::Settings> settings;
return new CardDAVSource(params, settings);
}
#endif
return RegisterSyncSource::InactiveSource;
}
}

View File

@ -22,3 +22,15 @@ if test "$enable_dav" = "yes"; then
BACKEND_CPPFLAGS="$BACKEND_CPPFLAGS $NEON_CFLAGS"
fi
AM_CONDITIONAL([ENABLE_ICAL], [test "$enable_dav" = "yes"])
AC_ARG_ENABLE(neon-compatibility,
AS_HELP_STRING([--enable-neon-compatibility],
[increase compatibility with binary libneon installations by loading libneon[-gnutls].27.so dynamically instead of linking against it]),
[enable_neon_compat="$enableval"],
[enable_neon_compat="no"]
)
if test "$enable_neon_compat" = "yes"; then
AC_DEFINE(NEON_COMPATIBILITY, 1, [dynamically open libneon])
NEON_LIBS="`echo $NEON_LIBS | sed -e 's/\(-lneon\|[^ ]*libneon.la\)/-ldl/'`"
fi
AM_CONDITIONAL([NEON_COMPATIBILITY], [test "$enable_neon_compat" = "yes"])

View File

@ -292,7 +292,10 @@ public:
// module!
string fullpath = dirpath + '/' + entry;
fullpath = normalizePath(fullpath);
dlhandle = dlopen(fullpath.c_str(), RTLD_NOW|RTLD_GLOBAL);
// RTLD_LAZY is needed for the WebDAV backend, which
// needs to do an explicit dlopen() of libneon in compatibility
// mode before any of the neon functions can be resolved.
dlhandle = dlopen(fullpath.c_str(), RTLD_LAZY|RTLD_GLOBAL);
// remember which modules were found and which were not
if (dlhandle) {
debug<<"Loading backend library "<<entry<<endl;