aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-02-03 17:16:50 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-02-03 17:16:50 +0000
commit63c8baae4819e82d0c03e5524b032d228dbb3487 (patch)
treeb362f6ea349ebbb2d12ea13b50c2d8f2b1932989
parent76dc8b38fcf2ff3619098b383ebacee3d7b5a35f (diff)
downloadpaludis-63c8baae4819e82d0c03e5524b032d228dbb3487.tar.gz
paludis-63c8baae4819e82d0c03e5524b032d228dbb3487.tar.xz
Split up VDBRepository. Add a new experimental Exndbam repository, which can replace VDB on systems that don't need EAPI 0/1 support.
-rw-r--r--paludis/ndbam.cc2
-rw-r--r--paludis/repositories/e/Makefile.am53
-rw-r--r--paludis/repositories/e/e_installed_repository.cc543
-rw-r--r--paludis/repositories/e/e_installed_repository.hh146
-rw-r--r--paludis/repositories/e/e_installed_repository.sr16
-rw-r--r--paludis/repositories/e/e_installed_repository_id.cc786
-rw-r--r--paludis/repositories/e/e_installed_repository_id.hh106
-rw-r--r--paludis/repositories/e/exndbam_id.cc116
-rw-r--r--paludis/repositories/e/exndbam_id.hh51
-rw-r--r--paludis/repositories/e/exndbam_repository.cc470
-rw-r--r--paludis/repositories/e/exndbam_repository.hh127
-rw-r--r--paludis/repositories/e/exndbam_repository.sr17
-rw-r--r--paludis/repositories/e/exndbam_repository_TEST.cc49
-rwxr-xr-xpaludis/repositories/e/exndbam_repository_TEST_cleanup.sh9
-rwxr-xr-xpaludis/repositories/e/exndbam_repository_TEST_setup.sh8
-rw-r--r--paludis/repositories/e/registration.cc2
-rw-r--r--paludis/repositories/e/vdb_id.cc753
-rw-r--r--paludis/repositories/e/vdb_id.hh67
-rw-r--r--paludis/repositories/e/vdb_repository.cc495
-rw-r--r--paludis/repositories/e/vdb_repository.hh98
-rw-r--r--paludis/repositories/e/vdb_repository.sr1
-rwxr-xr-xsrc/clients/paludis/install_TEST61
-rwxr-xr-xsrc/clients/paludis/install_TEST_setup.sh37
-rwxr-xr-xsrc/clients/paludis/upgrade_TEST49
-rwxr-xr-xsrc/clients/paludis/upgrade_TEST_setup.sh38
-rw-r--r--vim/syntax/paludis-repositories-conf.vim1
26 files changed, 2663 insertions, 1438 deletions
diff --git a/paludis/ndbam.cc b/paludis/ndbam.cc
index 0187b04..8d4c839 100644
--- a/paludis/ndbam.cc
+++ b/paludis/ndbam.cc
@@ -42,7 +42,7 @@ using namespace paludis;
#include <paludis/ndbam-sr.cc>
-template class Sequence<NDBAMEntry>;
+template class Sequence<tr1::shared_ptr<NDBAMEntry> >;
namespace
{
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index d303c7e..87fbce7 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -2,6 +2,7 @@ SUBDIRS = eapis ebuild . qa
CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda
DISTCLEANFILES = \
glsa-sr.hh glsa-sr.cc \
+ e_installed_repository-sr.hh e_installed_repository-sr.cc \
e_repository_params-sr.hh e_repository_params-sr.cc \
e_repository_params-se.hh e_repository_params-se.cc \
vdb_repository-sr.hh vdb_repository-sr.cc \
@@ -42,6 +43,9 @@ paludis_repositories_e_include_HEADERS = \
dep_parser-fwd.hh \
dep_spec_pretty_printer.hh \
dependencies_rewriter.hh \
+ e_installed_repository.hh \
+ e_installed_repository-sr.hh \
+ e_installed_repository_id.hh \
e_key.hh \
e_mask.hh \
e_repository.hh \
@@ -67,6 +71,9 @@ paludis_repositories_e_include_HEADERS = \
ebuild_id.hh \
eclass_mtimes.hh \
exheres_layout.hh \
+ exndbam_id.hh \
+ exndbam_repository.hh \
+ exndbam_repository-sr.hh \
fetch_visitor.hh \
glsa-sr.hh \
glsa.hh \
@@ -96,6 +103,8 @@ libpaludiserepository_la_SOURCES = \
dep_parser.cc \
dep_spec_pretty_printer.cc \
dependencies_rewriter.cc \
+ e_installed_repository.cc \
+ e_installed_repository_id.cc \
e_key.cc \
e_mask.cc \
e_repository.cc \
@@ -115,6 +124,8 @@ libpaludiserepository_la_SOURCES = \
ebuild_flat_metadata_cache.cc \
ebuild_id.cc \
eclass_mtimes.cc \
+ exndbam_id.cc \
+ exndbam_repository.cc \
exheres_layout.cc \
fetch_visitor.cc \
glsa.cc \
@@ -167,6 +178,20 @@ vdb_repository_TEST_LDADD = \
vdb_repository_TEST_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir)
+exndbam_repository_TEST_SOURCES = exndbam_repository_TEST.cc
+
+exndbam_repository_TEST_LDADD = \
+ libpaludiserepository.la \
+ $(top_builddir)/paludis/repositories/fake/libpaludisfakerepository.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/paludis/util/test_extras.o \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/environments/test/libpaludistestenvironment.la \
+ $(top_builddir)/test/libtest.a \
+ $(DYNAMIC_LD_LIBS)
+
+exndbam_repository_TEST_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir)
+
vdb_merger_TEST_SOURCES = vdb_merger_TEST.cc
vdb_merger_TEST_LDADD = \
@@ -295,6 +320,9 @@ EXTRA_DIST = \
e_repository_TEST.cc \
e_repository_TEST_setup.sh \
e_repository_TEST_cleanup.sh \
+ e_installed_repository-sr.hh \
+ e_installed_repository-sr.cc \
+ e_installed_repository.sr \
e_repository_params-sr.hh \
e_repository_params-sr.cc \
e_repository_params.sr \
@@ -304,6 +332,12 @@ EXTRA_DIST = \
e_repository_sets_TEST.cc \
e_repository_sets_TEST_setup.sh \
e_repository_sets_TEST_cleanup.sh \
+ exndbam_repository_TEST.cc \
+ exndbam_repository_TEST_setup.sh \
+ exndbam_repository_TEST_cleanup.sh \
+ exndbam_repository-sr.hh \
+ exndbam_repository-sr.cc \
+ exndbam_repository.sr \
fetch_visitor_TEST.cc \
fetch_visitor_TEST_setup.sh \
fetch_visitor_TEST_cleanup.sh \
@@ -336,12 +370,16 @@ EXTRA_DIST = \
BUILT_SOURCES = \
dep_parser-se.hh \
dep_parser-se.cc \
+ e_installed_repository-sr.hh \
+ e_installed_repository-sr.cc \
e_repository_params-sr.hh \
e_repository_params-sr.cc \
e_repository_params-se.hh \
e_repository_params-se.cc \
glsa-sr.hh \
glsa-sr.cc \
+ exndbam_repository-sr.hh \
+ exndbam_repository-sr.cc \
vdb_repository-sr.hh \
vdb_repository-sr.cc \
ebuild-sr.hh \
@@ -359,6 +397,7 @@ check_SCRIPTS = \
e_repository_TEST_setup.sh e_repository_TEST_cleanup.sh \
xml_things_TEST_setup.sh xml_things_TEST_cleanup.sh \
vdb_repository_TEST_setup.sh vdb_repository_TEST_cleanup.sh \
+ exndbam_repository_TEST_setup.sh exndbam_repository_TEST_cleanup.sh \
e_repository_sets_TEST_setup.sh e_repository_sets_TEST_cleanup.sh \
fetch_visitor_TEST_setup.sh fetch_visitor_TEST_cleanup.sh
@@ -382,6 +421,12 @@ TESTS_ENVIRONMENT = env \
$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/e/.libs/`" \
bash $(top_srcdir)/test/run_test.sh
+e_installed_repository-sr.hh : e_installed_repository.sr $(top_srcdir)/misc/make_sr.bash
+ $(top_srcdir)/misc/make_sr.bash --header $(srcdir)/e_installed_repository.sr > $@
+
+e_installed_repository-sr.cc : e_installed_repository.sr $(top_srcdir)/misc/make_sr.bash
+ $(top_srcdir)/misc/make_sr.bash --source $(srcdir)/e_installed_repository.sr > $@
+
e_repository_params-sr.hh : e_repository_params.sr $(top_srcdir)/misc/make_sr.bash
$(top_srcdir)/misc/make_sr.bash --header $(srcdir)/e_repository_params.sr > $@
@@ -424,6 +469,12 @@ glsa-sr.hh : glsa.sr $(top_srcdir)/misc/make_sr.bash
glsa-sr.cc : glsa.sr $(top_srcdir)/misc/make_sr.bash
$(top_srcdir)/misc/make_sr.bash --source $(srcdir)/glsa.sr > $@
+exndbam_repository-sr.hh : exndbam_repository.sr $(top_srcdir)/misc/make_sr.bash
+ $(top_srcdir)/misc/make_sr.bash --header $(srcdir)/exndbam_repository.sr > $@
+
+exndbam_repository-sr.cc : exndbam_repository.sr $(top_srcdir)/misc/make_sr.bash
+ $(top_srcdir)/misc/make_sr.bash --source $(srcdir)/exndbam_repository.sr > $@
+
vdb_repository-sr.hh : vdb_repository.sr $(top_srcdir)/misc/make_sr.bash
$(top_srcdir)/misc/make_sr.bash --header $(srcdir)/vdb_repository.sr > $@
@@ -486,6 +537,7 @@ TESTS = \
aa_visitor_TEST \
fetch_visitor_TEST \
source_uri_finder_TEST \
+ exndbam_repository_TEST \
vdb_repository_TEST
check_PROGRAMS = $(TESTS)
@@ -500,3 +552,4 @@ distcheck-deps : distcheck-deps-subdirs
distcheck-deps-subdirs :
for s in $(SUBDIRS) . ; do if test x$$s = x. ; then $(MAKE) distcheck-deps-local || exit 1 ; \
else $(MAKE) -C $$s distcheck-deps || exit 1 ; fi ; done
+
diff --git a/paludis/repositories/e/e_installed_repository.cc b/paludis/repositories/e/e_installed_repository.cc
new file mode 100644
index 0000000..3bcceb0
--- /dev/null
+++ b/paludis/repositories/e/e_installed_repository.cc
@@ -0,0 +1,543 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ *
+ * 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/repositories/e/e_installed_repository.hh>
+#include <paludis/repositories/e/e_repository_id.hh>
+#include <paludis/repositories/e/e_repository_params.hh>
+#include <paludis/repositories/e/eapi.hh>
+#include <paludis/repositories/e/eapi_phase.hh>
+#include <paludis/repositories/e/ebuild.hh>
+#include <paludis/repositories/e/e_repository.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/mutex.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/strip.hh>
+#include <paludis/util/system.hh>
+#include <paludis/util/map.hh>
+#include <paludis/action.hh>
+#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/environment.hh>
+#include <paludis/set_file.hh>
+#include <paludis/hook.hh>
+#include <paludis/dep_tag.hh>
+#include <fstream>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+#include <paludis/repositories/e/e_installed_repository-sr.cc>
+
+namespace paludis
+{
+ template <>
+ struct Implementation<EInstalledRepository>
+ {
+ EInstalledRepositoryParams params;
+ Mutex world_mutex;
+
+ Implementation(const EInstalledRepositoryParams & p) :
+ params(p)
+ {
+ }
+ };
+}
+
+EInstalledRepository::EInstalledRepository(const EInstalledRepositoryParams & p,
+ const RepositoryName & n, const RepositoryCapabilities & c) :
+ Repository(n, c),
+ PrivateImplementationPattern<EInstalledRepository>(new Implementation<EInstalledRepository>(p)),
+ _imp(PrivateImplementationPattern<EInstalledRepository>::_imp)
+{
+}
+
+EInstalledRepository::~EInstalledRepository()
+{
+}
+
+namespace
+{
+ struct SomeIDsMightSupportVisitor :
+ ConstVisitor<SupportsActionTestVisitorTypes>
+ {
+ bool result;
+
+ void visit(const SupportsActionTest<UninstallAction> &)
+ {
+ result = true;
+ }
+
+ void visit(const SupportsActionTest<InstalledAction> &)
+ {
+ result = true;
+ }
+
+ void visit(const SupportsActionTest<ConfigAction> &)
+ {
+ result = true;
+ }
+
+ void visit(const SupportsActionTest<InfoAction> &)
+ {
+ result = true;
+ }
+
+ void visit(const SupportsActionTest<PretendAction> &)
+ {
+ result = false;
+ }
+
+ void visit(const SupportsActionTest<FetchAction> &)
+ {
+ result = false;
+ }
+
+ void visit(const SupportsActionTest<InstallAction> &)
+ {
+ result = false;
+ }
+ };
+}
+
+bool
+EInstalledRepository::some_ids_might_support_action(const SupportsActionTestBase & test) const
+{
+ SomeIDsMightSupportVisitor v;
+ test.accept(v);
+ return v.result;
+}
+
+bool
+EInstalledRepository::is_suitable_destination_for(const PackageID & e) const
+{
+ std::string f(e.repository()->format_key() ? e.repository()->format_key()->value() : "");
+ return f == "ebuild" || f == "exheres" || f == "portage";
+}
+
+bool
+EInstalledRepository::is_default_destination() const
+{
+ return _imp->params.environment->root() == installed_root_key()->value();
+}
+
+bool
+EInstalledRepository::want_pre_post_phases() const
+{
+ return true;
+}
+
+void
+EInstalledRepository::add_string_to_world(const std::string & n) const
+{
+ using namespace tr1::placeholders;
+
+ Lock l(_imp->world_mutex);
+
+ Context context("When adding '" + n + "' to world file '" + stringify(_imp->params.world) + "':");
+
+ if (! _imp->params.world.exists())
+ {
+ std::ofstream f(stringify(_imp->params.world).c_str());
+ if (! f)
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context, "Cannot create world file '"
+ + stringify(_imp->params.world) + "'");
+ return;
+ }
+ }
+
+ SetFile world(SetFileParams::create()
+ .file_name(_imp->params.world)
+ .type(sft_simple)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
+ .tag(tr1::shared_ptr<DepTag>())
+ .environment(_imp->params.environment));
+ world.add(n);
+ world.rewrite();
+}
+
+void
+EInstalledRepository::remove_string_from_world(const std::string & n) const
+{
+ using namespace tr1::placeholders;
+
+ Lock l(_imp->world_mutex);
+
+ Context context("When removing '" + n + "' from world file '" + stringify(_imp->params.world) + "':");
+
+ if (_imp->params.world.exists())
+ {
+ SetFile world(SetFileParams::create()
+ .file_name(_imp->params.world)
+ .type(sft_simple)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
+ .tag(tr1::shared_ptr<DepTag>())
+ .environment(_imp->params.environment));
+
+ world.remove(n);
+ world.rewrite();
+ }
+}
+
+void
+EInstalledRepository::add_to_world(const QualifiedPackageName & n) const
+{
+ add_string_to_world(stringify(n));
+}
+
+void
+EInstalledRepository::add_to_world(const SetName & n) const
+{
+ add_string_to_world(stringify(n));
+}
+
+void
+EInstalledRepository::remove_from_world(const QualifiedPackageName & n) const
+{
+ remove_string_from_world(stringify(n));
+}
+
+void
+EInstalledRepository::remove_from_world(const SetName & n) const
+{
+ remove_string_from_world(stringify(n));
+}
+
+UseFlagState
+EInstalledRepository::query_use(const UseFlagName & f, const PackageID & e) const
+{
+ if (this != e.repository().get())
+ return use_unspecified;
+
+ if (! static_cast<const ERepositoryID *>(&e)->use_key())
+ return use_unspecified;
+
+ if (static_cast<const ERepositoryID *>(&e)->use_key()->value()->end() != static_cast<const ERepositoryID *>(&e)->use_key()->value()->find(f))
+ return use_enabled;
+ else
+ return use_disabled;
+}
+
+bool
+EInstalledRepository::query_use_mask(const UseFlagName & u, const PackageID & e) const
+{
+ return use_disabled == query_use(u, e);
+}
+
+bool
+EInstalledRepository::query_use_force(const UseFlagName & u, const PackageID & e) const
+{
+ return use_enabled == query_use(u, e);
+}
+
+HookResult
+EInstalledRepository::perform_hook(const Hook & hook) const
+{
+ Context context("When performing hook '" + stringify(hook.name()) + "' for repository '"
+ + stringify(name()) + "':");
+
+ return HookResult(0, "");
+}
+
+std::string
+EInstalledRepository::describe_use_flag(const UseFlagName &, const PackageID &) const
+{
+ return "";
+}
+
+tr1::shared_ptr<const UseFlagNameSet>
+EInstalledRepository::use_expand_flags() const
+{
+ return tr1::shared_ptr<const UseFlagNameSet>(new UseFlagNameSet);
+}
+
+tr1::shared_ptr<const UseFlagNameSet>
+EInstalledRepository::use_expand_prefixes() const
+{
+ return tr1::shared_ptr<const UseFlagNameSet>(new UseFlagNameSet);
+}
+
+tr1::shared_ptr<const UseFlagNameSet>
+EInstalledRepository::use_expand_hidden_prefixes() const
+{
+ return tr1::shared_ptr<const UseFlagNameSet>(new UseFlagNameSet);
+}
+
+tr1::shared_ptr<SetSpecTree::ConstItem>
+EInstalledRepository::package_set(const SetName & s) const
+{
+ using namespace tr1::placeholders;
+
+ Context context("When fetching package set '" + stringify(s) + "' from '" +
+ stringify(name()) + "':");
+
+ if ("everything" == s.data())
+ {
+ tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > result(new ConstTreeSequence<SetSpecTree, AllDepSpec>(
+ tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
+ tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(SetName("everything"), stringify(name())));
+
+ tr1::shared_ptr<const CategoryNamePartSet> cats(category_names());
+ for (CategoryNamePartSet::ConstIterator i(cats->begin()), i_end(cats->end()) ;
+ i != i_end ; ++i)
+ {
+ tr1::shared_ptr<const QualifiedPackageNameSet> pkgs(package_names(*i));
+ for (QualifiedPackageNameSet::ConstIterator e(pkgs->begin()), e_end(pkgs->end()) ;
+ e != e_end ; ++e)
+ {
+ tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(make_package_dep_spec().package(*e)));
+ spec->set_tag(tag);
+ result->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>(spec)));
+ }
+ }
+
+ return result;
+ }
+ else if ("world" == s.data())
+ {
+ tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(SetName("world"), stringify(name())));
+
+ if (_imp->params.world.exists())
+ {
+ SetFile world(SetFileParams::create()
+ .file_name(_imp->params.world)
+ .type(sft_simple)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
+ .tag(tag)
+ .environment(_imp->params.environment));
+ return world.contents();
+ }
+ else
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "World file '" + stringify(_imp->params.world) +
+ "' doesn't exist");
+
+ return tr1::shared_ptr<SetSpecTree::ConstItem>(new ConstTreeSequence<SetSpecTree, AllDepSpec>(
+ tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
+ }
+ else
+ return tr1::shared_ptr<SetSpecTree::ConstItem>();
+}
+
+tr1::shared_ptr<const SetNameSet>
+EInstalledRepository::sets_list() const
+{
+ Context context("While generating the list of sets:");
+
+ tr1::shared_ptr<SetNameSet> result(new SetNameSet);
+ result->insert(SetName("everything"));
+ result->insert(SetName("world"));
+ return result;
+}
+
+tr1::shared_ptr<const CategoryNamePartSet>
+EInstalledRepository::unimportant_category_names() const
+{
+ tr1::shared_ptr<CategoryNamePartSet> result(make_shared_ptr(new CategoryNamePartSet));
+ result->insert(CategoryNamePart("virtual"));
+ return result;
+}
+
+tr1::shared_ptr<const UseFlagNameSet>
+EInstalledRepository::arch_flags() const
+{
+ return tr1::shared_ptr<const UseFlagNameSet>(new UseFlagNameSet);
+}
+
+char
+EInstalledRepository::use_expand_separator(const PackageID & id) const
+{
+ if (this != id.repository().get())
+ return '\0';
+ const tr1::shared_ptr<const EAPI> & eapi(static_cast<const ERepositoryID &>(id).eapi());
+ return eapi->supported ? eapi->supported->ebuild_options->use_expand_separator : '\0';
+}
+
+std::string
+EInstalledRepository::get_environment_variable(
+ const tr1::shared_ptr<const PackageID> & id,
+ const std::string & var) const
+{
+ Context context("When fetching environment variable '" + var + "' for '" +
+ stringify(*id) + "':");
+
+ FSEntry ver_dir(id->fs_location_key()->value());
+
+ if (! ver_dir.is_directory_or_symlink_to_directory())
+ throw ActionError("Could not find Exndbam entry for '" + stringify(*id) + "'");
+
+ if ((ver_dir / var).is_regular_file_or_symlink_to_regular_file())
+ {
+ std::ifstream f(stringify(ver_dir / var).c_str());
+ if (! f)
+ throw ActionError("Could not read '" + stringify(ver_dir / var) + "'");
+ return strip_trailing_string(
+ std::string((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>()), "\n");
+ }
+ else if ((ver_dir / "environment.bz2").is_regular_file_or_symlink_to_regular_file())
+ {
+ std::stringstream p;
+ Command cmd(Command("bash -c '( bunzip2 < " + stringify(ver_dir / "environment.bz2" ) +
+ " ; echo echo \\$" + var + " ) | bash 2>/dev/null'").with_captured_stdout_stream(&p));
+ int exit_status(run_command(cmd));
+ std::string result(strip_trailing_string(std::string(
+ (std::istreambuf_iterator<char>(p)),
+ std::istreambuf_iterator<char>()), "\n"));
+ if (0 != exit_status)
+ throw ActionError("Could not load environment.bz2");
+ return result;
+ }
+ else
+ throw ActionError("Could not get variable '" + var + "' for '" + stringify(*id) + "'");
+}
+
+void
+EInstalledRepository::perform_config(const tr1::shared_ptr<const ERepositoryID> & id) const
+{
+ Context context("When configuring '" + stringify(*id) + "':");
+
+ if (! _imp->params.root.is_directory())
+ throw InstallActionError("Couldn't configure '" + stringify(*id) +
+ "' because root ('" + stringify(_imp->params.root) + "') is not a directory");
+
+ FSEntry ver_dir(id->fs_location_key()->value());
+
+ tr1::shared_ptr<FSEntrySequence> eclassdirs(new FSEntrySequence);
+ eclassdirs->push_back(ver_dir);
+
+ tr1::shared_ptr<FSEntry> load_env(new FSEntry(ver_dir / "environment.bz2"));
+ EAPIPhases phases(id->eapi()->supported->ebuild_phases->ebuild_config);
+
+ for (EAPIPhases::ConstIterator phase(phases.begin_phases()), phase_end(phases.end_phases()) ;
+ phase != phase_end ; ++phase)
+ {
+ EbuildConfigCommand config_cmd(EbuildCommandParams::create()
+ .environment(_imp->params.environment)
+ .package_id(id)
+ .ebuild_dir(ver_dir)
+ .ebuild_file(ver_dir / (stringify(id->name().package) + "-" + stringify(id->version()) + ".ebuild"))
+ .files_dir(ver_dir)
+ .eclassdirs(eclassdirs)
+ .exlibsdirs(make_shared_ptr(new FSEntrySequence))
+ .portdir(ver_dir)
+ .distdir(ver_dir)
+ .sandbox(phase->option("sandbox"))
+ .userpriv(phase->option("userpriv"))
+ .commands(join(phase->begin_commands(), phase->end_commands(), " "))
+ .builddir(_imp->params.builddir),
+
+ EbuildConfigCommandParams::create()
+ .root(stringify(_imp->params.root) + "/")
+ .load_environment(load_env.get()));
+
+ config_cmd();
+ }
+}
+
+void
+EInstalledRepository::perform_info(const tr1::shared_ptr<const ERepositoryID> & id) const
+{
+ Context context("When infoing '" + stringify(*id) + "':");
+
+ if (! _imp->params.root.is_directory())
+ throw InstallActionError("Couldn't info '" + stringify(*id) +
+ "' because root ('" + stringify(_imp->params.root) + "') is not a directory");
+
+ FSEntry ver_dir(id->fs_location_key()->value());
+
+ tr1::shared_ptr<FSEntrySequence> eclassdirs(new FSEntrySequence);
+ eclassdirs->push_back(ver_dir);
+
+ tr1::shared_ptr<FSEntry> load_env(new FSEntry(ver_dir / "environment.bz2"));
+
+ EAPIPhases phases(id->eapi()->supported->ebuild_phases->ebuild_info);
+
+ for (EAPIPhases::ConstIterator phase(phases.begin_phases()), phase_end(phases.end_phases()) ;
+ phase != phase_end ; ++phase)
+ {
+ if (phase->option("installed=false"))
+ continue;
+
+ /* try to find an info_vars file from the original repo */
+ FSEntry i("/dev/null");
+ if (id->source_origin_key())
+ {
+ RepositoryName rn(id->source_origin_key()->value());
+ if (_imp->params.environment->package_database()->has_repository_named(rn))
+ {
+ const tr1::shared_ptr<const Repository> r(_imp->params.environment->package_database()->fetch_repository(rn));
+ if (r->e_interface)
+ {
+ i = r->e_interface->info_variables_file(r->e_interface->params().location / "profiles");
+
+ /* also try its master, if it has one */
+ if ((! i.exists()) && r->e_interface->params().master_repository)
+ i = r->e_interface->info_variables_file(r->e_interface->params().master_repository->params().location / "profiles");
+ }
+ }
+ }
+
+ /* try to find an info_vars file from any repo */
+ if (i == FSEntry("/dev/null"))
+ {
+ for (PackageDatabase::RepositoryConstIterator r(_imp->params.environment->package_database()->begin_repositories()),
+ r_end(_imp->params.environment->package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ {
+ if (! (*r)->e_interface)
+ continue;
+
+ i = (*r)->e_interface->info_variables_file((*r)->e_interface->params().location / "profiles");
+ if (i.exists())
+ break;
+ }
+ }
+
+ EbuildInfoCommand info_cmd(EbuildCommandParams::create()
+ .environment(_imp->params.environment)
+ .package_id(id)
+ .ebuild_dir(ver_dir)
+ .ebuild_file(ver_dir / (stringify(id->name().package) + "-" + stringify(id->version()) + ".ebuild"))
+ .files_dir(ver_dir)
+ .eclassdirs(eclassdirs)
+ .exlibsdirs(make_shared_ptr(new FSEntrySequence))
+ .portdir(ver_dir)
+ .distdir(ver_dir)
+ .sandbox(phase->option("sandbox"))
+ .userpriv(phase->option("userpriv"))
+ .commands(join(phase->begin_commands(), phase->end_commands(), " "))
+ .builddir(_imp->params.builddir),
+
+ EbuildInfoCommandParams::create()
+ .root(stringify(_imp->params.root) + "/")
+ .use("")
+ .use_expand("")
+ .expand_vars(make_shared_ptr(new Map<std::string, std::string>))
+ .profiles(make_shared_ptr(new FSEntrySequence))
+ .info_vars(i)
+ .load_environment(load_env.get()));
+
+ info_cmd();
+ }
+}
+
diff --git a/paludis/repositories/e/e_installed_repository.hh b/paludis/repositories/e/e_installed_repository.hh
new file mode 100644
index 0000000..4a1a3cb
--- /dev/null
+++ b/paludis/repositories/e/e_installed_repository.hh
@@ -0,0 +1,146 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ *
+ * 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
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_E_INSTALLED_REPOSITORY_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_E_INSTALLED_REPOSITORY_HH 1
+
+#include <paludis/repository.hh>
+#include <paludis/repositories/e/e_repository_id.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+
+#include <paludis/repositories/e/e_installed_repository-sr.hh>
+
+ class EInstalledRepository :
+ public Repository,
+ public RepositoryUseInterface,
+ public RepositorySetsInterface,
+ public RepositoryWorldInterface,
+ public RepositoryEnvironmentVariableInterface,
+ public RepositoryDestinationInterface,
+ public RepositoryHookInterface,
+ private PrivateImplementationPattern<EInstalledRepository>
+ {
+ private:
+ void add_string_to_world(const std::string & n) const;
+ void remove_string_from_world(const std::string &) const;
+
+ PrivateImplementationPattern<EInstalledRepository>::ImpPtr & _imp;
+
+ protected:
+ EInstalledRepository(const EInstalledRepositoryParams &, const RepositoryName &, const RepositoryCapabilities &);
+ ~EInstalledRepository();
+
+ public:
+ /* RepositoryUseInterface */
+
+ virtual UseFlagState query_use(const UseFlagName &, const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool query_use_mask(const UseFlagName &, const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool query_use_force(const UseFlagName &, const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual tr1::shared_ptr<const UseFlagNameSet> arch_flags() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual tr1::shared_ptr<const UseFlagNameSet> use_expand_flags() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual tr1::shared_ptr<const UseFlagNameSet> use_expand_hidden_prefixes() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual tr1::shared_ptr<const UseFlagNameSet> use_expand_prefixes() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual char use_expand_separator(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::string describe_use_flag(const UseFlagName &,
+ const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /* RepositorySetsInterface */
+
+ virtual tr1::shared_ptr<SetSpecTree::ConstItem> package_set(const SetName & id) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual tr1::shared_ptr<const SetNameSet> sets_list() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /* RepositoryWorldInterface */
+
+ virtual void add_to_world(const QualifiedPackageName &) const;
+
+ virtual void add_to_world(const SetName &) const;
+
+ virtual void remove_from_world(const QualifiedPackageName &) const;
+
+ virtual void remove_from_world(const SetName &) const;
+
+ /* RepositoryEnvironmentVariableInterface */
+
+ virtual std::string get_environment_variable(
+ const tr1::shared_ptr<const PackageID> & for_package,
+ const std::string & var) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /* RepositoryDestinationInterface */
+
+ virtual bool is_suitable_destination_for(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool is_default_destination() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool want_pre_post_phases() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /* RepositoryHookInterface */
+
+ virtual HookResult perform_hook(const Hook & hook) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /* Repository */
+
+ virtual tr1::shared_ptr<const CategoryNamePartSet> unimportant_category_names() const;
+
+ virtual bool some_ids_might_support_action(const SupportsActionTestBase &) const;
+
+ ///\name For use by EInstalledRepositoryID
+ ///\{
+
+ virtual void perform_uninstall(const tr1::shared_ptr<const erepository::ERepositoryID> & id,
+ const UninstallActionOptions & o, bool reinstalling) const = 0;
+
+ virtual void perform_config(const tr1::shared_ptr<const erepository::ERepositoryID> & id) const;
+
+ virtual void perform_info(const tr1::shared_ptr<const erepository::ERepositoryID> & id) const;
+
+ ///\}
+ };
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/e_installed_repository.sr b/paludis/repositories/e/e_installed_repository.sr
new file mode 100644
index 0000000..a56ace3
--- /dev/null
+++ b/paludis/repositories/e/e_installed_repository.sr
@@ -0,0 +1,16 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et :
+
+make_class_EInstalledRepositoryParams()
+{
+ visible
+
+ key environment "Environment *"
+ key world "FSEntry"
+ key root "FSEntry"
+ key builddir "FSEntry"
+
+ allow_named_args
+}
+
+
diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc
new file mode 100644
index 0000000..d2ef306
--- /dev/null
+++ b/paludis/repositories/e/e_installed_repository_id.cc
@@ -0,0 +1,786 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007, 2008 Ciaran McCreesh
+ *
+ * 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/repositories/e/e_installed_repository_id.hh>
+#include <paludis/repositories/e/e_key.hh>
+#include <paludis/repositories/e/vdb_repository.hh>
+#include <paludis/repositories/e/eapi.hh>
+#include <paludis/repositories/e/dep_parser.hh>
+#include <paludis/repositories/e/dependencies_rewriter.hh>
+
+#include <paludis/name.hh>
+#include <paludis/version_spec.hh>
+#include <paludis/repository.hh>
+#include <paludis/distribution.hh>
+#include <paludis/environment.hh>
+#include <paludis/action.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/strip.hh>
+#include <paludis/util/mutex.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/literal_metadata_key.hh>
+#include <iterator>
+#include <fstream>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+namespace
+{
+ std::string file_contents(const FSEntry & f)
+ {
+ Context c("When reading '" + stringify(f) + "':");
+ std::ifstream i(stringify(f).c_str());
+ if (! i)
+ throw ConfigurationError("Cannot open '" + stringify(f) + "' for read");
+
+ return strip_trailing(std::string((std::istreambuf_iterator<char>(i)), std::istreambuf_iterator<char>()), "\r\n");
+ }
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<EInstalledRepositoryID>
+ {
+ mutable Mutex mutex;
+
+ const QualifiedPackageName name;
+ const VersionSpec version;
+ const Environment * const environment;
+ const tr1::shared_ptr<const Repository> repository;
+ const FSEntry dir;
+ mutable bool has_keys;
+
+ tr1::shared_ptr<const SlotName> slot;
+ tr1::shared_ptr<const EAPI> eapi;
+
+ tr1::shared_ptr<const MetadataFSEntryKey> fs_location;
+ tr1::shared_ptr<const MetadataCollectionKey<UseFlagNameSet> > use;
+ tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > inherited;
+ tr1::shared_ptr<const MetadataCollectionKey<IUseFlagSet> > iuse;
+ tr1::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> > license;
+ tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide;
+ tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > build_dependencies;
+ tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > run_dependencies;
+ tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > post_dependencies;
+ tr1::shared_ptr<const MetadataSpecTreeKey<RestrictSpecTree> > restrictions;
+ tr1::shared_ptr<const MetadataSpecTreeKey<FetchableURISpecTree> > src_uri;
+ tr1::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> > homepage;
+ tr1::shared_ptr<const MetadataStringKey> short_description;
+ tr1::shared_ptr<const MetadataContentsKey> contents;
+ tr1::shared_ptr<const MetadataTimeKey> installed_time;
+ tr1::shared_ptr<const MetadataStringKey> source_origin;
+ tr1::shared_ptr<const MetadataStringKey> binary_origin;
+
+ tr1::shared_ptr<const MetadataStringKey> asflags;
+ tr1::shared_ptr<const MetadataStringKey> cbuild;
+ tr1::shared_ptr<const MetadataStringKey> cflags;
+ tr1::shared_ptr<const MetadataStringKey> chost;
+ tr1::shared_ptr<const MetadataStringKey> ctarget;
+ tr1::shared_ptr<const MetadataStringKey> cxxflags;
+ tr1::shared_ptr<const MetadataStringKey> ldflags;
+ tr1::shared_ptr<const MetadataStringKey> pkgmanager;
+ tr1::shared_ptr<const MetadataStringKey> vdb_format;
+
+ tr1::shared_ptr<DependencyLabelSequence> build_dependencies_labels;
+ tr1::shared_ptr<DependencyLabelSequence> run_dependencies_labels;
+ tr1::shared_ptr<DependencyLabelSequence> post_dependencies_labels;
+
+ Implementation(const QualifiedPackageName & q, const VersionSpec & v,
+ const Environment * const e,
+ const tr1::shared_ptr<const Repository> r, const FSEntry & f) :
+ name(q),
+ version(v),
+ environment(e),
+ repository(r),
+ dir(f),
+ has_keys(false),
+ build_dependencies_labels(new DependencyLabelSequence),
+ run_dependencies_labels(new DependencyLabelSequence),
+ post_dependencies_labels(new DependencyLabelSequence)
+ {
+ build_dependencies_labels->push_back(make_shared_ptr(new DependencyBuildLabel("DEPEND")));
+ run_dependencies_labels->push_back(make_shared_ptr(new DependencyRunLabel("RDEPEND")));
+ post_dependencies_labels->push_back(make_shared_ptr(new DependencyPostLabel("PDEPEND")));
+ }
+ };
+}
+
+EInstalledRepositoryID::EInstalledRepositoryID(const QualifiedPackageName & q, const VersionSpec & v,
+ const Environment * const e,
+ const tr1::shared_ptr<const Repository> & r,
+ const FSEntry & f) :
+ PrivateImplementationPattern<EInstalledRepositoryID>(new Implementation<EInstalledRepositoryID>(q, v, e, r, f)),
+ _imp(PrivateImplementationPattern<EInstalledRepositoryID>::_imp)
+{
+}
+
+EInstalledRepositoryID::~EInstalledRepositoryID()
+{
+}
+
+void
+EInstalledRepositoryID::need_keys_added() const
+{
+ Lock l(_imp->mutex);
+
+ if (_imp->has_keys)
+ return;
+ _imp->has_keys = true;
+
+
+ // fs_location key could have been loaded by the ::fs_location_key() already. keep this
+ // at the top, other keys use it.
+ if (! _imp->fs_location)
+ {
+ _imp->fs_location.reset(new LiteralMetadataFSEntryKey(fs_location_raw_name(), fs_location_human_name(),
+ mkt_internal, _imp->dir));
+ add_metadata_key(_imp->fs_location);
+ }
+
+ Context context("When loading ID keys from '" + stringify(_imp->dir) + "':");
+
+ if (! eapi()->supported)
+ {
+ Log::get_instance()->message(ll_debug, lc_context) << "Not loading further keys for '" << *this << "' because EAPI '"
+ << eapi()->name << "' is not supported";
+ return;
+ }
+
+ const tr1::shared_ptr<const EAPIEbuildMetadataVariables> vars(eapi()->supported->ebuild_metadata_variables);
+ if (! vars)
+ throw InternalError(PALUDIS_HERE, "EAPI '" + eapi()->name + "' supported but has no ebuild_metadata_variables");
+
+ const tr1::shared_ptr<const EAPIEbuildEnvironmentVariables> env(eapi()->supported->ebuild_environment_variables);
+ if (! env)
+ throw InternalError(PALUDIS_HERE, "EAPI '" + eapi()->name + "' supported but has no ebuild_environment_variables");
+
+ if (! env->env_use.empty())
+ if ((_imp->dir / env->env_use).exists())
+ {
+ _imp->use.reset(new EUseKey(_imp->environment, shared_from_this(), env->env_use, env->description_use,
+ file_contents(_imp->dir / env->env_use), mkt_internal));
+ add_metadata_key(_imp->use);
+ }
+
+ if (! vars->metadata_inherited.empty())
+ if ((_imp->dir / vars->metadata_inherited).exists())
+ {
+ _imp->inherited.reset(new EInheritedKey(shared_from_this(), vars->metadata_inherited, vars->description_inherited,
+ file_contents(_imp->dir / vars->metadata_inherited), mkt_internal));
+ add_metadata_key(_imp->inherited);
+ }
+
+ if (! vars->metadata_iuse.empty())
+ if ((_imp->dir / vars->metadata_iuse).exists())
+ {
+ _imp->iuse.reset(new EIUseKey(_imp->environment, shared_from_this(), vars->metadata_iuse, vars->description_iuse,
+ file_contents(_imp->dir / vars->metadata_iuse), mkt_normal));
+ add_metadata_key(_imp->iuse);
+ }
+
+ if (! vars->metadata_license.empty())
+ if ((_imp->dir / vars->metadata_license).exists())
+ {
+ _imp->license.reset(new ELicenseKey(_imp->environment, shared_from_this(), vars->metadata_license, vars->description_license,
+ file_contents(_imp->dir / vars->metadata_license), mkt_normal));
+ add_metadata_key(_imp->license);
+ }
+
+ if (! vars->metadata_provide.empty())
+ if ((_imp->dir / vars->metadata_provide).exists())
+ {
+ _imp->provide.reset(new EProvideKey(_imp->environment, shared_from_this(), vars->metadata_provide, vars->description_provide,
+ file_contents(_imp->dir / vars->metadata_provide), mkt_internal));
+ add_metadata_key(_imp->provide);
+ }
+
+ if (! vars->metadata_dependencies.empty())
+ {
+ if ((_imp->dir / vars->metadata_dependencies).exists())
+ {
+ DependenciesRewriter rewriter;
+ parse_depend(file_contents(_imp->dir / vars->metadata_dependencies), *eapi(), shared_from_this())->accept(rewriter);
+
+ _imp->build_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_dependencies + ".DEPEND",
+ vars->description_dependencies + " (build)", rewriter.depend(), _imp->build_dependencies_labels, mkt_dependencies));
+ add_metadata_key(_imp->build_dependencies);
+
+ _imp->run_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_dependencies + ".RDEPEND",
+ vars->description_dependencies + " (run)", rewriter.rdepend(), _imp->build_dependencies_labels, mkt_dependencies));
+ add_metadata_key(_imp->run_dependencies);
+
+ _imp->post_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_dependencies + ".PDEPEND",
+ vars->description_dependencies + " (post)", rewriter.pdepend(), _imp->build_dependencies_labels, mkt_dependencies));
+ add_metadata_key(_imp->post_dependencies);
+ }
+ }
+ else
+ {
+ if (! vars->metadata_build_depend.empty())
+ if ((_imp->dir / vars->metadata_build_depend).exists())
+ {
+ _imp->build_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_build_depend,
+ vars->description_build_depend, file_contents(_imp->dir / vars->metadata_build_depend),
+ _imp->build_dependencies_labels, mkt_dependencies));
+ add_metadata_key(_imp->build_dependencies);
+ }
+
+ if (! vars->metadata_run_depend.empty())
+ if ((_imp->dir / vars->metadata_run_depend).exists())
+ {
+ _imp->run_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_run_depend,
+ vars->description_run_depend, file_contents(_imp->dir / vars->metadata_run_depend),
+ _imp->run_dependencies_labels, mkt_dependencies));
+ add_metadata_key(_imp->run_dependencies);
+ }
+
+ if (! vars->metadata_pdepend.empty())
+ if ((_imp->dir / vars->metadata_pdepend).exists())
+ {
+ _imp->post_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_pdepend,
+ vars->description_pdepend, file_contents(_imp->dir / vars->metadata_pdepend),
+ _imp->post_dependencies_labels, mkt_dependencies));
+ add_metadata_key(_imp->post_dependencies);
+ }
+ }
+
+ if (! vars->metadata_restrict.empty())
+ if ((_imp->dir / vars->metadata_restrict).exists())
+ {
+ _imp->restrictions.reset(new ERestrictKey(_imp->environment, shared_from_this(), vars->metadata_restrict, vars->description_restrict,
+ file_contents(_imp->dir / vars->metadata_restrict), mkt_internal));
+ add_metadata_key(_imp->restrictions);
+ }
+
+ if (! vars->metadata_src_uri.empty())
+ if ((_imp->dir / vars->metadata_src_uri).exists())
+ {
+ _imp->src_uri.reset(new EFetchableURIKey(_imp->environment, shared_from_this(), vars->metadata_src_uri, vars->description_src_uri,
+ file_contents(_imp->dir / vars->metadata_src_uri), mkt_dependencies));
+ add_metadata_key(_imp->src_uri);
+ }
+
+ if (! vars->metadata_description.empty())
+ if ((_imp->dir / vars->metadata_description).exists())
+ {
+ _imp->short_description.reset(new LiteralMetadataStringKey(vars->metadata_description,
+ vars->description_description, mkt_significant, file_contents(_imp->dir / vars->metadata_description)));
+ add_metadata_key(_imp->short_description);
+ }
+
+ if (! vars->metadata_homepage.empty())
+ if ((_imp->dir / vars->metadata_homepage).exists())
+ {
+ _imp->homepage.reset(new ESimpleURIKey(_imp->environment, shared_from_this(), vars->metadata_homepage, vars->description_homepage,
+ file_contents(_imp->dir / vars->metadata_homepage), mkt_significant));
+ add_metadata_key(_imp->homepage);
+ }
+
+ _imp->contents = make_contents_key();
+ add_metadata_key(_imp->contents);
+
+ _imp->installed_time.reset(new ECTimeKey(shared_from_this(), "INSTALLED_TIME", "Installed time",
+ _imp->dir / contents_filename(), mkt_normal));
+ add_metadata_key(_imp->installed_time);
+
+ if ((_imp->dir / "REPOSITORY").exists())
+ {
+ _imp->source_origin.reset(new LiteralMetadataStringKey("REPOSITORY", "Source repository",
+ mkt_normal, file_contents(_imp->dir / "REPOSITORY")));
+ add_metadata_key(_imp->source_origin);
+ }
+
+ if ((_imp->dir / "BINARY_REPOSITORY").exists())
+ {
+ _imp->binary_origin.reset(new LiteralMetadataStringKey("BINARY_REPOSITORY", "Binary repository",
+ mkt_normal, file_contents(_imp->dir / "BINARY_REPOSITORY")));
+ add_metadata_key(_imp->binary_origin);
+ }
+
+ if ((_imp->dir / "ASFLAGS").exists())
+ {
+ _imp->asflags.reset(new LiteralMetadataStringKey("ASFLAGS", "ASFLAGS",
+ mkt_internal, file_contents(_imp->dir / "ASFLAGS")));
+ add_metadata_key(_imp->asflags);
+ }
+
+ if ((_imp->dir / "CBUILD").exists())
+ {
+ _imp->cbuild.reset(new LiteralMetadataStringKey("CBUILD", "CBUILD",
+ mkt_internal, file_contents(_imp->dir / "CBUILD")));
+ add_metadata_key(_imp->cbuild);
+ }
+
+ if ((_imp->dir / "CFLAGS").exists())
+ {
+ _imp->cflags.reset(new LiteralMetadataStringKey("CFLAGS", "CFLAGS",
+ mkt_internal, file_contents(_imp->dir / "CFLAGS")));
+ add_metadata_key(_imp->cflags);
+ }
+
+ if ((_imp->dir / "CHOST").exists())
+ {
+ _imp->chost.reset(new LiteralMetadataStringKey("CHOST", "CHOST",
+ mkt_internal, file_contents(_imp->dir / "CHOST")));
+ add_metadata_key(_imp->chost);
+ }
+
+ if ((_imp->dir / "CXXFLAGS").exists())
+ {
+ _imp->cxxflags.reset(new LiteralMetadataStringKey("CXXFLAGS", "CXXFLAGS",
+ mkt_internal, file_contents(_imp->dir / "CXXFLAGS")));
+ add_metadata_key(_imp->cxxflags);
+ }
+
+ if ((_imp->dir / "LDFLAGS").exists())
+ {
+ _imp->ldflags.reset(new LiteralMetadataStringKey("LDFLAGS", "LDFLAGS",
+ mkt_internal, file_contents(_imp->dir / "LDFLAGS")));
+ add_metadata_key(_imp->ldflags);
+ }
+
+ if ((_imp->dir / "PKGMANAGER").exists())
+ {
+ _imp->pkgmanager.reset(new LiteralMetadataStringKey("PKGMANAGER", "Installed using",
+ mkt_normal, file_contents(_imp->dir / "PKGMANAGER")));
+ add_metadata_key(_imp->pkgmanager);
+ }
+
+ if ((_imp->dir / "VDB_FORMAT").exists())
+ {
+ _imp->vdb_format.reset(new LiteralMetadataStringKey("VDB_FORMAT", "VDB Format",
+ mkt_internal, file_contents(_imp->dir / "VDB_FORMAT")));
+ add_metadata_key(_imp->vdb_format);
+ }
+}
+
+void
+EInstalledRepositoryID::need_masks_added() const
+{
+}
+
+const std::string
+EInstalledRepositoryID::canonical_form(const PackageIDCanonicalForm f) const
+{
+ switch (f)
+ {
+ case idcf_full:
+ if (_imp->slot)
+ return stringify(name()) + "-" + stringify(version()) + ":" + stringify(slot()) + "::" +
+ stringify(repository()->name());
+
+ return stringify(name()) + "-" + stringify(version()) + "::" + stringify(repository()->name());
+
+ case idcf_no_version:
+ if (_imp->slot)
+ return stringify(name()) + ":" + stringify(slot()) + "::" +
+ stringify(repository()->name());
+
+ return stringify(name()) + "::" + stringify(repository()->name());
+
+ case idcf_version:
+ return stringify(version());
+
+ case last_idcf:
+ break;
+ }
+
+ throw InternalError(PALUDIS_HERE, "Bad PackageIDCanonicalForm");
+}
+
+const QualifiedPackageName
+EInstalledRepositoryID::name() const
+{
+ return _imp->name;
+}
+
+const VersionSpec
+EInstalledRepositoryID::version() const
+{
+ return _imp->version;
+}
+
+const SlotName
+EInstalledRepositoryID::slot() const
+{
+ Lock l(_imp->mutex);
+
+ if (_imp->slot)
+ return *_imp->slot;
+
+ Context context("When finding SLOT for '" + stringify(name()) + "-" + stringify(version()) + "::"
+ + stringify(repository()->name()) + "':");
+
+ if ((_imp->dir / "SLOT").exists())
+ _imp->slot.reset(new SlotName(file_contents(_imp->dir / "SLOT")));
+ else
+ {
+ Log::get_instance()->message(ll_warning, lc_context) << "No SLOT entry in '" << _imp->dir << "', pretending '0'";
+ _imp->slot.reset(new SlotName("0"));
+ }
+
+ return *_imp->slot;
+}
+
+const tr1::shared_ptr<const Repository>
+EInstalledRepositoryID::repository() const
+{
+ return _imp->repository;
+}
+
+const tr1::shared_ptr<const EAPI>
+EInstalledRepositoryID::eapi() const
+{
+ Lock l(_imp->mutex);
+
+ if (_imp->eapi)
+ return _imp->eapi;
+
+ Context context("When finding EAPI for '" + canonical_form(idcf_full) + "':");
+
+ if ((_imp->dir / "EAPI").exists())
+ _imp->eapi = EAPIData::get_instance()->eapi_from_string(file_contents(_imp->dir / "EAPI"));
+ else
+ {
+ Log::get_instance()->message(ll_debug, lc_context) << "No EAPI entry in '" << _imp->dir << "', pretending '"
+ << _imp->environment->default_distribution() << "'";
+ _imp->eapi = EAPIData::get_instance()->eapi_from_string(
+ DistributionData::get_instance()->distribution_from_string(
+ _imp->environment->default_distribution())->default_ebuild_eapi_when_unspecified);
+ }
+
+ return _imp->eapi;
+}
+
+const tr1::shared_ptr<const MetadataPackageIDKey>
+EInstalledRepositoryID::virtual_for_key() const
+{
+ return tr1::shared_ptr<const MetadataPackageIDKey>();
+}
+
+const tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> >
+EInstalledRepositoryID::keywords_key() const
+{
+ return tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> >();
+}
+
+const tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> >
+EInstalledRepositoryID::eclass_keywords_key() const
+{
+ return tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> >();
+}
+
+const tr1::shared_ptr<const MetadataCollectionKey<UseFlagNameSet> >
+EInstalledRepositoryID::use_key() const
+{
+ need_keys_added();
+ return _imp->use;
+}
+
+const tr1::shared_ptr<const MetadataCollectionKey<IUseFlagSet> >
+EInstalledRepositoryID::iuse_key() const
+{
+ need_keys_added();
+ return _imp->iuse;
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> >
+EInstalledRepositoryID::license_key() const
+{
+ need_keys_added();
+ return _imp->license;
+}
+
+const tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > >
+EInstalledRepositoryID::inherited_key() const
+{
+ need_keys_added();
+ return _imp->inherited;
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> >
+EInstalledRepositoryID::provide_key() const
+{
+ need_keys_added();
+ return _imp->provide;
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
+EInstalledRepositoryID::build_dependencies_key() const
+{
+ need_keys_added();
+ return _imp->build_dependencies;
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
+EInstalledRepositoryID::run_dependencies_key() const
+{
+ need_keys_added();
+ return _imp->run_dependencies;
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
+EInstalledRepositoryID::post_dependencies_key() const
+{
+ need_keys_added();
+ return _imp->post_dependencies;
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
+EInstalledRepositoryID::suggested_dependencies_key() const
+{
+ return tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >();
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<RestrictSpecTree> >
+EInstalledRepositoryID::restrict_key() const
+{
+ need_keys_added();
+ return _imp->restrictions;
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<FetchableURISpecTree> >
+EInstalledRepositoryID::fetches_key() const
+{
+ need_keys_added();
+ return _imp->src_uri;
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> >
+EInstalledRepositoryID::homepage_key() const
+{
+ need_keys_added();
+ return _imp->homepage;
+}
+
+const tr1::shared_ptr<const MetadataStringKey>
+EInstalledRepositoryID::short_description_key() const
+{
+ need_keys_added();
+ return _imp->short_description;
+}
+
+const tr1::shared_ptr<const MetadataStringKey>
+EInstalledRepositoryID::long_description_key() const
+{
+ return tr1::shared_ptr<const MetadataStringKey>();
+}
+
+const tr1::shared_ptr<const MetadataContentsKey>
+EInstalledRepositoryID::contents_key() const
+{
+ need_keys_added();
+ return _imp->contents;
+}
+
+const tr1::shared_ptr<const MetadataTimeKey>
+EInstalledRepositoryID::installed_time_key() const
+{
+ need_keys_added();
+ return _imp->installed_time;
+}
+
+const tr1::shared_ptr<const MetadataStringKey>
+EInstalledRepositoryID::source_origin_key() const
+{
+ need_keys_added();
+ return _imp->source_origin;
+}
+
+const tr1::shared_ptr<const MetadataStringKey>
+EInstalledRepositoryID::binary_origin_key() const
+{
+ need_keys_added();
+ return _imp->binary_origin;
+}
+
+const tr1::shared_ptr<const MetadataFSEntryKey>
+EInstalledRepositoryID::fs_location_key() const
+{
+ // Avoid loading whole metadata
+ if (! _imp->fs_location)
+ {
+ Lock l(_imp->mutex);
+
+ _imp->fs_location.reset(new LiteralMetadataFSEntryKey(fs_location_raw_name(),
+ fs_location_human_name(), mkt_internal, _imp->dir));
+ add_metadata_key(_imp->fs_location);
+ }
+
+ return _imp->fs_location;
+}
+
+const tr1::shared_ptr<const MetadataSizeKey>
+EInstalledRepositoryID::size_of_download_required_key() const
+{
+ return tr1::shared_ptr<const MetadataSizeKey>();
+}
+
+const tr1::shared_ptr<const MetadataSizeKey>
+EInstalledRepositoryID::size_of_all_distfiles_key() const
+{
+ return tr1::shared_ptr<const MetadataSizeKey>();
+}
+
+
+bool
+EInstalledRepositoryID::arbitrary_less_than_comparison(const PackageID &) const
+{
+ return false;
+}
+
+std::size_t
+EInstalledRepositoryID::extra_hash_value() const
+{
+ return 0;
+}
+
+namespace
+{
+ struct SupportsActionQuery :
+ ConstVisitor<SupportsActionTestVisitorTypes>
+ {
+ bool result;
+
+ SupportsActionQuery() :
+ result(false)
+ {
+ }
+
+ void visit(const SupportsActionTest<InstalledAction> &)
+ {
+ result = true;
+ }
+
+ void visit(const SupportsActionTest<InstallAction> &)
+ {
+ }
+
+ void visit(const SupportsActionTest<ConfigAction> &)
+ {
+ result = true;
+ }
+
+ void visit(const SupportsActionTest<FetchAction> &)
+ {
+ }
+
+ void visit(const SupportsActionTest<PretendAction> &)
+ {
+ }
+
+ void visit(const SupportsActionTest<InfoAction> &)
+ {
+ result = true;
+ }
+
+ void visit(const SupportsActionTest<UninstallAction> &)
+ {
+ result = true;
+ }
+ };
+}
+
+bool
+EInstalledRepositoryID::supports_action(const SupportsActionTestBase & b) const
+{
+ SupportsActionQuery q;
+ b.accept(q);
+ return q.result;
+}
+
+namespace
+{
+ struct PerformAction :
+ ConstVisitor<ActionVisitorTypes>
+ {
+ const tr1::shared_ptr<const erepository::ERepositoryID> id;
+
+ PerformAction(const tr1::shared_ptr<const erepository::ERepositoryID> i) :
+ id(i)
+ {
+ }
+
+ void visit(const UninstallAction & a)
+ {
+ tr1::static_pointer_cast<const EInstalledRepository>(id->repository())->perform_uninstall(id,
+ a.options, false);
+ }
+
+ void visit(const InstalledAction &)
+ {
+ }
+
+ void visit(const ConfigAction &)
+ {
+ tr1::static_pointer_cast<const EInstalledRepository>(id->repository())->perform_config(id);
+ }
+
+ void visit(const InfoAction &)
+ {
+ tr1::static_pointer_cast<const EInstalledRepository>(id->repository())->perform_info(id);
+ }
+
+ void visit(const InstallAction & a) PALUDIS_ATTRIBUTE((noreturn));
+ void visit(const PretendAction & a) PALUDIS_ATTRIBUTE((noreturn));
+ void visit(const FetchAction & a) PALUDIS_ATTRIBUTE((noreturn));
+ };
+
+ void PerformAction::visit(const InstallAction & a)
+ {
+ throw UnsupportedActionError(*id, a);
+ }
+
+ void PerformAction::visit(const PretendAction & a)
+ {
+ throw UnsupportedActionError(*id, a);
+ }
+
+ void PerformAction::visit(const FetchAction & a)
+ {
+ throw UnsupportedActionError(*id, a);
+ }
+}
+
+void
+EInstalledRepositoryID::perform_action(Action & a) const
+{
+ PerformAction b(shared_from_this());
+ a.accept(b);
+}
+
+const tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> >
+EInstalledRepositoryID::contains_key() const
+{
+ return tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> >();
+}
+
+const tr1::shared_ptr<const MetadataPackageIDKey>
+EInstalledRepositoryID::contained_in_key() const
+{
+ return tr1::shared_ptr<const MetadataPackageIDKey>();
+}
+
+
diff --git a/paludis/repositories/e/e_installed_repository_id.hh b/paludis/repositories/e/e_installed_repository_id.hh
new file mode 100644
index 0000000..64b9b4c
--- /dev/null
+++ b/paludis/repositories/e/e_installed_repository_id.hh
@@ -0,0 +1,106 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007, 2008 Ciaran McCreesh
+ *
+ * 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
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_E_INSTALLED_REPOSITORY_ID_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_E_INSTALLED_REPOSITORY_ID_HH 1
+
+#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/repositories/e/e_repository_id.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ class EInstalledRepositoryID :
+ public ERepositoryID,
+ public tr1::enable_shared_from_this<EInstalledRepositoryID>,
+ private PrivateImplementationPattern<EInstalledRepositoryID>
+ {
+ private:
+ PrivateImplementationPattern<EInstalledRepositoryID>::ImpPtr & _imp;
+
+ protected:
+ virtual void need_keys_added() const;
+ virtual void need_masks_added() const;
+
+ EInstalledRepositoryID(const QualifiedPackageName &, const VersionSpec &,
+ const Environment * const,
+ const tr1::shared_ptr<const Repository> &,
+ const FSEntry & file);
+
+ public:
+ ~EInstalledRepositoryID();
+
+ virtual const std::string canonical_form(const PackageIDCanonicalForm) const;
+
+ virtual const QualifiedPackageName name() const;
+ virtual const VersionSpec version() const;
+ virtual const SlotName slot() const;
+ virtual const tr1::shared_ptr<const Repository> repository() const;
+ virtual const tr1::shared_ptr<const EAPI> eapi() const;
+
+ virtual const tr1::shared_ptr<const MetadataPackageIDKey> virtual_for_key() const;
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const;
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > eclass_keywords_key() const;
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<IUseFlagSet> > iuse_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > build_dependencies_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > run_dependencies_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > post_dependencies_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > suggested_dependencies_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<RestrictSpecTree> > restrict_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<FetchableURISpecTree> > fetches_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> > homepage_key() const;
+ virtual const tr1::shared_ptr<const MetadataStringKey> short_description_key() const;
+ virtual const tr1::shared_ptr<const MetadataStringKey> long_description_key() const;
+ virtual const tr1::shared_ptr<const MetadataContentsKey> contents_key() const;
+ virtual const tr1::shared_ptr<const MetadataTimeKey> installed_time_key() const;
+ virtual const tr1::shared_ptr<const MetadataStringKey> source_origin_key() const;
+ virtual const tr1::shared_ptr<const MetadataStringKey> binary_origin_key() const;
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> > contains_key() const;
+ virtual const tr1::shared_ptr<const MetadataPackageIDKey> contained_in_key() const;
+ virtual const tr1::shared_ptr<const MetadataFSEntryKey> fs_location_key() const;
+ virtual const tr1::shared_ptr<const MetadataSizeKey> size_of_download_required_key() const;
+ virtual const tr1::shared_ptr<const MetadataSizeKey> size_of_all_distfiles_key() const;
+
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<UseFlagNameSet> > use_key() const;
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > inherited_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> > license_key() const;
+
+ virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual void perform_action(Action &) const;
+
+ virtual bool arbitrary_less_than_comparison(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::size_t extra_hash_value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::string fs_location_raw_name() const = 0;
+ virtual std::string fs_location_human_name() const = 0;
+ virtual std::string contents_filename() const = 0;
+ virtual tr1::shared_ptr<MetadataContentsKey> make_contents_key() const = 0;
+ };
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/exndbam_id.cc b/paludis/repositories/e/exndbam_id.cc
new file mode 100644
index 0000000..73bec83
--- /dev/null
+++ b/paludis/repositories/e/exndbam_id.cc
@@ -0,0 +1,116 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 Ciaran McCreesh
+ *
+ * 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/repositories/e/exndbam_id.hh>
+#include <paludis/util/mutex.hh>
+#include <paludis/util/tr1_functional.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/contents.hh>
+#include <paludis/ndbam.hh>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+namespace
+{
+ void create_file(Contents & c, const FSEntry & f)
+ {
+ c.add(make_shared_ptr(new ContentsFileEntry(stringify(f))));
+ }
+
+ void create_dir(Contents & c, const FSEntry & f)
+ {
+ c.add(make_shared_ptr(new ContentsDirEntry(stringify(f))));
+ }
+
+ void create_sym(Contents & c, const FSEntry & f, const FSEntry & t)
+ {
+ c.add(make_shared_ptr(new ContentsSymEntry(stringify(f), stringify(t))));
+ }
+
+ class ExndbamContentsKey :
+ public MetadataContentsKey
+ {
+ private:
+ const PackageID * const _id;
+ const NDBAM * const _db;
+ mutable Mutex _mutex;
+ mutable tr1::shared_ptr<Contents> _v;
+
+ public:
+ ExndbamContentsKey(const PackageID * const i, const NDBAM * const d) :
+ MetadataContentsKey("contents", "Contents", mkt_internal),
+ _id(i),
+ _db(d)
+ {
+ }
+
+ const tr1::shared_ptr<const Contents> value() const
+ {
+ Lock l(_mutex);
+ if (_v)
+ return _v;
+
+ using namespace tr1::placeholders;
+ _v.reset(new Contents);
+ _db->parse_contents(*_id,
+ tr1::bind(&create_file, tr1::ref(*_v), _1),
+ tr1::bind(&create_dir, tr1::ref(*_v), _1),
+ tr1::bind(&create_sym, tr1::ref(*_v), _1, _2)
+ );
+ return _v;
+ }
+ };
+}
+
+ExndbamID::ExndbamID(const QualifiedPackageName & q, const VersionSpec & v,
+ const Environment * const e,
+ const tr1::shared_ptr<const Repository> & r,
+ const FSEntry & f, const NDBAM * const n) :
+ EInstalledRepositoryID(q, v, e, r, f),
+ _ndbam(n)
+{
+}
+
+std::string
+ExndbamID::fs_location_raw_name() const
+{
+ return "EXNDBAMDIR";
+}
+
+std::string
+ExndbamID::fs_location_human_name() const
+{
+ return "Exndbam Directory";
+}
+
+std::string
+ExndbamID::contents_filename() const
+{
+ return "contents";
+}
+
+tr1::shared_ptr<MetadataContentsKey>
+ExndbamID::make_contents_key() const
+{
+ return make_shared_ptr(new ExndbamContentsKey(this, _ndbam));
+}
+
+
diff --git a/paludis/repositories/e/exndbam_id.hh b/paludis/repositories/e/exndbam_id.hh
new file mode 100644
index 0000000..7586b56
--- /dev/null
+++ b/paludis/repositories/e/exndbam_id.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 Ciaran McCreesh
+ *
+ * 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
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_EXNDBAM_ID_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_EXNDBAM_ID_HH 1
+
+#include <paludis/repositories/e/e_installed_repository_id.hh>
+#include <paludis/ndbam-fwd.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ class ExndbamID :
+ public EInstalledRepositoryID
+ {
+ private:
+ const NDBAM * const _ndbam;
+
+ public:
+ ExndbamID(const QualifiedPackageName &, const VersionSpec &,
+ const Environment * const,
+ const tr1::shared_ptr<const Repository> &,
+ const FSEntry & file,
+ const NDBAM * const);
+
+ virtual std::string fs_location_raw_name() const;
+ virtual std::string fs_location_human_name() const;
+ virtual std::string contents_filename() const;
+ virtual tr1::shared_ptr<MetadataContentsKey> make_contents_key() const;
+ };
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/exndbam_repository.cc b/paludis/repositories/e/exndbam_repository.cc
new file mode 100644
index 0000000..46369f9
--- /dev/null
+++ b/paludis/repositories/e/exndbam_repository.cc
@@ -0,0 +1,470 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 Ciaran McCreesh
+ *
+ * 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/repositories/e/exndbam_repository.hh>
+#include <paludis/repositories/e/exndbam_id.hh>
+#include <paludis/repositories/e/ebuild.hh>
+#include <paludis/repositories/e/eapi.hh>
+#include <paludis/repositories/e/eapi_phase.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/util/cookie.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/dir_iterator.hh>
+#include <paludis/util/kc.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/system.hh>
+#include <paludis/distribution.hh>
+#include <paludis/environment.hh>
+#include <paludis/ndbam.hh>
+#include <paludis/ndbam_merger.hh>
+#include <paludis/ndbam_unmerger.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/package_id.hh>
+#include <paludis/action.hh>
+#include <paludis/literal_metadata_key.hh>
+#include <fstream>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+#include <paludis/repositories/e/exndbam_repository-sr.cc>
+
+namespace
+{
+ bool supported_exndbam(const std::string & s)
+ {
+ return s == "exndbam-1";
+ }
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<ExndbamRepository>
+ {
+ ExndbamRepositoryParams params;
+ mutable NDBAM ndbam;
+
+ tr1::shared_ptr<const MetadataFSEntryKey> location_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> root_key;
+ tr1::shared_ptr<const MetadataStringKey> format_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> world_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> builddir_key;
+
+ Implementation(const ExndbamRepositoryParams & p) :
+ params(p),
+ ndbam(params.location, &supported_exndbam, "exndbam-1"),
+ location_key(new LiteralMetadataFSEntryKey("location", "location",
+ mkt_significant, params.location)),
+ root_key(new LiteralMetadataFSEntryKey("root", "root",
+ mkt_normal, params.root)),
+ format_key(new LiteralMetadataStringKey("format", "format",
+ mkt_significant, "vdb")),
+ world_key(new LiteralMetadataFSEntryKey("world", "world",
+ mkt_normal, params.world)),
+ builddir_key(new LiteralMetadataFSEntryKey("builddir", "builddir",
+ mkt_normal, params.builddir))
+ {
+ }
+ };
+}
+
+ExndbamRepository::ExndbamRepository(const RepositoryName & n, const ExndbamRepositoryParams & p) :
+ EInstalledRepository(
+ EInstalledRepositoryParams::create()
+ .environment(p.environment)
+ .world(p.world)
+ .builddir(p.builddir)
+ .root(p.root),
+ n, RepositoryCapabilities::create()
+ .sets_interface(this)
+ .syncable_interface(0)
+ .use_interface(this)
+ .world_interface(this)
+ .environment_variable_interface(this)
+ .mirrors_interface(0)
+ .provides_interface(0)
+ .virtuals_interface(0)
+ .destination_interface(this)
+ .e_interface(0)
+ .make_virtuals_interface(0)
+ .qa_interface(0)
+ .hook_interface(this)
+ .manifest_interface(0)),
+ PrivateImplementationPattern<ExndbamRepository>(new Implementation<ExndbamRepository>(p)),
+ _imp(PrivateImplementationPattern<ExndbamRepository>::_imp)
+{
+ _add_metadata_keys();
+}
+
+ExndbamRepository::~ExndbamRepository()
+{
+}
+
+void
+ExndbamRepository::_add_metadata_keys() const
+{
+ clear_metadata_keys();
+ add_metadata_key(_imp->location_key);
+ add_metadata_key(_imp->root_key);
+ add_metadata_key(_imp->format_key);
+ add_metadata_key(_imp->world_key);
+ add_metadata_key(_imp->builddir_key);
+}
+
+
+tr1::shared_ptr<Repository>
+ExndbamRepository::make_exndbam_repository(
+ Environment * const env,
+ tr1::shared_ptr<const Map<std::string, std::string> > m)
+{
+ std::string repo_file(m->end() == m->find("repo_file") ? std::string("?") : m->find("repo_file")->second);
+ Context context("When making Exndbam repository from repo_file '" + repo_file + "':");
+
+ std::string location;
+ if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
+ throw ExndbamRepositoryConfigurationError("Key 'location' not specified or empty");
+
+ std::string root;
+ if (m->end() == m->find("root") || ((root = m->find("root")->second)).empty())
+ root = "/";
+
+ std::string world;
+ if (m->end() == m->find("world") || ((world = m->find("world")->second)).empty())
+ world = location + "/world";
+
+ std::string builddir;
+ if (m->end() == m->find("builddir") || ((builddir = m->find("builddir")->second)).empty())
+ {
+ if (m->end() == m->find("buildroot") || ((builddir = m->find("buildroot")->second)).empty())
+ builddir = DistributionData::get_instance()->distribution_from_string(
+ env->default_distribution())->default_ebuild_builddir;
+ else
+ Log::get_instance()->message(ll_warning, lc_context) << "Key 'buildroot' is deprecated, use 'builddir' instead";
+ }
+
+ std::string name;
+ if (m->end() == m->find("name") || ((name = m->find("name")->second)).empty())
+ name = "installed";
+
+ return tr1::shared_ptr<Repository>(new ExndbamRepository(
+ RepositoryName(name),
+ ExndbamRepositoryParams::create()
+ .environment(env)
+ .location(location)
+ .root(root)
+ .world(world)
+ .builddir(builddir)));
+}
+
+void
+ExndbamRepository::invalidate()
+{
+ _imp.reset(new Implementation<ExndbamRepository>(_imp->params));
+ _add_metadata_keys();
+}
+
+void
+ExndbamRepository::invalidate_masks()
+{
+}
+
+tr1::shared_ptr<const PackageIDSequence>
+ExndbamRepository::package_ids(const QualifiedPackageName & q) const
+{
+ tr1::shared_ptr<NDBAMEntrySequence> entries(_imp->ndbam.entries(q));
+ tr1::shared_ptr<PackageIDSequence> result(new PackageIDSequence);
+
+ for (IndirectIterator<NDBAMEntrySequence::ConstIterator> e(entries->begin()), e_end(entries->end()) ;
+ e != e_end ; ++e)
+ {
+ Lock l(*e->mutex);
+ if (! e->package_id)
+ e->package_id.reset(new ExndbamID(e->name, e->version, _imp->params.environment,
+ shared_from_this(), e->fs_location, &_imp->ndbam));
+ result->push_back(e->package_id);
+ }
+
+ return result;
+}
+
+tr1::shared_ptr<const QualifiedPackageNameSet>
+ExndbamRepository::package_names(const CategoryNamePart & c) const
+{
+ return _imp->ndbam.package_names(c);
+}
+
+tr1::shared_ptr<const CategoryNamePartSet>
+ExndbamRepository::category_names() const
+{
+ return _imp->ndbam.category_names();
+}
+
+tr1::shared_ptr<const CategoryNamePartSet>
+ExndbamRepository::category_names_containing_package(
+ const PackageNamePart & p) const
+{
+ return _imp->ndbam.category_names_containing_package(p);
+}
+
+bool
+ExndbamRepository::has_package_named(const QualifiedPackageName & q) const
+{
+ return _imp->ndbam.has_package_named(q);
+}
+
+bool
+ExndbamRepository::has_category_named(const CategoryNamePart & c) const
+{
+ return _imp->ndbam.has_category_named(c);
+}
+
+ExndbamRepositoryConfigurationError::ExndbamRepositoryConfigurationError(
+ const std::string & msg) throw () :
+ ConfigurationError("Exndbam repository configuration error: " + msg)
+{
+}
+
+const tr1::shared_ptr<const MetadataStringKey>
+ExndbamRepository::format_key() const
+{
+ return _imp->format_key;
+}
+
+const tr1::shared_ptr<const MetadataFSEntryKey>
+ExndbamRepository::installed_root_key() const
+{
+ return _imp->root_key;
+}
+
+void
+ExndbamRepository::need_keys_added() const
+{
+}
+
+void
+ExndbamRepository::merge(const MergeOptions & m)
+{
+ Context context("When merging '" + stringify(*m.package_id) + "' at '" + stringify(m.image_dir)
+ + "' to Exndbam repository '" + stringify(name()) + "':");
+
+ if (! is_suitable_destination_for(*m.package_id))
+ throw InstallActionError("Not a suitable destination for '" + stringify(*m.package_id) + "'");
+
+ tr1::shared_ptr<const PackageID> if_overwritten_id, if_same_name_id;
+ {
+ tr1::shared_ptr<const PackageIDSequence> ids(package_ids(m.package_id->name()));
+ for (PackageIDSequence::ConstIterator v(ids->begin()), v_end(ids->end()) ;
+ v != v_end ; ++v)
+ {
+ if_same_name_id = *v;
+ if ((*v)->version() == m.package_id->version() && (*v)->slot() == m.package_id->slot())
+ {
+ if_overwritten_id = *v;
+ break;
+ }
+ }
+ }
+
+ FSEntry uid_dir(_imp->params.location);
+ if (if_same_name_id)
+ uid_dir = if_same_name_id->fs_location_key()->value().dirname();
+ else
+ {
+ std::string uid(stringify(m.package_id->name().category) + "---" + stringify(m.package_id->name().package));
+ uid_dir /= "data";
+ uid_dir.mkdir();
+ uid_dir /= uid;
+ uid_dir.mkdir();
+ }
+
+ FSEntry target_ver_dir(uid_dir);
+ target_ver_dir /= (stringify(m.package_id->version()) + ":" + stringify(m.package_id->slot()) + ":" + cookie());
+
+ if (target_ver_dir.exists())
+ throw InstallActionError("Temporary merge directory '" + stringify(target_ver_dir) + "' already exists, probably "
+ "due to a previous failed install. If it is safe to do so, please remove this directory and try again.");
+ target_ver_dir.mkdir();
+
+ WriteVDBEntryCommand write_vdb_entry_command(
+ WriteVDBEntryParams::create()
+ .environment(_imp->params.environment)
+ .package_id(tr1::static_pointer_cast<const ERepositoryID>(m.package_id))
+ .output_directory(target_ver_dir)
+ .environment_file(m.environment_file));
+
+ write_vdb_entry_command();
+
+ /* load CONFIG_PROTECT, CONFIG_PROTECT_MASK back */
+ std::string config_protect, config_protect_mask;
+ {
+ std::ifstream c(stringify(target_ver_dir / "CONFIG_PROTECT").c_str());
+ config_protect = std::string((std::istreambuf_iterator<char>(c)), std::istreambuf_iterator<char>());
+
+ std::ifstream c_m(stringify(target_ver_dir / "CONFIG_PROTECT_MASK").c_str());
+ config_protect_mask = std::string((std::istreambuf_iterator<char>(c_m)), std::istreambuf_iterator<char>());
+ }
+
+ NDBAMMerger merger(
+ NDBAMMergerOptions::create()
+ .environment(_imp->params.environment)
+ .image(m.image_dir)
+ .root(installed_root_key()->value())
+ .contents_file(target_ver_dir / "contents")
+ .config_protect(config_protect)
+ .config_protect_mask(config_protect_mask)
+ .package_id(m.package_id));
+
+ if (! merger.check())
+ {
+ for (DirIterator d(target_ver_dir, false), d_end ; d != d_end ; ++d)
+ FSEntry(*d).unlink();
+ target_ver_dir.rmdir();
+ throw InstallActionError("Not proceeding with install due to merge sanity check failing");
+ }
+
+ merger.merge();
+
+ _imp->ndbam.index(m.package_id->name(), uid_dir.basename());
+
+ if (if_overwritten_id)
+ {
+ UninstallActionOptions uninstall_options(false);
+ perform_uninstall(tr1::static_pointer_cast<const ERepositoryID>(if_overwritten_id), uninstall_options, true);
+ }
+
+ VDBPostMergeCommand post_merge_command(
+ VDBPostMergeCommandParams::create()
+ .root(installed_root_key()->value()));
+
+ post_merge_command();
+}
+
+void
+ExndbamRepository::perform_uninstall(const tr1::shared_ptr<const ERepositoryID> & id,
+ const UninstallActionOptions & o, bool replace) const
+{
+ Context context("When uninstalling '" + stringify(*id) + (replace ? "' for a reinstall:" : "':"));
+
+ bool last(! replace);
+ if (last)
+ {
+ tr1::shared_ptr<const PackageIDSequence> ids(package_ids(id->name()));
+ for (PackageIDSequence::ConstIterator v(ids->begin()), v_end(ids->end()) ;
+ v != v_end ; ++v)
+ if (**v != *id)
+ {
+ last = false;
+ break;
+ }
+ }
+
+ if (! _imp->params.root.is_directory())
+ throw InstallActionError("Couldn't uninstall '" + stringify(*id) +
+ "' because root ('" + stringify(_imp->params.root) + "') is not a directory");
+
+ FSEntry ver_dir(id->fs_location_key()->value());
+ tr1::shared_ptr<FSEntry> load_env(new FSEntry(ver_dir / "environment.bz2"));
+
+ tr1::shared_ptr<FSEntrySequence> eclassdirs(new FSEntrySequence);
+ eclassdirs->push_back(ver_dir);
+
+ EAPIPhases phases(id->eapi()->supported->ebuild_phases->ebuild_uninstall);
+ for (EAPIPhases::ConstIterator phase(phases.begin_phases()), phase_end(phases.end_phases()) ;
+ phase != phase_end ; ++phase)
+ {
+ if (phase->option("unmerge"))
+ {
+ /* load CONFIG_PROTECT, CONFIG_PROTECT_MASK from vdb, supplement with env */
+ std::string config_protect, config_protect_mask;
+ {
+ std::ifstream c(stringify(ver_dir / "CONFIG_PROTECT").c_str());
+ config_protect = std::string((std::istreambuf_iterator<char>(c)), std::istreambuf_iterator<char>()) +
+ " " + getenv_with_default("CONFIG_PROTECT", "");
+
+ std::ifstream c_m(stringify(ver_dir / "CONFIG_PROTECT_MASK").c_str());
+ config_protect_mask = std::string((std::istreambuf_iterator<char>(c_m)), std::istreambuf_iterator<char>()) +
+ " " + getenv_with_default("CONFIG_PROTECT_MASK", "");
+ }
+
+ /* unmerge */
+ NDBAMUnmerger unmerger(
+ NDBAMUnmergerOptions::create()
+ .environment(_imp->params.environment)
+ .root(installed_root_key()->value())
+ .contents_file(ver_dir / "contents")
+ .config_protect(config_protect)
+ .config_protect_mask(config_protect_mask)
+ .ndbam(&_imp->ndbam)
+ .package_id(id));
+
+ unmerger.unmerge();
+ }
+ else
+ {
+ EbuildCommandParams params(EbuildCommandParams::create()
+ .environment(_imp->params.environment)
+ .package_id(id)
+ .ebuild_dir(ver_dir)
+ .ebuild_file(ver_dir / (stringify(id->name().package) + "-" + stringify(id->version()) + ".ebuild"))
+ .files_dir(ver_dir)
+ .eclassdirs(eclassdirs)
+ .exlibsdirs(make_shared_ptr(new FSEntrySequence))
+ .portdir(_imp->params.location)
+ .distdir(ver_dir)
+ .sandbox(phase->option("sandbox"))
+ .userpriv(phase->option("userpriv"))
+ .commands(join(phase->begin_commands(), phase->end_commands(), " "))
+ .builddir(_imp->params.builddir));
+
+ EbuildUninstallCommandParams uninstall_params(EbuildUninstallCommandParams::create()
+ .root(stringify(_imp->params.root) + "/")
+ .disable_cfgpro(o[k::no_config_protect()])
+ .unmerge_only(false)
+ .loadsaveenv_dir(ver_dir)
+ .load_environment(load_env.get()));
+
+ EbuildUninstallCommand uninstall_cmd_pre(params, uninstall_params);
+ uninstall_cmd_pre();
+ }
+ }
+
+ for (DirIterator d(ver_dir, false), d_end ; d != d_end ; ++d)
+ FSEntry(*d).unlink();
+ ver_dir.rmdir();
+
+ if (last)
+ {
+ FSEntry pkg_dir(ver_dir.dirname());
+ pkg_dir.rmdir();
+
+ _imp->ndbam.deindex(id->name());
+ }
+}
+
+void
+ExndbamRepository::regenerate_cache() const
+{
+}
+
diff --git a/paludis/repositories/e/exndbam_repository.hh b/paludis/repositories/e/exndbam_repository.hh
new file mode 100644
index 0000000..4978b5b
--- /dev/null
+++ b/paludis/repositories/e/exndbam_repository.hh
@@ -0,0 +1,127 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 Ciaran McCreesh
+ *
+ * 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
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_EXNDBAM_REPOSITORY_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_EXNDBAM_REPOSITORY_HH 1
+
+#include <paludis/repositories/e/e_installed_repository.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/tr1_memory.hh>
+#include <paludis/util/map.hh>
+#include <paludis/repository.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ class ERepositoryID;
+ }
+
+#include <paludis/repositories/e/exndbam_repository-sr.hh>
+
+ class PALUDIS_VISIBLE ExndbamRepository :
+ public erepository::EInstalledRepository,
+ public tr1::enable_shared_from_this<ExndbamRepository>,
+ public PrivateImplementationPattern<ExndbamRepository>
+ {
+ private:
+ PrivateImplementationPattern<ExndbamRepository>::ImpPtr & _imp;
+ void _add_metadata_keys() const;
+
+ protected:
+ virtual void need_keys_added() const;
+
+ public:
+ /**
+ * Constructor.
+ */
+ ExndbamRepository(const RepositoryName & n, const ExndbamRepositoryParams &);
+
+ /**
+ * Virtual constructor.
+ */
+ static tr1::shared_ptr<Repository> make_exndbam_repository(
+ Environment * const env,
+ tr1::shared_ptr<const Map<std::string, std::string> > m);
+
+ /**
+ * Destructor.
+ */
+ ~ExndbamRepository();
+
+ virtual void invalidate();
+
+ virtual void invalidate_masks();
+
+ virtual void regenerate_cache() const;
+
+ /* RepositoryDestinationInterface */
+
+ virtual void merge(const MergeOptions &);
+
+ /* Repository */
+
+ virtual tr1::shared_ptr<const PackageIDSequence> package_ids(
+ const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual tr1::shared_ptr<const QualifiedPackageNameSet> package_names(
+ const CategoryNamePart &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual tr1::shared_ptr<const CategoryNamePartSet> category_names() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual tr1::shared_ptr<const CategoryNamePartSet> category_names_containing_package(
+ const PackageNamePart &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool has_package_named(const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool has_category_named(const CategoryNamePart &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /* Keys */
+
+ virtual const tr1::shared_ptr<const MetadataStringKey> format_key() const;
+ virtual const tr1::shared_ptr<const MetadataFSEntryKey> installed_root_key() const;
+
+ ///\name For use by ExndbamID
+ ///\{
+
+ void perform_uninstall(const tr1::shared_ptr<const erepository::ERepositoryID> & id,
+ const UninstallActionOptions & o, bool reinstalling) const;
+
+ ///\}
+
+ };
+
+ class PALUDIS_VISIBLE ExndbamRepositoryConfigurationError : public ConfigurationError
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ ExndbamRepositoryConfigurationError(const std::string & msg) throw ();
+ };
+}
+
+#endif
diff --git a/paludis/repositories/e/exndbam_repository.sr b/paludis/repositories/e/exndbam_repository.sr
new file mode 100644
index 0000000..e63f68d
--- /dev/null
+++ b/paludis/repositories/e/exndbam_repository.sr
@@ -0,0 +1,17 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et :
+
+make_class_ExndbamRepositoryParams()
+{
+ visible
+
+ key environment "Environment *"
+ key location FSEntry
+ key root FSEntry
+ key world FSEntry
+ key builddir FSEntry
+
+ allow_named_args
+}
+
+
diff --git a/paludis/repositories/e/exndbam_repository_TEST.cc b/paludis/repositories/e/exndbam_repository_TEST.cc
new file mode 100644
index 0000000..ab72803
--- /dev/null
+++ b/paludis/repositories/e/exndbam_repository_TEST.cc
@@ -0,0 +1,49 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 Ciaran McCreesh
+ *
+ * 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/repositories/e/exndbam_repository.hh>
+#include <paludis/environments/test/test_environment.hh>
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+
+using namespace test;
+using namespace paludis;
+
+namespace test_cases
+{
+ /**
+ * \test Test VDBRepository repo names
+ *
+ */
+ struct ExndbamRepositoryRepoNameTest : TestCase
+ {
+ ExndbamRepositoryRepoNameTest() : TestCase("repo name") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "exndbam");
+ keys->insert("location", "exndbam_repository_TEST_dir/repo1");
+ tr1::shared_ptr<Repository> repo(ExndbamRepository::make_exndbam_repository(&env, keys));
+ TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "installed");
+ }
+ } test_exndbam_repository_repo_name;
+}
+
diff --git a/paludis/repositories/e/exndbam_repository_TEST_cleanup.sh b/paludis/repositories/e/exndbam_repository_TEST_cleanup.sh
new file mode 100755
index 0000000..790816f
--- /dev/null
+++ b/paludis/repositories/e/exndbam_repository_TEST_cleanup.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d exndbam_repository_TEST_dir ] ; then
+ rm -fr exndbam_repository_TEST_dir
+else
+ true
+fi
+
diff --git a/paludis/repositories/e/exndbam_repository_TEST_setup.sh b/paludis/repositories/e/exndbam_repository_TEST_setup.sh
new file mode 100755
index 0000000..7b4fd25
--- /dev/null
+++ b/paludis/repositories/e/exndbam_repository_TEST_setup.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir -p exndbam_repository_TEST_dir || exit 1
+cd exndbam_repository_TEST_dir || exit 1
+
+mkdir -p repo1/ || exit 1
+
diff --git a/paludis/repositories/e/registration.cc b/paludis/repositories/e/registration.cc
index a7ae39c..88c9523 100644
--- a/paludis/repositories/e/registration.cc
+++ b/paludis/repositories/e/registration.cc
@@ -20,6 +20,7 @@
#include <paludis/repository_maker.hh>
#include <paludis/repositories/e/make_ebuild_repository.hh>
#include <paludis/repositories/e/vdb_repository.hh>
+#include <paludis/repositories/e/exndbam_repository.hh>
#include <paludis/util/log.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/map.hh>
@@ -60,6 +61,7 @@ void register_repositories(RepositoryMaker * maker)
maker->register_maker("exheres", &make_ebuild_repository_wrapped);
maker->register_maker("portage", &make_portage_repository);
maker->register_maker("vdb", &VDBRepository::make_vdb_repository);
+ maker->register_maker("exndbam", &ExndbamRepository::make_exndbam_repository);
}
#endif
diff --git a/paludis/repositories/e/vdb_id.cc b/paludis/repositories/e/vdb_id.cc
index b86899b..0e09c28 100644
--- a/paludis/repositories/e/vdb_id.cc
+++ b/paludis/repositories/e/vdb_id.cc
@@ -19,766 +19,41 @@
#include <paludis/repositories/e/vdb_id.hh>
#include <paludis/repositories/e/e_key.hh>
-#include <paludis/repositories/e/vdb_repository.hh>
-#include <paludis/repositories/e/eapi.hh>
-#include <paludis/repositories/e/dep_parser.hh>
-#include <paludis/repositories/e/dependencies_rewriter.hh>
-
-#include <paludis/name.hh>
-#include <paludis/version_spec.hh>
-#include <paludis/repository.hh>
-#include <paludis/distribution.hh>
-#include <paludis/environment.hh>
-#include <paludis/action.hh>
-#include <paludis/util/fs_entry.hh>
-#include <paludis/util/visitor-impl.hh>
-#include <paludis/util/stringify.hh>
-#include <paludis/util/log.hh>
-#include <paludis/util/private_implementation_pattern-impl.hh>
-#include <paludis/util/strip.hh>
-#include <paludis/util/mutex.hh>
#include <paludis/util/make_shared_ptr.hh>
-#include <paludis/literal_metadata_key.hh>
-#include <iterator>
-#include <fstream>
using namespace paludis;
using namespace paludis::erepository;
-namespace
-{
- std::string file_contents(const FSEntry & f)
- {
- Context c("When reading '" + stringify(f) + "':");
- std::ifstream i(stringify(f).c_str());
- if (! i)
- throw ConfigurationError("Cannot open '" + stringify(f) + "' for read");
-
- return strip_trailing(std::string((std::istreambuf_iterator<char>(i)), std::istreambuf_iterator<char>()), "\r\n");
- }
-}
-
-namespace paludis
-{
- template <>
- struct Implementation<VDBID>
- {
- mutable Mutex mutex;
-
- const QualifiedPackageName name;
- const VersionSpec version;
- const Environment * const environment;
- const tr1::shared_ptr<const Repository> repository;
- const FSEntry dir;
- mutable bool has_keys;
-
- tr1::shared_ptr<const SlotName> slot;
- tr1::shared_ptr<const EAPI> eapi;
-
- tr1::shared_ptr<const MetadataFSEntryKey> fs_location;
- tr1::shared_ptr<const MetadataCollectionKey<UseFlagNameSet> > use;
- tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > inherited;
- tr1::shared_ptr<const MetadataCollectionKey<IUseFlagSet> > iuse;
- tr1::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> > license;
- tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide;
- tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > build_dependencies;
- tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > run_dependencies;
- tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > post_dependencies;
- tr1::shared_ptr<const MetadataSpecTreeKey<RestrictSpecTree> > restrictions;
- tr1::shared_ptr<const MetadataSpecTreeKey<FetchableURISpecTree> > src_uri;
- tr1::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> > homepage;
- tr1::shared_ptr<const MetadataStringKey> short_description;
- tr1::shared_ptr<const MetadataContentsKey> contents;
- tr1::shared_ptr<const MetadataTimeKey> installed_time;
- tr1::shared_ptr<const MetadataStringKey> source_origin;
- tr1::shared_ptr<const MetadataStringKey> binary_origin;
-
- tr1::shared_ptr<const MetadataStringKey> asflags;
- tr1::shared_ptr<const MetadataStringKey> cbuild;
- tr1::shared_ptr<const MetadataStringKey> cflags;
- tr1::shared_ptr<const MetadataStringKey> chost;
- tr1::shared_ptr<const MetadataStringKey> ctarget;
- tr1::shared_ptr<const MetadataStringKey> cxxflags;
- tr1::shared_ptr<const MetadataStringKey> ldflags;
- tr1::shared_ptr<const MetadataStringKey> pkgmanager;
- tr1::shared_ptr<const MetadataStringKey> vdb_format;
-
- tr1::shared_ptr<DependencyLabelSequence> build_dependencies_labels;
- tr1::shared_ptr<DependencyLabelSequence> run_dependencies_labels;
- tr1::shared_ptr<DependencyLabelSequence> post_dependencies_labels;
-
- Implementation(const QualifiedPackageName & q, const VersionSpec & v,
- const Environment * const e,
- const tr1::shared_ptr<const Repository> r, const FSEntry & f) :
- name(q),
- version(v),
- environment(e),
- repository(r),
- dir(f),
- has_keys(false),
- build_dependencies_labels(new DependencyLabelSequence),
- run_dependencies_labels(new DependencyLabelSequence),
- post_dependencies_labels(new DependencyLabelSequence)
- {
- build_dependencies_labels->push_back(make_shared_ptr(new DependencyBuildLabel("DEPEND")));
- run_dependencies_labels->push_back(make_shared_ptr(new DependencyRunLabel("RDEPEND")));
- post_dependencies_labels->push_back(make_shared_ptr(new DependencyPostLabel("PDEPEND")));
- }
- };
-}
-
VDBID::VDBID(const QualifiedPackageName & q, const VersionSpec & v,
const Environment * const e,
const tr1::shared_ptr<const Repository> & r,
const FSEntry & f) :
- PrivateImplementationPattern<VDBID>(new Implementation<VDBID>(q, v, e, r, f)),
- _imp(PrivateImplementationPattern<VDBID>::_imp)
-{
-}
-
-VDBID::~VDBID()
+ EInstalledRepositoryID(q, v, e, r, f)
{
}
-void
-VDBID::need_keys_added() const
+std::string
+VDBID::fs_location_raw_name() const
{
- Lock l(_imp->mutex);
-
- if (_imp->has_keys)
- return;
- _imp->has_keys = true;
-
-
- // fs_location key could have been loaded by the ::fs_location_key() already.
- if (! _imp->fs_location)
- {
- _imp->fs_location.reset(new LiteralMetadataFSEntryKey("VDBDIR", "VDB Location",
- mkt_internal, _imp->dir));
- add_metadata_key(_imp->fs_location);
- }
-
- Context context("When loading VDB ID keys from '" + stringify(_imp->dir) + "':");
-
- if (! eapi()->supported)
- {
- Log::get_instance()->message(ll_debug, lc_context) << "Not loading further keys for '" << *this << "' because EAPI '"
- << eapi()->name << "' is not supported";
- return;
- }
-
- const tr1::shared_ptr<const EAPIEbuildMetadataVariables> vars(eapi()->supported->ebuild_metadata_variables);
- if (! vars)
- throw InternalError(PALUDIS_HERE, "EAPI '" + eapi()->name + "' supported but has no ebuild_metadata_variables");
-
- const tr1::shared_ptr<const EAPIEbuildEnvironmentVariables> env(eapi()->supported->ebuild_environment_variables);
- if (! env)
- throw InternalError(PALUDIS_HERE, "EAPI '" + eapi()->name + "' supported but has no ebuild_environment_variables");
-
- if (! env->env_use.empty())
- if ((_imp->dir / env->env_use).exists())
- {
- _imp->use.reset(new EUseKey(_imp->environment, shared_from_this(), env->env_use, env->description_use,
- file_contents(_imp->dir / env->env_use), mkt_internal));
- add_metadata_key(_imp->use);
- }
-
- if (! vars->metadata_inherited.empty())
- if ((_imp->dir / vars->metadata_inherited).exists())
- {
- _imp->inherited.reset(new EInheritedKey(shared_from_this(), vars->metadata_inherited, vars->description_inherited,
- file_contents(_imp->dir / vars->metadata_inherited), mkt_internal));
- add_metadata_key(_imp->inherited);
- }
-
- if (! vars->metadata_iuse.empty())
- if ((_imp->dir / vars->metadata_iuse).exists())
- {
- _imp->iuse.reset(new EIUseKey(_imp->environment, shared_from_this(), vars->metadata_iuse, vars->description_iuse,
- file_contents(_imp->dir / vars->metadata_iuse), mkt_normal));
- add_metadata_key(_imp->iuse);
- }
-
- if (! vars->metadata_license.empty())
- if ((_imp->dir / vars->metadata_license).exists())
- {
- _imp->license.reset(new ELicenseKey(_imp->environment, shared_from_this(), vars->metadata_license, vars->description_license,
- file_contents(_imp->dir / vars->metadata_license), mkt_normal));
- add_metadata_key(_imp->license);
- }
-
- if (! vars->metadata_provide.empty())
- if ((_imp->dir / vars->metadata_provide).exists())
- {
- _imp->provide.reset(new EProvideKey(_imp->environment, shared_from_this(), vars->metadata_provide, vars->description_provide,
- file_contents(_imp->dir / vars->metadata_provide), mkt_internal));
- add_metadata_key(_imp->provide);
- }
-
- if (! vars->metadata_dependencies.empty())
- {
- if ((_imp->dir / vars->metadata_dependencies).exists())
- {
- DependenciesRewriter rewriter;
- parse_depend(file_contents(_imp->dir / vars->metadata_dependencies), *eapi(), shared_from_this())->accept(rewriter);
-
- _imp->build_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_dependencies + ".DEPEND",
- vars->description_dependencies + " (build)", rewriter.depend(), _imp->build_dependencies_labels, mkt_dependencies));
- add_metadata_key(_imp->build_dependencies);
-
- _imp->run_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_dependencies + ".RDEPEND",
- vars->description_dependencies + " (run)", rewriter.rdepend(), _imp->build_dependencies_labels, mkt_dependencies));
- add_metadata_key(_imp->run_dependencies);
-
- _imp->post_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_dependencies + ".PDEPEND",
- vars->description_dependencies + " (post)", rewriter.pdepend(), _imp->build_dependencies_labels, mkt_dependencies));
- add_metadata_key(_imp->post_dependencies);
- }
- }
- else
- {
- if (! vars->metadata_build_depend.empty())
- if ((_imp->dir / vars->metadata_build_depend).exists())
- {
- _imp->build_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_build_depend,
- vars->description_build_depend, file_contents(_imp->dir / vars->metadata_build_depend),
- _imp->build_dependencies_labels, mkt_dependencies));
- add_metadata_key(_imp->build_dependencies);
- }
-
- if (! vars->metadata_run_depend.empty())
- if ((_imp->dir / vars->metadata_run_depend).exists())
- {
- _imp->run_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_run_depend,
- vars->description_run_depend, file_contents(_imp->dir / vars->metadata_run_depend),
- _imp->run_dependencies_labels, mkt_dependencies));
- add_metadata_key(_imp->run_dependencies);
- }
-
- if (! vars->metadata_pdepend.empty())
- if ((_imp->dir / vars->metadata_pdepend).exists())
- {
- _imp->post_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_pdepend,
- vars->description_pdepend, file_contents(_imp->dir / vars->metadata_pdepend),
- _imp->post_dependencies_labels, mkt_dependencies));
- add_metadata_key(_imp->post_dependencies);
- }
- }
-
- if (! vars->metadata_restrict.empty())
- if ((_imp->dir / vars->metadata_restrict).exists())
- {
- _imp->restrictions.reset(new ERestrictKey(_imp->environment, shared_from_this(), vars->metadata_restrict, vars->description_restrict,
- file_contents(_imp->dir / vars->metadata_restrict), mkt_internal));
- add_metadata_key(_imp->restrictions);
- }
-
- if (! vars->metadata_src_uri.empty())
- if ((_imp->dir / vars->metadata_src_uri).exists())
- {
- _imp->src_uri.reset(new EFetchableURIKey(_imp->environment, shared_from_this(), vars->metadata_src_uri, vars->description_src_uri,
- file_contents(_imp->dir / vars->metadata_src_uri), mkt_dependencies));
- add_metadata_key(_imp->src_uri);
- }
-
- if (! vars->metadata_description.empty())
- if ((_imp->dir / vars->metadata_description).exists())
- {
- _imp->short_description.reset(new LiteralMetadataStringKey(vars->metadata_description,
- vars->description_description, mkt_significant, file_contents(_imp->dir / vars->metadata_description)));
- add_metadata_key(_imp->short_description);
- }
-
- if (! vars->metadata_homepage.empty())
- if ((_imp->dir / vars->metadata_homepage).exists())
- {
- _imp->homepage.reset(new ESimpleURIKey(_imp->environment, shared_from_this(), vars->metadata_homepage, vars->description_homepage,
- file_contents(_imp->dir / vars->metadata_homepage), mkt_significant));
- add_metadata_key(_imp->homepage);
- }
-
- _imp->contents.reset(new EContentsKey(shared_from_this(), "CONTENTS", "Contents",
- _imp->dir / "CONTENTS", mkt_internal));
- add_metadata_key(_imp->contents);
-
- _imp->installed_time.reset(new ECTimeKey(shared_from_this(), "INSTALLED_TIME", "Installed time",
- _imp->dir / "CONTENTS", mkt_normal));
- add_metadata_key(_imp->installed_time);
-
- if ((_imp->dir / "REPOSITORY").exists())
- {
- _imp->source_origin.reset(new LiteralMetadataStringKey("REPOSITORY", "Source repository",
- mkt_normal, file_contents(_imp->dir / "REPOSITORY")));
- add_metadata_key(_imp->source_origin);
- }
-
- if ((_imp->dir / "BINARY_REPOSITORY").exists())
- {
- _imp->binary_origin.reset(new LiteralMetadataStringKey("BINARY_REPOSITORY", "Binary repository",
- mkt_normal, file_contents(_imp->dir / "BINARY_REPOSITORY")));
- add_metadata_key(_imp->binary_origin);
- }
-
- if ((_imp->dir / "ASFLAGS").exists())
- {
- _imp->asflags.reset(new LiteralMetadataStringKey("ASFLAGS", "ASFLAGS",
- mkt_internal, file_contents(_imp->dir / "ASFLAGS")));
- add_metadata_key(_imp->asflags);
- }
-
- if ((_imp->dir / "CBUILD").exists())
- {
- _imp->cbuild.reset(new LiteralMetadataStringKey("CBUILD", "CBUILD",
- mkt_internal, file_contents(_imp->dir / "CBUILD")));
- add_metadata_key(_imp->cbuild);
- }
-
- if ((_imp->dir / "CFLAGS").exists())
- {
- _imp->cflags.reset(new LiteralMetadataStringKey("CFLAGS", "CFLAGS",
- mkt_internal, file_contents(_imp->dir / "CFLAGS")));
- add_metadata_key(_imp->cflags);
- }
-
- if ((_imp->dir / "CHOST").exists())
- {
- _imp->chost.reset(new LiteralMetadataStringKey("CHOST", "CHOST",
- mkt_internal, file_contents(_imp->dir / "CHOST")));
- add_metadata_key(_imp->chost);
- }
-
- if ((_imp->dir / "CXXFLAGS").exists())
- {
- _imp->cxxflags.reset(new LiteralMetadataStringKey("CXXFLAGS", "CXXFLAGS",
- mkt_internal, file_contents(_imp->dir / "CXXFLAGS")));
- add_metadata_key(_imp->cxxflags);
- }
-
- if ((_imp->dir / "LDFLAGS").exists())
- {
- _imp->ldflags.reset(new LiteralMetadataStringKey("LDFLAGS", "LDFLAGS",
- mkt_internal, file_contents(_imp->dir / "LDFLAGS")));
- add_metadata_key(_imp->ldflags);
- }
-
- if ((_imp->dir / "PKGMANAGER").exists())
- {
- _imp->pkgmanager.reset(new LiteralMetadataStringKey("PKGMANAGER", "Installed using",
- mkt_normal, file_contents(_imp->dir / "PKGMANAGER")));
- add_metadata_key(_imp->pkgmanager);
- }
-
- if ((_imp->dir / "VDB_FORMAT").exists())
- {
- _imp->vdb_format.reset(new LiteralMetadataStringKey("VDB_FORMAT", "VDB Format",
- mkt_internal, file_contents(_imp->dir / "VDB_FORMAT")));
- add_metadata_key(_imp->vdb_format);
- }
-}
-
-void
-VDBID::need_masks_added() const
-{
-}
-
-const std::string
-VDBID::canonical_form(const PackageIDCanonicalForm f) const
-{
- switch (f)
- {
- case idcf_full:
- if (_imp->slot)
- return stringify(name()) + "-" + stringify(version()) + ":" + stringify(slot()) + "::" +
- stringify(repository()->name());
-
- return stringify(name()) + "-" + stringify(version()) + "::" + stringify(repository()->name());
-
- case idcf_no_version:
- if (_imp->slot)
- return stringify(name()) + ":" + stringify(slot()) + "::" +
- stringify(repository()->name());
-
- return stringify(name()) + "::" + stringify(repository()->name());
-
- case idcf_version:
- return stringify(version());
-
- case last_idcf:
- break;
- }
-
- throw InternalError(PALUDIS_HERE, "Bad PackageIDCanonicalForm");
-}
-
-const QualifiedPackageName
-VDBID::name() const
-{
- return _imp->name;
-}
-
-const VersionSpec
-VDBID::version() const
-{
- return _imp->version;
-}
-
-const SlotName
-VDBID::slot() const
-{
- Lock l(_imp->mutex);
-
- if (_imp->slot)
- return *_imp->slot;
-
- Context context("When finding SLOT for '" + stringify(name()) + "-" + stringify(version()) + "::"
- + stringify(repository()->name()) + "':");
-
- if ((_imp->dir / "SLOT").exists())
- _imp->slot.reset(new SlotName(file_contents(_imp->dir / "SLOT")));
- else
- {
- Log::get_instance()->message(ll_warning, lc_context) << "No SLOT entry in '" << _imp->dir << "', pretending '0'";
- _imp->slot.reset(new SlotName("0"));
- }
-
- return *_imp->slot;
-}
-
-const tr1::shared_ptr<const Repository>
-VDBID::repository() const
-{
- return _imp->repository;
-}
-
-const tr1::shared_ptr<const EAPI>
-VDBID::eapi() const
-{
- Lock l(_imp->mutex);
-
- if (_imp->eapi)
- return _imp->eapi;
-
- Context context("When finding EAPI for '" + canonical_form(idcf_full) + "':");
-
- if ((_imp->dir / "EAPI").exists())
- _imp->eapi = EAPIData::get_instance()->eapi_from_string(file_contents(_imp->dir / "EAPI"));
- else
- {
- Log::get_instance()->message(ll_debug, lc_context) << "No EAPI entry in '" << _imp->dir << "', pretending '"
- << _imp->environment->default_distribution() << "'";
- _imp->eapi = EAPIData::get_instance()->eapi_from_string(
- DistributionData::get_instance()->distribution_from_string(
- _imp->environment->default_distribution())->default_ebuild_eapi_when_unspecified);
- }
-
- return _imp->eapi;
-}
-
-const tr1::shared_ptr<const MetadataPackageIDKey>
-VDBID::virtual_for_key() const
-{
- return tr1::shared_ptr<const MetadataPackageIDKey>();
-}
-
-const tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> >
-VDBID::keywords_key() const
-{
- return tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> >();
-}
-
-const tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> >
-VDBID::eclass_keywords_key() const
-{
- return tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> >();
-}
-
-const tr1::shared_ptr<const MetadataCollectionKey<UseFlagNameSet> >
-VDBID::use_key() const
-{
- need_keys_added();
- return _imp->use;
-}
-
-const tr1::shared_ptr<const MetadataCollectionKey<IUseFlagSet> >
-VDBID::iuse_key() const
-{
- need_keys_added();
- return _imp->iuse;
-}
-
-const tr1::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> >
-VDBID::license_key() const
-{
- need_keys_added();
- return _imp->license;
-}
-
-const tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > >
-VDBID::inherited_key() const
-{
- need_keys_added();
- return _imp->inherited;
-}
-
-const tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> >
-VDBID::provide_key() const
-{
- need_keys_added();
- return _imp->provide;
-}
-
-const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
-VDBID::build_dependencies_key() const
-{
- need_keys_added();
- return _imp->build_dependencies;
-}
-
-const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
-VDBID::run_dependencies_key() const
-{
- need_keys_added();
- return _imp->run_dependencies;
-}
-
-const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
-VDBID::post_dependencies_key() const
-{
- need_keys_added();
- return _imp->post_dependencies;
-}
-
-const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
-VDBID::suggested_dependencies_key() const
-{
- return tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >();
-}
-
-const tr1::shared_ptr<const MetadataSpecTreeKey<RestrictSpecTree> >
-VDBID::restrict_key() const
-{
- need_keys_added();
- return _imp->restrictions;
-}
-
-const tr1::shared_ptr<const MetadataSpecTreeKey<FetchableURISpecTree> >
-VDBID::fetches_key() const
-{
- need_keys_added();
- return _imp->src_uri;
-}
-
-const tr1::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> >
-VDBID::homepage_key() const
-{
- need_keys_added();
- return _imp->homepage;
-}
-
-const tr1::shared_ptr<const MetadataStringKey>
-VDBID::short_description_key() const
-{
- need_keys_added();
- return _imp->short_description;
-}
-
-const tr1::shared_ptr<const MetadataStringKey>
-VDBID::long_description_key() const
-{
- return tr1::shared_ptr<const MetadataStringKey>();
-}
-
-const tr1::shared_ptr<const MetadataContentsKey>
-VDBID::contents_key() const
-{
- need_keys_added();
- return _imp->contents;
-}
-
-const tr1::shared_ptr<const MetadataTimeKey>
-VDBID::installed_time_key() const
-{
- need_keys_added();
- return _imp->installed_time;
-}
-
-const tr1::shared_ptr<const MetadataStringKey>
-VDBID::source_origin_key() const
-{
- need_keys_added();
- return _imp->source_origin;
-}
-
-const tr1::shared_ptr<const MetadataStringKey>
-VDBID::binary_origin_key() const
-{
- need_keys_added();
- return _imp->binary_origin;
-}
-
-const tr1::shared_ptr<const MetadataFSEntryKey>
-VDBID::fs_location_key() const
-{
- // Avoid loading whole metadata
- if (! _imp->fs_location)
- {
- Lock l(_imp->mutex);
-
- _imp->fs_location.reset(new LiteralMetadataFSEntryKey("VDBDIR", "VDB Location", mkt_internal, _imp->dir));
- add_metadata_key(_imp->fs_location);
- }
-
- return _imp->fs_location;
-}
-
-const tr1::shared_ptr<const MetadataSizeKey>
-VDBID::size_of_download_required_key() const
-{
- return tr1::shared_ptr<const MetadataSizeKey>();
-}
-
-const tr1::shared_ptr<const MetadataSizeKey>
-VDBID::size_of_all_distfiles_key() const
-{
- return tr1::shared_ptr<const MetadataSizeKey>();
-}
-
-
-bool
-VDBID::arbitrary_less_than_comparison(const PackageID &) const
-{
- return false;
-}
-
-std::size_t
-VDBID::extra_hash_value() const
-{
- return 0;
-}
-
-namespace
-{
- struct SupportsActionQuery :
- ConstVisitor<SupportsActionTestVisitorTypes>
- {
- bool result;
-
- SupportsActionQuery() :
- result(false)
- {
- }
-
- void visit(const SupportsActionTest<InstalledAction> &)
- {
- result = true;
- }
-
- void visit(const SupportsActionTest<InstallAction> &)
- {
- }
-
- void visit(const SupportsActionTest<ConfigAction> &)
- {
- result = true;
- }
-
- void visit(const SupportsActionTest<FetchAction> &)
- {
- }
-
- void visit(const SupportsActionTest<PretendAction> &)
- {
- }
-
- void visit(const SupportsActionTest<InfoAction> &)
- {
- result = true;
- }
-
- void visit(const SupportsActionTest<UninstallAction> &)
- {
- result = true;
- }
- };
-}
-
-bool
-VDBID::supports_action(const SupportsActionTestBase & b) const
-{
- SupportsActionQuery q;
- b.accept(q);
- return q.result;
-}
-
-namespace
-{
- struct PerformAction :
- ConstVisitor<ActionVisitorTypes>
- {
- const tr1::shared_ptr<const erepository::ERepositoryID> id;
-
- PerformAction(const tr1::shared_ptr<const erepository::ERepositoryID> i) :
- id(i)
- {
- }
-
- void visit(const UninstallAction & a)
- {
- tr1::static_pointer_cast<const VDBRepository>(id->repository())->perform_uninstall(id,
- a.options, false);
- }
-
- void visit(const InstalledAction &)
- {
- }
-
- void visit(const ConfigAction &)
- {
- tr1::static_pointer_cast<const VDBRepository>(id->repository())->perform_config(id);
- }
-
- void visit(const InfoAction &)
- {
- tr1::static_pointer_cast<const VDBRepository>(id->repository())->perform_info(id);
- }
-
- void visit(const InstallAction & a) PALUDIS_ATTRIBUTE((noreturn));
- void visit(const PretendAction & a) PALUDIS_ATTRIBUTE((noreturn));
- void visit(const FetchAction & a) PALUDIS_ATTRIBUTE((noreturn));
- };
-
- void PerformAction::visit(const InstallAction & a)
- {
- throw UnsupportedActionError(*id, a);
- }
-
- void PerformAction::visit(const PretendAction & a)
- {
- throw UnsupportedActionError(*id, a);
- }
-
- void PerformAction::visit(const FetchAction & a)
- {
- throw UnsupportedActionError(*id, a);
- }
+ return "VDBDIR";
}
-void
-VDBID::perform_action(Action & a) const
+std::string
+VDBID::fs_location_human_name() const
{
- PerformAction b(shared_from_this());
- a.accept(b);
+ return "VDB Directory";
}
-const tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> >
-VDBID::contains_key() const
+std::string
+VDBID::contents_filename() const
{
- return tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> >();
+ return "CONTENTS";
}
-const tr1::shared_ptr<const MetadataPackageIDKey>
-VDBID::contained_in_key() const
+tr1::shared_ptr<MetadataContentsKey>
+VDBID::make_contents_key() const
{
- return tr1::shared_ptr<const MetadataPackageIDKey>();
+ return make_shared_ptr(new EContentsKey(shared_from_this(), "CONTENTS", "Contents",
+ fs_location_key()->value() / "CONTENTS", mkt_internal));
}
diff --git a/paludis/repositories/e/vdb_id.hh b/paludis/repositories/e/vdb_id.hh
index 6c1481c..015b9bc 100644
--- a/paludis/repositories/e/vdb_id.hh
+++ b/paludis/repositories/e/vdb_id.hh
@@ -20,80 +20,25 @@
#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_GENTOO_VDB_ID_HH
#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GENTOO_VDB_ID_HH 1
-#include <paludis/package_id.hh>
-#include <paludis/metadata_key.hh>
-#include <paludis/environment-fwd.hh>
-#include <paludis/util/fs_entry-fwd.hh>
-#include <paludis/repositories/e/e_repository_id.hh>
+#include <paludis/repositories/e/e_installed_repository_id.hh>
namespace paludis
{
namespace erepository
{
class VDBID :
- public ERepositoryID,
- public tr1::enable_shared_from_this<VDBID>,
- private PrivateImplementationPattern<VDBID>
+ public EInstalledRepositoryID
{
- private:
- PrivateImplementationPattern<VDBID>::ImpPtr & _imp;
-
- protected:
- virtual void need_keys_added() const;
- virtual void need_masks_added() const;
-
public:
VDBID(const QualifiedPackageName &, const VersionSpec &,
const Environment * const,
const tr1::shared_ptr<const Repository> &,
const FSEntry & file);
- ~VDBID();
-
- virtual const std::string canonical_form(const PackageIDCanonicalForm) const;
-
- virtual const QualifiedPackageName name() const;
- virtual const VersionSpec version() const;
- virtual const SlotName slot() const;
- virtual const tr1::shared_ptr<const Repository> repository() const;
- virtual const tr1::shared_ptr<const EAPI> eapi() const;
-
- virtual const tr1::shared_ptr<const MetadataPackageIDKey> virtual_for_key() const;
- virtual const tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const;
- virtual const tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > eclass_keywords_key() const;
- virtual const tr1::shared_ptr<const MetadataCollectionKey<IUseFlagSet> > iuse_key() const;
- virtual const tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide_key() const;
- virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > build_dependencies_key() const;
- virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > run_dependencies_key() const;
- virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > post_dependencies_key() const;
- virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > suggested_dependencies_key() const;
- virtual const tr1::shared_ptr<const MetadataSpecTreeKey<RestrictSpecTree> > restrict_key() const;
- virtual const tr1::shared_ptr<const MetadataSpecTreeKey<FetchableURISpecTree> > fetches_key() const;
- virtual const tr1::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> > homepage_key() const;
- virtual const tr1::shared_ptr<const MetadataStringKey> short_description_key() const;
- virtual const tr1::shared_ptr<const MetadataStringKey> long_description_key() const;
- virtual const tr1::shared_ptr<const MetadataContentsKey> contents_key() const;
- virtual const tr1::shared_ptr<const MetadataTimeKey> installed_time_key() const;
- virtual const tr1::shared_ptr<const MetadataStringKey> source_origin_key() const;
- virtual const tr1::shared_ptr<const MetadataStringKey> binary_origin_key() const;
- virtual const tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> > contains_key() const;
- virtual const tr1::shared_ptr<const MetadataPackageIDKey> contained_in_key() const;
- virtual const tr1::shared_ptr<const MetadataFSEntryKey> fs_location_key() const;
- virtual const tr1::shared_ptr<const MetadataSizeKey> size_of_download_required_key() const;
- virtual const tr1::shared_ptr<const MetadataSizeKey> size_of_all_distfiles_key() const;
-
- virtual const tr1::shared_ptr<const MetadataCollectionKey<UseFlagNameSet> > use_key() const;
- virtual const tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > inherited_key() const;
- virtual const tr1::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> > license_key() const;
-
- virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual void perform_action(Action &) const;
-
- virtual bool arbitrary_less_than_comparison(const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual std::size_t extra_hash_value() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual std::string fs_location_raw_name() const;
+ virtual std::string fs_location_human_name() const;
+ virtual std::string contents_filename() const;
+ virtual tr1::shared_ptr<MetadataContentsKey> make_contents_key() const;
};
}
}
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index 0fbe87b..49a0b40 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -139,7 +139,13 @@ namespace paludis
}
VDBRepository::VDBRepository(const VDBRepositoryParams & p) :
- Repository(RepositoryName("installed"),
+ EInstalledRepository(
+ EInstalledRepositoryParams::create()
+ .environment(p.environment)
+ .root(p.root)
+ .builddir(p.builddir)
+ .world(p.world),
+ p.name,
RepositoryCapabilities::create()
.sets_interface(this)
.syncable_interface(0)
@@ -226,14 +232,6 @@ VDBRepository::category_names() const
return result;
}
-tr1::shared_ptr<const CategoryNamePartSet>
-VDBRepository::unimportant_category_names() const
-{
- tr1::shared_ptr<CategoryNamePartSet> result(make_shared_ptr(new CategoryNamePartSet));
- result->insert(CategoryNamePart("virtual"));
- return result;
-}
-
tr1::shared_ptr<const QualifiedPackageNameSet>
VDBRepository::package_names(const CategoryNamePart & c) const
{
@@ -273,35 +271,6 @@ VDBRepository::package_ids(const QualifiedPackageName & n) const
return _imp->ids.find(n)->second;
}
-UseFlagState
-VDBRepository::query_use(const UseFlagName & f, const PackageID & e) const
-{
- Lock l(*_imp->big_nasty_mutex);
-
- if (this != e.repository().get())
- return use_unspecified;
-
- if (! static_cast<const VDBID *>(&e)->use_key())
- return use_unspecified;
-
- if (static_cast<const VDBID *>(&e)->use_key()->value()->end() != static_cast<const VDBID *>(&e)->use_key()->value()->find(f))
- return use_enabled;
- else
- return use_disabled;
-}
-
-bool
-VDBRepository::query_use_mask(const UseFlagName & u, const PackageID & e) const
-{
- return use_disabled == query_use(u, e);
-}
-
-bool
-VDBRepository::query_use_force(const UseFlagName & u, const PackageID & e) const
-{
- return use_enabled == query_use(u, e);
-}
-
tr1::shared_ptr<Repository>
VDBRepository::make_vdb_repository(
Environment * const env,
@@ -360,6 +329,10 @@ VDBRepository::make_vdb_repository(
Log::get_instance()->message(ll_warning, lc_context) << "Key 'buildroot' is deprecated, use 'builddir' instead";
}
+ std::string name;
+ if (m->end() == m->find("name") || ((name = m->find("name")->second)).empty())
+ name = "installed";
+
return tr1::shared_ptr<Repository>(new VDBRepository(VDBRepositoryParams::create()
.environment(env)
.location(location)
@@ -367,6 +340,7 @@ VDBRepository::make_vdb_repository(
.world(world)
.builddir(builddir)
.provides_cache(provides_cache)
+ .name(RepositoryName(name))
.names_cache(names_cache)));
}
@@ -469,208 +443,6 @@ VDBRepository::perform_uninstall(const tr1::shared_ptr<const ERepositoryID> & id
}
void
-VDBRepository::perform_config(const tr1::shared_ptr<const ERepositoryID> & id) const
-{
- Context context("When configuring '" + stringify(*id) + "':");
-
- if (! _imp->params.root.is_directory())
- throw InstallActionError("Couldn't configure '" + stringify(*id) +
- "' because root ('" + stringify(_imp->params.root) + "') is not a directory");
-
- tr1::shared_ptr<FSEntrySequence> eclassdirs(new FSEntrySequence);
- eclassdirs->push_back(FSEntry(_imp->params.location / stringify(id->name().category) /
- (stringify(id->name().package) + "-" + stringify(id->version()))));
-
- FSEntry pkg_dir(_imp->params.location / stringify(id->name().category) /
- (stringify(id->name().package) + "-" + stringify(id->version())));
-
- tr1::shared_ptr<FSEntry> load_env(new FSEntry(pkg_dir / "environment.bz2"));
- EAPIPhases phases(id->eapi()->supported->ebuild_phases->ebuild_config);
-
- for (EAPIPhases::ConstIterator phase(phases.begin_phases()), phase_end(phases.end_phases()) ;
- phase != phase_end ; ++phase)
- {
- EbuildConfigCommand config_cmd(EbuildCommandParams::create()
- .environment(_imp->params.environment)
- .package_id(id)
- .ebuild_dir(pkg_dir)
- .ebuild_file(pkg_dir / (stringify(id->name().package) + "-" + stringify(id->version()) + ".ebuild"))
- .files_dir(pkg_dir)
- .eclassdirs(eclassdirs)
- .exlibsdirs(make_shared_ptr(new FSEntrySequence))
- .portdir(_imp->params.location)
- .distdir(pkg_dir)
- .sandbox(phase->option("sandbox"))
- .userpriv(phase->option("userpriv"))
- .commands(join(phase->begin_commands(), phase->end_commands(), " "))
- .builddir(_imp->params.builddir),
-
- EbuildConfigCommandParams::create()
- .root(stringify(_imp->params.root) + "/")
- .load_environment(load_env.get()));
-
- config_cmd();
- }
-}
-
-void
-VDBRepository::perform_info(const tr1::shared_ptr<const ERepositoryID> & id) const
-{
- Context context("When infoing '" + stringify(*id) + "':");
-
- if (! _imp->params.root.is_directory())
- throw InstallActionError("Couldn't info '" + stringify(*id) +
- "' because root ('" + stringify(_imp->params.root) + "') is not a directory");
-
- tr1::shared_ptr<FSEntrySequence> eclassdirs(new FSEntrySequence);
- eclassdirs->push_back(FSEntry(_imp->params.location / stringify(id->name().category) /
- (stringify(id->name().package) + "-" + stringify(id->version()))));
-
- FSEntry pkg_dir(_imp->params.location / stringify(id->name().category) /
- (stringify(id->name().package) + "-" + stringify(id->version())));
- tr1::shared_ptr<FSEntry> load_env(new FSEntry(pkg_dir / "environment.bz2"));
-
- EAPIPhases phases(id->eapi()->supported->ebuild_phases->ebuild_info);
-
- for (EAPIPhases::ConstIterator phase(phases.begin_phases()), phase_end(phases.end_phases()) ;
- phase != phase_end ; ++phase)
- {
- if (phase->option("installed=false"))
- continue;
-
- /* try to find an info_vars file from the original repo */
- FSEntry i("/dev/null");
- if (id->source_origin_key())
- {
- RepositoryName rn(id->source_origin_key()->value());
- if (_imp->params.environment->package_database()->has_repository_named(rn))
- {
- const tr1::shared_ptr<const Repository> r(_imp->params.environment->package_database()->fetch_repository(rn));
- if (r->e_interface)
- {
- i = r->e_interface->info_variables_file(r->e_interface->params().location / "profiles");
-
- /* also try its master, if it has one */
- if ((! i.exists()) && r->e_interface->params().master_repository)
- i = r->e_interface->info_variables_file(r->e_interface->params().master_repository->params().location / "profiles");
- }
- }
- }
-
- /* try to find an info_vars file from any repo */
- if (i == FSEntry("/dev/null"))
- {
- for (PackageDatabase::RepositoryConstIterator r(_imp->params.environment->package_database()->begin_repositories()),
- r_end(_imp->params.environment->package_database()->end_repositories()) ;
- r != r_end ; ++r)
- {
- if (! (*r)->e_interface)
- continue;
-
- i = (*r)->e_interface->info_variables_file((*r)->e_interface->params().location / "profiles");
- if (i.exists())
- break;
- }
- }
-
- EbuildInfoCommand info_cmd(EbuildCommandParams::create()
- .environment(_imp->params.environment)
- .package_id(id)
- .ebuild_dir(pkg_dir)
- .ebuild_file(pkg_dir / (stringify(id->name().package) + "-" + stringify(id->version()) + ".ebuild"))
- .files_dir(pkg_dir)
- .eclassdirs(eclassdirs)
- .exlibsdirs(make_shared_ptr(new FSEntrySequence))
- .portdir(_imp->params.location)
- .distdir(pkg_dir)
- .sandbox(phase->option("sandbox"))
- .userpriv(phase->option("userpriv"))
- .commands(join(phase->begin_commands(), phase->end_commands(), " "))
- .builddir(_imp->params.builddir),
-
- EbuildInfoCommandParams::create()
- .root(stringify(_imp->params.root) + "/")
- .use("")
- .use_expand("")
- .expand_vars(make_shared_ptr(new Map<std::string, std::string>))
- .profiles(make_shared_ptr(new FSEntrySequence))
- .info_vars(i)
- .load_environment(load_env.get()));
-
- info_cmd();
- }
-}
-
-tr1::shared_ptr<SetSpecTree::ConstItem>
-VDBRepository::package_set(const SetName & s) const
-{
- using namespace tr1::placeholders;
-
- Context context("When fetching package set '" + stringify(s) + "' from '" +
- stringify(name()) + "':");
-
- if ("everything" == s.data())
- {
- tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > result(new ConstTreeSequence<SetSpecTree, AllDepSpec>(
- tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
- tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(SetName("everything"), stringify(name())));
-
- need_category_names();
- std::for_each(_imp->categories.begin(), _imp->categories.end(),
- tr1::bind(tr1::mem_fn(&VDBRepository::need_package_ids), this,
- tr1::bind<CategoryNamePart>(tr1::mem_fn(
- &std::pair<const CategoryNamePart, tr1::shared_ptr<QualifiedPackageNameSet> >::first), _1)));
-
- for (CategoryMap::const_iterator i(_imp->categories.begin()), i_end(_imp->categories.end()) ;
- i != i_end ; ++i)
- for (QualifiedPackageNameSet::ConstIterator e(i->second->begin()), e_end(i->second->end()) ;
- e != e_end ; ++e)
- {
- tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(make_package_dep_spec().package(*e)));
- spec->set_tag(tag);
- result->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>(spec)));
- }
-
- return result;
- }
- else if ("world" == s.data())
- {
- tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(SetName("world"), stringify(name())));
-
- if (_imp->params.world.exists())
- {
- SetFile world(SetFileParams::create()
- .file_name(_imp->params.world)
- .type(sft_simple)
- .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
- .tag(tag)
- .environment(_imp->params.environment));
- return world.contents();
- }
- else
- Log::get_instance()->message(ll_warning, lc_no_context,
- "World file '" + stringify(_imp->params.world) +
- "' doesn't exist");
-
- return tr1::shared_ptr<SetSpecTree::ConstItem>(new ConstTreeSequence<SetSpecTree, AllDepSpec>(
- tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
- }
- else
- return tr1::shared_ptr<SetSpecTree::ConstItem>();
-}
-
-tr1::shared_ptr<const SetNameSet>
-VDBRepository::sets_list() const
-{
- Context context("While generating the list of sets:");
-
- tr1::shared_ptr<SetNameSet> result(new SetNameSet);
- result->insert(SetName("everything"));
- result->insert(SetName("world"));
- return result;
-}
-
-void
VDBRepository::invalidate()
{
Lock l(*_imp->big_nasty_mutex);
@@ -683,124 +455,6 @@ VDBRepository::invalidate_masks()
{
}
-void
-VDBRepository::add_string_to_world(const std::string & n) const
-{
- using namespace tr1::placeholders;
-
- Lock l(*_imp->big_nasty_mutex);
-
- Context context("When adding '" + n + "' to world file '" + stringify(_imp->params.world) + "':");
-
- if (! _imp->params.world.exists())
- {
- std::ofstream f(stringify(_imp->params.world).c_str());
- if (! f)
- {
- Log::get_instance()->message(ll_warning, lc_no_context, "Cannot create world file '"
- + stringify(_imp->params.world) + "'");
- return;
- }
- }
-
- SetFile world(SetFileParams::create()
- .file_name(_imp->params.world)
- .type(sft_simple)
- .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
- .tag(tr1::shared_ptr<DepTag>())
- .environment(_imp->params.environment));
- world.add(n);
- world.rewrite();
-}
-
-void
-VDBRepository::remove_string_from_world(const std::string & n) const
-{
- using namespace tr1::placeholders;
-
- Lock l(*_imp->big_nasty_mutex);
-
- Context context("When removing '" + n + "' from world file '" + stringify(_imp->params.world) + "':");
-
- if (_imp->params.world.exists())
- {
- SetFile world(SetFileParams::create()
- .file_name(_imp->params.world)
- .type(sft_simple)
- .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
- .tag(tr1::shared_ptr<DepTag>())
- .environment(_imp->params.environment));
-
- world.remove(n);
- world.rewrite();
- }
-}
-
-void
-VDBRepository::add_to_world(const QualifiedPackageName & n) const
-{
- add_string_to_world(stringify(n));
-}
-
-void
-VDBRepository::add_to_world(const SetName & n) const
-{
- add_string_to_world(stringify(n));
-}
-
-void
-VDBRepository::remove_from_world(const QualifiedPackageName & n) const
-{
- remove_string_from_world(stringify(n));
-}
-
-void
-VDBRepository::remove_from_world(const SetName & n) const
-{
- remove_string_from_world(stringify(n));
-}
-
-std::string
-VDBRepository::get_environment_variable(
- const tr1::shared_ptr<const PackageID> & id,
- const std::string & var) const
-{
- Context context("When fetching environment variable '" + var + "' for '" +
- stringify(*id) + "':");
-
- FSEntry vdb_dir(_imp->params.location / stringify(id->name().category)
- / (stringify(id->name().package) + "-" +
- stringify(id->version())));
-
- if (! vdb_dir.is_directory_or_symlink_to_directory())
- throw ActionError("Could not find VDB entry for '" + stringify(*id) + "'");
-
- if ((vdb_dir / var).is_regular_file_or_symlink_to_regular_file())
- {
- std::ifstream f(stringify(vdb_dir / var).c_str());
- if (! f)
- throw ActionError("Could not read '" + stringify(vdb_dir / var) + "'");
- return strip_trailing_string(
- std::string((std::istreambuf_iterator<char>(f)),
- std::istreambuf_iterator<char>()), "\n");
- }
- else if ((vdb_dir / "environment.bz2").is_regular_file_or_symlink_to_regular_file())
- {
- std::stringstream p;
- Command cmd(Command("bash -c '( bunzip2 < " + stringify(vdb_dir / "environment.bz2" ) +
- " ; echo echo \\$" + var + " ) | bash 2>/dev/null'").with_captured_stdout_stream(&p));
- int exit_status(run_command(cmd));
- std::string result(strip_trailing_string(std::string(
- (std::istreambuf_iterator<char>(p)),
- std::istreambuf_iterator<char>()), "\n"));
- if (0 != exit_status)
- throw ActionError("Could not load environment.bz2");
- return result;
- }
- else
- throw ActionError("Could not get variable '" + var + "' for '" + stringify(*id) + "'");
-}
-
tr1::shared_ptr<const RepositoryProvidesInterface::ProvidesSequence>
VDBRepository::provided_packages() const
{
@@ -815,39 +469,6 @@ VDBRepository::provided_packages() const
return _imp->provides;
}
-tr1::shared_ptr<const UseFlagNameSet>
-VDBRepository::arch_flags() const
-{
- return tr1::shared_ptr<const UseFlagNameSet>(new UseFlagNameSet);
-}
-
-tr1::shared_ptr<const UseFlagNameSet>
-VDBRepository::use_expand_flags() const
-{
- return tr1::shared_ptr<const UseFlagNameSet>(new UseFlagNameSet);
-}
-
-tr1::shared_ptr<const UseFlagNameSet>
-VDBRepository::use_expand_prefixes() const
-{
- return tr1::shared_ptr<const UseFlagNameSet>(new UseFlagNameSet);
-}
-
-tr1::shared_ptr<const UseFlagNameSet>
-VDBRepository::use_expand_hidden_prefixes() const
-{
- return tr1::shared_ptr<const UseFlagNameSet>(new UseFlagNameSet);
-}
-
-char
-VDBRepository::use_expand_separator(const PackageID & id) const
-{
- if (this != id.repository().get())
- return '\0';
- const tr1::shared_ptr<const EAPI> & eapi(static_cast<const VDBID &>(id).eapi());
- return eapi->supported ? eapi->supported->ebuild_options->use_expand_separator : '\0';
-}
-
bool
VDBRepository::load_provided_using_cache() const
{
@@ -1070,31 +691,6 @@ VDBRepository::category_names_containing_package(const PackageNamePart & p) cons
return result ? result : Repository::category_names_containing_package(p);
}
-bool
-VDBRepository::is_suitable_destination_for(const PackageID & e) const
-{
- std::string f(e.repository()->format_key() ? e.repository()->format_key()->value() : "");
- return f == "ebuild";
-}
-
-bool
-VDBRepository::is_default_destination() const
-{
- return _imp->params.environment->root() == installed_root_key()->value();
-}
-
-std::string
-VDBRepository::describe_use_flag(const UseFlagName &, const PackageID &) const
-{
- return "";
-}
-
-bool
-VDBRepository::want_pre_post_phases() const
-{
- return true;
-}
-
void
VDBRepository::merge(const MergeOptions & m)
{
@@ -1104,7 +700,7 @@ VDBRepository::merge(const MergeOptions & m)
if (! is_suitable_destination_for(*m.package_id))
throw InstallActionError("Not a suitable destination for '" + stringify(*m.package_id) + "'");
- bool is_replace(package_id_if_exists(m.package_id->name(), m.package_id->version()));
+ tr1::shared_ptr<const ERepositoryID> is_replace(package_id_if_exists(m.package_id->name(), m.package_id->version()));
FSEntry tmp_vdb_dir(_imp->params.location);
if (! tmp_vdb_dir.exists())
@@ -1174,7 +770,7 @@ VDBRepository::merge(const MergeOptions & m)
if (is_replace)
{
UninstallActionOptions uninstall_options(false);
- perform_uninstall(tr1::static_pointer_cast<const ERepositoryID>(m.package_id), uninstall_options, true);
+ perform_uninstall(is_replace, uninstall_options, true);
}
VDBPostMergeCommand post_merge_command(
@@ -1184,15 +780,6 @@ VDBRepository::merge(const MergeOptions & m)
post_merge_command();
}
-HookResult
-VDBRepository::perform_hook(const Hook & hook) const
-{
- Context context("When performing hook '" + stringify(hook.name()) + "' for repository '"
- + stringify(name()) + "':");
-
- return HookResult(0, "");
-}
-
void
VDBRepository::need_category_names() const
{
@@ -1288,60 +875,6 @@ VDBRepository::package_id_if_exists(const QualifiedPackageName & q, const Versio
return tr1::shared_ptr<const ERepositoryID>();
}
-namespace
-{
- struct SupportsActionQuery :
- ConstVisitor<SupportsActionTestVisitorTypes>
- {
- bool result;
-
- SupportsActionQuery() :
- result(false)
- {
- }
-
- void visit(const SupportsActionTest<InstalledAction> &)
- {
- result = true;
- }
-
- void visit(const SupportsActionTest<InstallAction> &)
- {
- }
-
- void visit(const SupportsActionTest<ConfigAction> &)
- {
- result = true;
- }
-
- void visit(const SupportsActionTest<PretendAction> &)
- {
- }
-
- void visit(const SupportsActionTest<FetchAction> &)
- {
- }
-
- void visit(const SupportsActionTest<InfoAction> &)
- {
- result = true;
- }
-
- void visit(const SupportsActionTest<UninstallAction> &)
- {
- result = true;
- }
- };
-}
-
-bool
-VDBRepository::some_ids_might_support_action(const SupportsActionTestBase & a) const
-{
- SupportsActionQuery q;
- a.accept(q);
- return q.result;
-}
-
void
VDBRepository::need_keys_added() const
{
diff --git a/paludis/repositories/e/vdb_repository.hh b/paludis/repositories/e/vdb_repository.hh
index 2bb3e50..1c514aa 100644
--- a/paludis/repositories/e/vdb_repository.hh
+++ b/paludis/repositories/e/vdb_repository.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
*
* 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
@@ -20,6 +20,7 @@
#ifndef PALUDIS_GUARD_PALUDIS_VDB_REPOSITORY_HH
#define PALUDIS_GUARD_PALUDIS_VDB_REPOSITORY_HH 1
+#include <paludis/repositories/e/e_installed_repository.hh>
#include <paludis/repository.hh>
#include <paludis/action-fwd.hh>
#include <paludis/util/attributes.hh>
@@ -49,14 +50,8 @@ namespace paludis
* \ingroup grpvdbrepository
*/
class PALUDIS_VISIBLE VDBRepository :
- public Repository,
- public RepositoryUseInterface,
- public RepositorySetsInterface,
- public RepositoryWorldInterface,
- public RepositoryEnvironmentVariableInterface,
+ public erepository::EInstalledRepository,
public RepositoryProvidesInterface,
- public RepositoryDestinationInterface,
- public RepositoryHookInterface,
public tr1::enable_shared_from_this<VDBRepository>,
public PrivateImplementationPattern<VDBRepository>
{
@@ -72,9 +67,6 @@ namespace paludis
void need_category_names() const;
void need_package_ids(const CategoryNamePart &) const;
- void add_string_to_world(const std::string & n) const;
- void remove_string_from_world(const std::string &) const;
-
const tr1::shared_ptr<const erepository::ERepositoryID> package_id_if_exists(const QualifiedPackageName &,
const VersionSpec &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -110,96 +102,18 @@ namespace paludis
virtual void regenerate_cache() const;
- ///\name For use by VDBID
- ///\{
-
- void perform_uninstall(const tr1::shared_ptr<const erepository::ERepositoryID> & id,
+ virtual void perform_uninstall(const tr1::shared_ptr<const erepository::ERepositoryID> & id,
const UninstallActionOptions & o, bool reinstalling) const;
- void perform_config(const tr1::shared_ptr<const erepository::ERepositoryID> & id) const;
-
- void perform_info(const tr1::shared_ptr<const erepository::ERepositoryID> & id) const;
-
- ///\}
-
- /* RepositoryUseInterface */
-
- virtual UseFlagState query_use(const UseFlagName &, const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual bool query_use_mask(const UseFlagName &, const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual bool query_use_force(const UseFlagName &, const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual tr1::shared_ptr<const UseFlagNameSet> arch_flags() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual tr1::shared_ptr<const UseFlagNameSet> use_expand_flags() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual tr1::shared_ptr<const UseFlagNameSet> use_expand_hidden_prefixes() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual tr1::shared_ptr<const UseFlagNameSet> use_expand_prefixes() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual char use_expand_separator(const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual std::string describe_use_flag(const UseFlagName &,
- const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- /* RepositorySetsInterface */
-
- virtual tr1::shared_ptr<SetSpecTree::ConstItem> package_set(const SetName & id) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual tr1::shared_ptr<const SetNameSet> sets_list() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- /* RepositoryWorldInterface */
-
- virtual void add_to_world(const QualifiedPackageName &) const;
-
- virtual void add_to_world(const SetName &) const;
-
- virtual void remove_from_world(const QualifiedPackageName &) const;
-
- virtual void remove_from_world(const SetName &) const;
-
/* RepositoryProvidesInterface */
virtual tr1::shared_ptr<const ProvidesSequence> provided_packages() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- /* RepositoryEnvironmentVariableInterface */
-
- virtual std::string get_environment_variable(
- const tr1::shared_ptr<const PackageID> & for_package,
- const std::string & var) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
/* RepositoryDestinationInterface */
- virtual bool is_suitable_destination_for(const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual bool is_default_destination() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual bool want_pre_post_phases() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
virtual void merge(const MergeOptions &);
- /* RepositoryHookInterface */
-
- virtual HookResult perform_hook(const Hook & hook) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
/* Repository */
virtual tr1::shared_ptr<const PackageIDSequence> package_ids(
@@ -223,10 +137,6 @@ namespace paludis
virtual bool has_category_named(const CategoryNamePart &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual tr1::shared_ptr<const CategoryNamePartSet> unimportant_category_names() const;
-
- virtual bool some_ids_might_support_action(const SupportsActionTestBase &) const;
-
/* Keys */
virtual const tr1::shared_ptr<const MetadataStringKey> format_key() const;
virtual const tr1::shared_ptr<const MetadataFSEntryKey> installed_root_key() const;
diff --git a/paludis/repositories/e/vdb_repository.sr b/paludis/repositories/e/vdb_repository.sr
index 312b562..cfa8ada 100644
--- a/paludis/repositories/e/vdb_repository.sr
+++ b/paludis/repositories/e/vdb_repository.sr
@@ -12,6 +12,7 @@ make_class_VDBRepositoryParams()
key provides_cache FSEntry
key names_cache FSEntry
key builddir FSEntry
+ key name RepositoryName
doxygen_comment << "END"
/**
diff --git a/src/clients/paludis/install_TEST b/src/clients/paludis/install_TEST
index aa92938..94e6428 100755
--- a/src/clients/paludis/install_TEST
+++ b/src/clients/paludis/install_TEST
@@ -1,32 +1,39 @@
#!/bin/bash
-PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
- --list-packages || exit 12
-
-PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
- --query test-category/target || exit 13
-
-PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
- --has-version test-category/target && exit 1
-PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
- --install target --resume-command-template `pwd`/install_TEST_dir/resume \
- --checks always && exit 2
-( echo -n './paludis ' ; cut -d ' ' -f2- < install_TEST_dir/resume ) > install_TEST_dir/fixedresume
-cat install_TEST_dir/fixedresume
-PALUDIS_HOME=./install_TEST_dir/config/ bash `pwd`/install_TEST_dir/fixedresume --checks none || exit 3
-./install_TEST_dir/root/usr/bin/testbin | grep success >/dev/null || exit 4
-grep target install_TEST_dir/root/var/db/pkg/world >/dev/null || exit 5
-PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
- --has-version test-category/target || exit 6
-PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
- --uninstall target || exit 7
-[[ -f ./install_TEST_dir/root/usr/bin/testbin ]] && exit 8
-PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
- --has-version test-category/target && exit 9
-grep target install_TEST_dir/root/var/db/pkg/world >/dev/null && exit 10
-
-PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
- -qMD test-category/target || exit 11
+for c in vdb_config exndbam_config ; do
+
+ PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test-$c \
+ --list-packages || exit 12
+
+ PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test-$c \
+ --query test-category/target || exit 13
+
+ PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test-$c \
+ --has-version test-category/target && exit 1
+ PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test-$c \
+ --install target --resume-command-template `pwd`/install_TEST_dir/resume \
+ --checks always && exit 2
+ ( echo -n './paludis ' ; cut -d ' ' -f2- < install_TEST_dir/resume ) > install_TEST_dir/fixedresume
+ cat install_TEST_dir/fixedresume
+ PALUDIS_HOME=./install_TEST_dir/config/ bash `pwd`/install_TEST_dir/fixedresume --checks none || exit 3
+ ./install_TEST_dir/root/usr/bin/testbin | grep success >/dev/null || exit 4
+ grep target install_TEST_dir/root/var/db/$([[ $c == vdb_config ]] && echo pkg || echo exndbam )/world >/dev/null || exit 5
+ PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test-$c \
+ --has-version test-category/target || exit 6
+ PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test-$c \
+ --contents test-category/target || exit 12
+ PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test-$c \
+ --uninstall target || exit 7
+ [[ -f ./install_TEST_dir/root/usr/bin/testbin ]] && exit 8
+ PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test-$c \
+ --has-version test-category/target && exit 9
+ grep target install_TEST_dir/root/var/db/$([[ $c == vdb_config ]] && echo pkg || echo exndbam )/world >/dev/null && exit 10
+
+ PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test-$c \
+ -qMD test-category/target || exit 11
+
+ rm -fr install_TEST_dir/root/usr
+done
true
diff --git a/src/clients/paludis/install_TEST_setup.sh b/src/clients/paludis/install_TEST_setup.sh
index 650e88b..057bf2d 100755
--- a/src/clients/paludis/install_TEST_setup.sh
+++ b/src/clients/paludis/install_TEST_setup.sh
@@ -5,31 +5,39 @@ mkdir install_TEST_dir || exit 1
cd install_TEST_dir || exit 1
mkdir -p build
-mkdir -p config/.paludis-install-test
-cat <<END > config/.paludis-install-test/specpath.conf
+mkdir -p config/.paludis-install-test-vdb_config
+cat <<END > config/.paludis-install-test-vdb_config/specpath.conf
root = `pwd`/root
-config-suffix =
+config-suffix = vdb
END
-mkdir -p root/${SYSCONFDIR}/paludis/repositories
-cat <<END > root/${SYSCONFDIR}/paludis/use.conf
+mkdir -p config/.paludis-install-test-exndbam_config
+cat <<END > config/.paludis-install-test-exndbam_config/specpath.conf
+root = `pwd`/root
+config-suffix = exndbam
+END
+
+for c in vdb exndbam ; do
+
+ mkdir -p root/${SYSCONFDIR}/paludis${c}/repositories
+ cat <<END > root/${SYSCONFDIR}/paludis${c}/use.conf
*/* foo
END
-cat <<END > root/${SYSCONFDIR}/paludis/licenses.conf
+ cat <<END > root/${SYSCONFDIR}/paludis${c}/licenses.conf
*/* *
END
-cat <<END > root/${SYSCONFDIR}/paludis/keywords.conf
+ cat <<END > root/${SYSCONFDIR}/paludis${c}/keywords.conf
*/* test
END
-cat <<END > root/${SYSCONFDIR}/paludis/bashrc
+ cat <<END > root/${SYSCONFDIR}/paludis${c}/bashrc
export CHOST="my-chost"
export USER_BASHRC_WAS_USED=yes
END
-cat <<END > root/${SYSCONFDIR}/paludis/repositories/repo1.conf
+ cat <<END > root/${SYSCONFDIR}/paludis${c}/repositories/repo1.conf
location = `pwd`/repo1
cache = /var/empty
format = ebuild
@@ -38,7 +46,9 @@ profiles = \${location}/profiles/testprofile \${location}/profiles/anothertestpr
buildroot = `pwd`/build
END
-cat <<END > root/${SYSCONFDIR}/paludis/repositories/installed.conf
+done
+
+cat <<END > root/${SYSCONFDIR}/paludisvdb/repositories/installed.conf
location = `pwd`/root/var/db/pkg
format = vdb
names_cache = /var/empty
@@ -46,8 +56,15 @@ provides_cache = /var/empty
buildroot = `pwd`/build
END
+cat <<END > root/${SYSCONFDIR}/paludisexndbam/repositories/installed.conf
+location = `pwd`/root/var/db/exndbam
+format = exndbam
+buildroot = `pwd`/build
+END
+
mkdir -p root/tmp
mkdir -p root/var/db/pkg
+mkdir -p root/var/db/exndbam
touch root/${SYSCONFDIR}/ld.so.conf
mkdir -p repo1/{eclass,distfiles,profiles/{testprofile,anothertestprofile},test-category/target/files} || exit 1
diff --git a/src/clients/paludis/upgrade_TEST b/src/clients/paludis/upgrade_TEST
index 3de7ff8..30fd89f 100755
--- a/src/clients/paludis/upgrade_TEST
+++ b/src/clients/paludis/upgrade_TEST
@@ -1,23 +1,42 @@
#!/bin/bash
-PALUDIS_HOME=./upgrade_TEST_dir/config/ REPEAT= \
- ./paludis --config-suffix upgrade-test --install =test-category/target-1 || exit 1
+for c in vdb_config exndbam_config ; do
-./upgrade_TEST_dir/root/usr/bin/testbin | grep testbin-1 >/dev/null || exit 2
-./upgrade_TEST_dir/root/usr/bin/testbin1 | grep testbin1 >/dev/null || exit 3
-./upgrade_TEST_dir/root/usr/bin/testbin2 && exit 4
+ PALUDIS_HOME=./upgrade_TEST_dir/$c/ REPEAT= \
+ ./paludis -E :upgrade-test --query -M =test-category/target-1 || exit 13
-PALUDIS_HOME=./upgrade_TEST_dir/config/ REPEAT=yes \
- ./paludis --config-suffix upgrade-test --install =test-category/target-1 || exit 5
+ PALUDIS_HOME=./upgrade_TEST_dir/$c/ REPEAT= \
+ ./paludis -E :upgrade-test --install =test-category/target-1 || exit 1
-./upgrade_TEST_dir/root/usr/bin/testbin | grep testbin-1 >/dev/null || exit 6
-./upgrade_TEST_dir/root/usr/bin/testbin1 | grep repeatbin1 >/dev/null || exit 7
-./upgrade_TEST_dir/root/usr/bin/testbin2 && exit 8
+ PALUDIS_HOME=./upgrade_TEST_dir/$c/ REPEAT= \
+ ./paludis -E :upgrade-test --query -M =test-category/target-1 || exit 14
-PALUDIS_HOME=./upgrade_TEST_dir/config/ \
- ./paludis --config-suffix upgrade-test --install target || exit 9
+ ./upgrade_TEST_dir/root/usr/bin/testbin | grep testbin-1 >/dev/null || exit 2
+ ./upgrade_TEST_dir/root/usr/bin/testbin1 | grep testbin1 >/dev/null || exit 3
+ ./upgrade_TEST_dir/root/usr/bin/testbin2 && exit 4
-./upgrade_TEST_dir/root/usr/bin/testbin | grep testbin-2 >/dev/null || exit 10
-./upgrade_TEST_dir/root/usr/bin/testbin1 2>/dev/null && exit 11
-./upgrade_TEST_dir/root/usr/bin/testbin2 | grep testbin2 >/dev/null || exit 12
+ PALUDIS_HOME=./upgrade_TEST_dir/$c/ REPEAT=yes \
+ ./paludis -E :upgrade-test --install =test-category/target-1 || exit 5
+
+ PALUDIS_HOME=./upgrade_TEST_dir/$c/ REPEAT= \
+ ./paludis -E :upgrade-test --query -M =test-category/target-1 || exit 15
+
+ ./upgrade_TEST_dir/root/usr/bin/testbin | grep testbin-1 >/dev/null || exit 6
+ ./upgrade_TEST_dir/root/usr/bin/testbin1 | grep repeatbin1 >/dev/null || exit 7
+ ./upgrade_TEST_dir/root/usr/bin/testbin2 && exit 8
+
+ PALUDIS_HOME=./upgrade_TEST_dir/$c/ \
+ ./paludis -E :upgrade-test --install target || exit 9
+
+
+ PALUDIS_HOME=./upgrade_TEST_dir/$c/ REPEAT= \
+ ./paludis -E :upgrade-test --query -M target || exit 16
+
+ ./upgrade_TEST_dir/root/usr/bin/testbin | grep testbin-2 >/dev/null || exit 10
+ ./upgrade_TEST_dir/root/usr/bin/testbin1 2>/dev/null && exit 11
+ ./upgrade_TEST_dir/root/usr/bin/testbin2 | grep testbin2 >/dev/null || exit 12
+
+ rm -fr upgrade_TEST_dir/root/usr
+
+done
diff --git a/src/clients/paludis/upgrade_TEST_setup.sh b/src/clients/paludis/upgrade_TEST_setup.sh
index f4c3405..fb1a739 100755
--- a/src/clients/paludis/upgrade_TEST_setup.sh
+++ b/src/clients/paludis/upgrade_TEST_setup.sh
@@ -5,31 +5,39 @@ mkdir upgrade_TEST_dir || exit 1
cd upgrade_TEST_dir || exit 1
mkdir -p build
-mkdir -p config/.paludis-upgrade-test
-cat <<END > config/.paludis-upgrade-test/specpath.conf
+mkdir -p vdb_config/.paludis-upgrade-test
+cat <<END > vdb_config/.paludis-upgrade-test/specpath.conf
root = `pwd`/root
-config-suffix =
+config-suffix = vdb
END
-mkdir -p root/${SYSCONFDIR}/paludis/repositories
-cat <<END > root/${SYSCONFDIR}/paludis/use.conf
+mkdir -p exndbam_config/.paludis-upgrade-test
+cat <<END > exndbam_config/.paludis-upgrade-test/specpath.conf
+root = `pwd`/root
+config-suffix = exndbam
+END
+
+for a in vdb exndbam ; do
+
+ mkdir -p root/${SYSCONFDIR}/paludis${a}/repositories
+ cat <<END > root/${SYSCONFDIR}/paludis${a}/use.conf
*/* foo
END
-cat <<END > root/${SYSCONFDIR}/paludis/licenses.conf
+ cat <<END > root/${SYSCONFDIR}/paludis${a}/licenses.conf
*/* *
END
-cat <<END > root/${SYSCONFDIR}/paludis/keywords.conf
+ cat <<END > root/${SYSCONFDIR}/paludis${a}/keywords.conf
*/* test
END
-cat <<END > root/${SYSCONFDIR}/paludis/bashrc
+ cat <<END > root/${SYSCONFDIR}/paludis${a}/bashrc
export CHOST="my-chost"
export USER_BASHRC_WAS_USED=yes
END
-cat <<END > root/${SYSCONFDIR}/paludis/repositories/repo1.conf
+ cat <<END > root/${SYSCONFDIR}/paludis${a}/repositories/repo1.conf
location = `pwd`/repo1
cache = /var/empty
format = ebuild
@@ -38,7 +46,9 @@ profiles = \${location}/profiles/testprofile
buildroot = `pwd`/build
END
-cat <<END > root/${SYSCONFDIR}/paludis/repositories/installed.conf
+done
+
+cat <<END > root/${SYSCONFDIR}/paludisvdb/repositories/installed.conf
location = \${ROOT}/var/db/pkg
format = vdb
names_cache = /var/empty
@@ -46,10 +56,18 @@ provides_cache = /var/empty
buildroot = `pwd`/build
END
+cat <<END > root/${SYSCONFDIR}/paludisexndbam/repositories/installed.conf
+location = \${ROOT}/var/db/exndbam
+format = exndbam
+buildroot = `pwd`/build
+END
+
mkdir -p root/tmp
touch root/${SYSCONFDIR}/ld.so.conf
mkdir -p root/var/db/pkg
+mkdir -p root/var/db/exndbam
+
mkdir -p repo1/{eclass,distfiles,profiles/testprofile,test-category/target/files} || exit 1
mkdir -p src/target-1
diff --git a/vim/syntax/paludis-repositories-conf.vim b/vim/syntax/paludis-repositories-conf.vim
index f3218ba..fe4ad89 100644
--- a/vim/syntax/paludis-repositories-conf.vim
+++ b/vim/syntax/paludis-repositories-conf.vim
@@ -45,6 +45,7 @@ syn keyword PaludisRepositoriesConfKnownKey contained
\ world provides_cache importance layout use_manifest
\ binary_uri_prefix binary_keywords binary_destination
\ eapi_when_unspecified eapi_when_unknown profile_eapi
+ \ name
syn keyword PaludisRepositoriesConfKnownValue contained
\ use require ignore