aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-08-11 12:47:15 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-08-11 19:18:14 +0100
commit59ebf547d0096912cc7b1110926300cd5d227640 (patch)
tree520b6fcb711b07f36a6748e603a49461531f6bcf
parent8cf3a9dca43a6799a15d749b266e070525e7a46b (diff)
downloadpaludis-59ebf547d0096912cc7b1110926300cd5d227640.tar.gz
paludis-59ebf547d0096912cc7b1110926300cd5d227640.tar.xz
Replace RepositoryMaker with a more flexible RepositoryFactory.
-rw-r--r--paludis/dep_list_TEST.hh23
-rw-r--r--paludis/environments/no_config/no_config_environment.cc21
-rw-r--r--paludis/environments/paludis/paludis_config.cc8
-rw-r--r--paludis/environments/paludis/paludis_environment.cc5
-rw-r--r--paludis/environments/portage/portage_environment.cc28
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc18
-rw-r--r--paludis/repositories/cran/cran_installed_repository.hh18
-rw-r--r--paludis/repositories/cran/cran_installed_repository_TEST.cc2
-rw-r--r--paludis/repositories/cran/cran_repository.cc21
-rw-r--r--paludis/repositories/cran/cran_repository.hh18
-rw-r--r--paludis/repositories/cran/cran_repository_TEST.cc4
-rw-r--r--paludis/repositories/cran/registration.cc40
-rw-r--r--paludis/repositories/e/Makefile.am2
-rw-r--r--paludis/repositories/e/e_repository.cc279
-rw-r--r--paludis/repositories/e/e_repository.hh17
-rw-r--r--paludis/repositories/e/e_repository_TEST.cc95
-rw-r--r--paludis/repositories/e/e_repository_sets_TEST.cc9
-rw-r--r--paludis/repositories/e/exndbam_repository.cc22
-rw-r--r--paludis/repositories/e/exndbam_repository.hh23
-rw-r--r--paludis/repositories/e/exndbam_repository_TEST.cc7
-rw-r--r--paludis/repositories/e/make_ebuild_repository.cc300
-rw-r--r--paludis/repositories/e/make_ebuild_repository.hh51
-rw-r--r--paludis/repositories/e/qa/manifest_TEST.cc38
-rw-r--r--paludis/repositories/e/qa/qa.cc7
-rw-r--r--paludis/repositories/e/qa/visibility_TEST.cc5
-rw-r--r--paludis/repositories/e/registration.cc66
-rw-r--r--paludis/repositories/e/vdb_repository.cc22
-rw-r--r--paludis/repositories/e/vdb_repository.hh24
-rw-r--r--paludis/repositories/e/vdb_repository_TEST.cc41
-rw-r--r--paludis/repositories/e/xml_things.cc9
-rw-r--r--paludis/repositories/fake/fake_repository.cc9
-rw-r--r--paludis/repositories/gems/gems_repository.cc49
-rw-r--r--paludis/repositories/gems/gems_repository.hh17
-rw-r--r--paludis/repositories/gems/installed_gems_repository.cc42
-rw-r--r--paludis/repositories/gems/installed_gems_repository.hh17
-rw-r--r--paludis/repositories/gems/registration.cc90
-rw-r--r--paludis/repositories/unavailable/registration.cc54
-rw-r--r--paludis/repositories/unavailable/unavailable_repository.cc48
-rw-r--r--paludis/repositories/unavailable/unavailable_repository.hh17
-rw-r--r--paludis/repositories/unpackaged/installed_repository.cc39
-rw-r--r--paludis/repositories/unpackaged/installed_repository.hh17
-rw-r--r--paludis/repositories/unpackaged/registration.cc115
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository.cc71
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository.hh17
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc40
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.hh20
-rw-r--r--paludis/repositories/virtuals/registration.cc40
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc32
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.hh21
-rw-r--r--paludis/repository_factory-fwd.hh28
-rw-r--r--paludis/repository_factory.cc204
-rw-r--r--paludis/repository_factory.hh145
-rw-r--r--paludis/repository_maker.cc167
-rw-r--r--paludis/repository_maker.hh125
-rw-r--r--paludis/uninstall_list_TEST.cc11
-rw-r--r--src/clients/importare/importare.cc4
-rw-r--r--src/clients/paludis/applets.cc5
58 files changed, 1553 insertions, 1116 deletions
diff --git a/paludis/dep_list_TEST.hh b/paludis/dep_list_TEST.hh
index e27a236..2be8a40 100644
--- a/paludis/dep_list_TEST.hh
+++ b/paludis/dep_list_TEST.hh
@@ -28,7 +28,7 @@
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/environments/test/test_environment.hh>
-#include <paludis/repository_maker.hh>
+#include <paludis/repository_factory.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
#include <string>
@@ -78,9 +78,22 @@ namespace paludis
#ifdef ENABLE_VIRTUALS_REPOSITORY
std::string virtuals_repo_keys(const std::string & k)
{
- if (k == "root")
+ if (k == "format")
+ return "virtuals";
+ else if (k == "root")
return "/";
- return "";
+ else
+ return "";
+ }
+
+ std::string installed_virtuals_repo_keys(const std::string & k)
+ {
+ if (k == "format")
+ return "installed_virtuals";
+ else if (k == "root")
+ return "/";
+ else
+ return "";
}
#endif
}
@@ -115,8 +128,8 @@ namespace test_cases
repo(new FakeRepository(&env, RepositoryName("repo"))),
installed_repo(new FakeInstalledRepository(&env, RepositoryName("installed"))),
#ifdef ENABLE_VIRTUALS_REPOSITORY
- virtuals_repo((*(*RepositoryMaker::get_instance())["virtuals"])(&env, virtuals_repo_keys)),
- installed_virtuals_repo((*(*RepositoryMaker::get_instance())["installed_virtuals"])(&env, virtuals_repo_keys)),
+ virtuals_repo(RepositoryFactory::get_instance()->create(&env, virtuals_repo_keys)),
+ installed_virtuals_repo(RepositoryFactory::get_instance()->create(&env, installed_virtuals_repo_keys)),
#endif
done_populate(false)
{
diff --git a/paludis/environments/no_config/no_config_environment.cc b/paludis/environments/no_config/no_config_environment.cc
index 05557af..0bfa89f 100644
--- a/paludis/environments/no_config/no_config_environment.cc
+++ b/paludis/environments/no_config/no_config_environment.cc
@@ -17,7 +17,7 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "no_config_environment.hh"
+#include <paludis/environments/no_config/no_config_environment.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/log.hh>
#include <paludis/util/dir_iterator.hh>
@@ -27,15 +27,14 @@
#include <paludis/util/sequence.hh>
#include <paludis/util/create_iterator-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
-#include <paludis/repository_maker.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/config_file.hh>
#include <paludis/util/wrapped_output_iterator.hh>
#include <paludis/distribution.hh>
#include <paludis/package_database.hh>
#include <paludis/hook.hh>
-#include <paludis/repositories/e/e_repository_params.hh>
#include <paludis/literal_metadata_key.hh>
+#include <paludis/repository_factory.hh>
#include <algorithm>
#include <set>
#include <list>
@@ -191,8 +190,7 @@ Implementation<NoConfigEnvironment>::initialise(NoConfigEnvironment * const env)
keys->insert("cache", "/var/empty");
package_database->add_repository(1, ((master_repo =
- RepositoryMaker::get_instance()->find_maker("ebuild")(env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)))));
+ RepositoryFactory::get_instance()->create(env, std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)))));
}
}
@@ -218,13 +216,15 @@ Implementation<NoConfigEnvironment>::initialise(NoConfigEnvironment * const env)
keys->insert("layout", "exheres");
package_database->add_repository(2, ((main_repo =
- RepositoryMaker::get_instance()->find_maker("ebuild")(env,
+ RepositoryFactory::get_instance()->create(env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)))));
#ifdef ENABLE_VIRTUALS_REPOSITORY
+ std::tr1::shared_ptr<Map<std::string, std::string> > v_keys(new Map<std::string, std::string>);
+ v_keys->insert("format", "virtuals");
if ((*DistributionData::get_instance()->distribution_from_string(env->distribution())).support_old_style_virtuals())
- package_database->add_repository(-2, RepositoryMaker::get_instance()->find_maker("virtuals")(env,
- std::tr1::bind(from_keys, make_shared_ptr(new Map<std::string, std::string>), std::tr1::placeholders::_1)));
+ package_database->add_repository(-2, RepositoryFactory::get_instance()->create(env,
+ std::tr1::bind(from_keys, v_keys, std::tr1::placeholders::_1)));
#endif
}
else
@@ -240,16 +240,17 @@ Implementation<NoConfigEnvironment>::initialise(NoConfigEnvironment * const env)
keys->insert("provides_cache", "/var/empty");
keys->insert("location", stringify(top_level_dir));
- package_database->add_repository(1, RepositoryMaker::get_instance()->find_maker("vdb")(env,
+ package_database->add_repository(1, RepositoryFactory::get_instance()->create(env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
std::tr1::shared_ptr<Map<std::string, std::string> > iv_keys(
new Map<std::string, std::string>);
iv_keys->insert("root", "/");
+ iv_keys->insert("format", "installed_virtuals");
#ifdef ENABLE_VIRTUALS_REPOSITORY
if ((*DistributionData::get_instance()->distribution_from_string(env->distribution())).support_old_style_virtuals())
- package_database->add_repository(-2, RepositoryMaker::get_instance()->find_maker("installed_virtuals")(env,
+ package_database->add_repository(-2, RepositoryFactory::get_instance()->create(env,
std::tr1::bind(from_keys, iv_keys, std::tr1::placeholders::_1)));
#endif
}
diff --git a/paludis/environments/paludis/paludis_config.cc b/paludis/environments/paludis/paludis_config.cc
index 302295f..19e52e7 100644
--- a/paludis/environments/paludis/paludis_config.cc
+++ b/paludis/environments/paludis/paludis_config.cc
@@ -378,19 +378,21 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
/* add virtuals repositories */
if ((*DistributionData::get_instance()->distribution_from_string(distribution())).support_old_style_virtuals())
{
- std::tr1::shared_ptr<Map<std::string, std::string> > iv_keys(
- new Map<std::string, std::string>);
+ std::tr1::shared_ptr<Map<std::string, std::string> > iv_keys(new Map<std::string, std::string>);
iv_keys->insert("root", root_prefix.empty() ? "/" : root_prefix);
+ iv_keys->insert("format", "installed_virtuals");
_imp->repos.push_back(make_named_values<RepositoryConfigEntry>(
value_for<n::format>("installed_virtuals"),
value_for<n::importance>(-1),
value_for<n::keys>(std::tr1::bind(&from_keys, iv_keys, std::tr1::placeholders::_1))
));
+ std::tr1::shared_ptr<Map<std::string, std::string> > v_keys(new Map<std::string, std::string>);
+ v_keys->insert("format", "virtuals");
_imp->repos.push_back(make_named_values<RepositoryConfigEntry>(
value_for<n::format>("virtuals"),
value_for<n::importance>(-2),
- value_for<n::keys>(std::tr1::bind(&from_keys, make_shared_ptr(new Map<std::string, std::string>), std::tr1::placeholders::_1))
+ value_for<n::keys>(std::tr1::bind(&from_keys, v_keys, std::tr1::placeholders::_1))
));
}
#endif
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index d260469..75b9306 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -26,8 +26,6 @@
#include <paludis/environments/paludis/mirrors_conf.hh>
#include <paludis/environments/paludis/world.hh>
-#include <paludis/repository_maker.hh>
-
#include <paludis/util/config_file.hh>
#include <paludis/hooker.hh>
#include <paludis/hook.hh>
@@ -38,6 +36,7 @@
#include <paludis/mask.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/literal_metadata_key.hh>
+#include <paludis/repository_factory.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/log.hh>
@@ -152,7 +151,7 @@ PaludisEnvironment::PaludisEnvironment(const std::string & s) :
for (PaludisConfig::RepositoryConstIterator r(_imp->config->begin_repositories()),
r_end(_imp->config->end_repositories()) ; r != r_end ; ++r)
_imp->package_database->add_repository((*r).importance(),
- RepositoryMaker::get_instance()->find_maker((*r).format())(this, (*r).keys()));
+ RepositoryFactory::get_instance()->create(this, (*r).keys()));
add_metadata_key(_imp->format_key);
add_metadata_key(_imp->config_location_key);
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index cadb039..f440341 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -35,7 +35,6 @@
#include <paludis/util/options.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/visitor-impl.hh>
-#include <paludis/repository_maker.hh>
#include <paludis/util/config_file.hh>
#include <paludis/hooker.hh>
#include <paludis/hook.hh>
@@ -48,6 +47,7 @@
#include <paludis/dep_tag.hh>
#include <paludis/util/mutex.hh>
#include <paludis/literal_metadata_key.hh>
+#include <paludis/repository_factory.hh>
#include <tr1/functional>
#include <functional>
#include <algorithm>
@@ -464,11 +464,10 @@ void
PortageEnvironment::_add_virtuals_repository()
{
#ifdef ENABLE_VIRTUALS_REPOSITORY
- std::tr1::shared_ptr<Map<std::string, std::string> > keys(
- new Map<std::string, std::string>);
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "virtuals");
package_database()->add_repository(-2,
- RepositoryMaker::get_instance()->find_maker("virtuals")(this,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ RepositoryFactory::get_instance()->create(this, std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
#endif
}
@@ -476,12 +475,11 @@ void
PortageEnvironment::_add_installed_virtuals_repository()
{
#ifdef ENABLE_VIRTUALS_REPOSITORY
- std::tr1::shared_ptr<Map<std::string, std::string> > keys(
- new Map<std::string, std::string>);
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
keys->insert("root", stringify(root()));
+ keys->insert("format", "installed_virtuals");
package_database()->add_repository(-1,
- RepositoryMaker::get_instance()->find_maker("installed_virtuals")(this,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ RepositoryFactory::get_instance()->create(this, std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
#endif
}
@@ -496,8 +494,7 @@ void
PortageEnvironment::_add_ebuild_repository(const FSEntry & portdir, const std::string & master,
const std::string & sync, int importance)
{
- std::tr1::shared_ptr<Map<std::string, std::string> > keys(
- new Map<std::string, std::string>);
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
keys->insert("root", stringify(root()));
keys->insert("location", stringify(portdir));
keys->insert("profiles", stringify((_imp->conf_dir / "make.profile").realpath()) + " " +
@@ -514,8 +511,7 @@ PortageEnvironment::_add_ebuild_repository(const FSEntry & portdir, const std::s
keys->insert("builddir", builddir);
package_database()->add_repository(importance,
- RepositoryMaker::get_instance()->find_maker("ebuild")(this,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ RepositoryFactory::get_instance()->create(this, std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
}
void
@@ -530,8 +526,7 @@ PortageEnvironment::_add_vdb_repository()
{
Context context("When creating vdb repository:");
- std::tr1::shared_ptr<Map<std::string, std::string> > keys(
- new Map<std::string, std::string>);
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
keys->insert("root", stringify(root()));
keys->insert("location", stringify(root() / "/var/db/pkg"));
keys->insert("format", "vdb");
@@ -542,8 +537,7 @@ PortageEnvironment::_add_vdb_repository()
builddir.append("/portage");
keys->insert("builddir", builddir);
package_database()->add_repository(1,
- RepositoryMaker::get_instance()->find_maker("vdb")(this,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ RepositoryFactory::get_instance()->create(this, std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
}
PortageEnvironment::~PortageEnvironment()
diff --git a/paludis/files.m4 b/paludis/files.m4
index 1d584ba..6a0487d 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -63,7 +63,7 @@ add(`query_visitor', `hh', `cc')
add(`range_rewriter', `hh', `cc', `test')
add(`report_task', `hh', `cc')
add(`repository', `hh', `fwd', `cc')
-add(`repository_maker', `hh', `cc')
+add(`repository_factory', `hh', `fwd', `cc')
add(`repository_name_cache', `hh', `cc', `test', `testscript')
add(`selection', `hh', `cc', `fwd', `test')
add(`selection_handler', `hh', `cc', `fwd')
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index 479c6d0..c338a42 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -373,7 +373,7 @@ CRANInstalledRepository::do_installed_time(const QualifiedPackageName & q,
#endif
std::tr1::shared_ptr<Repository>
-CRANInstalledRepository::make_cran_installed_repository(
+CRANInstalledRepository::repository_factory_create(
Environment * const env,
const std::tr1::function<std::string (const std::string &)> & f)
{
@@ -396,6 +396,22 @@ CRANInstalledRepository::make_cran_installed_repository(
.root(root)));
}
+RepositoryName
+CRANInstalledRepository::repository_factory_name(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> &)
+{
+ return RepositoryName("installed-cran");
+}
+
+std::tr1::shared_ptr<const RepositoryNameSet>
+CRANInstalledRepository::repository_factory_dependencies(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> &)
+{
+ return make_shared_ptr(new RepositoryNameSet);
+}
+
CRANInstalledRepositoryConfigurationError::CRANInstalledRepositoryConfigurationError(
const std::string & msg) throw () :
ConfigurationError("CRAN installed repository configuration error: " + msg)
diff --git a/paludis/repositories/cran/cran_installed_repository.hh b/paludis/repositories/cran/cran_installed_repository.hh
index 1779034..92000ee 100644
--- a/paludis/repositories/cran/cran_installed_repository.hh
+++ b/paludis/repositories/cran/cran_installed_repository.hh
@@ -65,13 +65,23 @@ namespace paludis
*/
CRANInstalledRepository(const CRANInstalledRepositoryParams &);
- /**
- * Virtual constructor.
- */
- static std::tr1::shared_ptr<Repository> make_cran_installed_repository(
+ ///\name RepositoryFactory functions
+ ///\{
+
+ static RepositoryName repository_factory_name(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<Repository> repository_factory_create(
Environment * const env,
const std::tr1::function<std::string (const std::string &)> &);
+ static std::tr1::shared_ptr<const RepositoryNameSet> repository_factory_dependencies(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ ///\}
+
/**
* Destructor.
*/
diff --git a/paludis/repositories/cran/cran_installed_repository_TEST.cc b/paludis/repositories/cran/cran_installed_repository_TEST.cc
index 0e6daaf..0d1b2cd 100644
--- a/paludis/repositories/cran/cran_installed_repository_TEST.cc
+++ b/paludis/repositories/cran/cran_installed_repository_TEST.cc
@@ -59,7 +59,7 @@ namespace test_cases
keys->insert("library", "cran_installed_repository_TEST_dir/library");
keys->insert("location", "cran_installed_repository_TEST_dir/repo1");
keys->insert("builddir", "cran_installed_repository_TEST_dir/tmp");
- std::tr1::shared_ptr<Repository> repo(CRANInstalledRepository::make_cran_installed_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(CRANInstalledRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
TEST_CHECK(repo->has_category_named(CategoryNamePart("cran")));
}
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index b09b72d..09cae10 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -26,7 +26,6 @@
#include <paludis/literal_metadata_key.hh>
#include <paludis/repositories/cran/cran_package_id.hh>
#include <paludis/repositories/cran/cran_repository.hh>
-#include <paludis/repository_maker.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/set.hh>
#include <paludis/util/sequence.hh>
@@ -399,7 +398,7 @@ CRANRepository::sync() const
}
std::tr1::shared_ptr<Repository>
-CRANRepository::make_cran_repository(
+CRANRepository::repository_factory_create(
Environment * const env,
const std::tr1::function<std::string (const std::string &)> & f)
{
@@ -446,6 +445,24 @@ CRANRepository::make_cran_repository(
.mirror(mirror)));
}
+RepositoryName
+CRANRepository::repository_factory_name(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> & f)
+{
+ if (f("location").empty())
+ throw CRANRepositoryConfigurationError("Key 'location' not specified or empty");
+ return fetch_repo_name(f("location"));
+}
+
+std::tr1::shared_ptr<const RepositoryNameSet>
+CRANRepository::repository_factory_dependencies(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> &)
+{
+ return make_shared_ptr(new RepositoryNameSet);
+}
+
CRANRepositoryConfigurationError::CRANRepositoryConfigurationError(
const std::string & msg) throw () :
ConfigurationError("CRAN repository configuration error: " + msg)
diff --git a/paludis/repositories/cran/cran_repository.hh b/paludis/repositories/cran/cran_repository.hh
index 811be24..786627d 100644
--- a/paludis/repositories/cran/cran_repository.hh
+++ b/paludis/repositories/cran/cran_repository.hh
@@ -74,13 +74,23 @@ namespace paludis
*/
CRANRepository(const CRANRepositoryParams &);
- /**
- * Virtual constructor.
- */
- static std::tr1::shared_ptr<Repository> make_cran_repository(
+ ///\name RepositoryFactory functions
+ ///\{
+
+ static RepositoryName repository_factory_name(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<Repository> repository_factory_create(
Environment * const env,
const std::tr1::function<std::string (const std::string &)> &);
+ static std::tr1::shared_ptr<const RepositoryNameSet> repository_factory_dependencies(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ ///\}
+
/**
* Destructor.
*/
diff --git a/paludis/repositories/cran/cran_repository_TEST.cc b/paludis/repositories/cran/cran_repository_TEST.cc
index 622511e..bec44f9 100644
--- a/paludis/repositories/cran/cran_repository_TEST.cc
+++ b/paludis/repositories/cran/cran_repository_TEST.cc
@@ -60,7 +60,7 @@ namespace test_cases
keys->insert("library", "cran_repository_TEST_dir/library");
keys->insert("location", "cran_repository_TEST_dir/repo1");
keys->insert("builddir", "cran_repository_TEST_dir/tmp");
- std::tr1::shared_ptr<Repository> repo(CRANRepository::make_cran_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(CRANRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
TEST_CHECK(repo->has_category_named(CategoryNamePart("cran")));
TEST_CHECK(repo->has_package_named(QualifiedPackageName("cran/testpackage1")));
@@ -80,7 +80,7 @@ namespace test_cases
keys->insert("library", "cran_repository_TEST_dir/library");
keys->insert("location", "cran_repository_TEST_dir/repo2");
keys->insert("builddir", "cran_repository_TEST_dir/tmp");
- std::tr1::shared_ptr<Repository> repo(CRANRepository::make_cran_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(CRANRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
TEST_CHECK(repo->has_package_named(QualifiedPackageName("cran/testbundle")));
TEST_CHECK(repo->has_package_named(QualifiedPackageName("cran/bundlepkg1")));
diff --git a/paludis/repositories/cran/registration.cc b/paludis/repositories/cran/registration.cc
index 68b7241..663460a 100644
--- a/paludis/repositories/cran/registration.cc
+++ b/paludis/repositories/cran/registration.cc
@@ -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
@@ -17,26 +17,36 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/repository_maker.hh>
+#include <paludis/repository_factory.hh>
#include <paludis/repositories/cran/cran_repository.hh>
#include <paludis/repositories/cran/cran_installed_repository.hh>
-#include "config.h"
+#include <paludis/util/set.hh>
using namespace paludis;
-#ifndef MONOLITHIC
+extern "C" void paludis_initialise_repository_so(RepositoryFactory * const factory) PALUDIS_VISIBLE;
-extern "C"
+void paludis_initialise_repository_so(RepositoryFactory * const factory)
{
- void PALUDIS_VISIBLE register_repositories(RepositoryMaker * maker);
+ std::tr1::shared_ptr<Set<std::string> > cran_formats(new Set<std::string>);
+ cran_formats->insert("cran");
+
+ factory->add_repository_format(
+ cran_formats,
+ &CRANRepository::repository_factory_name,
+ &CRANRepository::repository_factory_create,
+ &CRANRepository::repository_factory_dependencies
+ );
+
+ std::tr1::shared_ptr<Set<std::string> > installed_cran_formats(new Set<std::string>);
+ installed_cran_formats->insert("installed_cran");
+ installed_cran_formats->insert("installed-cran");
+
+ factory->add_repository_format(
+ installed_cran_formats,
+ &CRANInstalledRepository::repository_factory_name,
+ &CRANInstalledRepository::repository_factory_create,
+ &CRANInstalledRepository::repository_factory_dependencies
+ );
}
-void register_repositories(RepositoryMaker * maker)
-{
- maker->register_maker("cran", &CRANRepository::make_cran_repository);
- maker->register_maker("installed_cran", &CRANInstalledRepository::make_cran_installed_repository);
-}
-
-#endif
-
-
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 6e3eae9..16d2a4b 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -75,7 +75,6 @@ paludis_repositories_e_include_HEADERS = \
glsa-sr.hh \
glsa.hh \
layout.hh \
- make_ebuild_repository.hh \
manifest2_entry-sr.hh \
manifest2_reader.hh \
pipe_command_handler.hh \
@@ -126,7 +125,6 @@ libpaludiserepository_@PALUDIS_PC_SLOT@_la_SOURCES = \
fix_locked_dependencies.cc \
glsa.cc \
layout.cc \
- make_ebuild_repository.cc \
manifest2_reader.cc \
pipe_command_handler.cc \
registration.cc \
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 41ff7ed..1935fb2 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -77,6 +77,7 @@
#include <paludis/util/sha256.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/destringify.hh>
#include <tr1/functional>
#include <tr1/unordered_map>
@@ -1438,3 +1439,281 @@ ERepository::info_vars_key() const
return _imp->info_vars_key;
}
+RepositoryName
+ERepository::repository_factory_name(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> & key_function)
+{
+ Context context("When finding repository name for e repository from repo_file '" + key_function("repo_file") + "':");
+
+ if (key_function("location").empty())
+ throw ERepositoryConfigurationError("Key 'location' unspecified or empty");
+ return fetch_repo_name(FSEntry(key_function("location")));
+}
+
+std::tr1::shared_ptr<Repository>
+ERepository::repository_factory_create(
+ Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> & f)
+{
+ Context context("When making ebuild repository from repo_file '" + f("repo_file") + "':");
+
+ std::string location(f("location"));
+ if (location.empty())
+ throw ERepositoryConfigurationError("Key 'location' not specified or empty");
+
+ std::tr1::shared_ptr<KeyValueConfigFile> layout_conf((FSEntry(location) / "metadata/layout.conf").exists() ?
+ new KeyValueConfigFile(FSEntry(location) / "metadata/layout.conf", KeyValueConfigFileOptions(),
+ &KeyValueConfigFile::no_defaults, &KeyValueConfigFile::no_transformation)
+ : 0);
+
+ std::tr1::shared_ptr<const RepositoryName> master_repository_name;
+ std::tr1::shared_ptr<const ERepository> master_repository;
+ if (! f("master_repository").empty())
+ {
+ Context context_local("When finding configuration information for master_repository '"
+ + stringify(f("master_repository")) + "':");
+
+ master_repository_name.reset(new RepositoryName(f("master_repository")));
+ std::tr1::shared_ptr<const Repository> master_repository_uncasted(
+ env->package_database()->fetch_repository(*master_repository_name));
+
+ std::string format("unknown");
+ if (master_repository_uncasted->format_key())
+ format = master_repository_uncasted->format_key()->value();
+
+ if (format != "ebuild")
+ throw ERepositoryConfigurationError("Master repository format is '" +
+ stringify(format) + "', not 'ebuild'");
+
+ master_repository = std::tr1::static_pointer_cast<const ERepository>(master_repository_uncasted);
+ if (master_repository->params().master_repository)
+ throw ERepositoryConfigurationError("Requested master repository has a master_repository of '" +
+ stringify(master_repository->params().master_repository->name()) + "', so it cannot "
+ "be used as a master repository");
+ }
+
+ std::tr1::shared_ptr<FSEntrySequence> profiles(new FSEntrySequence);
+ tokenise_whitespace(f("profiles"), create_inserter<FSEntry>(std::back_inserter(*profiles)));
+ if (profiles->empty())
+ {
+ if (master_repository)
+ std::copy(master_repository->params().profiles->begin(),
+ master_repository->params().profiles->end(), profiles->back_inserter());
+ else
+ throw ERepositoryConfigurationError("No profiles have been specified");
+ }
+
+ std::tr1::shared_ptr<FSEntrySequence> eclassdirs(new FSEntrySequence);
+ tokenise_whitespace(f("eclassdirs"), create_inserter<FSEntry>(std::back_inserter(*eclassdirs)));
+ if (eclassdirs->empty())
+ {
+ if (master_repository)
+ std::copy(master_repository->params().eclassdirs->begin(),
+ master_repository->params().eclassdirs->end(), eclassdirs->back_inserter());
+ eclassdirs->push_back(location + "/eclass");
+ }
+
+ std::string distdir(f("distdir"));
+ if (distdir.empty())
+ {
+ if (master_repository)
+ distdir = stringify(master_repository->params().distdir);
+ else
+ {
+ distdir = (*DistributionData::get_instance()->distribution_from_string(
+ env->distribution())).default_ebuild_distdir();
+ if (distdir.empty())
+ distdir = location + "/distfiles";
+ else if ('/' != distdir.at(0))
+ distdir = location + "/" + distdir;
+ }
+ }
+
+ std::string setsdir(f("setsdir"));
+ if (setsdir.empty())
+ setsdir = location + "/sets";
+
+ std::string securitydir(f("securitydir"));
+ if (securitydir.empty())
+ securitydir = location + "/metadata/glsa";
+
+ std::string newsdir(f("newsdir"));
+ if (newsdir.empty())
+ newsdir = location + "/metadata/news";
+
+ std::string cache(f("cache"));
+ if (cache.empty())
+ {
+ cache = location + "/metadata/cache";
+ if (! FSEntry(cache).exists())
+ cache = "/var/empty";
+ }
+
+ std::string write_cache(f("write_cache"));
+ if (write_cache.empty())
+ write_cache = (*DistributionData::get_instance()->distribution_from_string(
+ env->distribution())).default_ebuild_write_cache();
+
+ bool append_repository_name_to_write_cache(true);
+ if (! f("append_repository_name_to_write_cache").empty())
+ {
+ Context item_context("When handling append_repository_name_to_write_cache key:");
+ append_repository_name_to_write_cache = destringify<bool>(f("append_repository_name_to_write_cache"));
+ }
+
+ bool ignore_deprecated_profiles(false);
+ if (! f("ignore_deprecated_profiles").empty())
+ {
+ Context item_context("When handling ignore_deprecated_profiles key:");
+ ignore_deprecated_profiles = destringify<bool>(f("ignore_deprecated_profiles"));
+ }
+
+ std::string eapi_when_unknown(f("eapi_when_unknown"));
+ if (eapi_when_unknown.empty())
+ {
+ if (! layout_conf
+ || (eapi_when_unknown = layout_conf->get("eapi_when_unknown")).empty())
+ eapi_when_unknown = (*DistributionData::get_instance()->distribution_from_string(
+ env->distribution())).default_ebuild_eapi_when_unknown();
+ }
+
+ std::string eapi_when_unspecified(f("eapi_when_unspecified"));
+ if (eapi_when_unspecified.empty())
+ {
+ if (! layout_conf
+ || (eapi_when_unspecified = layout_conf->get("eapi_when_unspecified")).empty())
+ eapi_when_unspecified = (*DistributionData::get_instance()->distribution_from_string(
+ env->distribution())).default_ebuild_eapi_when_unspecified();
+ }
+
+ std::string profile_eapi(f("profile_eapi"));
+ if (profile_eapi.empty())
+ {
+ if (! layout_conf
+ || (profile_eapi = layout_conf->get("eapi_when_unspecified")).empty())
+ profile_eapi = (*DistributionData::get_instance()->distribution_from_string(
+ env->distribution())).default_ebuild_profile_eapi();
+ }
+
+ std::string names_cache(f("names_cache"));
+ if (names_cache.empty())
+ {
+ names_cache = (*DistributionData::get_instance()->distribution_from_string(
+ env->distribution())).default_ebuild_names_cache();
+ if (names_cache.empty())
+ {
+ Log::get_instance()->message("e.ebuild.configuration.no_names_cache", ll_warning, lc_no_context)
+ << "The names_cache key is not set in '" << f("repo_file")
+ << "'. You should read the Paludis documentation and select an appropriate value.";
+ names_cache = "/var/empty";
+ }
+ }
+
+ std::string sync(f("sync"));
+
+ std::string sync_options(f("sync_options"));
+
+ if (! f("sync_exclude").empty())
+ {
+ Log::get_instance()->message("e.ebuild.configuration.deprecated", ll_warning, lc_no_context)
+ << "The sync_exclude key in '" << f("repo_file") << "' is deprecated in favour of sync_options = --exclude-from=";
+ if (! sync_options.empty())
+ sync_options += " ";
+ sync_options += "--exclude-from='" + f("sync_exclude") + "'";
+ }
+
+ std::string builddir(f("builddir"));
+ if (builddir.empty())
+ {
+ builddir = f("buildroot");
+ if (builddir.empty())
+ {
+ if (master_repository)
+ builddir = stringify(master_repository->params().builddir);
+ else
+ builddir = (*DistributionData::get_instance()->distribution_from_string(
+ env->distribution())).default_ebuild_builddir();
+ }
+ else
+ Log::get_instance()->message("e.ebuild.configuration.deprecated", ll_warning, lc_context)
+ << "Key 'buildroot' is deprecated, use 'builddir' instead";
+ }
+
+ std::string layout(f("layout"));
+ if (layout.empty())
+ {
+ if (! layout_conf
+ || (layout = layout_conf->get("layout")).empty())
+ layout = (*DistributionData::get_instance()->distribution_from_string(
+ env->distribution())).default_ebuild_layout();
+ }
+
+ erepository::UseManifest use_manifest(erepository::manifest_use);
+ if (! f("use_manifest").empty())
+ {
+ Context item_context("When handling use_manifest key:");
+ use_manifest = destringify<erepository::UseManifest>(f("use_manifest"));
+ }
+
+ bool binary_destination(false);
+ if (! f("binary_destination").empty())
+ {
+ Context item_context("When handling binary_destination key:");
+ binary_destination = destringify<bool>(f("binary_destination"));
+ }
+
+ std::string binary_uri_prefix(f("binary_uri_prefix"));
+
+ std::string binary_distdir(f("binary_distdir"));
+
+ std::string binary_keywords(f("binary_keywords"));
+
+ if (binary_keywords.empty())
+ {
+ if (binary_destination)
+ throw ERepositoryConfigurationError("binary_destination = true, but binary_keywords is unset or empty");
+ }
+
+ return std::tr1::shared_ptr<ERepository>(new ERepository(ERepositoryParams::create()
+ .entry_format("ebuild")
+ .layout(layout)
+ .environment(env)
+ .location(location)
+ .profiles(profiles)
+ .cache(cache)
+ .write_cache(write_cache)
+ .names_cache(names_cache)
+ .eclassdirs(eclassdirs)
+ .distdir(distdir)
+ .securitydir(securitydir)
+ .setsdir(setsdir)
+ .newsdir(newsdir)
+ .sync(sync)
+ .sync_options(sync_options)
+ .master_repository(master_repository)
+ .write_bin_uri_prefix("")
+ .eapi_when_unknown(eapi_when_unknown)
+ .eapi_when_unspecified(eapi_when_unspecified)
+ .profile_eapi(profile_eapi)
+ .use_manifest(use_manifest)
+ .append_repository_name_to_write_cache(append_repository_name_to_write_cache)
+ .ignore_deprecated_profiles(ignore_deprecated_profiles)
+ .binary_destination(binary_destination)
+ .binary_uri_prefix(binary_uri_prefix)
+ .binary_distdir(binary_distdir)
+ .binary_keywords(binary_keywords)
+ .builddir(FSEntry(builddir).realpath_if_exists())));
+}
+
+std::tr1::shared_ptr<const RepositoryNameSet>
+ERepository::repository_factory_dependencies(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> & f)
+{
+ std::tr1::shared_ptr<RepositoryNameSet> result(new RepositoryNameSet);
+ if (! f("master_repository").empty())
+ result->insert(RepositoryName(f("master_repository")));
+ return result;
+}
+
diff --git a/paludis/repositories/e/e_repository.hh b/paludis/repositories/e/e_repository.hh
index 9e23b1e..c1ec7df 100644
--- a/paludis/repositories/e/e_repository.hh
+++ b/paludis/repositories/e/e_repository.hh
@@ -244,6 +244,23 @@ namespace paludis
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > installed_root_key() const;
virtual const std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > info_vars_key() const;
+
+ ///\name RepositoryFactory functions
+ ///\{
+
+ static RepositoryName repository_factory_name(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<Repository> repository_factory_create(
+ Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<const RepositoryNameSet> repository_factory_dependencies(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ ///\}
};
}
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index ef1e8a1..339ba27 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -20,13 +20,11 @@
#include <paludis/repositories/e/e_repository.hh>
#include <paludis/repositories/e/e_repository_exceptions.hh>
#include <paludis/repositories/e/e_repository_id.hh>
-#include <paludis/repositories/e/make_ebuild_repository.hh>
#include <paludis/repositories/e/vdb_repository.hh>
#include <paludis/repositories/e/eapi.hh>
#include <paludis/repositories/e/dep_spec_pretty_printer.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
-#include <paludis/repository_maker.hh>
#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/system.hh>
#include <paludis/util/visitor-impl.hh>
@@ -44,6 +42,7 @@
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/selection.hh>
+#include <paludis/repository_factory.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
#include <tr1/functional>
@@ -84,7 +83,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo1");
keys->insert("profiles", "e_repository_TEST_dir/repo1/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "test-repo-1");
}
@@ -103,7 +102,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo2");
keys->insert("profiles", "e_repository_TEST_dir/repo2/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "x-repo2");
}
@@ -122,7 +121,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo3");
keys->insert("profiles", "e_repository_TEST_dir/repo3/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "x-repo3");
}
@@ -141,7 +140,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo1");
keys->insert("profiles", "e_repository_TEST_dir/repo1/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
for (int pass = 1 ; pass <= 2 ; ++pass)
@@ -169,7 +168,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo1");
keys->insert("profiles", "e_repository_TEST_dir/repo1/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
for (int pass = 1 ; pass <= 2 ; ++pass)
@@ -199,7 +198,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo4");
keys->insert("profiles", "e_repository_TEST_dir/repo4/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
for (int pass = 1 ; pass <= 2 ; ++pass)
@@ -235,7 +234,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo4");
keys->insert("profiles", "e_repository_TEST_dir/repo4/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
repo->package_names(CategoryNamePart("cat-one"));
@@ -275,7 +274,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo4");
keys->insert("profiles", "e_repository_TEST_dir/repo4/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
std::tr1::shared_ptr<const QualifiedPackageNameSet> names;
@@ -324,7 +323,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo5");
keys->insert("profiles", "e_repository_TEST_dir/repo5/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
std::tr1::shared_ptr<const QualifiedPackageNameSet> names;
@@ -357,7 +356,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo4");
keys->insert("profiles", "e_repository_TEST_dir/repo4/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
for (int pass = 1 ; pass <= 2 ; ++pass)
@@ -401,7 +400,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo8");
keys->insert("profiles", "e_repository_TEST_dir/repo8/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
for (int pass = 1 ; pass <= 2 ; ++pass)
@@ -443,7 +442,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo6");
keys->insert("profiles", "e_repository_TEST_dir/repo6/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -484,7 +483,7 @@ namespace test_cases
keys->insert("write_cache", "e_repository_TEST_dir/repo7/metadata/cache");
keys->insert("location", "e_repository_TEST_dir/repo7");
keys->insert("profiles", "e_repository_TEST_dir/repo7/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -565,7 +564,7 @@ namespace test_cases
keys->insert("write_cache", "e_repository_TEST_dir/repo7/metadata/cache");
keys->insert("location", "e_repository_TEST_dir/repo7");
keys->insert("profiles", "e_repository_TEST_dir/repo7/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -622,7 +621,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo7");
keys->insert("profiles", "e_repository_TEST_dir/repo7/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -655,8 +654,8 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo9");
keys->insert("profiles", "e_repository_TEST_dir/repo9/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ std::tr1::shared_ptr<ERepository> repo(std::tr1::static_pointer_cast<ERepository>(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1))));
env.package_database()->add_repository(1, repo);
for (int pass = 1 ; pass <= 2 ; ++pass)
@@ -705,7 +704,7 @@ namespace test_cases
keys18->insert("names_cache", "/var/empty");
keys18->insert("location", "e_repository_TEST_dir/repo18");
keys18->insert("profiles", "e_repository_TEST_dir/repo18/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo18(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo18(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys18, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo18);
@@ -715,7 +714,7 @@ namespace test_cases
keys19->insert("names_cache", "/var/empty");
keys19->insert("location", "e_repository_TEST_dir/repo19");
keys19->insert("master_repository", "test-repo-18");
- std::tr1::shared_ptr<ERepository> repo19(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo19(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys19, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo19);
@@ -761,7 +760,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo10");
keys->insert("profiles", "e_repository_TEST_dir/repo10/profiles/profile/subprofile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -796,8 +795,8 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo10");
keys->insert("profiles", "e_repository_TEST_dir/repo10/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ std::tr1::shared_ptr<ERepository> repo(std::tr1::static_pointer_cast<ERepository>(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1))));
env.package_database()->add_repository(1, repo);
TEST_CHECK((*env[selection::RequireExactlyOne(generator::Matches(
@@ -828,8 +827,8 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo15");
keys->insert("profiles", "e_repository_TEST_dir/repo15/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ std::tr1::shared_ptr<ERepository> repo(std::tr1::static_pointer_cast<ERepository>(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1))));
env.package_database()->add_repository(1, repo);
bool has_one(false), has_two(false), has_three(false);
@@ -900,8 +899,8 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo11");
keys->insert("profiles", "e_repository_TEST_dir/repo11/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ std::tr1::shared_ptr<ERepository> repo(std::tr1::static_pointer_cast<ERepository>(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1))));
repo->make_manifest(QualifiedPackageName("category/package"));
std::multiset<std::string> made_manifest, reference_manifest;
@@ -949,7 +948,7 @@ namespace test_cases
keys->insert("eapi_when_unspecified", "exheres-0");
keys->insert("profile_eapi", "exheres-0");
keys->insert("distdir", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "distdir"));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -1051,8 +1050,8 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo11");
keys->insert("profiles", "e_repository_TEST_dir/repo11/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ std::tr1::shared_ptr<ERepository> repo(std::tr1::static_pointer_cast<ERepository>(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1))));
env.package_database()->add_repository(1, repo);
FetchAction action(make_named_values<FetchActionOptions>(
@@ -1105,7 +1104,7 @@ namespace test_cases
keys->insert("profile_eapi", "0");
keys->insert("distdir", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "distdir"));
keys->insert("builddir", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "build"));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -1117,10 +1116,13 @@ namespace test_cases
#ifdef ENABLE_VIRTUALS_REPOSITORY
std::tr1::shared_ptr<Map<std::string, std::string> > iv_keys(new Map<std::string, std::string>);
iv_keys->insert("root", "/");
- env.package_database()->add_repository(-2, RepositoryMaker::get_instance()->find_maker("installed_virtuals")(&env,
+ iv_keys->insert("format", "installed_virtuals");
+ env.package_database()->add_repository(-2, RepositoryFactory::get_instance()->create(&env,
std::tr1::bind(from_keys, iv_keys, std::tr1::placeholders::_1)));
- env.package_database()->add_repository(-2, RepositoryMaker::get_instance()->find_maker("virtuals")(&env,
- std::tr1::bind(from_keys, make_shared_ptr(new Map<std::string, std::string>), std::tr1::placeholders::_1)));
+ std::tr1::shared_ptr<Map<std::string, std::string> > v_keys(new Map<std::string, std::string>);
+ v_keys->insert("format", "virtuals");
+ env.package_database()->add_repository(-2, RepositoryFactory::get_instance()->create(&env,
+ std::tr1::bind(from_keys, v_keys, std::tr1::placeholders::_1)));
#endif
InstallAction action(make_named_values<InstallActionOptions>(
@@ -1361,7 +1363,7 @@ namespace test_cases
keys->insert("profile_eapi", "0");
keys->insert("distdir", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "distdir"));
keys->insert("builddir", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "build"));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -1446,7 +1448,7 @@ namespace test_cases
keys->insert("profile_eapi", "0");
keys->insert("distdir", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "distdir"));
keys->insert("builddir", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "build"));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -1601,7 +1603,7 @@ namespace test_cases
keys->insert("profile_eapi", "0");
keys->insert("distdir", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "distdir"));
keys->insert("builddir", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "build"));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -1779,7 +1781,7 @@ namespace test_cases
keys->insert("profile_eapi", "exheres-0");
keys->insert("distdir", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "distdir"));
keys->insert("builddir", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "build"));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -1791,10 +1793,13 @@ namespace test_cases
#ifdef ENABLE_VIRTUALS_REPOSITORY
std::tr1::shared_ptr<Map<std::string, std::string> > iv_keys(new Map<std::string, std::string>);
iv_keys->insert("root", "/");
- env.package_database()->add_repository(-2, RepositoryMaker::get_instance()->find_maker("installed_virtuals")(&env,
+ iv_keys->insert("format", "installed_virtuals");
+ env.package_database()->add_repository(-2, RepositoryFactory::get_instance()->create(&env,
std::tr1::bind(from_keys, iv_keys, std::tr1::placeholders::_1)));
- env.package_database()->add_repository(-2, RepositoryMaker::get_instance()->find_maker("virtuals")(&env,
- std::tr1::bind(from_keys, make_shared_ptr(new Map<std::string, std::string>), std::tr1::placeholders::_1)));
+ std::tr1::shared_ptr<Map<std::string, std::string> > v_keys(new Map<std::string, std::string>);
+ v_keys->insert("format", "virtuals");
+ env.package_database()->add_repository(-2, RepositoryFactory::get_instance()->create(&env,
+ std::tr1::bind(from_keys, v_keys, std::tr1::placeholders::_1)));
#endif
InstallAction action(make_named_values<InstallActionOptions>(
@@ -2208,7 +2213,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_TEST_dir/repo17");
keys->insert("profiles", "e_repository_TEST_dir/repo17/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -2266,7 +2271,7 @@ namespace test_cases
keys->insert("distdir", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "distdir"));
keys->insert("builddir", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "symlinked_build"));
keys->insert("root", stringify(FSEntry("e_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -2277,7 +2282,7 @@ namespace test_cases
keys->insert("location", "e_repository_TEST_dir/vdb");
keys->insert("builddir", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("e_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<Repository> installed_repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::shared_ptr<Repository> installed_repo(VDBRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, installed_repo);
diff --git a/paludis/repositories/e/e_repository_sets_TEST.cc b/paludis/repositories/e/e_repository_sets_TEST.cc
index da88d55..716aece 100644
--- a/paludis/repositories/e/e_repository_sets_TEST.cc
+++ b/paludis/repositories/e/e_repository_sets_TEST.cc
@@ -18,7 +18,6 @@
*/
#include <paludis/repositories/e/e_repository.hh>
-#include <paludis/repositories/e/make_ebuild_repository.hh>
#include <paludis/repositories/e/dep_spec_pretty_printer.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
#include <paludis/util/visitor-impl.hh>
@@ -61,7 +60,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_sets_TEST_dir/repo1");
keys->insert("profiles", "e_repository_sets_TEST_dir/repo1/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
std::tr1::shared_ptr<const SetNameSet> sets_list(repo->sets_interface()->sets_list());
@@ -85,7 +84,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_sets_TEST_dir/repo1");
keys->insert("profiles", "e_repository_sets_TEST_dir/repo1/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
std::tr1::shared_ptr<FakeInstalledRepository> installed(
new FakeInstalledRepository(&env, RepositoryName("installed")));
@@ -118,7 +117,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_sets_TEST_dir/repo1");
keys->insert("profiles", "e_repository_sets_TEST_dir/repo1/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -150,7 +149,7 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "e_repository_sets_TEST_dir/repo1");
keys->insert("profiles", "e_repository_sets_TEST_dir/repo1/profiles/profile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
std::tr1::shared_ptr<FakeInstalledRepository> installed(
diff --git a/paludis/repositories/e/exndbam_repository.cc b/paludis/repositories/e/exndbam_repository.cc
index a22fd29..c209618 100644
--- a/paludis/repositories/e/exndbam_repository.cc
+++ b/paludis/repositories/e/exndbam_repository.cc
@@ -132,7 +132,7 @@ ExndbamRepository::_add_metadata_keys() const
}
std::tr1::shared_ptr<Repository>
-ExndbamRepository::make_exndbam_repository(
+ExndbamRepository::repository_factory_create(
Environment * const env,
const std::tr1::function<std::string (const std::string &)> & f)
{
@@ -181,6 +181,26 @@ ExndbamRepository::make_exndbam_repository(
.builddir(builddir)));
}
+RepositoryName
+ExndbamRepository::repository_factory_name(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> & f)
+{
+ std::string name(f("name"));
+ if (name.empty())
+ return RepositoryName("installed");
+ else
+ return RepositoryName(name);
+}
+
+std::tr1::shared_ptr<const RepositoryNameSet>
+ExndbamRepository::repository_factory_dependencies(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> &)
+{
+ return make_shared_ptr(new RepositoryNameSet);
+}
+
void
ExndbamRepository::invalidate()
{
diff --git a/paludis/repositories/e/exndbam_repository.hh b/paludis/repositories/e/exndbam_repository.hh
index 006c05c..005df94 100644
--- a/paludis/repositories/e/exndbam_repository.hh
+++ b/paludis/repositories/e/exndbam_repository.hh
@@ -55,13 +55,6 @@ namespace paludis
ExndbamRepository(const RepositoryName & n, const ExndbamRepositoryParams &);
/**
- * Virtual constructor.
- */
- static std::tr1::shared_ptr<Repository> make_exndbam_repository(
- Environment * const env,
- const std::tr1::function<std::string (const std::string &)> &);
-
- /**
* Destructor.
*/
~ExndbamRepository();
@@ -112,6 +105,22 @@ namespace paludis
///\}
+ ///\name RepositoryFactory functions
+ ///\{
+
+ static RepositoryName repository_factory_name(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<Repository> repository_factory_create(
+ Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<const RepositoryNameSet> repository_factory_dependencies(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ ///\}
};
class PALUDIS_VISIBLE ExndbamRepositoryConfigurationError : public ConfigurationError
diff --git a/paludis/repositories/e/exndbam_repository_TEST.cc b/paludis/repositories/e/exndbam_repository_TEST.cc
index 09c01bb..bdc8476 100644
--- a/paludis/repositories/e/exndbam_repository_TEST.cc
+++ b/paludis/repositories/e/exndbam_repository_TEST.cc
@@ -19,7 +19,6 @@
#include <paludis/repositories/e/e_repository.hh>
#include <paludis/repositories/e/exndbam_repository.hh>
-#include <paludis/repositories/e/make_ebuild_repository.hh>
#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/indirect_iterator-impl.hh>
@@ -62,7 +61,7 @@ namespace test_cases
std::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");
- std::tr1::shared_ptr<Repository> repo(ExndbamRepository::make_exndbam_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ExndbamRepository::ExndbamRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "installed");
}
@@ -98,7 +97,7 @@ namespace test_cases
keys->insert("distdir", stringify(FSEntry::cwd() / "exndbam_repository_TEST_dir" / "distdir"));
keys->insert("builddir", stringify(FSEntry::cwd() / "exndbam_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("exndbam_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<ERepository> repo1(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo1(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo1);
@@ -107,7 +106,7 @@ namespace test_cases
keys->insert("location", "exndbam_repository_TEST_dir/postinsttest");
keys->insert("builddir", stringify(FSEntry::cwd() / "exndbam_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("exndbam_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<Repository> exndbam_repo(ExndbamRepository::make_exndbam_repository(&env,
+ std::tr1::shared_ptr<Repository> exndbam_repo(ExndbamRepository::ExndbamRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(0, exndbam_repo);
diff --git a/paludis/repositories/e/make_ebuild_repository.cc b/paludis/repositories/e/make_ebuild_repository.cc
deleted file mode 100644
index c796b25..0000000
--- a/paludis/repositories/e/make_ebuild_repository.cc
+++ /dev/null
@@ -1,300 +0,0 @@
-/* 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 "make_ebuild_repository.hh"
-#include <paludis/util/log.hh>
-#include <paludis/util/tokeniser.hh>
-#include <paludis/util/map.hh>
-#include <paludis/util/sequence.hh>
-#include <paludis/util/destringify.hh>
-#include <paludis/util/create_iterator-impl.hh>
-#include <paludis/util/wrapped_forward_iterator.hh>
-#include <paludis/util/wrapped_output_iterator.hh>
-#include <paludis/util/options.hh>
-#include <paludis/util/config_file.hh>
-#include <paludis/repositories/e/e_repository_exceptions.hh>
-#include <paludis/environment.hh>
-#include <paludis/distribution.hh>
-#include <paludis/metadata_key.hh>
-
-using namespace paludis;
-
-std::tr1::shared_ptr<ERepository>
-paludis::make_ebuild_repository(
- Environment * const env,
- const std::tr1::function<std::string (const std::string &)> & f)
-{
- Context context("When making ebuild repository from repo_file '" + f("repo_file") + "':");
-
- std::string location(f("location"));
- if (location.empty())
- throw ERepositoryConfigurationError("Key 'location' not specified or empty");
-
- std::tr1::shared_ptr<KeyValueConfigFile> layout_conf((FSEntry(location) / "metadata/layout.conf").exists() ?
- new KeyValueConfigFile(FSEntry(location) / "metadata/layout.conf", KeyValueConfigFileOptions(),
- &KeyValueConfigFile::no_defaults, &KeyValueConfigFile::no_transformation)
- : 0);
-
- std::tr1::shared_ptr<const RepositoryName> master_repository_name;
- std::tr1::shared_ptr<const ERepository> master_repository;
- if (! f("master_repository").empty())
- {
- Context context_local("When finding configuration information for master_repository '"
- + stringify(f("master_repository")) + "':");
-
- master_repository_name.reset(new RepositoryName(f("master_repository")));
-
- std::tr1::shared_ptr<const Repository> master_repository_uncasted(
- env->package_database()->fetch_repository(*master_repository_name));
-
- std::string format("unknown");
- if (master_repository_uncasted->format_key())
- format = master_repository_uncasted->format_key()->value();
- if (format != "ebuild")
- throw ERepositoryConfigurationError("Master repository format is '" +
- stringify(format) + "', not 'ebuild'");
-
- master_repository = std::tr1::static_pointer_cast<const ERepository>(master_repository_uncasted);
-
- if (master_repository->params().master_repository)
- throw ERepositoryConfigurationError("Requested master repository has a master_repository of '" +
- stringify(master_repository->params().master_repository->name()) + "', so it cannot "
- "be used as a master repository");
- }
-
- std::tr1::shared_ptr<FSEntrySequence> profiles(new FSEntrySequence);
- tokenise_whitespace(f("profiles"), create_inserter<FSEntry>(std::back_inserter(*profiles)));
-
- if (profiles->empty())
- {
- if (master_repository)
- std::copy(master_repository->params().profiles->begin(),
- master_repository->params().profiles->end(), profiles->back_inserter());
- else
- throw ERepositoryConfigurationError("No profiles have been specified");
- }
-
- std::tr1::shared_ptr<FSEntrySequence> eclassdirs(new FSEntrySequence);
- tokenise_whitespace(f("eclassdirs"), create_inserter<FSEntry>(std::back_inserter(*eclassdirs)));
-
- if (eclassdirs->empty())
- {
- if (master_repository)
- std::copy(master_repository->params().eclassdirs->begin(),
- master_repository->params().eclassdirs->end(), eclassdirs->back_inserter());
-
- eclassdirs->push_back(location + "/eclass");
- }
-
- std::string distdir(f("distdir"));
- if (distdir.empty())
- {
- if (master_repository)
- distdir = stringify(master_repository->params().distdir);
- else
- {
- distdir = (*DistributionData::get_instance()->distribution_from_string(
- env->distribution())).default_ebuild_distdir();
- if (distdir.empty())
- distdir = location + "/distfiles";
- else if ('/' != distdir.at(0))
- distdir = location + "/" + distdir;
- }
- }
-
- std::string setsdir(f("setsdir"));
- if (setsdir.empty())
- setsdir = location + "/sets";
-
- std::string securitydir(f("securitydir"));
- if (securitydir.empty())
- securitydir = location + "/metadata/glsa";
-
- std::string newsdir(f("newsdir"));
- if (newsdir.empty())
- newsdir = location + "/metadata/news";
-
- std::string cache(f("cache"));
- if (cache.empty())
- {
- cache = location + "/metadata/cache";
- if (! FSEntry(cache).exists())
- cache = "/var/empty";
- }
-
- std::string write_cache(f("write_cache"));
- if (write_cache.empty())
- write_cache = (*DistributionData::get_instance()->distribution_from_string(
- env->distribution())).default_ebuild_write_cache();
-
- bool append_repository_name_to_write_cache(true);
- if (! f("append_repository_name_to_write_cache").empty())
- {
- Context item_context("When handling append_repository_name_to_write_cache key:");
- append_repository_name_to_write_cache = destringify<bool>(f("append_repository_name_to_write_cache"));
- }
-
- bool ignore_deprecated_profiles(false);
- if (! f("ignore_deprecated_profiles").empty())
- {
- Context item_context("When handling ignore_deprecated_profiles key:");
- ignore_deprecated_profiles = destringify<bool>(f("ignore_deprecated_profiles"));
- }
-
- std::string eapi_when_unknown(f("eapi_when_unknown"));
- if (eapi_when_unknown.empty())
- {
- if (! layout_conf
- || (eapi_when_unknown = layout_conf->get("eapi_when_unknown")).empty())
- eapi_when_unknown = (*DistributionData::get_instance()->distribution_from_string(
- env->distribution())).default_ebuild_eapi_when_unknown();
- }
-
- std::string eapi_when_unspecified(f("eapi_when_unspecified"));
- if (eapi_when_unspecified.empty())
- {
- if (! layout_conf
- || (eapi_when_unspecified = layout_conf->get("eapi_when_unspecified")).empty())
- eapi_when_unspecified = (*DistributionData::get_instance()->distribution_from_string(
- env->distribution())).default_ebuild_eapi_when_unspecified();
- }
-
- std::string profile_eapi(f("profile_eapi"));
- if (profile_eapi.empty())
- {
- if (! layout_conf
- || (profile_eapi = layout_conf->get("eapi_when_unspecified")).empty())
- profile_eapi = (*DistributionData::get_instance()->distribution_from_string(
- env->distribution())).default_ebuild_profile_eapi();
- }
-
- std::string names_cache(f("names_cache"));
- if (names_cache.empty())
- {
- names_cache = (*DistributionData::get_instance()->distribution_from_string(
- env->distribution())).default_ebuild_names_cache();
- if (names_cache.empty())
- {
- Log::get_instance()->message("e.ebuild.configuration.no_names_cache", ll_warning, lc_no_context)
- << "The names_cache key is not set in '" << f("repo_file")
- << "'. You should read the Paludis documentation and select an appropriate value.";
- names_cache = "/var/empty";
- }
- }
-
- std::string sync(f("sync"));
- std::string sync_options(f("sync_options"));
-
- if (! f("sync_exclude").empty())
- {
- Log::get_instance()->message("e.ebuild.configuration.deprecated", ll_warning, lc_no_context)
- << "The sync_exclude key in '" << f("repo_file") << "' is deprecated in favour of sync_options = --exclude-from=";
- if (! sync_options.empty())
- sync_options += " ";
- sync_options += "--exclude-from='" + f("sync_exclude") + "'";
- }
-
- std::string builddir(f("builddir"));
- if (builddir.empty())
- {
- builddir = f("buildroot");
- if (builddir.empty())
- {
- if (master_repository)
- builddir = stringify(master_repository->params().builddir);
- else
- builddir = (*DistributionData::get_instance()->distribution_from_string(
- env->distribution())).default_ebuild_builddir();
- }
- else
- Log::get_instance()->message("e.ebuild.configuration.deprecated", ll_warning, lc_context)
- << "Key 'buildroot' is deprecated, use 'builddir' instead";
- }
-
- std::string layout(f("layout"));
- if (layout.empty())
- {
- if (! layout_conf
- || (layout = layout_conf->get("layout")).empty())
- layout = (*DistributionData::get_instance()->distribution_from_string(
- env->distribution())).default_ebuild_layout();
- }
-
- erepository::UseManifest use_manifest(erepository::manifest_use);
- if (! f("use_manifest").empty())
- {
- Context item_context("When handling use_manifest key:");
- use_manifest = destringify<erepository::UseManifest>(f("use_manifest"));
- }
-
- bool binary_destination(false);
- if (! f("binary_destination").empty())
- {
- Context item_context("When handling binary_destination key:");
- binary_destination = destringify<bool>(f("binary_destination"));
- }
-
- std::string binary_uri_prefix(f("binary_uri_prefix"));
- std::string binary_distdir(f("binary_distdir"));
- std::string binary_keywords(f("binary_keywords"));
- if (binary_keywords.empty())
- {
- if (binary_destination)
- throw ERepositoryConfigurationError("binary_destination = true, but binary_keywords is unset or empty");
- }
-
- return std::tr1::shared_ptr<ERepository>(new ERepository(ERepositoryParams::create()
- .entry_format("ebuild")
- .layout(layout)
- .environment(env)
- .location(location)
- .profiles(profiles)
- .cache(cache)
- .write_cache(write_cache)
- .names_cache(names_cache)
- .eclassdirs(eclassdirs)
- .distdir(distdir)
- .securitydir(securitydir)
- .setsdir(setsdir)
- .newsdir(newsdir)
- .sync(sync)
- .sync_options(sync_options)
- .master_repository(master_repository)
- .write_bin_uri_prefix("")
- .eapi_when_unknown(eapi_when_unknown)
- .eapi_when_unspecified(eapi_when_unspecified)
- .profile_eapi(profile_eapi)
- .use_manifest(use_manifest)
- .append_repository_name_to_write_cache(append_repository_name_to_write_cache)
- .ignore_deprecated_profiles(ignore_deprecated_profiles)
- .binary_destination(binary_destination)
- .binary_uri_prefix(binary_uri_prefix)
- .binary_distdir(binary_distdir)
- .binary_keywords(binary_keywords)
- .builddir(FSEntry(builddir).realpath_if_exists())));
-}
-
-std::tr1::shared_ptr<Repository>
-paludis::make_ebuild_repository_wrapped(
- Environment * const env,
- const std::tr1::function<std::string (const std::string &)> & f)
-{
- return make_ebuild_repository(env, f);
-}
-
diff --git a/paludis/repositories/e/make_ebuild_repository.hh b/paludis/repositories/e/make_ebuild_repository.hh
deleted file mode 100644
index b122cb5..0000000
--- a/paludis/repositories/e/make_ebuild_repository.hh
+++ /dev/null
@@ -1,51 +0,0 @@
-/* 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_MAKE_EBUILD_REPOSITORY_HH
-#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_MAKE_EBUILD_REPOSITORY_HH 1
-
-#include <paludis/repositories/e/e_repository.hh>
-#include <paludis/util/map-fwd.hh>
-
-namespace paludis
-{
- /**
- * Create an ebuild format repository.
- *
- * \see ERepository
- * \ingroup grperepository
- */
- std::tr1::shared_ptr<ERepository>
- make_ebuild_repository(
- Environment * const,
- const std::tr1::function<std::string (const std::string &)> &) PALUDIS_VISIBLE;
-
- /**
- * Create an ebuild format repository (wrapper for our virtual constructor).
- *
- * \see ERepository
- * \ingroup grperepository
- */
- std::tr1::shared_ptr<Repository>
- make_ebuild_repository_wrapped(
- Environment * const env,
- const std::tr1::function<std::string (const std::string &)> &) PALUDIS_VISIBLE;
-}
-
-#endif
diff --git a/paludis/repositories/e/qa/manifest_TEST.cc b/paludis/repositories/e/qa/manifest_TEST.cc
index bc5ce85..7eddc48 100644
--- a/paludis/repositories/e/qa/manifest_TEST.cc
+++ b/paludis/repositories/e/qa/manifest_TEST.cc
@@ -26,7 +26,7 @@
#include <paludis/util/map.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/environments/test/test_environment.hh>
-#include <paludis/repositories/e/make_ebuild_repository.hh>
+#include <paludis/repositories/e/e_repository.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -90,8 +90,8 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "manifest_TEST_dir/repo1");
keys->insert("profiles", stringify(FSEntry::cwd() / "manifest_TEST_dir/repo1/profiles/test"));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ std::tr1::shared_ptr<ERepository> repo(std::tr1::static_pointer_cast<ERepository>(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1))));
env.package_database()->add_repository(1, repo);
QualifiedPackageName qpn("cat/not-signed");
@@ -116,8 +116,8 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "manifest_TEST_dir/repo1");
keys->insert("profiles", stringify(FSEntry::cwd() / "manifest_TEST_dir/repo1/profiles/test"));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ std::tr1::shared_ptr<ERepository> repo(std::tr1::static_pointer_cast<ERepository>(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1))));
env.package_database()->add_repository(1, repo);
QualifiedPackageName qpn("cat/good");
@@ -141,8 +141,8 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "manifest_TEST_dir/repo1");
keys->insert("profiles", stringify(FSEntry::cwd() / "manifest_TEST_dir/repo1/profiles/test"));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ std::tr1::shared_ptr<ERepository> repo(std::tr1::static_pointer_cast<ERepository>(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1))));
env.package_database()->add_repository(1, repo);
QualifiedPackageName qpn("cat/bad-type");
@@ -166,8 +166,8 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "manifest_TEST_dir/repo1");
keys->insert("profiles", stringify(FSEntry::cwd() / "manifest_TEST_dir/repo1/profiles/test"));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ std::tr1::shared_ptr<ERepository> repo(std::tr1::static_pointer_cast<ERepository>(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1))));
env.package_database()->add_repository(1, repo);
QualifiedPackageName qpn("cat/bad-size");
@@ -191,8 +191,8 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "manifest_TEST_dir/repo1");
keys->insert("profiles", stringify(FSEntry::cwd() / "manifest_TEST_dir/repo1/profiles/test"));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ std::tr1::shared_ptr<ERepository> repo(std::tr1::static_pointer_cast<ERepository>(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1))));
env.package_database()->add_repository(1, repo);
QualifiedPackageName qpn("cat/bad-hash");
@@ -216,8 +216,8 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "manifest_TEST_dir/repo1");
keys->insert("profiles", stringify(FSEntry::cwd() / "manifest_TEST_dir/repo1/profiles/test"));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ std::tr1::shared_ptr<ERepository> repo(std::tr1::static_pointer_cast<ERepository>(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1))));
env.package_database()->add_repository(1, repo);
QualifiedPackageName qpn("cat/missing");
@@ -241,8 +241,8 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "manifest_TEST_dir/repo1");
keys->insert("profiles", stringify(FSEntry::cwd() / "manifest_TEST_dir/repo1/profiles/test"));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ std::tr1::shared_ptr<ERepository> repo(std::tr1::static_pointer_cast<ERepository>(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1))));
env.package_database()->add_repository(1, repo);
QualifiedPackageName qpn("cat/stray");
@@ -266,8 +266,8 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "manifest_TEST_dir/repo1");
keys->insert("profiles", stringify(FSEntry::cwd() / "manifest_TEST_dir/repo1/profiles/test"));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ std::tr1::shared_ptr<ERepository> repo(std::tr1::static_pointer_cast<ERepository>(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1))));
env.package_database()->add_repository(1, repo);
QualifiedPackageName qpn("cat/unused-distfile");
@@ -291,8 +291,8 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "manifest_TEST_dir/repo1");
keys->insert("profiles", stringify(FSEntry::cwd() / "manifest_TEST_dir/repo1/profiles/test"));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ std::tr1::shared_ptr<ERepository> repo(std::tr1::static_pointer_cast<ERepository>(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1))));
env.package_database()->add_repository(1, repo);
QualifiedPackageName qpn("cat/undigested-distfile");
diff --git a/paludis/repositories/e/qa/qa.cc b/paludis/repositories/e/qa/qa.cc
index 03633b6..e762390 100644
--- a/paludis/repositories/e/qa/qa.cc
+++ b/paludis/repositories/e/qa/qa.cc
@@ -27,13 +27,14 @@ using namespace paludis;
namespace paludis
{
- class RepositoryMaker;
+ class RepositoryFactory;
class ERepository;
}
extern "C"
{
- void PALUDIS_VISIBLE register_repositories(paludis::RepositoryMaker * maker);
+ void PALUDIS_VISIBLE paludis_initialise_repository_so(paludis::RepositoryFactory * const);
+
void PALUDIS_VISIBLE check_qa(
const Environment * const,
const std::tr1::shared_ptr<const ERepository> &,
@@ -44,7 +45,7 @@ extern "C"
const FSEntry &);
}
-void register_repositories(paludis::RepositoryMaker *)
+void paludis_initialise_repository_so(paludis::RepositoryFactory * const)
{
}
diff --git a/paludis/repositories/e/qa/visibility_TEST.cc b/paludis/repositories/e/qa/visibility_TEST.cc
index e632604..08465ff 100644
--- a/paludis/repositories/e/qa/visibility_TEST.cc
+++ b/paludis/repositories/e/qa/visibility_TEST.cc
@@ -19,7 +19,6 @@
#include "visibility.hh"
#include <paludis/repositories/e/e_repository.hh>
-#include <paludis/repositories/e/make_ebuild_repository.hh>
#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/map.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
@@ -90,8 +89,8 @@ namespace test_cases
keys->insert("names_cache", "/var/empty");
keys->insert("location", "visibility_TEST_dir/repo1");
keys->insert("profiles", stringify(FSEntry::cwd() / "visibility_TEST_dir/repo1/profiles/test"));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ std::tr1::shared_ptr<ERepository> repo(std::tr1::static_pointer_cast<ERepository>(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1))));
env.package_database()->add_repository(1, repo);
{
diff --git a/paludis/repositories/e/registration.cc b/paludis/repositories/e/registration.cc
index e22e2ce..07ad5e6 100644
--- a/paludis/repositories/e/registration.cc
+++ b/paludis/repositories/e/registration.cc
@@ -17,24 +17,16 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/repository_maker.hh>
-#include <paludis/repositories/e/make_ebuild_repository.hh>
+#include <paludis/repository_factory.hh>
+#include <paludis/repositories/e/e_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>
-#include "config.h"
+#include <paludis/util/set.hh>
using namespace paludis;
-#ifndef MONOLITHIC
-
-extern "C"
-{
- void PALUDIS_VISIBLE register_repositories(RepositoryMaker * maker);
-}
-
namespace
{
std::tr1::shared_ptr<Repository>
@@ -47,19 +39,53 @@ namespace
Log::get_instance()->message("e.portage.configuration.deprecated", ll_warning, lc_context)
<< "Format 'portage' is deprecated, use 'ebuild' instead";
- return make_ebuild_repository_wrapped(env, f);
+ return ERepository::repository_factory_create(env, f);
}
}
-void register_repositories(RepositoryMaker * maker)
+extern "C" void paludis_initialise_repository_so(RepositoryFactory * const factory) PALUDIS_VISIBLE;
+
+void paludis_initialise_repository_so(RepositoryFactory * const factory)
{
- maker->register_maker("ebuild", &make_ebuild_repository_wrapped);
- 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);
-}
+ std::tr1::shared_ptr<Set<std::string> > ebuild_formats(new Set<std::string>);
+ ebuild_formats->insert("ebuild");
+ ebuild_formats->insert("exheres");
-#endif
+ factory->add_repository_format(
+ ebuild_formats,
+ &ERepository::repository_factory_name,
+ &ERepository::repository_factory_create,
+ &ERepository::repository_factory_dependencies
+ );
+ std::tr1::shared_ptr<Set<std::string> > deprecated_ebuild_formats(new Set<std::string>);
+ deprecated_ebuild_formats->insert("portage");
+
+ factory->add_repository_format(
+ deprecated_ebuild_formats,
+ &ERepository::repository_factory_name,
+ make_portage_repository,
+ &ERepository::repository_factory_dependencies
+ );
+
+ std::tr1::shared_ptr<Set<std::string> > vdb_formats(new Set<std::string>);
+ vdb_formats->insert("vdb");
+
+ factory->add_repository_format(
+ vdb_formats,
+ &VDBRepository::repository_factory_name,
+ &VDBRepository::repository_factory_create,
+ &VDBRepository::repository_factory_dependencies
+ );
+
+ std::tr1::shared_ptr<Set<std::string> > exndbam_formats(new Set<std::string>);
+ exndbam_formats->insert("exndbam");
+
+ factory->add_repository_format(
+ exndbam_formats,
+ &ExndbamRepository::repository_factory_name,
+ &ExndbamRepository::repository_factory_create,
+ &ExndbamRepository::repository_factory_dependencies
+ );
+}
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index fcd9511..cf8c2d8 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -279,7 +279,7 @@ VDBRepository::package_ids(const QualifiedPackageName & n) const
}
std::tr1::shared_ptr<Repository>
-VDBRepository::make_vdb_repository(
+VDBRepository::repository_factory_create(
Environment * const env,
const std::tr1::function<std::string (const std::string &)> & f)
{
@@ -357,6 +357,26 @@ VDBRepository::make_vdb_repository(
.names_cache(names_cache)));
}
+RepositoryName
+VDBRepository::repository_factory_name(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> & f)
+{
+ std::string name(f("name"));
+ if (name.empty())
+ return RepositoryName("installed");
+ else
+ return RepositoryName(name);
+}
+
+std::tr1::shared_ptr<const RepositoryNameSet>
+VDBRepository::repository_factory_dependencies(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> &)
+{
+ return make_shared_ptr(new RepositoryNameSet);
+}
+
VDBRepositoryConfigurationError::VDBRepositoryConfigurationError(
const std::string & msg) throw () :
ConfigurationError("VDB repository configuration error: " + msg)
diff --git a/paludis/repositories/e/vdb_repository.hh b/paludis/repositories/e/vdb_repository.hh
index b47483a..47c6d64 100644
--- a/paludis/repositories/e/vdb_repository.hh
+++ b/paludis/repositories/e/vdb_repository.hh
@@ -87,13 +87,6 @@ namespace paludis
VDBRepository(const VDBRepositoryParams &);
/**
- * Virtual constructor.
- */
- static std::tr1::shared_ptr<Repository> make_vdb_repository(
- Environment * const env,
- const std::tr1::function<std::string (const std::string &)> &);
-
- /**
* Destructor.
*/
~VDBRepository();
@@ -142,6 +135,23 @@ namespace paludis
/* Keys */
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > installed_root_key() const;
+
+ ///\name RepositoryFactory functions
+ ///\{
+
+ static RepositoryName repository_factory_name(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<Repository> repository_factory_create(
+ Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<const RepositoryNameSet> repository_factory_dependencies(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ ///\}
};
/**
diff --git a/paludis/repositories/e/vdb_repository_TEST.cc b/paludis/repositories/e/vdb_repository_TEST.cc
index 76ed1bd..a20b8fe 100644
--- a/paludis/repositories/e/vdb_repository_TEST.cc
+++ b/paludis/repositories/e/vdb_repository_TEST.cc
@@ -20,7 +20,6 @@
#include <paludis/repositories/e/vdb_repository.hh>
#include <paludis/repositories/e/dep_spec_pretty_printer.hh>
#include <paludis/repositories/e/e_repository.hh>
-#include <paludis/repositories/e/make_ebuild_repository.hh>
#include <paludis/environments/test/test_environment.hh>
#include <paludis/package_database.hh>
#include <paludis/metadata_key.hh>
@@ -78,7 +77,7 @@ namespace test_cases
keys->insert("provides_cache", "/var/empty");
keys->insert("location", "vdb_repository_TEST_dir/repo1");
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
- std::tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(VDBRepository::VDBRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "installed");
}
@@ -99,7 +98,7 @@ namespace test_cases
keys->insert("provides_cache", "/var/empty");
keys->insert("location", "vdb_repository_TEST_dir/repo1");
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
- std::tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(VDBRepository::VDBRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
TEST_CHECK(repo->has_category_named(CategoryNamePart("cat-one")));
@@ -123,7 +122,7 @@ namespace test_cases
keys->insert("provides_cache", "/var/empty");
keys->insert("location", "vdb_repository_TEST_dir/repo1");
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
- std::tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(VDBRepository::VDBRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -202,7 +201,7 @@ namespace test_cases
keys->insert("location", "vdb_repository_TEST_dir/repo1");
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
keys->insert("world", "vdb_repository_TEST_dir/world-no-match-no-eol");
- std::tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(VDBRepository::VDBRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -257,7 +256,7 @@ namespace test_cases
keys->insert("provides_cache", "/var/empty");
keys->insert("location", "vdb_repository_TEST_dir/repo2");
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
- std::tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(VDBRepository::VDBRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -320,7 +319,7 @@ namespace test_cases
keys->insert("distdir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "distdir"));
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -331,7 +330,7 @@ namespace test_cases
keys->insert("location", "vdb_repository_TEST_dir/repo3");
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(0, vdb_repo);
@@ -434,7 +433,7 @@ namespace test_cases
keys->insert("distdir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "distdir"));
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -445,7 +444,7 @@ namespace test_cases
keys->insert("location", "vdb_repository_TEST_dir/repo3");
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(0, vdb_repo);
@@ -548,7 +547,7 @@ namespace test_cases
keys->insert("distdir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "distdir"));
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
@@ -559,7 +558,7 @@ namespace test_cases
keys->insert("location", "vdb_repository_TEST_dir/namesincrtest");
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(0, vdb_repo);
@@ -830,7 +829,7 @@ namespace test_cases
keys->insert("location", "vdb_repository_TEST_dir/providestest");
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(0, vdb_repo);
@@ -921,7 +920,7 @@ namespace test_cases
keys->insert("distdir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "distdir"));
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<ERepository> repo1(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo1(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo1);
@@ -937,7 +936,7 @@ namespace test_cases
keys->insert("distdir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "distdir"));
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<ERepository> repo2(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo2(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(2, repo2);
@@ -948,7 +947,7 @@ namespace test_cases
keys->insert("location", "vdb_repository_TEST_dir/providesincrtest");
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(0, vdb_repo);
@@ -1156,7 +1155,7 @@ namespace test_cases
keys->insert("distdir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "distdir"));
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<ERepository> repo1(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo1(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo1);
@@ -1172,7 +1171,7 @@ namespace test_cases
keys->insert("distdir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "distdir"));
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<ERepository> repo2(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo2(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(2, repo2);
@@ -1183,7 +1182,7 @@ namespace test_cases
keys->insert("location", "vdb_repository_TEST_dir/reinstalltest");
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(0, vdb_repo);
@@ -1263,7 +1262,7 @@ namespace test_cases
keys->insert("distdir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "distdir"));
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<ERepository> repo1(make_ebuild_repository(&env,
+ std::tr1::shared_ptr<Repository> repo1(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo1);
@@ -1274,7 +1273,7 @@ namespace test_cases
keys->insert("location", "vdb_repository_TEST_dir/postinsttest");
keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
- std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(0, vdb_repo);
diff --git a/paludis/repositories/e/xml_things.cc b/paludis/repositories/e/xml_things.cc
index b72f55f..a6ed6db 100644
--- a/paludis/repositories/e/xml_things.cc
+++ b/paludis/repositories/e/xml_things.cc
@@ -202,15 +202,10 @@ create_glsa_from_xml_file(const std::string & filename)
namespace paludis
{
- class RepositoryMaker;
+ class RepositoryFactory;
}
-extern "C"
-{
- void PALUDIS_VISIBLE register_repositories(RepositoryMaker * maker);
-}
-
-void register_repositories(RepositoryMaker *)
+extern "C" void PALUDIS_VISIBLE paludis_initialise_repository_so(paludis::RepositoryFactory * const)
{
}
diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc
index ba5a821..73d0758 100644
--- a/paludis/repositories/fake/fake_repository.cc
+++ b/paludis/repositories/fake/fake_repository.cc
@@ -125,15 +125,10 @@ FakeRepository::add_virtual_package(const QualifiedPackageName & q, std::tr1::sh
namespace paludis
{
- class RepositoryMaker;
+ class RepositoryFactory;
}
-extern "C"
-{
- void PALUDIS_VISIBLE register_repositories(RepositoryMaker * maker);
-}
-
-void register_repositories(RepositoryMaker *)
+extern "C" void PALUDIS_VISIBLE paludis_initialise_repository_so(paludis::RepositoryFactory * const)
{
}
diff --git a/paludis/repositories/gems/gems_repository.cc b/paludis/repositories/gems/gems_repository.cc
index 4b77049..d704078 100644
--- a/paludis/repositories/gems/gems_repository.cc
+++ b/paludis/repositories/gems/gems_repository.cc
@@ -22,6 +22,7 @@
#include <paludis/repositories/gems/yaml.hh>
#include <paludis/repositories/gems/gem_specification.hh>
#include <paludis/repositories/gems/gem_specifications.hh>
+#include <paludis/repositories/gems/exceptions.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
@@ -35,6 +36,8 @@
#include <paludis/action.hh>
#include <paludis/metadata_key.hh>
#include <paludis/literal_metadata_key.hh>
+#include <paludis/distribution.hh>
+#include <paludis/environment.hh>
#include <tr1/unordered_map>
#include <fstream>
@@ -354,3 +357,49 @@ GemsRepository::installed_root_key() const
return std::tr1::shared_ptr<const MetadataValueKey<FSEntry> >();
}
+std::tr1::shared_ptr<Repository>
+GemsRepository::repository_factory_create(
+ Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> & f)
+{
+ std::string location(f("location"));
+ if (location.empty())
+ throw gems::RepositoryConfigurationError("Key 'location' not specified or empty");
+
+ std::string install_dir(f("install_dir"));
+ if (install_dir.empty())
+ throw gems::RepositoryConfigurationError("Key 'install_dir' not specified or empty");
+
+ std::string sync(f("sync"));
+
+ std::string sync_options(f("sync_options"));
+
+ std::string builddir(f("builddir"));
+ if (builddir.empty())
+ builddir = (*DistributionData::get_instance()->distribution_from_string(env->distribution())).default_ebuild_builddir();
+
+ return make_shared_ptr(new GemsRepository(gems::RepositoryParams::create()
+ .location(location)
+ .sync(sync)
+ .sync_options(sync_options)
+ .environment(env)
+ .install_dir(install_dir)
+ .builddir(builddir)));
+}
+
+RepositoryName
+GemsRepository::repository_factory_name(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> &)
+{
+ return RepositoryName("gems");
+}
+
+std::tr1::shared_ptr<const RepositoryNameSet>
+GemsRepository::repository_factory_dependencies(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> &)
+{
+ return make_shared_ptr(new RepositoryNameSet);
+}
+
diff --git a/paludis/repositories/gems/gems_repository.hh b/paludis/repositories/gems/gems_repository.hh
index e67d254..48ac64d 100644
--- a/paludis/repositories/gems/gems_repository.hh
+++ b/paludis/repositories/gems/gems_repository.hh
@@ -88,6 +88,23 @@ namespace paludis
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > installed_root_key() const;
+
+ ///\name RepositoryFactory functions
+ ///\{
+
+ static RepositoryName repository_factory_name(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<Repository> repository_factory_create(
+ Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<const RepositoryNameSet> repository_factory_dependencies(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ ///\}
};
}
diff --git a/paludis/repositories/gems/installed_gems_repository.cc b/paludis/repositories/gems/installed_gems_repository.cc
index 1f5a968..da22e58 100644
--- a/paludis/repositories/gems/installed_gems_repository.cc
+++ b/paludis/repositories/gems/installed_gems_repository.cc
@@ -21,6 +21,7 @@
#include <paludis/repositories/gems/params.hh>
#include <paludis/repositories/gems/gem_specification.hh>
#include <paludis/repositories/gems/yaml.hh>
+#include <paludis/repositories/gems/exceptions.hh>
#include <paludis/package_database.hh>
#include <paludis/environment.hh>
#include <paludis/util/stringify.hh>
@@ -38,6 +39,7 @@
#include <paludis/util/hashes.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/literal_metadata_key.hh>
+#include <paludis/distribution.hh>
#include <paludis/action.hh>
#include <tr1/unordered_map>
@@ -371,3 +373,43 @@ InstalledGemsRepository::installed_root_key() const
return _imp->root_key;
}
+RepositoryName
+InstalledGemsRepository::repository_factory_name(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> &)
+{
+ return RepositoryName("installed-gems");
+}
+
+std::tr1::shared_ptr<const RepositoryNameSet>
+InstalledGemsRepository::repository_factory_dependencies(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> &)
+{
+ return make_shared_ptr(new RepositoryNameSet);
+}
+
+std::tr1::shared_ptr<Repository>
+InstalledGemsRepository::repository_factory_create(
+ Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> & f)
+{
+ std::string install_dir(f("install_dir"));
+ if (install_dir.empty())
+ throw gems::RepositoryConfigurationError("Key 'install_dir' not specified or empty");
+
+ std::string builddir(f("builddir"));
+ if (builddir.empty())
+ builddir = (*DistributionData::get_instance()->distribution_from_string(env->distribution())).default_ebuild_builddir();
+
+ std::string root(f("root"));
+ if (root.empty())
+ root = "/";
+
+ return make_shared_ptr(new InstalledGemsRepository(gems::InstalledRepositoryParams::create()
+ .environment(env)
+ .install_dir(install_dir)
+ .root(root)
+ .builddir(builddir)));
+}
+
diff --git a/paludis/repositories/gems/installed_gems_repository.hh b/paludis/repositories/gems/installed_gems_repository.hh
index 9b53482..d7f7cb1 100644
--- a/paludis/repositories/gems/installed_gems_repository.hh
+++ b/paludis/repositories/gems/installed_gems_repository.hh
@@ -103,6 +103,23 @@ namespace paludis
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > installed_root_key() const;
+
+ ///\name RepositoryFactory functions
+ ///\{
+
+ static RepositoryName repository_factory_name(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<Repository> repository_factory_create(
+ Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<const RepositoryNameSet> repository_factory_dependencies(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ ///\}
};
}
diff --git a/paludis/repositories/gems/registration.cc b/paludis/repositories/gems/registration.cc
index 1d2d54c..554cfc6 100644
--- a/paludis/repositories/gems/registration.cc
+++ b/paludis/repositories/gems/registration.cc
@@ -17,84 +17,42 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/repository_maker.hh>
+#include <paludis/repository_factory.hh>
#include <paludis/repositories/gems/gems_repository.hh>
#include <paludis/repositories/gems/installed_gems_repository.hh>
#include <paludis/repositories/gems/params.hh>
#include <paludis/repositories/gems/exceptions.hh>
#include <paludis/util/make_shared_ptr.hh>
-#include <paludis/util/map.hh>
+#include <paludis/util/set.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/distribution.hh>
#include <paludis/environment.hh>
using namespace paludis;
-namespace
-{
- std::tr1::shared_ptr<Repository>
- make_gems_repository(
- Environment * const env,
- const std::tr1::function<std::string (const std::string &)> & f)
- {
- std::string location(f("location"));
- if (location.empty())
- throw gems::RepositoryConfigurationError("Key 'location' not specified or empty");
-
- std::string install_dir(f("install_dir"));
- if (install_dir.empty())
- throw gems::RepositoryConfigurationError("Key 'install_dir' not specified or empty");
-
- std::string sync(f("sync"));
-
- std::string sync_options(f("sync_options"));
-
- std::string builddir(f("builddir"));
- if (builddir.empty())
- builddir = (*DistributionData::get_instance()->distribution_from_string(env->distribution())).default_ebuild_builddir();
-
- return make_shared_ptr(new GemsRepository(gems::RepositoryParams::create()
- .location(location)
- .sync(sync)
- .sync_options(sync_options)
- .environment(env)
- .install_dir(install_dir)
- .builddir(builddir)));
- }
-
- std::tr1::shared_ptr<Repository>
- make_installed_gems_repository(
- Environment * const env,
- const std::tr1::function<std::string (const std::string &)> & f)
- {
- std::string install_dir(f("install_dir"));
- if (install_dir.empty())
- throw gems::RepositoryConfigurationError("Key 'install_dir' not specified or empty");
-
- std::string builddir(f("builddir"));
- if (builddir.empty())
- builddir = (*DistributionData::get_instance()->distribution_from_string(env->distribution())).default_ebuild_builddir();
-
- std::string root(f("root"));
- if (root.empty())
- root = "/";
-
- return make_shared_ptr(new InstalledGemsRepository(gems::InstalledRepositoryParams::create()
- .environment(env)
- .install_dir(install_dir)
- .root(root)
- .builddir(builddir)));
- }
-}
-
-extern "C"
-{
- void PALUDIS_VISIBLE register_repositories(RepositoryMaker * maker);
-}
+extern "C" void paludis_initialise_repository_so(RepositoryFactory * const factory) PALUDIS_VISIBLE;
-void register_repositories(RepositoryMaker * maker)
+void paludis_initialise_repository_so(RepositoryFactory * const factory)
{
- maker->register_maker("gems", &make_gems_repository);
- maker->register_maker("installed_gems", &make_installed_gems_repository);
+ std::tr1::shared_ptr<Set<std::string> > gems_formats(new Set<std::string>);
+ gems_formats->insert("gems");
+
+ factory->add_repository_format(
+ gems_formats,
+ GemsRepository::repository_factory_name,
+ GemsRepository::repository_factory_create,
+ GemsRepository::repository_factory_dependencies
+ );
+
+ std::tr1::shared_ptr<Set<std::string> > installed_gems_formats(new Set<std::string>);
+ installed_gems_formats->insert("installed_gems");
+ installed_gems_formats->insert("installed-gems");
+
+ factory->add_repository_format(
+ installed_gems_formats,
+ InstalledGemsRepository::repository_factory_name,
+ InstalledGemsRepository::repository_factory_create,
+ InstalledGemsRepository::repository_factory_dependencies
+ );
}
diff --git a/paludis/repositories/unavailable/registration.cc b/paludis/repositories/unavailable/registration.cc
index a408f10..eb13e6f 100644
--- a/paludis/repositories/unavailable/registration.cc
+++ b/paludis/repositories/unavailable/registration.cc
@@ -17,54 +17,24 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/repository_maker.hh>
+#include <paludis/repository_factory.hh>
#include <paludis/repositories/unavailable/unavailable_repository.hh>
-#include <paludis/util/map.hh>
-#include <paludis/util/wrapped_forward_iterator.hh>
-#include <paludis/util/make_named_values.hh>
+#include <paludis/util/set.hh>
using namespace paludis;
using namespace paludis::unavailable_repository;
-extern "C"
-{
- void PALUDIS_VISIBLE register_repositories(RepositoryMaker * maker);
-}
-
-namespace
-{
- std::tr1::shared_ptr<Repository>
- make_unavailable_repository(
- Environment * const env,
- const std::tr1::function<std::string (const std::string &)> & f)
- {
- Context context("When making unavailable repository from repo_file '" + f("repo_file") + "':");
-
- std::string name_str(f("name"));
- if (name_str.empty())
- name_str = "unavailable";
-
- std::string location(f("location"));
- if (location.empty())
- throw UnavailableRepositoryConfigurationError("Key 'location' not specified or empty");
-
- std::string sync(f("sync"));
-
- std::string sync_options(f("sync_options"));
-
- return std::tr1::shared_ptr<UnavailableRepository>(new UnavailableRepository(
- make_named_values<UnavailableRepositoryParams>(
- value_for<n::environment>(env),
- value_for<n::location>(location),
- value_for<n::name>(RepositoryName(name_str)),
- value_for<n::sync>(sync),
- value_for<n::sync_options>(sync_options)
- )));
- }
-}
+extern "C" void paludis_initialise_repository_so(RepositoryFactory * const factory) PALUDIS_VISIBLE;
-void register_repositories(RepositoryMaker * maker)
+void paludis_initialise_repository_so(RepositoryFactory * const factory)
{
- maker->register_maker("unavailable", &make_unavailable_repository);
+ std::tr1::shared_ptr<Set<std::string> > unavailable_formats(new Set<std::string>);
+ unavailable_formats->insert("unavailable");
+
+ factory->add_repository_format(unavailable_formats,
+ &UnavailableRepository::repository_factory_name,
+ &UnavailableRepository::repository_factory_create,
+ &UnavailableRepository::repository_factory_dependencies
+ );
}
diff --git a/paludis/repositories/unavailable/unavailable_repository.cc b/paludis/repositories/unavailable/unavailable_repository.cc
index 42da646..5280cbd 100644
--- a/paludis/repositories/unavailable/unavailable_repository.cc
+++ b/paludis/repositories/unavailable/unavailable_repository.cc
@@ -294,5 +294,53 @@ UnavailableRepository::sync() const
return true;
}
+std::tr1::shared_ptr<Repository>
+UnavailableRepository::repository_factory_create(
+ Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> & f)
+{
+ Context context("When making unavailable repository from repo_file '" + f("repo_file") + "':");
+
+ std::string name_str(f("name"));
+ if (name_str.empty())
+ name_str = "unavailable";
+
+ std::string location(f("location"));
+ if (location.empty())
+ throw UnavailableRepositoryConfigurationError("Key 'location' not specified or empty");
+
+ std::string sync(f("sync"));
+
+ std::string sync_options(f("sync_options"));
+
+ return std::tr1::shared_ptr<UnavailableRepository>(new UnavailableRepository(
+ make_named_values<UnavailableRepositoryParams>(
+ value_for<n::environment>(env),
+ value_for<n::location>(location),
+ value_for<n::name>(RepositoryName(name_str)),
+ value_for<n::sync>(sync),
+ value_for<n::sync_options>(sync_options)
+ )));
+}
+
+RepositoryName
+UnavailableRepository::repository_factory_name(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> & f)
+{
+ if (f("name").empty())
+ return RepositoryName("unavailable");
+ else
+ return RepositoryName(f("name"));
+}
+
+std::tr1::shared_ptr<const RepositoryNameSet>
+UnavailableRepository::repository_factory_dependencies(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> &)
+{
+ return make_shared_ptr(new RepositoryNameSet);
+}
+
template class PrivateImplementationPattern<unavailable_repository::UnavailableRepository>;
diff --git a/paludis/repositories/unavailable/unavailable_repository.hh b/paludis/repositories/unavailable/unavailable_repository.hh
index 95be501..7ac3fa1 100644
--- a/paludis/repositories/unavailable/unavailable_repository.hh
+++ b/paludis/repositories/unavailable/unavailable_repository.hh
@@ -92,6 +92,23 @@ namespace paludis
virtual void invalidate_masks();
virtual bool sync() const;
+
+ ///\name RepositoryFactory functions
+ ///\{
+
+ static RepositoryName repository_factory_name(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<Repository> repository_factory_create(
+ Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<const RepositoryNameSet> repository_factory_dependencies(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ ///\}
};
}
diff --git a/paludis/repositories/unpackaged/installed_repository.cc b/paludis/repositories/unpackaged/installed_repository.cc
index 4fb5a10..9f3c719 100644
--- a/paludis/repositories/unpackaged/installed_repository.cc
+++ b/paludis/repositories/unpackaged/installed_repository.cc
@@ -19,6 +19,7 @@
#include <paludis/repositories/unpackaged/installed_repository.hh>
#include <paludis/repositories/unpackaged/installed_id.hh>
+#include <paludis/repositories/unpackaged/exceptions.hh>
#include <paludis/ndbam.hh>
#include <paludis/ndbam_merger.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
@@ -480,3 +481,41 @@ InstalledUnpackagedRepository::installed_root_key() const
return _imp->root_key;
}
+std::tr1::shared_ptr<Repository>
+InstalledUnpackagedRepository::repository_factory_create(
+ Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> & f)
+{
+ Context context("When creating InstalledUnpackagedRepository:");
+
+ std::string location(f("location"));
+ if (location.empty())
+ throw unpackaged_repositories::RepositoryConfigurationError("Key 'location' not specified or empty");
+
+ std::string root(f("root"));
+ if (root.empty())
+ throw unpackaged_repositories::RepositoryConfigurationError("Key 'root' not specified or empty");
+
+ return make_shared_ptr(new InstalledUnpackagedRepository(RepositoryName("installed-unpackaged"),
+ unpackaged_repositories::InstalledUnpackagedRepositoryParams::create()
+ .environment(env)
+ .location(location)
+ .root(root)));
+}
+
+RepositoryName
+InstalledUnpackagedRepository::repository_factory_name(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> &)
+{
+ return RepositoryName("installed-unpackaged");
+}
+
+std::tr1::shared_ptr<const RepositoryNameSet>
+InstalledUnpackagedRepository::repository_factory_dependencies(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> &)
+{
+ return make_shared_ptr(new RepositoryNameSet);
+}
+
diff --git a/paludis/repositories/unpackaged/installed_repository.hh b/paludis/repositories/unpackaged/installed_repository.hh
index 240c15d..d16af38 100644
--- a/paludis/repositories/unpackaged/installed_repository.hh
+++ b/paludis/repositories/unpackaged/installed_repository.hh
@@ -100,6 +100,23 @@ namespace paludis
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > installed_root_key() const;
+
+ ///\name RepositoryFactory functions
+ ///\{
+
+ static RepositoryName repository_factory_name(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<Repository> repository_factory_create(
+ Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<const RepositoryNameSet> repository_factory_dependencies(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ ///\}
};
}
diff --git a/paludis/repositories/unpackaged/registration.cc b/paludis/repositories/unpackaged/registration.cc
index 74fb46b..0cca450 100644
--- a/paludis/repositories/unpackaged/registration.cc
+++ b/paludis/repositories/unpackaged/registration.cc
@@ -17,104 +17,37 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/repository_maker.hh>
#include <paludis/util/attributes.hh>
-#include <paludis/util/make_shared_ptr.hh>
-#include <paludis/util/wrapped_forward_iterator.hh>
-#include <paludis/util/destringify.hh>
-#include <paludis/util/make_named_values.hh>
+#include <paludis/util/set.hh>
+#include <paludis/repository_factory.hh>
#include <paludis/repositories/unpackaged/installed_repository.hh>
#include <paludis/repositories/unpackaged/unpackaged_repository.hh>
-#include <paludis/repositories/unpackaged/exceptions.hh>
using namespace paludis;
-namespace
-{
- std::tr1::shared_ptr<Repository>
- make_unpackaged_repository(
- Environment * const env,
- const std::tr1::function<std::string (const std::string &)> & f)
- {
- Context context("When creating UnpackagedRepository:");
-
- std::string location(f("location"));
- if (location.empty())
- throw unpackaged_repositories::RepositoryConfigurationError("Key 'location' not specified or empty");
-
- std::string install_under(f("install_under"));
- if (install_under.empty())
- install_under = "/";
-
- std::string name(f("name"));
- if (name.empty())
- throw unpackaged_repositories::RepositoryConfigurationError("Key 'name' not specified or empty");
-
- std::string version(f("version"));
- if (version.empty())
- throw unpackaged_repositories::RepositoryConfigurationError("Key 'version' not specified or empty");
-
- std::string slot(f("slot"));
- if (slot.empty())
- throw unpackaged_repositories::RepositoryConfigurationError("Key 'slot' not specified or empty");
-
- std::string build_dependencies(f("build_dependencies"));
- std::string run_dependencies(f("run_dependencies"));
- std::string description(f("description"));
-
- int rewrite_ids_over_to_root(-1);
- if (! f("rewrite_ids_over_to_root").empty())
- {
- Context item_context("When handling rewrite_ids_over_to_root key:");
- rewrite_ids_over_to_root = destringify<int>(f("rewrite_ids_over_to_root"));
- }
-
- return make_shared_ptr(new UnpackagedRepository(RepositoryName("unpackaged"),
- make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
- value_for<n::build_dependencies>(build_dependencies),
- value_for<n::description>(description),
- value_for<n::environment>(env),
- value_for<n::install_under>(install_under),
- value_for<n::location>(location),
- value_for<n::name>(QualifiedPackageName(name)),
- value_for<n::rewrite_ids_over_to_root>(rewrite_ids_over_to_root),
- value_for<n::run_dependencies>(run_dependencies),
- value_for<n::slot>(SlotName(slot)),
- value_for<n::version>(VersionSpec(version))
- )));
- }
-
- std::tr1::shared_ptr<Repository>
- make_installed_unpackaged_repository(
- Environment * const env,
- const std::tr1::function<std::string (const std::string &)> & f)
- {
- Context context("When creating InstalledUnpackagedRepository:");
-
- std::string location(f("location"));
- if (location.empty())
- throw unpackaged_repositories::RepositoryConfigurationError("Key 'location' not specified or empty");
-
- std::string root(f("root"));
- if (root.empty())
- throw unpackaged_repositories::RepositoryConfigurationError("Key 'root' not specified or empty");
-
- return make_shared_ptr(new InstalledUnpackagedRepository(RepositoryName("installed-unpackaged"),
- unpackaged_repositories::InstalledUnpackagedRepositoryParams::create()
- .environment(env)
- .location(location)
- .root(root)));
- }
-}
-
-extern "C"
-{
- void PALUDIS_VISIBLE register_repositories(RepositoryMaker * maker);
-}
+extern "C" void paludis_initialise_repository_so(RepositoryFactory * const factory) PALUDIS_VISIBLE;
-void register_repositories(RepositoryMaker * maker)
+void paludis_initialise_repository_so(RepositoryFactory * const factory)
{
- maker->register_maker("unpackaged", &make_unpackaged_repository);
- maker->register_maker("installed_unpackaged", &make_installed_unpackaged_repository);
+ std::tr1::shared_ptr<Set<std::string> > unpackaged_formats(new Set<std::string>);
+ unpackaged_formats->insert("unpackaged");
+
+ factory->add_repository_format(
+ unpackaged_formats,
+ &UnpackagedRepository::repository_factory_name,
+ &UnpackagedRepository::repository_factory_create,
+ &UnpackagedRepository::repository_factory_dependencies
+ );
+
+ std::tr1::shared_ptr<Set<std::string> > installed_unpackaged_formats(new Set<std::string>);
+ installed_unpackaged_formats->insert("installed_unpackaged");
+ installed_unpackaged_formats->insert("installed-unpackaged");
+
+ factory->add_repository_format(
+ installed_unpackaged_formats,
+ &InstalledUnpackagedRepository::repository_factory_name,
+ &InstalledUnpackagedRepository::repository_factory_create,
+ &InstalledUnpackagedRepository::repository_factory_dependencies
+ );
}
diff --git a/paludis/repositories/unpackaged/unpackaged_repository.cc b/paludis/repositories/unpackaged/unpackaged_repository.cc
index 73fa542..4896c80 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository.cc
+++ b/paludis/repositories/unpackaged/unpackaged_repository.cc
@@ -19,12 +19,14 @@
#include <paludis/repositories/unpackaged/unpackaged_repository.hh>
#include <paludis/repositories/unpackaged/unpackaged_id.hh>
+#include <paludis/repositories/unpackaged/exceptions.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/set.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/destringify.hh>
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
#include <paludis/action.hh>
@@ -201,3 +203,72 @@ UnpackagedRepository::installed_root_key() const
return std::tr1::shared_ptr<const MetadataValueKey<FSEntry> >();
}
+std::tr1::shared_ptr<Repository>
+UnpackagedRepository::repository_factory_create(
+ Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> & f)
+{
+ Context context("When creating UnpackagedRepository:");
+
+ std::string location(f("location"));
+ if (location.empty())
+ throw unpackaged_repositories::RepositoryConfigurationError("Key 'location' not specified or empty");
+
+ std::string install_under(f("install_under"));
+ if (install_under.empty())
+ install_under = "/";
+
+ std::string name(f("name"));
+ if (name.empty())
+ throw unpackaged_repositories::RepositoryConfigurationError("Key 'name' not specified or empty");
+
+ std::string version(f("version"));
+ if (version.empty())
+ throw unpackaged_repositories::RepositoryConfigurationError("Key 'version' not specified or empty");
+
+ std::string slot(f("slot"));
+ if (slot.empty())
+ throw unpackaged_repositories::RepositoryConfigurationError("Key 'slot' not specified or empty");
+
+ std::string build_dependencies(f("build_dependencies"));
+ std::string run_dependencies(f("run_dependencies"));
+ std::string description(f("description"));
+
+ int rewrite_ids_over_to_root(-1);
+ if (! f("rewrite_ids_over_to_root").empty())
+ {
+ Context item_context("When handling rewrite_ids_over_to_root key:");
+ rewrite_ids_over_to_root = destringify<int>(f("rewrite_ids_over_to_root"));
+ }
+
+ return make_shared_ptr(new UnpackagedRepository(RepositoryName("unpackaged"),
+ make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
+ value_for<n::build_dependencies>(build_dependencies),
+ value_for<n::description>(description),
+ value_for<n::environment>(env),
+ value_for<n::install_under>(install_under),
+ value_for<n::location>(location),
+ value_for<n::name>(QualifiedPackageName(name)),
+ value_for<n::rewrite_ids_over_to_root>(rewrite_ids_over_to_root),
+ value_for<n::run_dependencies>(run_dependencies),
+ value_for<n::slot>(SlotName(slot)),
+ value_for<n::version>(VersionSpec(version))
+ )));
+}
+
+RepositoryName
+UnpackagedRepository::repository_factory_name(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> & f)
+{
+ return RepositoryName(f("name"));
+}
+
+std::tr1::shared_ptr<const RepositoryNameSet>
+UnpackagedRepository::repository_factory_dependencies(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> &)
+{
+ return make_shared_ptr(new RepositoryNameSet);
+}
+
diff --git a/paludis/repositories/unpackaged/unpackaged_repository.hh b/paludis/repositories/unpackaged/unpackaged_repository.hh
index 7020f31..470967a 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository.hh
+++ b/paludis/repositories/unpackaged/unpackaged_repository.hh
@@ -105,6 +105,23 @@ namespace paludis
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > installed_root_key() const;
+
+ ///\name RepositoryFactory functions
+ ///\{
+
+ static RepositoryName repository_factory_name(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<Repository> repository_factory_create(
+ Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<const RepositoryNameSet> repository_factory_dependencies(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ ///\}
};
}
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index 5b5147c..c402aff 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -171,18 +171,6 @@ InstalledVirtualsRepository::need_ids() const
_imp->has_ids = true;
}
-std::tr1::shared_ptr<Repository>
-InstalledVirtualsRepository::make_installed_virtuals_repository(
- Environment * const env,
- const std::tr1::function<std::string (const std::string &)> & f)
-{
- std::string root_str(f("root"));
- if (root_str.empty())
- throw ConfigurationError("No root specified for InstalledVirtualsRepository");
-
- return std::tr1::shared_ptr<Repository>(new InstalledVirtualsRepository(env, FSEntry(root_str)));
-}
-
std::tr1::shared_ptr<const PackageIDSequence>
InstalledVirtualsRepository::package_ids(const QualifiedPackageName & q) const
{
@@ -344,3 +332,31 @@ InstalledVirtualsRepository::need_keys_added() const
{
}
+RepositoryName
+InstalledVirtualsRepository::repository_factory_name(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> & f)
+{
+ return make_name(FSEntry(f("root")));
+}
+
+std::tr1::shared_ptr<Repository>
+InstalledVirtualsRepository::repository_factory_create(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> & f)
+{
+ if (f("root").empty())
+ throw ConfigurationError("Key 'root' unspecified or empty");
+
+ return make_shared_ptr(new InstalledVirtualsRepository(env, f("root")));
+}
+
+std::tr1::shared_ptr<const RepositoryNameSet>
+InstalledVirtualsRepository::repository_factory_dependencies(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> &)
+{
+ return make_shared_ptr(new RepositoryNameSet);
+}
+
+
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.hh b/paludis/repositories/virtuals/installed_virtuals_repository.hh
index 334220c..93ba80a 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.hh
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.hh
@@ -57,13 +57,23 @@ namespace paludis
///\}
- /**
- * Create an InstalledVirtualsRepository instance.
- */
- static std::tr1::shared_ptr<Repository> make_installed_virtuals_repository(
- Environment * const env,
+ ///\name RepositoryFactory functions
+ ///\{
+
+ static RepositoryName repository_factory_name(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<Repository> repository_factory_create(
+ const Environment * const env,
const std::tr1::function<std::string (const std::string &)> &);
+ static std::tr1::shared_ptr<const RepositoryNameSet> repository_factory_dependencies(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ ///\}
+
virtual std::tr1::shared_ptr<const CategoryNamePartSet> unimportant_category_names() const;
virtual void invalidate();
diff --git a/paludis/repositories/virtuals/registration.cc b/paludis/repositories/virtuals/registration.cc
index 61776fa..bc533be 100644
--- a/paludis/repositories/virtuals/registration.cc
+++ b/paludis/repositories/virtuals/registration.cc
@@ -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
@@ -17,26 +17,36 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/repository_maker.hh>
+#include <paludis/repository_factory.hh>
#include <paludis/repositories/virtuals/installed_virtuals_repository.hh>
#include <paludis/repositories/virtuals/virtuals_repository.hh>
-#include "config.h"
+#include <paludis/util/set.hh>
using namespace paludis;
-#ifndef MONOLITHIC
+extern "C" void paludis_initialise_repository_so(RepositoryFactory * const factory) PALUDIS_VISIBLE;
-extern "C"
+void paludis_initialise_repository_so(RepositoryFactory * const factory)
{
- void PALUDIS_VISIBLE register_repositories(RepositoryMaker * maker);
+ std::tr1::shared_ptr<Set<std::string> > virtuals_formats(new Set<std::string>);
+ virtuals_formats->insert("virtuals");
+
+ factory->add_repository_format(
+ virtuals_formats,
+ &VirtualsRepository::repository_factory_name,
+ &VirtualsRepository::repository_factory_create,
+ &VirtualsRepository::repository_factory_dependencies
+ );
+
+ std::tr1::shared_ptr<Set<std::string> > installed_virtuals_formats(new Set<std::string>);
+ installed_virtuals_formats->insert("installed_virtuals");
+ installed_virtuals_formats->insert("installed-virtuals");
+
+ factory->add_repository_format(
+ installed_virtuals_formats,
+ &InstalledVirtualsRepository::repository_factory_name,
+ &InstalledVirtualsRepository::repository_factory_create,
+ &InstalledVirtualsRepository::repository_factory_dependencies
+ );
}
-void register_repositories(RepositoryMaker * maker)
-{
- maker->register_maker("virtuals", &VirtualsRepository::make_virtuals_repository);
- maker->register_maker("installed_virtuals", &InstalledVirtualsRepository::make_installed_virtuals_repository);
-}
-
-#endif
-
-
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index d5ece7a..addb771 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -253,14 +253,6 @@ VirtualsRepository::need_ids() const
swap(my_ids, _imp->ids);
}
-std::tr1::shared_ptr<Repository>
-VirtualsRepository::make_virtuals_repository(
- Environment * const env,
- const std::tr1::function<std::string (const std::string &)> &)
-{
- return std::tr1::shared_ptr<Repository>(new VirtualsRepository(env));
-}
-
std::tr1::shared_ptr<const PackageIDSequence>
VirtualsRepository::package_ids(const QualifiedPackageName & q) const
{
@@ -438,3 +430,27 @@ VirtualsRepository::need_keys_added() const
{
}
+RepositoryName
+VirtualsRepository::repository_factory_name(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> &)
+{
+ return RepositoryName("virtuals");
+}
+
+std::tr1::shared_ptr<Repository>
+VirtualsRepository::repository_factory_create(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &)
+{
+ return make_shared_ptr(new VirtualsRepository(env));
+}
+
+std::tr1::shared_ptr<const RepositoryNameSet>
+VirtualsRepository::repository_factory_dependencies(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> &)
+{
+ return make_shared_ptr(new RepositoryNameSet);
+}
+
diff --git a/paludis/repositories/virtuals/virtuals_repository.hh b/paludis/repositories/virtuals/virtuals_repository.hh
index 915c22c..5c67c78 100644
--- a/paludis/repositories/virtuals/virtuals_repository.hh
+++ b/paludis/repositories/virtuals/virtuals_repository.hh
@@ -56,13 +56,24 @@ namespace paludis
///\}
- /**
- * Create a VirtualsRepository instance.
- */
- static std::tr1::shared_ptr<Repository> make_virtuals_repository(
- Environment * const env,
+
+ ///\name RepositoryFactory functions
+ ///\{
+
+ static RepositoryName repository_factory_name(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<Repository> repository_factory_create(
+ const Environment * const env,
const std::tr1::function<std::string (const std::string &)> &);
+ static std::tr1::shared_ptr<const RepositoryNameSet> repository_factory_dependencies(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ ///\}
+
virtual std::tr1::shared_ptr<const CategoryNamePartSet> unimportant_category_names() const;
virtual void invalidate();
diff --git a/paludis/repository_factory-fwd.hh b/paludis/repository_factory-fwd.hh
new file mode 100644
index 0000000..471679c
--- /dev/null
+++ b/paludis/repository_factory-fwd.hh
@@ -0,0 +1,28 @@
+/* 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_REPOSITORY_FACTORY_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORY_FACTORY_FWD_HH 1
+
+namespace paludis
+{
+ class RepositoryFactory;
+}
+
+#endif
diff --git a/paludis/repository_factory.cc b/paludis/repository_factory.cc
new file mode 100644
index 0000000..f5150b2
--- /dev/null
+++ b/paludis/repository_factory.cc
@@ -0,0 +1,204 @@
+/* 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/repository_factory.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/instantiation_policy-impl.hh>
+#include <paludis/util/member_iterator-impl.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/util/join.hh>
+#include <paludis/util/named_value.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/system.hh>
+#include <paludis/util/dir_iterator.hh>
+#include <paludis/util/is_file_with_extension.hh>
+#include <paludis/name.hh>
+#include <paludis/about.hh>
+#include <tr1/unordered_map>
+#include <list>
+#include <dlfcn.h>
+#include <stdint.h>
+
+using namespace paludis;
+
+namespace paludis
+{
+ namespace n
+ {
+ struct create_function;
+ struct dependencies_function;
+ struct name_function;
+ }
+}
+
+namespace
+{
+ struct Funcs
+ {
+ NamedValue<n::create_function, RepositoryFactory::CreateFunction> create_function;
+ NamedValue<n::dependencies_function, RepositoryFactory::DependenciesFunction> dependencies_function;
+ NamedValue<n::name_function, RepositoryFactory::NameFunction> name_function;
+ };
+
+ typedef std::tr1::unordered_map<std::string, Funcs> Keys;
+
+ const Funcs & fetch(const Keys & keys, const std::string & key)
+ {
+ if (key.empty())
+ throw ConfigurationError("Key 'format' not specified when creating a repository");
+
+ Keys::const_iterator i(keys.find(key));
+ if (i == keys.end())
+ throw ConfigurationError("Format '" + key + "' not supported when creating a repository (known formats are { "
+ + join(first_iterator(keys.begin()), first_iterator(keys.end()), ", ") + "}");
+
+ return i->second;
+ }
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<RepositoryFactory>
+ {
+ Keys keys;
+ std::list<void *> dl_opened;
+ };
+}
+
+RepositoryFactory::RepositoryFactory() :
+ PrivateImplementationPattern<RepositoryFactory>(new Implementation<RepositoryFactory>)
+{
+ FSEntry so_dir(getenv_with_default("PALUDIS_REPOSITORY_SO_DIR", LIBDIR "/paludis/repositories"));
+ if (! so_dir.is_directory())
+ throw InternalError(PALUDIS_HERE, "PALUDIS_REPOSITORY_SO_DIR '" + stringify(so_dir) + "' not a directory");
+ _load_dir(so_dir);
+}
+
+RepositoryFactory::~RepositoryFactory()
+{
+}
+
+void
+RepositoryFactory::_load_dir(const FSEntry & so_dir)
+{
+ for (DirIterator d(so_dir), d_end ; d != d_end ; ++d)
+ {
+ if (d->is_directory())
+ _load_dir(*d);
+
+ if (! is_file_with_extension(*d, ".so." + stringify(100 * PALUDIS_VERSION_MAJOR + PALUDIS_VERSION_MINOR),
+ IsFileWithOptions()))
+ continue;
+
+ /* don't use RTLD_LOCAL, g++ is over happy about template instantiations, and it
+ * can lead to multiple singleton instances. */
+ void * dl(dlopen(stringify(*d).c_str(), RTLD_GLOBAL | RTLD_NOW));
+
+ if (dl)
+ {
+ _imp->dl_opened.push_back(dl);
+
+ void * reg(dlsym(dl, "paludis_initialise_repository_so"));
+ if (reg)
+ {
+ reinterpret_cast<void (*)(RepositoryFactory * const)>(reinterpret_cast<uintptr_t>(reg))(this);
+ }
+ else
+ throw InternalError(PALUDIS_HERE, "No paludis_initialise_repository_so function defined in '" + stringify(*d) + "'");
+ }
+ else
+ throw InternalError(PALUDIS_HERE, "Couldn't dlopen '" + stringify(*d) + "': " + stringify(dlerror()));
+ }
+
+ if ((so_dir / ".libs").is_directory())
+ _load_dir(so_dir / ".libs");
+}
+
+const std::tr1::shared_ptr<Repository>
+RepositoryFactory::create(
+ Environment * const env,
+ const KeyFunction & key_function
+ ) const
+{
+ Context context("When creating repository" + (key_function("repo_file").empty() ? ":" :
+ " from file '" + key_function("repo_file") + ":"));
+ return fetch(_imp->keys, key_function("format")).create_function()(env, key_function);
+}
+
+const std::tr1::shared_ptr<const RepositoryNameSet>
+RepositoryFactory::dependencies(
+ const Environment * const env,
+ const KeyFunction & key_function
+ ) const
+{
+ Context context("When working out dependencies for repository" + (key_function("repo_file").empty() ? ":" :
+ " from file '" + key_function("repo_file") + ":"));
+ return fetch(_imp->keys, key_function("format")).dependencies_function()(env, key_function);
+}
+
+const RepositoryName
+RepositoryFactory::name(
+ const Environment * const env,
+ const KeyFunction & key_function
+ ) const
+{
+ Context context("When working out name for repository" + (key_function("repo_file").empty() ? ":" :
+ " from file '" + key_function("repo_file") + ":"));
+ return fetch(_imp->keys, key_function("format")).name_function()(env, key_function);
+}
+
+RepositoryFactory::ConstIterator
+RepositoryFactory::begin_keys() const
+{
+ return first_iterator(_imp->keys.begin());
+}
+
+RepositoryFactory::ConstIterator
+RepositoryFactory::end_keys() const
+{
+ return first_iterator(_imp->keys.end());
+}
+
+void
+RepositoryFactory::add_repository_format(
+ const std::tr1::shared_ptr<const Set<std::string> > & formats,
+ const NameFunction & name_function,
+ const CreateFunction & create_function,
+ const DependenciesFunction & dependencies_function
+ )
+{
+ for (Set<std::string>::ConstIterator f(formats->begin()), f_end(formats->end()) ;
+ f != f_end ; ++f)
+ {
+ if (! _imp->keys.insert(std::make_pair(*f, make_named_values<Funcs>(
+ value_for<n::create_function>(create_function),
+ value_for<n::dependencies_function>(dependencies_function),
+ value_for<n::name_function>(name_function)
+ ))).second)
+ throw ConfigurationError("Handler for repository format '" + stringify(*f) + "' already exists");
+ }
+}
+
+template class PrivateImplementationPattern<RepositoryFactory>;
+template class InstantiationPolicy<RepositoryFactory, instantiation_method::SingletonTag>;
+template class WrappedForwardIterator<RepositoryFactory::ConstIteratorTag, const std::string>;
+
diff --git a/paludis/repository_factory.hh b/paludis/repository_factory.hh
new file mode 100644
index 0000000..d3d2598
--- /dev/null
+++ b/paludis/repository_factory.hh
@@ -0,0 +1,145 @@
+/* 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_REPOSITORY_FACTORY_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORY_FACTORY_HH 1
+
+#include <paludis/repository_factory-fwd.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/wrapped_forward_iterator-fwd.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/repository-fwd.hh>
+#include <paludis/name-fwd.hh>
+#include <tr1/functional>
+#include <tr1/memory>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE RepositoryFactory :
+ private PrivateImplementationPattern<RepositoryFactory>,
+ public InstantiationPolicy<RepositoryFactory, instantiation_method::SingletonTag>
+ {
+ friend class InstantiationPolicy<RepositoryFactory, instantiation_method::SingletonTag>;
+
+ private:
+ RepositoryFactory();
+ ~RepositoryFactory();
+
+ void _load_dir(const FSEntry &);
+
+ public:
+ typedef std::tr1::function<std::string (const std::string &)> KeyFunction;
+
+ typedef std::tr1::function<const std::tr1::shared_ptr<Repository>(
+ Environment * const,
+ const KeyFunction &
+ )> CreateFunction;
+
+ typedef std::tr1::function<const std::tr1::shared_ptr<const RepositoryNameSet> (
+ const Environment * const,
+ const KeyFunction &
+ )> DependenciesFunction;
+
+ typedef std::tr1::function<const RepositoryName (
+ const Environment * const,
+ const KeyFunction &
+ )> NameFunction;
+
+ /**
+ * Construct a given repository, or throw ConfigurationError.
+ *
+ * If the repository to be created has dependencies upon another
+ * repository, that repository must have been created and added
+ * to the environment's package database first.
+ *
+ * The returned repository is <em>not</em> added to the Environment's
+ * package database.
+ *
+ * \param key_function should return the value for a given key. The
+ * 'format' key must return a value (e.g. 'ebuild'), which is used
+ * to select the return type. The 'repo_name' key's value should be
+ * the file that best describes the location of the file containing
+ * the repository config, if such a file exists. Other key names are
+ * repository defined, but typically include things like 'location'
+ * and 'sync'.
+ */
+ const std::tr1::shared_ptr<Repository> create(
+ Environment * const env,
+ const KeyFunction & key_function
+ ) const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+
+ /**
+ * Find the name of the repository that would be constructed if the
+ * supplied parameters were passed to RepositoryFactory::create.
+ *
+ * \see RepositoryFactory::create for parameter documentation.
+ */
+ const RepositoryName name(
+ const Environment * const env,
+ const KeyFunction & key_function
+ ) const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /**
+ * Fetch the names of any repositories depended upon by a particular
+ * repository.
+ *
+ * \see RepositoryFactory::create for parameter documentation.
+ */
+ const std::tr1::shared_ptr<const RepositoryNameSet> dependencies(
+ const Environment * const env,
+ const KeyFunction & key_function
+ ) const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /**
+ * Add a repository format.
+ *
+ * \param formats must have at least one value, and no value may be
+ * specified more than once across all invocations.
+ *
+ * \param name_function is used to implement RepositoryMaker::name.
+ *
+ * \param create_function is used to implement RepositoryMaker::create.
+ *
+ * \param dependencies_function is used to implement
+ * RepositoryMaker::dependencies.
+ */
+ void add_repository_format(
+ const std::tr1::shared_ptr<const Set<std::string> > & formats,
+ const NameFunction & name_function,
+ const CreateFunction & create_function,
+ const DependenciesFunction & dependencies_function
+ );
+
+ struct ConstIteratorTag;
+ typedef WrappedForwardIterator<ConstIteratorTag, const std::string> ConstIterator;
+ ConstIterator begin_keys() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ ConstIterator end_keys() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<RepositoryFactory>;
+ extern template class InstantiationPolicy<RepositoryFactory, instantiation_method::SingletonTag>;
+#endif
+}
+
+#endif
diff --git a/paludis/repository_maker.cc b/paludis/repository_maker.cc
deleted file mode 100644
index 498cc6d..0000000
--- a/paludis/repository_maker.cc
+++ /dev/null
@@ -1,167 +0,0 @@
-/* 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 "repository_maker.hh"
-#include <paludis/util/fs_entry.hh>
-#include <paludis/util/dir_iterator.hh>
-#include <paludis/util/private_implementation_pattern-impl.hh>
-#include <paludis/util/instantiation_policy-impl.hh>
-#include <paludis/util/is_file_with_extension.hh>
-#include <paludis/util/map.hh>
-#include <paludis/util/system.hh>
-#include <paludis/util/virtual_constructor-impl.hh>
-#include <paludis/about.hh>
-#include <list>
-#include <dlfcn.h>
-#include <stdint.h>
-
-#include "config.h"
-
-#ifdef MONOLITHIC
-# include <paludis/repositories/portage/make_ebuild_repository.hh>
-# include <paludis/repositories/vdb/vdb_repository.hh>
-# include <paludis/repositories/virtuals/installed_virtuals_repository.hh>
-# include <paludis/repositories/virtuals/virtuals_repository.hh>
-#endif
-
-using namespace paludis;
-
-template class VirtualConstructor<std::string,
- std::tr1::shared_ptr<Repository> (*) (Environment * const,
- const std::tr1::function<std::string (const std::string &)> &),
- virtual_constructor_not_found::ThrowException<NoSuchRepositoryTypeError> >;
-
-template class InstantiationPolicy<RepositoryMaker, instantiation_method::SingletonTag>;
-
-NoSuchRepositoryTypeError::NoSuchRepositoryTypeError(const std::string & format) throw ():
- ConfigurationError("No available maker for repository type '" + format + "'")
-{
-}
-
-PaludisRepositorySoDirNotADirectoryError::PaludisRepositorySoDirNotADirectoryError() throw () :
- Exception("PALUDIS_REPOSITORY_SO_DIR not a directory")
-{
-}
-
-PaludisRepositorySoDirCannotDlopenError::PaludisRepositorySoDirCannotDlopenError(
- const std::string & file, const std::string & e) throw () :
- Exception("Cannot dlopen a repository. so file"),
- _file(file),
- _dlerr(e)
-{
-}
-
-PaludisRepositorySoDirCannotDlopenError::~PaludisRepositorySoDirCannotDlopenError() throw ()
-{
-}
-
-const char *
-PaludisRepositorySoDirCannotDlopenError::what() const throw ()
-{
- if (_what.empty())
- _what = std::string(Exception::what()) +
- ": Cannot dlopen repository .so file '" + _file + "': '" + _dlerr + "'";
- return _what.c_str();
-}
-
-namespace paludis
-{
- template<>
- struct Implementation<RepositoryMaker>
- {
- std::list<void *> dl_opened;
- };
-}
-
-void
-RepositoryMaker::load_dir(const FSEntry & so_dir)
-{
- for (DirIterator d(so_dir), d_end ; d != d_end ; ++d)
- {
- if (d->is_directory())
- load_dir(*d);
-
- if (! is_file_with_extension(*d, ".so." + stringify(100 * PALUDIS_VERSION_MAJOR + PALUDIS_VERSION_MINOR),
- IsFileWithOptions()))
- continue;
-
- /* don't use RTLD_LOCAL, g++ is over happy about template instantiations, and it
- * can lead to multiple singleton instances. */
- void * dl(dlopen(stringify(*d).c_str(), RTLD_GLOBAL | RTLD_NOW));
-
- if (dl)
- {
- _imp->dl_opened.push_back(dl);
-
- void * reg(dlsym(dl, "register_repositories"));
- if (reg)
- {
- reinterpret_cast<void (*)(RepositoryMaker *)>(
- reinterpret_cast<uintptr_t>(reg))(this);
- }
- else
- throw PaludisRepositorySoDirCannotDlopenError(stringify(*d),
- "no register_repositories function defined");
- }
- else
- throw PaludisRepositorySoDirCannotDlopenError(stringify(*d), dlerror());
- }
-
- if ((so_dir / ".libs").is_directory())
- load_dir(so_dir / ".libs");
-}
-
-RepositoryMaker::RepositoryMaker() :
- PrivateImplementationPattern<RepositoryMaker>(new Implementation<RepositoryMaker>)
-{
-#ifdef MONOLITHIC
-
- register_maker("ebuild", &make_ebuild_repository_wrapped);
- register_maker("vdb", &VDBRepository::make_vdb_repository);
- register_maker("virtuals", &VirtualsRepository::make_virtuals_repository);
- register_maker("installed_virtuals", &InstalledVirtualsRepository::make_installed_virtuals_repository);
-
-#else
- FSEntry so_dir(getenv_with_default("PALUDIS_REPOSITORY_SO_DIR", LIBDIR "/paludis/repositories"));
-
- if (! so_dir.is_directory())
- throw PaludisRepositorySoDirNotADirectoryError();
-
- load_dir(so_dir);
-
-#endif
-}
-
-RepositoryMaker::~RepositoryMaker()
-{
-}
-
-#ifndef MONOLITHIC
-
-extern "C"
-{
- void PALUDIS_VISIBLE register_repositories(RepositoryMaker * maker);
-}
-
-void register_repositories(RepositoryMaker *)
-{
-}
-
-#endif
-
diff --git a/paludis/repository_maker.hh b/paludis/repository_maker.hh
deleted file mode 100644
index 91aaf1d..0000000
--- a/paludis/repository_maker.hh
+++ /dev/null
@@ -1,125 +0,0 @@
-/* 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_REPOSITORY_MAKER_HH
-#define PALUDIS_GUARD_PALUDIS_REPOSITORY_MAKER_HH 1
-
-#include <paludis/util/instantiation_policy.hh>
-#include <paludis/util/private_implementation_pattern.hh>
-#include <paludis/util/virtual_constructor.hh>
-#include <paludis/util/map-fwd.hh>
-#include <paludis/repository.hh>
-#include <tr1/functional>
-
-/** \file
- * Declarations for the RepositoryMaker.
- *
- * \ingroup g_repository
- *
- * \section Examples
- *
- * - \ref example_repository.cc "example_repository.cc"
- */
-
-namespace paludis
-{
- class FSEntry;
-
- /**
- * Thrown if a repository of the specified type does not exist.
- *
- * \ingroup g_exceptions
- * \ingroup g_repository
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE NoSuchRepositoryTypeError : public ConfigurationError
- {
- public:
- /**
- * Constructor.
- */
- NoSuchRepositoryTypeError(const std::string & format) throw ();
- };
-
- /**
- * Thrown if PALUDIS_REPOSITORY_SO_DIR is not a directory.
- *
- * \ingroup g_exceptions
- * \ingroup g_repository
- */
- class PALUDIS_VISIBLE PaludisRepositorySoDirNotADirectoryError :
- public Exception
- {
- public:
- PaludisRepositorySoDirNotADirectoryError() throw ();
- };
-
- /**
- * Thrown if a repository .so cannot be used.
- *
- * \ingroup g_exceptions
- * \ingroup g_repository
- */
- class PALUDIS_VISIBLE PaludisRepositorySoDirCannotDlopenError :
- public Exception
- {
- private:
- std::string _file, _dlerr;
- mutable std::string _what;
-
- public:
- ///\name Basic operations
- ///\{
-
- PaludisRepositorySoDirCannotDlopenError(const std::string & file,
- const std::string & e) throw ();
-
- ~PaludisRepositorySoDirCannotDlopenError() throw ();
-
- ///\}
-
- const char * what() const throw ();
- };
-
- /**
- * Virtual constructor for repositories.
- *
- * \ingroup g_repository
- */
- class PALUDIS_VISIBLE RepositoryMaker :
- public VirtualConstructor<std::string,
- std::tr1::shared_ptr<Repository> (*) (Environment * const,
- const std::tr1::function<std::string (const std::string &)> &),
- virtual_constructor_not_found::ThrowException<NoSuchRepositoryTypeError> >,
- public InstantiationPolicy<RepositoryMaker, instantiation_method::SingletonTag>,
- private PrivateImplementationPattern<RepositoryMaker>
- {
- friend class InstantiationPolicy<RepositoryMaker, instantiation_method::SingletonTag>;
-
- private:
- RepositoryMaker();
-
- void load_dir(const FSEntry &);
-
- public:
- ~RepositoryMaker();
- };
-}
-
-#endif
diff --git a/paludis/uninstall_list_TEST.cc b/paludis/uninstall_list_TEST.cc
index 460a5f9..5ee8c38 100644
--- a/paludis/uninstall_list_TEST.cc
+++ b/paludis/uninstall_list_TEST.cc
@@ -25,8 +25,8 @@
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/options.hh>
#include <paludis/package_database.hh>
-#include <paludis/repository_maker.hh>
#include <paludis/user_dep_spec.hh>
+#include <paludis/repository_factory.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
#include <string>
@@ -51,9 +51,12 @@ namespace paludis
#ifdef ENABLE_VIRTUALS_REPOSITORY
namespace
{
- std::string virtuals_repo_keys(const std::string &)
+ std::string virtuals_repo_keys(const std::string & key)
{
- return "";
+ if (key == "format")
+ return "virtuals";
+ else
+ return "";
}
}
#endif
@@ -86,7 +89,7 @@ namespace test_cases
env(),
installed_repo(new FakeInstalledRepository(&env, RepositoryName("installed"))),
#ifdef ENABLE_VIRTUALS_REPOSITORY
- virtuals_repo((*(*RepositoryMaker::get_instance())["virtuals"])(&env, virtuals_repo_keys)),
+ virtuals_repo(RepositoryFactory::get_instance()->create(&env, virtuals_repo_keys)),
#endif
targets(new PackageIDSequence),
done_populate(false),
diff --git a/src/clients/importare/importare.cc b/src/clients/importare/importare.cc
index ad6839d..d023f54 100644
--- a/src/clients/importare/importare.cc
+++ b/src/clients/importare/importare.cc
@@ -30,7 +30,7 @@
#include <paludis/util/sequence.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/about.hh>
-#include <paludis/repository_maker.hh>
+#include <paludis/repository_factory.hh>
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
#include <paludis/stringify_formatter.hh>
@@ -201,7 +201,7 @@ main(int argc, char *argv[])
keys->insert("description", description);
keys->insert("build_dependencies", build_dependencies);
keys->insert("run_dependencies", run_dependencies);
- std::tr1::shared_ptr<Repository> repo((*RepositoryMaker::get_instance()->find_maker("unpackaged"))(env.get(),
+ std::tr1::shared_ptr<Repository> repo(RepositoryFactory::get_instance()->create(env.get(),
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env->package_database()->add_repository(10, repo);
std::tr1::shared_ptr<const PackageIDSequence> ids(repo->package_ids(q));
diff --git a/src/clients/paludis/applets.cc b/src/clients/paludis/applets.cc
index 9f55a15..2198c61 100644
--- a/src/clients/paludis/applets.cc
+++ b/src/clients/paludis/applets.cc
@@ -28,7 +28,7 @@
#include <paludis/util/system.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/virtual_constructor-impl.hh>
-#include <paludis/repository_maker.hh>
+#include <paludis/repository_factory.hh>
#include <string>
#include <set>
#include <map>
@@ -333,8 +333,7 @@ int do_list_repository_formats()
{
int return_code(1);
- std::set<std::string> keys;
- RepositoryMaker::get_instance()->copy_keys(std::inserter(keys, keys.begin()));
+ std::set<std::string> keys(RepositoryFactory::get_instance()->begin_keys(), RepositoryFactory::get_instance()->end_keys());
if (! keys.empty())
{