aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-06-30 05:34:25 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-06-30 05:34:25 +0100
commita7eff252d935e5654a2e039dff6cce547e4fd999 (patch)
tree1964a54d33dfdbb21ea99db24ec5a240cabb6eae
parent8e4a4a04e8e87102f97f75485c772c5cf408742c (diff)
downloadpaludis-a7eff252d935e5654a2e039dff6cce547e4fd999.tar.gz
paludis-a7eff252d935e5654a2e039dff6cce547e4fd999.tar.xz
Make repository_defaults.conf work again.
Rather than passing a map to the repository VC, we pass a function. This means we don't have to iterate over a KeyValueConfigFile's keys, which doesn't work well with a defaults function. Fixes: ticket:609. Squashed commit of the following: commit 47b484222ad25a47c088af5eec332219ece400c6 Author: Ciaran McCreesh <ciaran.mccreesh@googlemail.com> Date: Mon Jun 30 05:33:41 2008 +0100 moar commit 653477eb3f89044ef1fbd5d878c54acb6afc27e8 Author: Ciaran McCreesh <ciaran.mccreesh@googlemail.com> Date: Mon Jun 30 04:42:55 2008 +0100 start
-rw-r--r--paludis/environments/no_config/no_config_environment.cc23
-rw-r--r--paludis/environments/paludis/paludis_environment.cc16
-rw-r--r--paludis/environments/portage/portage_environment.cc22
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc16
-rw-r--r--paludis/repositories/cran/cran_installed_repository.hh2
-rw-r--r--paludis/repositories/cran/cran_installed_repository_TEST.cc17
-rw-r--r--paludis/repositories/cran/cran_repository.cc32
-rw-r--r--paludis/repositories/cran/cran_repository.hh3
-rw-r--r--paludis/repositories/cran/cran_repository_TEST.cc22
-rw-r--r--paludis/repositories/e/e_repository_TEST.cc246
-rw-r--r--paludis/repositories/e/e_repository_sets_TEST.cc57
-rw-r--r--paludis/repositories/e/exndbam_repository.cc31
-rw-r--r--paludis/repositories/e/exndbam_repository.hh2
-rw-r--r--paludis/repositories/e/exndbam_repository_TEST.cc21
-rw-r--r--paludis/repositories/e/make_ebuild_repository.cc132
-rw-r--r--paludis/repositories/e/make_ebuild_repository.hh4
-rw-r--r--paludis/repositories/e/qa/manifest_TEST.cc38
-rw-r--r--paludis/repositories/e/qa/visibility_TEST.cc13
-rw-r--r--paludis/repositories/e/registration.cc10
-rw-r--r--paludis/repositories/e/vdb_repository.cc40
-rw-r--r--paludis/repositories/e/vdb_repository.hh2
-rw-r--r--paludis/repositories/e/vdb_repository_TEST.cc88
-rw-r--r--paludis/repositories/gems/registration.cc36
-rw-r--r--paludis/repositories/unavailable/registration.cc27
-rw-r--r--paludis/repositories/unpackaged/registration.cc50
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc8
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.hh2
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc2
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.hh2
-rw-r--r--paludis/repository_maker.cc4
-rw-r--r--paludis/repository_maker.hh3
-rw-r--r--src/clients/importare/importare.cc13
32 files changed, 500 insertions, 484 deletions
diff --git a/paludis/environments/no_config/no_config_environment.cc b/paludis/environments/no_config/no_config_environment.cc
index e86401c..84bb2ce 100644
--- a/paludis/environments/no_config/no_config_environment.cc
+++ b/paludis/environments/no_config/no_config_environment.cc
@@ -132,6 +132,16 @@ namespace
throw ConfigurationError("Can't work out what kind of repository this is");
}
+
+ std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
+ const std::string & k)
+ {
+ Map<std::string, std::string>::ConstIterator mm(m->find(k));
+ if (m->end() == mm)
+ return "";
+ else
+ return mm->second;
+ }
}
Implementation<NoConfigEnvironment>::Implementation(
@@ -180,7 +190,8 @@ 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, keys))));
+ RepositoryMaker::get_instance()->find_maker("ebuild")(env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)))));
}
}
@@ -206,11 +217,12 @@ Implementation<NoConfigEnvironment>::initialise(NoConfigEnvironment * const env)
keys->insert("layout", "exheres");
package_database->add_repository(2, ((main_repo =
- RepositoryMaker::get_instance()->find_maker("ebuild")(env, keys))));
+ RepositoryMaker::get_instance()->find_maker("ebuild")(env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)))));
if ((*DistributionData::get_instance()->distribution_from_string(env->distribution()))[k::support_old_style_virtuals()])
package_database->add_repository(-2, RepositoryMaker::get_instance()->find_maker("virtuals")(env,
- std::tr1::shared_ptr<Map<std::string, std::string> >()));
+ std::tr1::bind(from_keys, make_shared_ptr(new Map<std::string, std::string>), std::tr1::placeholders::_1)));
}
else
{
@@ -225,7 +237,8 @@ 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, keys));
+ package_database->add_repository(1, RepositoryMaker::get_instance()->find_maker("vdb")(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>);
@@ -233,7 +246,7 @@ Implementation<NoConfigEnvironment>::initialise(NoConfigEnvironment * const env)
if ((*DistributionData::get_instance()->distribution_from_string(env->distribution()))[k::support_old_style_virtuals()])
package_database->add_repository(-2, RepositoryMaker::get_instance()->find_maker("installed_virtuals")(env,
- iv_keys));
+ std::tr1::bind(from_keys, iv_keys, std::tr1::placeholders::_1)));
}
}
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index 7718807..b4cd6b6 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -142,6 +142,19 @@ namespace paludis
};
}
+namespace
+{
+ std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
+ const std::string & k)
+ {
+ Map<std::string, std::string>::ConstIterator mm(m->find(k));
+ if (m->end() == mm)
+ return "";
+ else
+ return mm->second;
+ }
+}
+
PaludisEnvironment::PaludisEnvironment(const std::string & s) :
PrivateImplementationPattern<PaludisEnvironment>(new Implementation<PaludisEnvironment>(
this, std::tr1::shared_ptr<PaludisConfig>(new PaludisConfig(this, s)))),
@@ -172,7 +185,8 @@ PaludisEnvironment::PaludisEnvironment(const std::string & s) :
}
_imp->package_database->add_repository(r->importance,
- RepositoryMaker::get_instance()->find_maker(r->format)(this, r->keys));
+ RepositoryMaker::get_instance()->find_maker(r->format)(this,
+ std::tr1::bind(from_keys, r->keys, std::tr1::placeholders::_1)));
}
add_metadata_key(_imp->format_key);
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index a32dfd9..1b036d7 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -229,6 +229,16 @@ namespace
return value;
return make_incremental(k, var, before, value);
}
+
+ std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
+ const std::string & k)
+ {
+ Map<std::string, std::string>::ConstIterator mm(m->find(k));
+ if (m->end() == mm)
+ return "";
+ else
+ return mm->second;
+ }
}
PortageEnvironment::PortageEnvironment(const std::string & s) :
@@ -458,7 +468,8 @@ PortageEnvironment::_add_virtuals_repository()
std::tr1::shared_ptr<Map<std::string, std::string> > keys(
new Map<std::string, std::string>);
package_database()->add_repository(-2,
- RepositoryMaker::get_instance()->find_maker("virtuals")(this, keys));
+ RepositoryMaker::get_instance()->find_maker("virtuals")(this,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
}
void
@@ -468,7 +479,8 @@ PortageEnvironment::_add_installed_virtuals_repository()
new Map<std::string, std::string>);
keys->insert("root", stringify(root()));
package_database()->add_repository(-1,
- RepositoryMaker::get_instance()->find_maker("installed_virtuals")(this, keys));
+ RepositoryMaker::get_instance()->find_maker("installed_virtuals")(this,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
}
void
@@ -500,7 +512,8 @@ 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, keys));
+ RepositoryMaker::get_instance()->find_maker("ebuild")(this,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
}
void
@@ -527,7 +540,8 @@ PortageEnvironment::_add_vdb_repository()
builddir.append("/portage");
keys->insert("builddir", builddir);
package_database()->add_repository(1,
- RepositoryMaker::get_instance()->find_maker("vdb")(this, keys));
+ RepositoryMaker::get_instance()->find_maker("vdb")(this,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
}
PortageEnvironment::~PortageEnvironment()
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index a3f6bce..e2a4030 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -373,21 +373,19 @@ CRANInstalledRepository::do_installed_time(const QualifiedPackageName & q,
std::tr1::shared_ptr<Repository>
CRANInstalledRepository::make_cran_installed_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > m)
+ const std::tr1::function<std::string (const std::string &)> & f)
{
- Context context("When making CRAN installed repository from repo_file '" +
- (m->end() == m->find("repo_file") ? std::string("?") : m->find("repo_file")->second) + "':");
+ Context context("When making CRAN installed repository from repo_file '" + f("repo_file") + "':");
- std::string location;
- if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
+ std::string location(f("location"));
+ if (location.empty())
throw CRANInstalledRepositoryConfigurationError("Key 'location' not specified or empty");
- std::string root;
- if (m->end() == m->find("root") || ((root = m->find("root")->second)).empty())
+ std::string root(f("root"));
+ if (root.empty())
root = stringify(env->root());
- std::string world;
- if (m->end() != m->find("world") && ! ((world = m->find("world")->second)).empty())
+ if (! f("world").empty())
throw CRANInstalledRepositoryConfigurationError("Key 'world' is no longer supported.");
return std::tr1::shared_ptr<Repository>(new CRANInstalledRepository(CRANInstalledRepositoryParams::create()
diff --git a/paludis/repositories/cran/cran_installed_repository.hh b/paludis/repositories/cran/cran_installed_repository.hh
index 5cea94f..1779034 100644
--- a/paludis/repositories/cran/cran_installed_repository.hh
+++ b/paludis/repositories/cran/cran_installed_repository.hh
@@ -70,7 +70,7 @@ namespace paludis
*/
static std::tr1::shared_ptr<Repository> make_cran_installed_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > m);
+ 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 d8a6180..0e6daaf 100644
--- a/paludis/repositories/cran/cran_installed_repository_TEST.cc
+++ b/paludis/repositories/cran/cran_installed_repository_TEST.cc
@@ -25,12 +25,26 @@
#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/system.hh>
#include <paludis/util/map.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
using namespace test;
using namespace paludis;
+namespace
+{
+ std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
+ const std::string & k)
+ {
+ Map<std::string, std::string>::ConstIterator mm(m->find(k));
+ if (m->end() == mm)
+ return "";
+ else
+ return mm->second;
+ }
+}
+
namespace test_cases
{
struct CRANInstalledRepositoryPackagesTest : TestCase
@@ -45,7 +59,8 @@ 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, keys));
+ std::tr1::shared_ptr<Repository> repo(CRANInstalledRepository::make_cran_installed_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
TEST_CHECK(repo->has_category_named(CategoryNamePart("cran")));
}
} test_cran_repository_installed_packages;
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index 53adec0..d6e840d 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -399,35 +399,35 @@ CRANRepository::sync() const
std::tr1::shared_ptr<Repository>
CRANRepository::make_cran_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > m)
+ const std::tr1::function<std::string (const std::string &)> & f)
{
- Context context("When making CRAN repository from repo_file '" +
- (m->end() == m->find("repo_file") ? std::string("?") : m->find("repo_file")->second) + "':");
+ Context context("When making CRAN repository from repo_file '" + f("repo_file") + "':");
- std::string location;
- if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
+ std::string location(f("location"));
+ if (location.empty())
throw CRANRepositoryConfigurationError("Key 'location' not specified or empty");
- std::string library;
- if (m->end() == m->find("library") || ((library = m->find("library")->second)).empty())
+ std::string library(f("library"));
+ if (library.empty())
throw CRANRepositoryConfigurationError("Key 'library' not specified or empty");
- std::string distdir;
- if (m->end() == m->find("distdir") || ((distdir = m->find("distdir")->second)).empty())
+ std::string distdir(f("distdir"));
+ if (distdir.empty())
distdir = location + "/distfiles";
- std::string mirror;
- if (m->end() == m->find("mirror") || ((mirror = m->find("mirror")->second)).empty())
+ std::string mirror(f("mirror"));
+ if (mirror.empty())
mirror = "http://cran.r-project.org/";
- std::string sync;
- if (m->end() == m->find("sync") || ((sync = m->find("sync")->second)).empty())
+ std::string sync(f("sync"));
+ if (sync.empty())
sync = "rsync://cran.r-project.org/CRAN";
- std::string builddir;
- if (m->end() == m->find("builddir") || ((builddir = m->find("builddir")->second)).empty())
+ std::string builddir(f("builddir"));
+ if (builddir.empty())
{
- if (m->end() == m->find("buildroot") || ((builddir = m->find("buildroot")->second)).empty())
+ builddir = f("buildroot");
+ if (builddir.empty())
builddir = "/var/tmp/paludis";
else
Log::get_instance()->message("cran.configuration.deprecated", ll_warning, lc_context)
diff --git a/paludis/repositories/cran/cran_repository.hh b/paludis/repositories/cran/cran_repository.hh
index b87da04..811be24 100644
--- a/paludis/repositories/cran/cran_repository.hh
+++ b/paludis/repositories/cran/cran_repository.hh
@@ -24,7 +24,6 @@
#include <paludis/repository.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/private_implementation_pattern.hh>
-#include <paludis/util/map-fwd.hh>
#include <paludis/environment-fwd.hh>
#include <tr1/memory>
#include <string>
@@ -80,7 +79,7 @@ namespace paludis
*/
static std::tr1::shared_ptr<Repository> make_cran_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > m);
+ 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 3d2b567..622511e 100644
--- a/paludis/repositories/cran/cran_repository_TEST.cc
+++ b/paludis/repositories/cran/cran_repository_TEST.cc
@@ -26,12 +26,26 @@
#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/system.hh>
#include <paludis/util/map.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
using namespace test;
using namespace paludis;
+namespace
+{
+ std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
+ const std::string & k)
+ {
+ Map<std::string, std::string>::ConstIterator mm(m->find(k));
+ if (m->end() == mm)
+ return "";
+ else
+ return mm->second;
+ }
+}
+
namespace test_cases
{
struct CRANRepositoryPackagesTest : TestCase
@@ -46,8 +60,8 @@ 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, keys));
+ std::tr1::shared_ptr<Repository> repo(CRANRepository::make_cran_repository(&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")));
TEST_CHECK(repo->has_package_named(QualifiedPackageName("cran/testpackage2")));
@@ -66,8 +80,8 @@ 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, keys));
+ std::tr1::shared_ptr<Repository> repo(CRANRepository::make_cran_repository(&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")));
TEST_CHECK(repo->has_package_named(QualifiedPackageName("cran/bundlepkg2")));
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index 669d6e2..39dfdb5 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -32,6 +32,7 @@
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/map.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/set.hh>
#include <paludis/util/kc.hh>
#include <paludis/package_id.hh>
@@ -53,17 +54,21 @@
using namespace test;
using namespace paludis;
-/** \file
- * Test cases for ERepository.
- *
- */
+namespace
+{
+ std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
+ const std::string & k)
+ {
+ Map<std::string, std::string>::ConstIterator mm(m->find(k));
+ if (m->end() == mm)
+ return "";
+ else
+ return mm->second;
+ }
+}
namespace test_cases
{
- /**
- * \test Test ERepository repository names.
- *
- */
struct ERepositoryRepoNameTest : TestCase
{
ERepositoryRepoNameTest() : TestCase("repo name") { }
@@ -72,22 +77,17 @@ namespace test_cases
{
TestEnvironment env;
env.set_paludis_command("/bin/false");
- 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", "ebuild");
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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "test-repo-1");
}
} test_e_repository_repo_name;
- /**
- * \test Test ERepository repository with no names.
- *
- */
struct ERepositoryNoRepoNameTest : TestCase
{
ERepositoryNoRepoNameTest() : TestCase("no repo name") { }
@@ -96,22 +96,17 @@ namespace test_cases
{
TestEnvironment env;
env.set_paludis_command("/bin/false");
- 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", "ebuild");
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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "x-repo2");
}
} test_e_repository_no_repo_name;
- /**
- * \test Test ERepository repository empty names.
- *
- */
struct ERepositoryEmptyRepoNameTest : TestCase
{
ERepositoryEmptyRepoNameTest() : TestCase("empty repo name") { }
@@ -120,22 +115,17 @@ namespace test_cases
{
TestEnvironment env;
env.set_paludis_command("/bin/false");
- 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", "ebuild");
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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "x-repo3");
}
} test_e_repository_empty_repo_name;
- /**
- * \test Test ERepository repository has_category_named.
- *
- */
struct ERepositoryHasCategoryNamedTest : TestCase
{
ERepositoryHasCategoryNamedTest() : TestCase("has category named") { }
@@ -144,14 +134,13 @@ namespace test_cases
{
TestEnvironment env;
env.set_paludis_command("/bin/false");
- 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", "ebuild");
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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
for (int pass = 1 ; pass <= 2 ; ++pass)
{
@@ -165,10 +154,6 @@ namespace test_cases
}
} test_e_repository_has_category_named;
- /**
- * \test Test ERepository category_names.
- *
- */
struct ERepositoryCategoryNamesTest : TestCase
{
ERepositoryCategoryNamesTest() : TestCase("category names") { }
@@ -177,14 +162,13 @@ namespace test_cases
{
TestEnvironment env;
env.set_paludis_command("/bin/false");
- 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", "ebuild");
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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
for (int pass = 1 ; pass <= 2 ; ++pass)
{
@@ -200,10 +184,6 @@ namespace test_cases
}
} test_e_repository_category_names;
- /**
- * \test Test ERepository has_package_named.
- *
- */
struct ERepositoryHasPackageNamedTest : TestCase
{
ERepositoryHasPackageNamedTest() : TestCase("has package named") { }
@@ -212,14 +192,13 @@ namespace test_cases
{
TestEnvironment env;
env.set_paludis_command("/bin/false");
- 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", "ebuild");
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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
for (int pass = 1 ; pass <= 2 ; ++pass)
{
@@ -241,10 +220,6 @@ namespace test_cases
}
} test_e_repository_has_package_named;
- /**
- * \test Test ERepository has_package_named cached.
- *
- */
struct ERepositoryHasPackageNamedCachedTest : TestCase
{
ERepositoryHasPackageNamedCachedTest() : TestCase("has package named cached") { }
@@ -253,14 +228,13 @@ namespace test_cases
{
TestEnvironment env;
env.set_paludis_command("/bin/false");
- 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", "ebuild");
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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
repo->package_names(CategoryNamePart("cat-one"));
repo->package_names(CategoryNamePart("cat-two"));
@@ -286,10 +260,6 @@ namespace test_cases
}
} test_e_repository_has_package_named_cached;
- /**
- * \test Test ERepository package_names.
- *
- */
struct ERepositoryPackageNamesTest : TestCase
{
ERepositoryPackageNamesTest() : TestCase("package names") { }
@@ -298,14 +268,13 @@ namespace test_cases
{
TestEnvironment env;
env.set_paludis_command("/bin/false");
- 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", "ebuild");
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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
std::tr1::shared_ptr<const QualifiedPackageNameSet> names;
@@ -340,10 +309,6 @@ namespace test_cases
}
} test_e_repository_package_names;
- /**
- * \test Test ERepository bad package names.
- *
- */
struct ERepositoryBadPackageNamesTest : TestCase
{
ERepositoryBadPackageNamesTest() : TestCase("bad package names") { }
@@ -352,14 +317,13 @@ namespace test_cases
{
TestEnvironment env;
env.set_paludis_command("/bin/false");
- 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", "ebuild");
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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
std::tr1::shared_ptr<const QualifiedPackageNameSet> names;
@@ -391,8 +355,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
for (int pass = 1 ; pass <= 2 ; ++pass)
{
@@ -420,10 +384,6 @@ namespace test_cases
}
} test_e_repository_versions;
- /**
- * \test Test ERepository duff versions.
- *
- */
struct ERepositoryDuffVersionsTest : TestCase
{
ERepositoryDuffVersionsTest() : TestCase("duff versions") { }
@@ -434,14 +394,13 @@ namespace test_cases
TestEnvironment env;
env.set_paludis_command("/bin/false");
- 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", "ebuild");
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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
for (int pass = 1 ; pass <= 2 ; ++pass)
{
@@ -469,10 +428,6 @@ namespace test_cases
}
} test_e_repository_duff_versions;
- /**
- * \test Test ERepository cached metadata.
- *
- */
struct ERepositoryMetadataCachedTest : TestCase
{
ERepositoryMetadataCachedTest() : TestCase("metadata cached") { }
@@ -481,13 +436,13 @@ namespace test_cases
{
TestEnvironment env;
env.set_paludis_command("/bin/false");
- 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", "ebuild");
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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&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)
@@ -503,10 +458,6 @@ namespace test_cases
}
} test_e_repository_metadata_cached;
- /**
- * \test Test ERepository uncached metadata.
- *
- */
struct ERepositoryMetadataUncachedTest : TestCase
{
ERepositoryMetadataUncachedTest() : TestCase("metadata uncached") { }
@@ -531,7 +482,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
for (int pass = 1 ; pass <= 3 ; ++pass)
@@ -599,7 +551,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
for (int pass = 1 ; pass <= 3 ; ++pass)
@@ -631,10 +584,6 @@ namespace test_cases
}
} test_e_repository_metadata_stale;
- /**
- * \test Test ERepository unparsable metadata.
- *
- */
struct ERepositoryMetadataUnparsableTest : TestCase
{
ERepositoryMetadataUnparsableTest() : TestCase("metadata unparsable") { }
@@ -659,7 +608,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&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)
@@ -677,10 +627,6 @@ namespace test_cases
}
} test_e_repository_metadata_unparsable;
- /**
- * \test Test ERepository query_use and query_use_mask functions.
- *
- */
struct ERepositoryQueryUseTest : TestCase
{
ERepositoryQueryUseTest() : TestCase("USE query") { }
@@ -695,7 +641,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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&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)
@@ -729,10 +676,6 @@ namespace test_cases
}
} test_e_repository_query_use;
- /**
- * \test Test ERepository repository masks.
- *
- */
struct ERepositoryRepositoryMasksTest : TestCase
{
ERepositoryRepositoryMasksTest() : TestCase("repository masks") { }
@@ -748,7 +691,8 @@ 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, keys18));
+ std::tr1::shared_ptr<ERepository> repo18(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys18, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo18);
std::tr1::shared_ptr<Map<std::string, std::string> > keys19(
@@ -757,7 +701,8 @@ 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, keys19));
+ std::tr1::shared_ptr<ERepository> repo19(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys19, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo19);
TEST_CHECK((*env[selection::RequireExactlyOne(generator::Matches(
@@ -788,10 +733,6 @@ namespace test_cases
}
} test_e_repository_repository_masks;
- /**
- * \test Test ERepository query_profile_masks functions.
- *
- */
struct ERepositoryQueryProfileMasksTest : TestCase
{
ERepositoryQueryProfileMasksTest() : TestCase("profiles package.mask") { }
@@ -806,7 +747,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/subprofile");
- std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&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)
@@ -826,10 +768,6 @@ namespace test_cases
}
} test_e_repository_query_profile_masks;
- /**
- * \test Test ERepository invalidate_masks functions.
- *
- */
struct ERepositoryInvalidateMasksTest : TestCase
{
ERepositoryInvalidateMasksTest() : TestCase("invalidate_masks") { }
@@ -844,7 +782,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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&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(
@@ -861,10 +800,6 @@ namespace test_cases
}
} test_e_repository_invalidate_masks;
- /**
- * \test Test ERepository virtuals.
- *
- */
struct ERepositoryVirtualsTest : TestCase
{
ERepositoryVirtualsTest() : TestCase("virtuals") { }
@@ -879,7 +814,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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&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);
@@ -936,10 +872,6 @@ namespace test_cases
}
} test_e_repository_virtuals;
- /**
- * \test Test ERepository Manifest2 generation.
- *
- */
struct ERepositoryManifestTest : TestCase
{
ERepositoryManifestTest() : TestCase("manifest2") { }
@@ -954,8 +886,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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&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;
@@ -1003,7 +935,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
FetchAction action(FetchActionOptions::named_create()
@@ -1104,8 +1037,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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
FetchAction action(FetchActionOptions::named_create()
@@ -1152,7 +1085,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
std::tr1::shared_ptr<FakeInstalledRepository> installed_repo(new FakeInstalledRepository(&env, RepositoryName("installed")));
@@ -1162,9 +1096,10 @@ namespace test_cases
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));
+ env.package_database()->add_repository(-2, RepositoryMaker::get_instance()->find_maker("installed_virtuals")(&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::shared_ptr<Map<std::string, std::string> >()));
+ std::tr1::bind(from_keys, make_shared_ptr(new Map<std::string, std::string>), std::tr1::placeholders::_1)));
InstallAction action(InstallActionOptions::named_create()
(k::debug_build(), iado_none)
@@ -1383,7 +1318,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
std::tr1::shared_ptr<FakeInstalledRepository> installed_repo(new FakeInstalledRepository(&env, RepositoryName("installed")));
@@ -1447,7 +1383,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
std::tr1::shared_ptr<FakeInstalledRepository> installed_repo(new FakeInstalledRepository(&env, RepositoryName("installed")));
@@ -1540,7 +1477,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
std::tr1::shared_ptr<FakeInstalledRepository> installed_repo(new FakeInstalledRepository(&env, RepositoryName("installed")));
@@ -1599,7 +1537,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
std::tr1::shared_ptr<FakeInstalledRepository> installed_repo(new FakeInstalledRepository(&env, RepositoryName("installed")));
@@ -1609,9 +1548,10 @@ namespace test_cases
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));
+ env.package_database()->add_repository(-2, RepositoryMaker::get_instance()->find_maker("installed_virtuals")(&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::shared_ptr<Map<std::string, std::string> >()));
+ std::tr1::bind(from_keys, make_shared_ptr(new Map<std::string, std::string>), std::tr1::placeholders::_1)));
InstallAction action(InstallActionOptions::named_create()
(k::debug_build(), iado_none)
@@ -1998,8 +1938,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
@@ -2056,7 +1996,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
keys.reset(new Map<std::string, std::string>);
@@ -2066,7 +2007,8 @@ 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, keys));
+ std::tr1::shared_ptr<Repository> installed_repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, installed_repo);
InstallAction action(InstallActionOptions::named_create()
diff --git a/paludis/repositories/e/e_repository_sets_TEST.cc b/paludis/repositories/e/e_repository_sets_TEST.cc
index c07a7e6..82a73ed 100644
--- a/paludis/repositories/e/e_repository_sets_TEST.cc
+++ b/paludis/repositories/e/e_repository_sets_TEST.cc
@@ -34,17 +34,21 @@
using namespace test;
using namespace paludis;
-/** \file
- * Test cases for ERepositorySets.
- *
- */
+namespace
+{
+ std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
+ const std::string & k)
+ {
+ Map<std::string, std::string>::ConstIterator mm(m->find(k));
+ if (m->end() == mm)
+ return "";
+ else
+ return mm->second;
+ }
+}
namespace test_cases
{
- /**
- * \test Test ERepositorySets sets list.
- *
- */
struct ERepositorySetsSetsListTest : TestCase
{
ERepositorySetsSetsListTest() : TestCase("sets list") { }
@@ -52,14 +56,13 @@ namespace test_cases
void run()
{
TestEnvironment env;
- 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", "ebuild");
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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
std::tr1::shared_ptr<const SetNameSet> sets_list((*repo)[k::sets_interface()]->sets_list());
TEST_CHECK_EQUAL(sets_list->size(), 4U);
@@ -70,10 +73,6 @@ namespace test_cases
}
} test_e_repository_sets_sets_list;
- /**
- * \test Test ERepositorySets maintainer-defined sets.
- *
- */
struct ERepositorySetsMaintainerDefinedSetsTest : TestCase
{
ERepositorySetsMaintainerDefinedSetsTest() : TestCase("maintainer-defined sets") { }
@@ -81,14 +80,13 @@ namespace test_cases
void run()
{
TestEnvironment env;
- 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", "ebuild");
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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
std::tr1::shared_ptr<FakeInstalledRepository> installed(
new FakeInstalledRepository(&env, RepositoryName("installed")));
installed->add_version("cat-two", "bar", "1.5");
@@ -103,10 +101,6 @@ namespace test_cases
} test_e_repository_sets_maintainer_defined_sets_list;
#if ENABLE_GLSA
- /**
- * \test Test ERepositorySets insecurity set.
- *
- */
struct ERepositorySetsInsecuritySetTest : TestCase
{
ERepositorySetsInsecuritySetTest() : TestCase("insecurity set") { }
@@ -119,14 +113,13 @@ namespace test_cases
void run()
{
TestEnvironment env;
- 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", "ebuild");
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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
std::tr1::shared_ptr<SetSpecTree::ConstItem> insecurity((*repo)[k::sets_interface()]->package_set(SetName("insecurity")));
@@ -139,10 +132,6 @@ namespace test_cases
}
} test_e_repository_sets_insecurity_set;
- /**
- * \test Test ERepositorySets security set.
- *
- */
struct ERepositorySetsSecuritySetTest : TestCase
{
ERepositorySetsSecuritySetTest() : TestCase("security set") { }
@@ -161,8 +150,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
std::tr1::shared_ptr<FakeInstalledRepository> installed(
new FakeInstalledRepository(&env, RepositoryName("installed")));
diff --git a/paludis/repositories/e/exndbam_repository.cc b/paludis/repositories/e/exndbam_repository.cc
index d64cfc0..d59a7bd 100644
--- a/paludis/repositories/e/exndbam_repository.cc
+++ b/paludis/repositories/e/exndbam_repository.cc
@@ -129,40 +129,39 @@ ExndbamRepository::_add_metadata_keys() const
add_metadata_key(_imp->builddir_key);
}
-
std::tr1::shared_ptr<Repository>
ExndbamRepository::make_exndbam_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > m)
+ const std::tr1::function<std::string (const std::string &)> & f)
{
- std::string repo_file(m->end() == m->find("repo_file") ? std::string("?") : m->find("repo_file")->second);
- Context context("When making Exndbam repository from repo_file '" + repo_file + "':");
+ Context context("When making Exndbam repository from repo_file '" + f("repo_file") + "':");
- std::string location;
- if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
+ std::string location(f("location"));
+ if (location.empty())
throw ExndbamRepositoryConfigurationError("Key 'location' not specified or empty");
- std::string root;
- if (m->end() == m->find("root") || ((root = m->find("root")->second)).empty())
+ std::string root(f("root"));
+ if (root.empty())
root = "/";
- std::string builddir;
- if (m->end() == m->find("builddir") || ((builddir = m->find("builddir")->second)).empty())
+ std::string builddir(f("builddir"));
+ if (builddir.empty())
{
- if (m->end() == m->find("buildroot") || ((builddir = m->find("buildroot")->second)).empty())
+ builddir = f("buildroot");
+ if (builddir.empty())
builddir = (*DistributionData::get_instance()->distribution_from_string(
- env->distribution()))[k::default_ebuild_builddir()];
+ env->distribution()))[k::default_ebuild_builddir()];
else
Log::get_instance()->message("e.exndbam.configuration.deprecated", ll_warning, lc_context)
<< "Key 'buildroot' is deprecated, use 'builddir' instead";
}
- std::string name;
- if (m->end() == m->find("name") || ((name = m->find("name")->second)).empty())
+ std::string name(f("name"));
+ if (name.empty())
name = "installed";
- std::string deprecated_world;
- if (m->end() == m->find("world") || ((deprecated_world = m->find("world")->second)).empty())
+ std::string deprecated_world(f("world"));
+ if (deprecated_world.empty())
deprecated_world = "/DOESNOTEXIST";
else
Log::get_instance()->message("e.exndbam.configuration.deprecated", ll_warning, lc_context) << "Specifying world location " <<
diff --git a/paludis/repositories/e/exndbam_repository.hh b/paludis/repositories/e/exndbam_repository.hh
index e07de72..49de3fd 100644
--- a/paludis/repositories/e/exndbam_repository.hh
+++ b/paludis/repositories/e/exndbam_repository.hh
@@ -59,7 +59,7 @@ namespace paludis
*/
static std::tr1::shared_ptr<Repository> make_exndbam_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > m);
+ const std::tr1::function<std::string (const std::string &)> &);
/**
* Destructor.
diff --git a/paludis/repositories/e/exndbam_repository_TEST.cc b/paludis/repositories/e/exndbam_repository_TEST.cc
index c8091a8..b6072e0 100644
--- a/paludis/repositories/e/exndbam_repository_TEST.cc
+++ b/paludis/repositories/e/exndbam_repository_TEST.cc
@@ -19,18 +19,28 @@
#include <paludis/repositories/e/exndbam_repository.hh>
#include <paludis/environments/test/test_environment.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
using namespace test;
using namespace paludis;
+namespace
+{
+ std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
+ const std::string & k)
+ {
+ Map<std::string, std::string>::ConstIterator mm(m->find(k));
+ if (m->end() == mm)
+ return "";
+ else
+ return mm->second;
+ }
+}
+
namespace test_cases
{
- /**
- * \test Test VDBRepository repo names
- *
- */
struct ExndbamRepositoryRepoNameTest : TestCase
{
ExndbamRepositoryRepoNameTest() : TestCase("repo name") { }
@@ -41,7 +51,8 @@ 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, keys));
+ std::tr1::shared_ptr<Repository> repo(ExndbamRepository::make_exndbam_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "installed");
}
} test_exndbam_repository_repo_name;
diff --git a/paludis/repositories/e/make_ebuild_repository.cc b/paludis/repositories/e/make_ebuild_repository.cc
index d7fccbd..022643d 100644
--- a/paludis/repositories/e/make_ebuild_repository.cc
+++ b/paludis/repositories/e/make_ebuild_repository.cc
@@ -39,15 +39,12 @@ using namespace paludis;
std::tr1::shared_ptr<ERepository>
paludis::make_ebuild_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > m)
+ const std::tr1::function<std::string (const std::string &)> & f)
{
- std::string repo_file(m->end() == m->find("repo_file") ? std::string("?") :
- m->find("repo_file")->second);
+ Context context("When making ebuild repository from repo_file '" + f("repo_file") + "':");
- Context context("When making ebuild repository from repo_file '" + repo_file + "':");
-
- std::string location;
- if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
+ 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() ?
@@ -57,12 +54,12 @@ paludis::make_ebuild_repository(
std::tr1::shared_ptr<const RepositoryName> master_repository_name;
std::tr1::shared_ptr<const ERepository> master_repository;
- if (m->end() != m->find("master_repository") && ! m->find("master_repository")->second.empty())
+ if (! f("master_repository").empty())
{
Context context_local("When finding configuration information for master_repository '"
- + stringify(m->find("master_repository")->second) + "':");
+ + stringify(f("master_repository")) + "':");
- master_repository_name.reset(new RepositoryName(m->find("master_repository")->second));
+ 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));
@@ -83,9 +80,7 @@ paludis::make_ebuild_repository(
}
std::tr1::shared_ptr<FSEntrySequence> profiles(new FSEntrySequence);
- if (m->end() != m->find("profiles"))
- tokenise_whitespace(m->find("profiles")->second,
- create_inserter<FSEntry>(std::back_inserter(*profiles)));
+ tokenise_whitespace(f("profiles"), create_inserter<FSEntry>(std::back_inserter(*profiles)));
if (profiles->empty())
{
@@ -97,10 +92,7 @@ paludis::make_ebuild_repository(
}
std::tr1::shared_ptr<FSEntrySequence> eclassdirs(new FSEntrySequence);
-
- if (m->end() != m->find("eclassdirs"))
- tokenise_whitespace(m->find("eclassdirs")->second,
- create_inserter<FSEntry>(std::back_inserter(*eclassdirs)));
+ tokenise_whitespace(f("eclassdirs"), create_inserter<FSEntry>(std::back_inserter(*eclassdirs)));
if (eclassdirs->empty())
{
@@ -111,8 +103,8 @@ paludis::make_ebuild_repository(
eclassdirs->push_back(location + "/eclass");
}
- std::string distdir;
- if (m->end() == m->find("distdir") || ((distdir = m->find("distdir")->second)).empty())
+ std::string distdir(f("distdir"));
+ if (distdir.empty())
{
if (master_repository)
distdir = stringify(master_repository->params().distdir);
@@ -127,47 +119,47 @@ paludis::make_ebuild_repository(
}
}
- std::string setsdir;
- if (m->end() == m->find("setsdir") || ((setsdir = m->find("setsdir")->second)).empty())
+ std::string setsdir(f("setsdir"));
+ if (setsdir.empty())
setsdir = location + "/sets";
- std::string securitydir;
- if (m->end() == m->find("securitydir") || ((securitydir = m->find("securitydir")->second)).empty())
+ std::string securitydir(f("securitydir"));
+ if (securitydir.empty())
securitydir = location + "/metadata/glsa";
- std::string newsdir;
- if (m->end() == m->find("newsdir") || ((newsdir = m->find("newsdir")->second)).empty())
+ std::string newsdir(f("newsdir"));
+ if (newsdir.empty())
newsdir = location + "/metadata/news";
- std::string cache;
- if (m->end() == m->find("cache") || ((cache = m->find("cache")->second)).empty())
+ std::string cache(f("cache"));
+ if (cache.empty())
{
cache = location + "/metadata/cache";
if (! FSEntry(cache).exists())
cache = "/var/empty";
}
- std::string write_cache;
- if (m->end() == m->find("write_cache") || ((write_cache = m->find("write_cache")->second)).empty())
+ std::string write_cache(f("write_cache"));
+ if (write_cache.empty())
write_cache = (*DistributionData::get_instance()->distribution_from_string(
env->distribution()))[k::default_ebuild_write_cache()];
bool append_repository_name_to_write_cache(true);
- if (m->end() != m->find("append_repository_name_to_write_cache") && ! m->find("append_repository_name_to_write_cache")->second.empty())
+ 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>(m->find("append_repository_name_to_write_cache")->second);
+ append_repository_name_to_write_cache = destringify<bool>(f("append_repository_name_to_write_cache"));
}
bool ignore_deprecated_profiles(false);
- if (m->end() != m->find("ignore_deprecated_profiles") && ! m->find("ignore_deprecated_profiles")->second.empty())
+ if (! f("ignore_deprecated_profiles").empty())
{
Context item_context("When handling ignore_deprecated_profiles key:");
- ignore_deprecated_profiles = destringify<bool>(m->find("ignore_deprecated_profiles")->second);
+ ignore_deprecated_profiles = destringify<bool>(f("ignore_deprecated_profiles"));
}
- std::string eapi_when_unknown;
- if (m->end() == m->find("eapi_when_unknown") || ((eapi_when_unknown = m->find("eapi_when_unknown")->second)).empty())
+ 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())
@@ -175,17 +167,17 @@ paludis::make_ebuild_repository(
env->distribution()))[k::default_ebuild_eapi_when_unknown()];
}
- std::string eapi_when_unspecified;
- if (m->end() == m->find("eapi_when_unspecified") || ((eapi_when_unspecified = m->find("eapi_when_unspecified")->second)).empty())
+ std::string eapi_when_unspecified(f("eapi_when_unspecified"));
+ if (eapi_when_unspecified.empty())
{
- if (! layout_conf
+ if (! layout_conf
|| (eapi_when_unspecified = layout_conf->get("eapi_when_unspecified")).empty())
eapi_when_unspecified = (*DistributionData::get_instance()->distribution_from_string(
env->distribution()))[k::default_ebuild_eapi_when_unspecified()];
}
- std::string profile_eapi;
- if (m->end() == m->find("profile_eapi") || ((profile_eapi = m->find("profile_eapi")->second)).empty())
+ std::string profile_eapi(f("profile_eapi"));
+ if (profile_eapi.empty())
{
if (! layout_conf
|| (profile_eapi = layout_conf->get("eapi_when_unspecified")).empty())
@@ -193,53 +185,51 @@ paludis::make_ebuild_repository(
env->distribution()))[k::default_ebuild_profile_eapi()];
}
- std::string names_cache;
- if (m->end() == m->find("names_cache") || ((names_cache = m->find("names_cache")->second)).empty())
+ std::string names_cache(f("names_cache"));
+ if (names_cache.empty())
{
names_cache = (*DistributionData::get_instance()->distribution_from_string(
env->distribution()))[k::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 '" << repo_file
+ << "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;
- if (m->end() != m->find("sync"))
- sync = m->find("sync")->second;
-
- std::string sync_options;
- if (m->end() != m->find("sync_options"))
- sync_options = m->find("sync_options")->second;
+ std::string sync(f("sync"));
+ std::string sync_options(f("sync_options"));
- if (m->end() != m->find("sync_exclude"))
+ if (! f("sync_exclude").empty())
{
Log::get_instance()->message("e.ebuild.configuration.deprecated", ll_warning, lc_no_context)
- << "The sync_exclude key in '" << repo_file << "' is deprecated in favour of sync_options = --exclude-from=";
+ << "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='" + m->find("sync_exclude")->second + "'";
+ sync_options += "--exclude-from='" + f("sync_exclude") + "'";
}
- std::string builddir;
- if (m->end() == m->find("builddir") || ((builddir = m->find("builddir")->second)).empty())
+ std::string builddir(f("builddir"));
+ if (builddir.empty())
{
- if (m->end() == m->find("buildroot") || ((builddir = m->find("buildroot")->second)).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()))[k::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;
- if (m->end() == m->find("layout") || ((layout = m->find("layout")->second)).empty())
+ std::string layout(f("layout"));
+ if (layout.empty())
{
if (! layout_conf
|| (layout = layout_conf->get("layout")).empty())
@@ -248,29 +238,23 @@ paludis::make_ebuild_repository(
}
erepository::UseManifest use_manifest(erepository::manifest_use);
- if (m->end() != m->find("use_manifest") && ! m->find("use_manifest")->second.empty())
+ if (! f("use_manifest").empty())
{
Context item_context("When handling use_manifest key:");
- use_manifest = destringify<erepository::UseManifest>(m->find("use_manifest")->second);
+ use_manifest = destringify<erepository::UseManifest>(f("use_manifest"));
}
bool binary_destination(false);
- if (m->end() != m->find("binary_destination") && ! m->find("binary_destination")->second.empty())
+ if (! f("binary_destination").empty())
{
Context item_context("When handling binary_destination key:");
- binary_destination = destringify<bool>(m->find("binary_destination")->second);
+ binary_destination = destringify<bool>(f("binary_destination"));
}
- std::string binary_uri_prefix;
- if (m->end() != m->find("binary_uri_prefix"))
- binary_uri_prefix = m->find("binary_uri_prefix")->second;
-
- std::string binary_distdir;
- if (m->end() == m->find("binary_distdir") || ((binary_distdir = m->find("binary_distdir")->second)).empty())
- binary_distdir = distdir;
-
- std::string binary_keywords;
- if (m->end() == m->find("binary_keywords") || ((binary_keywords = m->find("binary_keywords")->second)).empty())
+ 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");
@@ -310,8 +294,8 @@ paludis::make_ebuild_repository(
std::tr1::shared_ptr<Repository>
paludis::make_ebuild_repository_wrapped(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > m)
+ const std::tr1::function<std::string (const std::string &)> & f)
{
- return make_ebuild_repository(env, m);
+ return make_ebuild_repository(env, f);
}
diff --git a/paludis/repositories/e/make_ebuild_repository.hh b/paludis/repositories/e/make_ebuild_repository.hh
index 9d0f6eb..b122cb5 100644
--- a/paludis/repositories/e/make_ebuild_repository.hh
+++ b/paludis/repositories/e/make_ebuild_repository.hh
@@ -34,7 +34,7 @@ namespace paludis
std::tr1::shared_ptr<ERepository>
make_ebuild_repository(
Environment * const,
- std::tr1::shared_ptr<const Map<std::string, std::string> >) PALUDIS_VISIBLE;
+ const std::tr1::function<std::string (const std::string &)> &) PALUDIS_VISIBLE;
/**
* Create an ebuild format repository (wrapper for our virtual constructor).
@@ -45,7 +45,7 @@ namespace paludis
std::tr1::shared_ptr<Repository>
make_ebuild_repository_wrapped(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > m);
+ 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 e5b7511..bc5ce85 100644
--- a/paludis/repositories/e/qa/manifest_TEST.cc
+++ b/paludis/repositories/e/qa/manifest_TEST.cc
@@ -24,6 +24,7 @@
#include <paludis/util/fd_holder.hh>
#include <paludis/util/fs_entry.hh>
#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 <test/test_framework.hh>
@@ -58,6 +59,16 @@ namespace
{
}
};
+
+ std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
+ const std::string & k)
+ {
+ Map<std::string, std::string>::ConstIterator mm(m->find(k));
+ if (m->end() == mm)
+ return "";
+ else
+ return mm->second;
+ }
}
namespace test_cases
@@ -79,7 +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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
QualifiedPackageName qpn("cat/not-signed");
@@ -104,7 +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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
QualifiedPackageName qpn("cat/good");
@@ -128,7 +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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
QualifiedPackageName qpn("cat/bad-type");
@@ -152,7 +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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
QualifiedPackageName qpn("cat/bad-size");
@@ -176,7 +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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
QualifiedPackageName qpn("cat/bad-hash");
@@ -200,7 +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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
QualifiedPackageName qpn("cat/missing");
@@ -224,7 +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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
QualifiedPackageName qpn("cat/stray");
@@ -248,7 +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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
QualifiedPackageName qpn("cat/unused-distfile");
@@ -272,7 +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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&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/visibility_TEST.cc b/paludis/repositories/e/qa/visibility_TEST.cc
index 4e91c28..e632604 100644
--- a/paludis/repositories/e/qa/visibility_TEST.cc
+++ b/paludis/repositories/e/qa/visibility_TEST.cc
@@ -64,6 +64,16 @@ namespace
{
}
};
+
+ std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
+ const std::string & k)
+ {
+ Map<std::string, std::string>::ConstIterator mm(m->find(k));
+ if (m->end() == mm)
+ return "";
+ else
+ return mm->second;
+ }
}
namespace test_cases
@@ -80,7 +90,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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&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 fcd346f..e22e2ce 100644
--- a/paludis/repositories/e/registration.cc
+++ b/paludis/repositories/e/registration.cc
@@ -40,18 +40,14 @@ namespace
std::tr1::shared_ptr<Repository>
make_portage_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > m)
+ const std::tr1::function<std::string (const std::string &)> & f)
{
- std::string repo_file = "?";
- if (m->end() != m->find("repo_file"))
- repo_file = m->find("repo_file")->second;
-
- Context context("When creating repository using '" + repo_file + "':");
+ Context context("When creating repository using '" + f("repo_file") + "':");
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, m);
+ return make_ebuild_repository_wrapped(env, f);
}
}
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index db585ea..cd0a136 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -279,21 +279,20 @@ VDBRepository::package_ids(const QualifiedPackageName & n) const
std::tr1::shared_ptr<Repository>
VDBRepository::make_vdb_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > m)
+ const std::tr1::function<std::string (const std::string &)> & f)
{
- std::string repo_file(m->end() == m->find("repo_file") ? std::string("?") : m->find("repo_file")->second);
- Context context("When making VDB repository from repo_file '" + repo_file + "':");
+ Context context("When making VDB repository from repo_file '" + f("repo_file") + "':");
- std::string location;
- if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
+ std::string location(f("location"));
+ if (location.empty())
throw VDBRepositoryConfigurationError("Key 'location' not specified or empty");
- std::string root;
- if (m->end() == m->find("root") || ((root = m->find("root")->second)).empty())
+ std::string root(f("root"));
+ if (root.empty())
root = "/";
- std::string deprecated_world;
- if (m->end() == m->find("world") || ((deprecated_world = m->find("world")->second)).empty())
+ std::string deprecated_world(f("world"));
+ if (deprecated_world.empty())
deprecated_world = "/DOESNOTEXIST";
else
Log::get_instance()->message("e.vdb.configuration.deprecated", ll_warning, lc_context) << "Specifying world location " <<
@@ -301,38 +300,39 @@ VDBRepository::make_vdb_repository(
"read but not updated. If you have recently upgraded from <paludis-0.26.0_alpha13, consult "
"the FAQ Upgrades section.";
- std::string provides_cache;
- if (m->end() == m->find("provides_cache") || ((provides_cache = m->find("provides_cache")->second)).empty())
+ std::string provides_cache(f("provides_cache"));
+ if (provides_cache.empty())
{
provides_cache = (*DistributionData::get_instance()->distribution_from_string(
env->distribution()))[k::default_vdb_provides_cache()];
if (provides_cache.empty())
{
Log::get_instance()->message("e.vdb.configuration.no_provides_cache", ll_warning, lc_no_context)
- << "The provides_cache key is not set in '" << repo_file
+ << "The provides_cache key is not set in '" << f("repo_file")
<< "'. You should read the Paludis documentation and select an appropriate value.";
provides_cache = "/var/empty";
}
}
- std::string names_cache;
- if (m->end() == m->find("names_cache") || ((names_cache = m->find("names_cache")->second)).empty())
+ std::string names_cache(f("names_cache"));
+ if (names_cache.empty())
{
names_cache = (*DistributionData::get_instance()->distribution_from_string(
env->distribution()))[k::default_vdb_names_cache()];
if (names_cache.empty())
{
Log::get_instance()->message("e.vdb.configuration.no_names_cache", ll_warning, lc_no_context)
- << "The names_cache key is not set in '" << repo_file
+ << "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 builddir;
- if (m->end() == m->find("builddir") || ((builddir = m->find("builddir")->second)).empty())
+ std::string builddir(f("builddir"));
+ if (builddir.empty())
{
- if (m->end() == m->find("buildroot") || ((builddir = m->find("buildroot")->second)).empty())
+ builddir = f("buildroot");
+ if (builddir.empty())
builddir = (*DistributionData::get_instance()->distribution_from_string(
env->distribution()))[k::default_ebuild_builddir()];
else
@@ -340,8 +340,8 @@ VDBRepository::make_vdb_repository(
<< "Key 'buildroot' is deprecated, use 'builddir' instead";
}
- std::string name;
- if (m->end() == m->find("name") || ((name = m->find("name")->second)).empty())
+ std::string name(f("name"));
+ if (name.empty())
name = "installed";
return std::tr1::shared_ptr<Repository>(new VDBRepository(VDBRepositoryParams::create()
diff --git a/paludis/repositories/e/vdb_repository.hh b/paludis/repositories/e/vdb_repository.hh
index c9bca8d..67657de 100644
--- a/paludis/repositories/e/vdb_repository.hh
+++ b/paludis/repositories/e/vdb_repository.hh
@@ -91,7 +91,7 @@ namespace paludis
*/
static std::tr1::shared_ptr<Repository> make_vdb_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > m);
+ const std::tr1::function<std::string (const std::string &)> &);
/**
* Destructor.
diff --git a/paludis/repositories/e/vdb_repository_TEST.cc b/paludis/repositories/e/vdb_repository_TEST.cc
index 75c9aaa..b895f09 100644
--- a/paludis/repositories/e/vdb_repository_TEST.cc
+++ b/paludis/repositories/e/vdb_repository_TEST.cc
@@ -48,17 +48,21 @@
using namespace test;
using namespace paludis;
-/** \file
- * Test cases for VDBRepository.
- *
- */
+namespace
+{
+ std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
+ const std::string & k)
+ {
+ Map<std::string, std::string>::ConstIterator mm(m->find(k));
+ if (m->end() == mm)
+ return "";
+ else
+ return mm->second;
+ }
+}
namespace test_cases
{
- /**
- * \test Test VDBRepository repo names
- *
- */
struct VDBRepositoryRepoNameTest : TestCase
{
VDBRepositoryRepoNameTest() : TestCase("repo name") { }
@@ -73,15 +77,12 @@ 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, keys));
+ std::tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "installed");
}
} test_vdb_repository_repo_name;
- /**
- * \test Test VDBRepository has_category_named
- *
- */
struct VDBRepositoryHasCategoryNamedTest : TestCase
{
VDBRepositoryHasCategoryNamedTest() : TestCase("has category named") { }
@@ -97,8 +98,8 @@ 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, keys));
+ std::tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
TEST_CHECK(repo->has_category_named(CategoryNamePart("cat-one")));
TEST_CHECK(repo->has_category_named(CategoryNamePart("cat-two")));
@@ -106,10 +107,6 @@ namespace test_cases
}
} test_vdb_repository_has_category_named;
- /**
- * \test Test VDBRepository query_use
- *
- */
struct VDBRepositoryQueryUseTest : TestCase
{
VDBRepositoryQueryUseTest() : TestCase("query USE") { }
@@ -125,7 +122,8 @@ 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, keys));
+ std::tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
std::tr1::shared_ptr<const PackageID> e1(*env[selection::RequireExactlyOne(generator::Matches(
@@ -138,9 +136,6 @@ namespace test_cases
}
} test_vdb_repository_query_use;
- /**
- * \test Test VDBRepository CONTENTS.
- */
struct VDBRepositoryContentsTest : TestCase
{
VDBRepositoryContentsTest() : TestCase("CONTENTS") { }
@@ -206,8 +201,8 @@ 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, keys));
+ std::tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
std::tr1::shared_ptr<const PackageID> e1(*env[selection::RequireExactlyOne(generator::Matches(
@@ -261,8 +256,8 @@ 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, keys));
+ std::tr1::shared_ptr<Repository> repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
@@ -324,7 +319,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
keys.reset(new Map<std::string, std::string>);
@@ -334,7 +330,8 @@ 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, keys));
+ std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(0, vdb_repo);
InstallAction install_action(InstallActionOptions::named_create()
@@ -439,7 +436,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
keys.reset(new Map<std::string, std::string>);
@@ -449,7 +447,8 @@ 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, keys));
+ std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(0, vdb_repo);
InstallAction install_action(InstallActionOptions::named_create()
@@ -554,7 +553,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo);
keys.reset(new Map<std::string, std::string>);
@@ -564,7 +564,8 @@ 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, keys));
+ std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(0, vdb_repo);
InstallAction install_action(InstallActionOptions::named_create()
@@ -807,7 +808,8 @@ 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, keys));
+ std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(0, vdb_repo);
TEST_CHECK(! provides_cache.exists());
@@ -897,7 +899,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo1(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo1);
keys.reset(new Map<std::string, std::string>);
@@ -912,7 +915,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo2(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(2, repo2);
keys.reset(new Map<std::string, std::string>);
@@ -922,7 +926,8 @@ 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, keys));
+ std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(0, vdb_repo);
InstallAction install_action(InstallActionOptions::named_create()
@@ -1110,7 +1115,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo1(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(1, repo1);
keys.reset(new Map<std::string, std::string>);
@@ -1125,7 +1131,8 @@ 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, keys));
+ std::tr1::shared_ptr<ERepository> repo2(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(2, repo2);
keys.reset(new Map<std::string, std::string>);
@@ -1135,7 +1142,8 @@ 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, keys));
+ std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
env.package_database()->add_repository(0, vdb_repo);
InstallAction install_action(InstallActionOptions::named_create()
diff --git a/paludis/repositories/gems/registration.cc b/paludis/repositories/gems/registration.cc
index 5b86062..f161ccb 100644
--- a/paludis/repositories/gems/registration.cc
+++ b/paludis/repositories/gems/registration.cc
@@ -36,26 +36,22 @@ namespace
std::tr1::shared_ptr<Repository>
make_gems_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > m)
+ const std::tr1::function<std::string (const std::string &)> & f)
{
- std::string location;
- if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
+ std::string location(f("location"));
+ if (location.empty())
throw gems::RepositoryConfigurationError("Key 'location' not specified or empty");
- std::string install_dir;
- if (m->end() == m->find("install_dir") || ((install_dir = m->find("install_dir")->second)).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;
- if (m->end() != m->find("sync"))
- sync = m->find("sync")->second;
+ std::string sync(f("sync"));
- std::string sync_options;
- if (m->end() != m->find("sync_options"))
- sync_options = m->find("sync_options")->second;
+ std::string sync_options(f("sync_options"));
- std::string builddir;
- if (m->end() == m->find("builddir") || ((builddir = m->find("builddir")->second)).empty())
+ std::string builddir(f("builddir"));
+ if (builddir.empty())
builddir = (*DistributionData::get_instance()->distribution_from_string(env->distribution()))[k::default_ebuild_builddir()];
return make_shared_ptr(new GemsRepository(gems::RepositoryParams::create()
@@ -70,18 +66,18 @@ namespace
std::tr1::shared_ptr<Repository>
make_installed_gems_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > m)
+ const std::tr1::function<std::string (const std::string &)> & f)
{
- std::string install_dir;
- if (m->end() == m->find("install_dir") || ((install_dir = m->find("install_dir")->second)).empty())
+ std::string install_dir(f("install_dir"));
+ if (install_dir.empty())
throw gems::RepositoryConfigurationError("Key 'install_dir' not specified or empty");
- std::string builddir;
- if (m->end() == m->find("builddir") || ((builddir = m->find("builddir")->second)).empty())
+ std::string builddir(f("builddir"));
+ if (builddir.empty())
builddir = (*DistributionData::get_instance()->distribution_from_string(env->distribution()))[k::default_ebuild_builddir()];
- std::string root;
- if (m->end() == m->find("root") || ((root = m->find("root")->second)).empty())
+ std::string root(f("root"));
+ if (root.empty())
root = "/";
return make_shared_ptr(new InstalledGemsRepository(gems::InstalledRepositoryParams::create()
diff --git a/paludis/repositories/unavailable/registration.cc b/paludis/repositories/unavailable/registration.cc
index 0643dff..bc88d95 100644
--- a/paludis/repositories/unavailable/registration.cc
+++ b/paludis/repositories/unavailable/registration.cc
@@ -35,32 +35,25 @@ namespace
std::tr1::shared_ptr<Repository>
make_unavailable_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > m)
+ const std::tr1::function<std::string (const std::string &)> & f)
{
- std::string repo_file(m->end() == m->find("repo_file") ? std::string("?") :
- m->find("repo_file")->second);
+ Context context("When making unavailable repository from repo_file '" + f("repo_file") + "':");
- Context context("When making unavailable repository from repo_file '" + repo_file + "':");
+ std::string name_str(f("name"));
+ if (name_str.empty())
+ name_str = "unavailable";
- std::string name_str;
- RepositoryName name(m->end() == m->find("name") || (name_str = m->find("name")->second).empty()
- ? "unavailable" : name_str);
-
- std::string location;
- if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
+ std::string location(f("location"));
+ if (location.empty())
throw UnavailableRepositoryConfigurationError("Key 'location' not specified or empty");
- std::string sync;
- if (m->end() != m->find("sync"))
- sync = m->find("sync")->second;
+ std::string sync(f("sync"));
- std::string sync_options;
- if (m->end() != m->find("sync_options"))
- sync_options = m->find("sync_options")->second;
+ std::string sync_options(f("sync_options"));
return std::tr1::shared_ptr<UnavailableRepository>(new UnavailableRepository(
UnavailableRepositoryParams::named_create()
- (k::name(), name)
+ (k::name(), RepositoryName(name_str))
(k::location(), location)
(k::sync(), sync)
(k::sync_options(), sync_options)
diff --git a/paludis/repositories/unpackaged/registration.cc b/paludis/repositories/unpackaged/registration.cc
index 117bec5..115d391 100644
--- a/paludis/repositories/unpackaged/registration.cc
+++ b/paludis/repositories/unpackaged/registration.cc
@@ -33,47 +33,39 @@ namespace
std::tr1::shared_ptr<Repository>
make_unpackaged_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > m)
+ const std::tr1::function<std::string (const std::string &)> & f)
{
Context context("When creating UnpackagedRepository:");
- std::string location;
- if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
+ std::string location(f("location"));
+ if (location.empty())
throw unpackaged_repositories::RepositoryConfigurationError("Key 'location' not specified or empty");
- std::string install_under;
- if (m->end() == m->find("install_under") || ((install_under = m->find("install_under")->second)).empty())
+ std::string install_under(f("install_under"));
+ if (install_under.empty())
install_under = "/";
- std::string name;
- if (m->end() == m->find("name") || ((name = m->find("name")->second)).empty())
+ std::string name(f("name"));
+ if (name.empty())
throw unpackaged_repositories::RepositoryConfigurationError("Key 'name' not specified or empty");
- std::string version;
- if (m->end() == m->find("version") || ((version = m->find("version")->second)).empty())
+ std::string version(f("version"));
+ if (version.empty())
throw unpackaged_repositories::RepositoryConfigurationError("Key 'version' not specified or empty");
- std::string slot;
- if (m->end() == m->find("slot") || ((slot = m->find("slot")->second)).empty())
+ std::string slot(f("slot"));
+ if (slot.empty())
throw unpackaged_repositories::RepositoryConfigurationError("Key 'slot' not specified or empty");
- std::string build_dependencies;
- if (m->end() != m->find("build_dependencies"))
- build_dependencies = m->find("build_dependencies")->second;
-
- std::string run_dependencies;
- if (m->end() != m->find("run_dependencies"))
- run_dependencies = m->find("run_dependencies")->second;
-
- std::string description;
- if (m->end() != m->find("description"))
- description = m->find("description")->second;
+ 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 (m->end() != m->find("rewrite_ids_over_to_root") && ! m->find("rewrite_ids_over_to_root")->second.empty())
+ 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>(m->find("rewrite_ids_over_to_root")->second);
+ rewrite_ids_over_to_root = destringify<int>(f("rewrite_ids_over_to_root"));
}
return make_shared_ptr(new UnpackagedRepository(RepositoryName("unpackaged"),
@@ -93,16 +85,16 @@ namespace
std::tr1::shared_ptr<Repository>
make_installed_unpackaged_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > m)
+ const std::tr1::function<std::string (const std::string &)> & f)
{
Context context("When creating InstalledUnpackagedRepository:");
- std::string location;
- if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
+ std::string location(f("location"));
+ if (location.empty())
throw unpackaged_repositories::RepositoryConfigurationError("Key 'location' not specified or empty");
- std::string root;
- if (m->end() == m->find("root") || ((root = m->find("root")->second)).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"),
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index 4e4c398..cc09b13 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -172,13 +172,9 @@ InstalledVirtualsRepository::need_ids() const
std::tr1::shared_ptr<Repository>
InstalledVirtualsRepository::make_installed_virtuals_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> > k)
+ const std::tr1::function<std::string (const std::string &)> & f)
{
- std::string root_str;
-
- if (k && (k->end() != k->find("root")))
- root_str = k->find("root")->second;
-
+ std::string root_str(f("root"));
if (root_str.empty())
throw ConfigurationError("No root specified for InstalledVirtualsRepository");
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.hh b/paludis/repositories/virtuals/installed_virtuals_repository.hh
index 48ee405..334220c 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.hh
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.hh
@@ -62,7 +62,7 @@ namespace paludis
*/
static std::tr1::shared_ptr<Repository> make_installed_virtuals_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> >);
+ const std::tr1::function<std::string (const std::string &)> &);
virtual std::tr1::shared_ptr<const CategoryNamePartSet> unimportant_category_names() const;
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index 112db88..b0b0fb2 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -254,7 +254,7 @@ VirtualsRepository::need_ids() const
std::tr1::shared_ptr<Repository>
VirtualsRepository::make_virtuals_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> >)
+ const std::tr1::function<std::string (const std::string &)> &)
{
return std::tr1::shared_ptr<Repository>(new VirtualsRepository(env));
}
diff --git a/paludis/repositories/virtuals/virtuals_repository.hh b/paludis/repositories/virtuals/virtuals_repository.hh
index dd60886..915c22c 100644
--- a/paludis/repositories/virtuals/virtuals_repository.hh
+++ b/paludis/repositories/virtuals/virtuals_repository.hh
@@ -61,7 +61,7 @@ namespace paludis
*/
static std::tr1::shared_ptr<Repository> make_virtuals_repository(
Environment * const env,
- std::tr1::shared_ptr<const Map<std::string, std::string> >);
+ const std::tr1::function<std::string (const std::string &)> &);
virtual std::tr1::shared_ptr<const CategoryNamePartSet> unimportant_category_names() const;
diff --git a/paludis/repository_maker.cc b/paludis/repository_maker.cc
index 2d0e672..498cc6d 100644
--- a/paludis/repository_maker.cc
+++ b/paludis/repository_maker.cc
@@ -43,8 +43,8 @@
using namespace paludis;
template class VirtualConstructor<std::string,
- std::tr1::shared_ptr<Repository> (*) (Environment * const,
- std::tr1::shared_ptr<const Map<std::string, 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>;
diff --git a/paludis/repository_maker.hh b/paludis/repository_maker.hh
index 08c893c..91aaf1d 100644
--- a/paludis/repository_maker.hh
+++ b/paludis/repository_maker.hh
@@ -25,6 +25,7 @@
#include <paludis/util/virtual_constructor.hh>
#include <paludis/util/map-fwd.hh>
#include <paludis/repository.hh>
+#include <tr1/functional>
/** \file
* Declarations for the RepositoryMaker.
@@ -104,7 +105,7 @@ namespace paludis
class PALUDIS_VISIBLE RepositoryMaker :
public VirtualConstructor<std::string,
std::tr1::shared_ptr<Repository> (*) (Environment * const,
- std::tr1::shared_ptr<const Map<std::string, std::string> >),
+ const std::tr1::function<std::string (const std::string &)> &),
virtual_constructor_not_found::ThrowException<NoSuchRepositoryTypeError> >,
public InstantiationPolicy<RepositoryMaker, instantiation_method::SingletonTag>,
private PrivateImplementationPattern<RepositoryMaker>
diff --git a/src/clients/importare/importare.cc b/src/clients/importare/importare.cc
index 55a1a8b..ad6839d 100644
--- a/src/clients/importare/importare.cc
+++ b/src/clients/importare/importare.cc
@@ -63,6 +63,16 @@ namespace
cout << " git " << PALUDIS_GIT_HEAD;
cout << endl;
}
+
+ std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
+ const std::string & k)
+ {
+ Map<std::string, std::string>::ConstIterator mm(m->find(k));
+ if (m->end() == mm)
+ return "";
+ else
+ return mm->second;
+ }
}
int
@@ -191,7 +201,8 @@ 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(), keys));
+ std::tr1::shared_ptr<Repository> repo((*RepositoryMaker::get_instance()->find_maker("unpackaged"))(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));
if (1 != std::distance(ids->begin(), ids->end()))