aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-27 00:45:33 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-27 00:45:33 +0000
commitac0ae7a7d6b892e3296e4361bab8108d150c8850 (patch)
treed0c6b2ed70ed9db733380b1f2527627c6b055916
parentab2b391ebf40a67a953c2bfecd67c18bb4727b57 (diff)
downloadpaludis-ac0ae7a7d6b892e3296e4361bab8108d150c8850.tar.gz
paludis-ac0ae7a7d6b892e3296e4361bab8108d150c8850.tar.xz
Dynamically load repositories from .so files in libdir/paludis/repositories. Fixes: BerliosChangeLogFR2423
-rw-r--r--paludis/Makefile.am.m47
-rw-r--r--paludis/args/Makefile.am9
-rw-r--r--paludis/files.m41
-rw-r--r--paludis/qa/Makefile.am.m44
-rw-r--r--paludis/repositories/fake/Makefile.am2
-rw-r--r--paludis/repositories/nothing/Makefile.am2
-rw-r--r--paludis/repositories/portage/Makefile.am10
-rw-r--r--paludis/repositories/vdb/Makefile.am6
-rw-r--r--paludis/repository_so_loader.cc85
-rw-r--r--src/gtkpaludis/Makefile.am6
-rw-r--r--src/paludis/Makefile.am15
-rw-r--r--src/paludis/paludis.cc4
-rw-r--r--src/qualudis/Makefile.am15
13 files changed, 136 insertions, 30 deletions
diff --git a/paludis/Makefile.am.m4 b/paludis/Makefile.am.m4
index ffbf3de..91ae584 100644
--- a/paludis/Makefile.am.m4
+++ b/paludis/Makefile.am.m4
@@ -15,7 +15,8 @@ $1_TEST_LDADD = \
$(top_builddir)/test/libtest.a \
libpaludis.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
- $(top_builddir)/paludis/repositories/fake/libpaludisfakerepository.la
+ $(top_builddir)/paludis/repositories/fake/libpaludisfakerepository.la \
+ $(DYNAMIC_LD_LIBS)
$1_TEST_CXXFLAGS = -I$(top_srcdir)
')dnl
define(`addtestscript', `define(`testscriptlist', testscriptlist `$1_TEST_setup.sh $1_TEST_cleanup.sh')')dnl
@@ -42,7 +43,8 @@ AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@
DEFS= \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DLIBEXECDIR=\"$(libexecdir)\" \
- -DDATADIR=\"$(datadir)\"
+ -DDATADIR=\"$(datadir)\" \
+ -DLIBDIR=\"$(libdir)\"
EXTRA_DIST = about.hh.in Makefile.am.m4 paludis.hh.m4 files.m4 \
hashed_containers.hh.in testscriptlist
SUBDIRS = digests util . repositories args qa selinux tasks
@@ -55,6 +57,7 @@ TESTS = testlist
TESTS_ENVIRONMENT = env \
PALUDIS_EBUILD_DIR="$(top_srcdir)/ebuild/" \
PALUDIS_SKIP_CONFIG="yes" \
+ PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
TEST_SCRIPT_DIR="$(srcdir)/" \
bash $(top_srcdir)/test/run_test.sh
diff --git a/paludis/args/Makefile.am b/paludis/args/Makefile.am
index 9ca9716..27d8bae 100644
--- a/paludis/args/Makefile.am
+++ b/paludis/args/Makefile.am
@@ -33,7 +33,11 @@ libpaludisargs_la_SOURCES = $(paludis_args_include_HEADERS) \
libpaludisargs_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
-TESTS_ENVIRONMENT = env -u PALUDIS_OPTIONS TEST_SCRIPT_DIR="$(srcdir)/" bash $(top_srcdir)/test/run_test.sh
+TESTS_ENVIRONMENT = env -u PALUDIS_OPTIONS \
+ TEST_SCRIPT_DIR="$(srcdir)/" \
+ PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
+ bash $(top_srcdir)/test/run_test.sh
+
lib_LTLIBRARIES = libpaludisargs.la
check_PROGRAMS = $(TESTS)
@@ -41,7 +45,8 @@ test_ldadd = \
$(top_builddir)/test/libtest.a \
libpaludisargs.la \
$(top_builddir)/paludis/libpaludis.la \
- $(top_builddir)/paludis/util/libpaludisutil.la
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(DYNAMIC_LD_LIBS)
args_TEST_SOURCES = args_TEST.cc
args_TEST_LDADD = $(test_ldadd)
diff --git a/paludis/files.m4 b/paludis/files.m4
index dd6dc12..5e52a9b 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -30,6 +30,7 @@ add(`paludis', `hh')
add(`portage_dep_lexer', `hh', `cc', `test')
add(`portage_dep_parser', `hh', `cc', `test')
add(`repository', `hh', `cc')
+add(`repository_so_loader', `cc')
add(`syncer', `hh', `cc')
add(`test_environment', `hh', `cc')
add(`version_metadata', `hh', `cc')
diff --git a/paludis/qa/Makefile.am.m4 b/paludis/qa/Makefile.am.m4
index 5034410..fce09dc 100644
--- a/paludis/qa/Makefile.am.m4
+++ b/paludis/qa/Makefile.am.m4
@@ -15,7 +15,8 @@ $1_TEST_LDADD = \
$(top_builddir)/test/libtest.a \
libpaludisqa.la \
$(top_builddir)/paludis/libpaludis.la \
- $(top_builddir)/paludis/util/libpaludisutil.la
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(DYNAMIC_LD_LIBS)
$1_TEST_CXXFLAGS = -I$(top_srcdir)
')dnl
define(`addtestscript', `define(`testscriptlist', testscriptlist `$1_TEST_setup.sh $1_TEST_cleanup.sh')')dnl
@@ -40,6 +41,7 @@ TESTS = testlist
TESTS_ENVIRONMENT = env \
PALUDIS_EBUILD_DIR="$(srcdir)/ebuild/" \
+ PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
TEST_SCRIPT_DIR="$(srcdir)/" \
bash $(top_srcdir)/test/run_test.sh
diff --git a/paludis/repositories/fake/Makefile.am b/paludis/repositories/fake/Makefile.am
index 20be5bc..4a918d5 100644
--- a/paludis/repositories/fake/Makefile.am
+++ b/paludis/repositories/fake/Makefile.am
@@ -7,7 +7,7 @@ DEFS= \
-DLIBEXECDIR=\"$(libexecdir)\" \
-DDATADIR=\"$(datadir)\"
-paludis_repositories_libdir = $(libdir)
+paludis_repositories_libdir = $(libdir)/paludis/repositories
paludis_repositories_lib_LTLIBRARIES = libpaludisfakerepository.la
libpaludisfakerepository_la_SOURCES = fake_repository.cc fake_repository.hh
libpaludisfakerepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
diff --git a/paludis/repositories/nothing/Makefile.am b/paludis/repositories/nothing/Makefile.am
index cad77cc..cbe30d8 100644
--- a/paludis/repositories/nothing/Makefile.am
+++ b/paludis/repositories/nothing/Makefile.am
@@ -7,7 +7,7 @@ DEFS= \
-DLIBEXECDIR=\"$(libexecdir)\" \
-DDATADIR=\"$(datadir)\"
-paludis_repositories_libdir = $(libdir)
+paludis_repositories_libdir = $(libdir)/paludis/repositories
paludis_repositories_lib_LTLIBRARIES = libpaludisnothingrepository.la
libpaludisnothingrepository_la_SOURCES = nothing_repository.cc nothing_repository.hh
libpaludisnothingrepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
diff --git a/paludis/repositories/portage/Makefile.am b/paludis/repositories/portage/Makefile.am
index 85af0c2..ea41012 100644
--- a/paludis/repositories/portage/Makefile.am
+++ b/paludis/repositories/portage/Makefile.am
@@ -5,10 +5,10 @@ AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@
DEFS= \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DLIBEXECDIR=\"$(libexecdir)\" \
- -DDATADIR=\"$(datadir)\"
+ -DDATADIR=\"$(datadir)\" \
+ -DLIBDIR=\"$(libdir)\"
-
-paludis_repositories_libdir = $(libdir)
+paludis_repositories_libdir = $(libdir)/paludis/repositories
paludis_repositories_lib_LTLIBRARIES = libpaludisportagerepository.la
paludis_repositories_portage_includedir = $(includedir)/paludis/repositories/portage/
libpaludisportagerepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
@@ -33,7 +33,8 @@ portage_repository_TEST_LDADD = \
$(top_builddir)/test/libtest.a \
libpaludisportagerepository.la \
$(top_builddir)/paludis/libpaludis.la \
- $(top_builddir)/paludis/util/libpaludisutil.la
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(DYNAMIC_LD_LIBS)
portage_repository_TEST_CXXFLAGS = -I$(top_srcdir)
@@ -49,5 +50,6 @@ TESTS_ENVIRONMENT = env \
PALUDIS_EBUILD_DIR="$(top_srcdir)/ebuild/" \
PALUDIS_SKIP_CONFIG="yes" \
TEST_SCRIPT_DIR="$(srcdir)/" \
+ PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
bash $(top_srcdir)/test/run_test.sh
diff --git a/paludis/repositories/vdb/Makefile.am b/paludis/repositories/vdb/Makefile.am
index d102b8d..5d2863d 100644
--- a/paludis/repositories/vdb/Makefile.am
+++ b/paludis/repositories/vdb/Makefile.am
@@ -7,7 +7,7 @@ DEFS= \
-DLIBEXECDIR=\"$(libexecdir)\" \
-DDATADIR=\"$(datadir)\"
-paludis_repositories_libdir = $(libdir)
+paludis_repositories_libdir = $(libdir)/paludis/repositories
paludis_repositories_lib_LTLIBRARIES = libpaludisvdbrepository.la
libpaludisvdbrepository_la_SOURCES = vdb_repository.cc vdb_repository.hh
libpaludisvdbrepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
@@ -23,7 +23,8 @@ vdb_repository_TEST_LDADD = \
$(top_builddir)/test/libtest.a \
libpaludisvdbrepository.la \
$(top_builddir)/paludis/libpaludis.la \
- $(top_builddir)/paludis/util/libpaludisutil.la
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(DYNAMIC_LD_LIBS)
vdb_repository_TEST_CXXFLAGS = -I$(top_srcdir)
@@ -38,6 +39,7 @@ check_SCRIPTS = vdb_repository_TEST_setup.sh vdb_repository_TEST_cleanup.sh
TESTS_ENVIRONMENT = env \
PALUDIS_EBUILD_DIR="$(top_srcdir)/ebuild/" \
PALUDIS_SKIP_CONFIG="yes" \
+ PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
TEST_SCRIPT_DIR="$(srcdir)/" \
bash $(top_srcdir)/test/run_test.sh
diff --git a/paludis/repository_so_loader.cc b/paludis/repository_so_loader.cc
new file mode 100644
index 0000000..3d0a6bc
--- /dev/null
+++ b/paludis/repository_so_loader.cc
@@ -0,0 +1,85 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/util/system.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/dir_iterator.hh>
+#include <paludis/util/is_file_with_extension.hh>
+
+#include <dlfcn.h>
+#include <list>
+#include <algorithm>
+
+using namespace paludis;
+
+namespace
+{
+ struct RepositorySoLoader
+ {
+ RepositorySoLoader();
+ ~RepositorySoLoader();
+
+ void load_dir(const FSEntry &);
+
+ std::list<void *> dl_opened;
+ };
+
+ static RepositorySoLoader repository_so_loader;
+}
+
+RepositorySoLoader::RepositorySoLoader()
+{
+ FSEntry so_dir(getenv_with_default("PALUDIS_REPOSITORY_SO_DIR",
+ LIBDIR "/paludis/repositories"));
+
+ if (! so_dir.is_directory())
+ throw InternalError(PALUDIS_HERE, "PALUDIS_REPOSITORY_SO_DIR '" + stringify(so_dir)
+ + "' is not a directory");
+
+ load_dir(so_dir);
+}
+
+void
+RepositorySoLoader::load_dir(const FSEntry & so_dir)
+{
+ for (DirIterator d(so_dir), d_end ; d != d_end ; ++d)
+ {
+ if (d->is_directory())
+ load_dir(*d);
+
+ if (! IsFileWithExtension(".so")(*d))
+ continue;
+
+ void * dl(dlopen(stringify(*d).c_str(), RTLD_LOCAL | RTLD_NOW));
+
+ if (dl)
+ dl_opened.push_back(dl);
+ else
+ throw InternalError(PALUDIS_HERE, "Can't dlopen " + stringify(*d));
+ }
+
+ if ((so_dir / ".libs").is_directory())
+ load_dir(so_dir / ".libs");
+}
+
+RepositorySoLoader::~RepositorySoLoader()
+{
+ std::for_each(dl_opened.begin(), dl_opened.end(), &::dlclose);
+}
+
diff --git a/src/gtkpaludis/Makefile.am b/src/gtkpaludis/Makefile.am
index 5ad80ca..88c442d 100644
--- a/src/gtkpaludis/Makefile.am
+++ b/src/gtkpaludis/Makefile.am
@@ -23,14 +23,12 @@ gtkpaludis_SOURCES = \
gtkpaludis.cc
gtkpaludis_LDADD = \
- $(top_builddir)/paludis/repositories/nothing/libpaludisnothingrepository.la \
- $(top_builddir)/paludis/repositories/portage/libpaludisportagerepository.la \
- $(top_builddir)/paludis/repositories/vdb/libpaludisvdbrepository.la \
$(top_builddir)/paludis/tasks/libpaludistasks.a \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/args/libpaludisargs.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
- $(DEPS_LIBS)
+ $(DEPS_LIBS) \
+ $(DYNAMIC_LD_LIBS)
INCLUDES = $(DEPS_CFLAGS)
diff --git a/src/paludis/Makefile.am b/src/paludis/Makefile.am
index 9d2ca27..89cdf3f 100644
--- a/src/paludis/Makefile.am
+++ b/src/paludis/Makefile.am
@@ -1,7 +1,10 @@
AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@
DEFS= \
-DSYSCONFDIR=\"$(sysconfdir)\" \
- -DLIBEXECDIR=\"$(libexecdir)\"
+ -DDATADIR=\"$(datadir)\" \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
+ -DLIBDIR=\"$(libdir)\"
+
SUBDIRS = .
bin_PROGRAMS = paludis
@@ -19,7 +22,8 @@ man_paludis_SOURCES = \
man_paludis_LDADD = \
$(top_builddir)/paludis/args/libpaludisargs.la \
- $(top_builddir)/paludis/util/libpaludisutil.la
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(DYNAMIC_LD_LIBS)
paludis_SOURCES = \
applets.hh applets.cc \
@@ -37,19 +41,18 @@ paludis_SOURCES = \
paludis.cc
paludis_LDADD = \
- $(top_builddir)/paludis/repositories/nothing/libpaludisnothingrepository.la \
- $(top_builddir)/paludis/repositories/portage/libpaludisportagerepository.la \
- $(top_builddir)/paludis/repositories/vdb/libpaludisvdbrepository.la \
$(top_builddir)/paludis/tasks/libpaludistasks.a \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/args/libpaludisargs.la \
- $(top_builddir)/paludis/util/libpaludisutil.la
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(DYNAMIC_LD_LIBS)
TESTS_ENVIRONMENT = env \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_NO_GLOBAL_HOOKS="yes" \
PALUDIS_EBUILD_DIR="`$(top_srcdir)/ebuild/utils/canonicalise $(top_srcdir)/ebuild/`" \
PALUDIS_EBUILD_DIR_FALLBACK="`$(top_srcdir)/ebuild/utils/canonicalise $(top_builddir)/ebuild/`" \
+ PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
SYSCONFDIR="$(sysconfdir)" \
bash $(top_srcdir)/test/run_test.sh bash
diff --git a/src/paludis/paludis.cc b/src/paludis/paludis.cc
index 6d496d2..6029225 100644
--- a/src/paludis/paludis.cc
+++ b/src/paludis/paludis.cc
@@ -77,8 +77,10 @@ namespace
<< endl;
cout << "CXXFLAGS: " << PALUDIS_BUILD_CXXFLAGS << endl;
cout << "LDFLAGS: " << PALUDIS_BUILD_LDFLAGS << endl;
- cout << "SYSCONFDIR: " << SYSCONFDIR << endl;
+ cout << "DATADIR: " << DATADIR << endl;
+ cout << "LIBDIR: " << LIBDIR << endl;
cout << "LIBEXECDIR: " << LIBEXECDIR << endl;
+ cout << "SYSCONFDIR: " << SYSCONFDIR << endl;
cout << "stdlib: "
#if defined(__GLIBCXX__)
# define XSTRINGIFY(x) #x
diff --git a/src/qualudis/Makefile.am b/src/qualudis/Makefile.am
index ac12ad4..74714ed 100644
--- a/src/qualudis/Makefile.am
+++ b/src/qualudis/Makefile.am
@@ -23,22 +23,25 @@ man_qualudis_LDADD = \
$(top_builddir)/paludis/qa/libpaludisqa.la \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/args/libpaludisargs.la \
- $(top_builddir)/paludis/util/libpaludisutil.la
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(DYNAMIC_LD_LIBS)
qualudis_SOURCES = \
qualudis_command_line.hh qualudis_command_line.cc \
qualudis.cc
qualudis_LDADD = \
- $(top_builddir)/paludis/repositories/nothing/libpaludisnothingrepository.la \
- $(top_builddir)/paludis/repositories/portage/libpaludisportagerepository.la \
- $(top_builddir)/paludis/repositories/vdb/libpaludisvdbrepository.la \
$(top_builddir)/paludis/qa/libpaludisqa.la \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/args/libpaludisargs.la \
- $(top_builddir)/paludis/util/libpaludisutil.la
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(DYNAMIC_LD_LIBS)
+
+TESTS_ENVIRONMENT = env \
+ TEST_SCRIPT_DIR="$(srcdir)/" \
+ PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
+ bash $(top_srcdir)/test/run_test.sh bash
-TESTS_ENVIRONMENT = env TEST_SCRIPT_DIR="$(srcdir)/" bash $(top_srcdir)/test/run_test.sh bash
TESTS = version_TEST
version_TEST :