aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-23 22:43:06 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-23 22:43:06 +0000
commit976241d2a2cff7ee70b3e81efa0540b7ab40312f (patch)
treebe5f70cbed4d09860a6b36176411a93d7db96f4f
parentb0b93868cbbc1a484c130c9e4a91ac250f2832bd (diff)
downloadpaludis-976241d2a2cff7ee70b3e81efa0540b7ab40312f.tar.gz
paludis-976241d2a2cff7ee70b3e81efa0540b7ab40312f.tar.xz
Fix blocker handling. Fixes: ticket:24
-rw-r--r--paludis/dep_list/Makefile.am14
-rw-r--r--paludis/dep_list/dep_list.cc125
-rw-r--r--paludis/dep_list/dep_list.hh4
-rw-r--r--paludis/dep_list/dep_list.sr1
-rw-r--r--paludis/dep_list/dep_list_TEST.cc236
-rw-r--r--paludis/dep_list/dep_list_TEST.hh166
-rw-r--r--paludis/dep_list/dep_list_TEST_blockers.cc333
-rw-r--r--paludis/dep_list/uninstall_list_TEST.cc4
-rw-r--r--paludis/package_database_TEST.cc18
-rw-r--r--paludis/repositories/fake/fake_installed_repository.cc65
-rw-r--r--paludis/repositories/fake/fake_installed_repository.hh12
-rw-r--r--paludis/repositories/fake/fake_repository.cc44
-rw-r--r--paludis/repositories/fake/fake_repository.hh20
-rw-r--r--paludis/repositories/fake/fake_repository_base.cc20
-rw-r--r--paludis/repositories/fake/fake_repository_base.hh6
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc10
-rw-r--r--paludis/repository_name_cache_TEST.cc16
17 files changed, 783 insertions, 311 deletions
diff --git a/paludis/dep_list/Makefile.am b/paludis/dep_list/Makefile.am
index 79dd065..3120326 100644
--- a/paludis/dep_list/Makefile.am
+++ b/paludis/dep_list/Makefile.am
@@ -47,12 +47,15 @@ endif
EXTRA_DIST = \
dep_list_TEST.cc \
+ dep_list_TEST.hh \
+ dep_list_TEST_blockers.cc \
uninstall_list_TEST.cc \
dep_list.sr dep_list-sr.hh dep_list-sr.cc \
uninstall_list.sr uninstall_list-sr.hh uninstall_list-sr.cc
TESTS = \
dep_list_TEST \
+ dep_list_TEST_blockers \
uninstall_list_TEST
TESTS_ENVIRONMENT = env \
@@ -75,6 +78,17 @@ dep_list_TEST_LDADD = \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/util/libpaludisutil.la
+dep_list_TEST_blockers_SOURCES = dep_list_TEST_blockers.cc
+dep_list_TEST_blockers_LDADD = \
+ $(top_builddir)/paludis/environment/test/libpaludistestenvironment.la \
+ $(top_builddir)/paludis/repositories/fake/libpaludisfakerepository.la \
+ $(top_builddir)/paludis/repositories/virtuals/libpaludisvirtualsrepository.la \
+ $(top_builddir)/paludis/util/test_extras.o \
+ $(top_builddir)/test/libtest.a \
+ libpaludisdeplist.la \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la
+
uninstall_list_TEST_SOURCES = uninstall_list_TEST.cc
uninstall_list_TEST_LDADD = \
$(top_builddir)/paludis/environment/test/libpaludistestenvironment.la \
diff --git a/paludis/dep_list/dep_list.cc b/paludis/dep_list/dep_list.cc
index e1046ec..91e28b6 100644
--- a/paludis/dep_list/dep_list.cc
+++ b/paludis/dep_list/dep_list.cc
@@ -288,10 +288,12 @@ struct DepList::QueryVisitor :
{
bool result;
const DepList * const d;
+ bool ignore_current_pde;
- QueryVisitor(const DepList * const dd) :
+ QueryVisitor(const DepList * const dd, const bool i) :
result(true),
- d(dd)
+ d(dd),
+ ignore_current_pde(i)
{
}
@@ -312,21 +314,74 @@ DepList::QueryVisitor::visit(const PlainTextDepAtom * const)
void
DepList::QueryVisitor::visit(const PackageDepAtom * const a)
{
- /* a pda matches either if we're already installed, or if we will be installed
- * by the time the current point in the dep list is reached. */
+ /* a pda matches if we'll be installed by the time we reach the current point. This
+ * means that merely being installed is not enough, if we'll have our version changed
+ * by something in the merge list. */
- if (! d->_imp->env->package_database()->query(*a, is_installed_only, qo_whatever)->empty())
- result = true;
- else
+ result = false;
+
+ PackageDatabaseEntryCollection::ConstPointer matches(d->_imp->env->package_database()->query(
+ *a, is_installed_only, qo_whatever));
+
+ for (PackageDatabaseEntryCollection::Iterator m(matches->begin()), m_end(matches->end()) ;
+ m != m_end ; ++m)
{
+ /* check that we haven't been replaced by something in the same slot */
+ VersionMetadata::ConstPointer vm(d->_imp->env->package_database()->fetch_repository(m->repository)->
+ version_metadata(m->name, m->version));
+ SlotName slot(vm->slot);
+ const VirtualMetadata * const vif(vm->get_virtual_interface());
+
std::pair<MergeListIndex::const_iterator, MergeListIndex::const_iterator> p(
d->_imp->merge_list_index.equal_range(a->package()));
- if (p.second != std::find_if(p.first, p.second,
- MatchDepListEntryAgainstPackageDepAtom(d->_imp->env, a)))
+ bool replaced(false);
+ PackageDepAtom atom(a->package());
+ while (p.second != ((p.first = std::find_if(p.first, p.second,
+ MatchDepListEntryAgainstPackageDepAtom(d->_imp->env, &atom)))))
+ {
+ if (p.first->second->metadata->slot != slot)
+ p.first = next(p.first);
+ else if (ignore_current_pde &&
+ p.first->second == d->_imp->current_merge_list_entry)
+ p.first = next(p.first);
+ else if (ignore_current_pde &&
+ d->_imp->current_merge_list_entry != d->_imp->merge_list.end() &&
+ p.first->second->associated_entry == &*d->_imp->current_merge_list_entry &&
+ (a->version_requirements_ptr() || a->slot_ptr() ||
+ (vif && vif->virtual_for.name != p.first->second->associated_entry->package.name)))
+ p.first = next(p.first);
+ else
+ {
+ replaced = true;
+ break;
+ }
+ }
+
+ if (! replaced)
+ {
result = true;
+ return;
+ }
+ }
+
+ /* check the merge list for any new packages that match */
+ std::pair<MergeListIndex::const_iterator, MergeListIndex::const_iterator> p(
+ d->_imp->merge_list_index.equal_range(a->package()));
+
+ while (p.second != ((p.first = std::find_if(p.first, p.second,
+ MatchDepListEntryAgainstPackageDepAtom(d->_imp->env, a)))))
+ {
+ if (ignore_current_pde && p.first->second == d->_imp->current_merge_list_entry)
+ p.first = next(p.first);
+ else if (ignore_current_pde && d->_imp->current_merge_list_entry != d->_imp->merge_list.end()
+ && p.first->second->associated_entry == &*d->_imp->current_merge_list_entry)
+ p.first = next(p.first);
else
- result = false;
+ {
+ result = true;
+ return;
+ }
}
}
@@ -767,44 +822,17 @@ DepList::AddVisitor::visit(const AnyDepAtom * const a)
void
DepList::AddVisitor::visit(const BlockDepAtom * const a)
{
- if (! d->already_installed(a->blocked_atom()))
- return;
-
- Context context("When checking BlockDepAtom '!" + stringify(*a->blocked_atom()) + "':");
-
/* special case: the provider of virtual/blah can DEPEND upon !virtual/blah. */
/* special case: foo/bar can DEPEND upon !foo/bar. */
- if (d->_imp->current_pde())
- {
- if (d->_imp->current_pde()->name == a->blocked_atom()->package())
- {
- Log::get_instance()->message(ll_debug, lc_context, "Ignoring self block '"
- + stringify(*a->blocked_atom()) + "' for package '"
- + stringify(*d->_imp->current_pde()) + "'");
+ if (d->_imp->current_merge_list_entry != d->_imp->merge_list.end())
+ if (d->_imp->current_merge_list_entry->kind == dlk_already_installed)
return;
- }
- VersionMetadata::ConstPointer metadata(d->_imp->env->package_database()->fetch_repository(
- d->_imp->current_pde()->repository)->version_metadata(d->_imp->current_pde()->name,
- d->_imp->current_pde()->version));
- if (metadata->get_ebuild_interface())
- {
- bool skip(false);
- DepAtomFlattener f(d->_imp->env, d->_imp->current_pde(), metadata->get_ebuild_interface()->provide());
- for (DepAtomFlattener::Iterator i(f.begin()), i_end(f.end()) ; i != i_end && ! skip ; ++i)
- if ((*i)->text() == stringify(a->blocked_atom()->package()))
- skip = true;
+ if (! d->already_installed(a->blocked_atom(), true))
+ return;
- if (skip)
- {
- Log::get_instance()->message(ll_debug, lc_context,
- "Ignoring self block (via PROVIDE) '" + stringify(*a->blocked_atom())
- + "' for package '" + stringify(*d->_imp->current_pde()) + "'");
- return;
- }
- }
- }
+ Context context("When checking BlockDepAtom '!" + stringify(*a->blocked_atom()) + "':");
switch (d->_imp->opts->blocks)
{
@@ -968,6 +996,7 @@ DepList::add_package(const PackageDatabaseEntry & p, DepTag::ConstPointer tag)
.state(dle_no_deps)
.tags(DepListEntryTags::Pointer(new DepListEntryTags::Concrete))
.destinations(RepositoryNameCollection::Pointer(new RepositoryNameCollection::Concrete))
+ .associated_entry(0)
.kind(metadata->get_virtual_interface() ? dlk_virtual : dlk_package))),
our_merge_entry_post_position(our_merge_entry_position);
@@ -1027,6 +1056,7 @@ DepList::add_package(const PackageDatabaseEntry & p, DepTag::ConstPointer tag)
.state(dle_has_all_deps)
.tags(DepListEntryTags::Pointer(new DepListEntryTags::Concrete))
.destinations(RepositoryNameCollection::Pointer(new RepositoryNameCollection::Concrete))
+ .associated_entry(&*_imp->current_merge_list_entry)
.kind(dlk_provided)));
_imp->merge_list_index.insert(std::make_pair((*i)->text(), our_merge_entry_post_position));
}
@@ -1091,6 +1121,7 @@ DepList::add_error_package(const PackageDatabaseEntry & p, const DepListEntryKin
.state(dle_has_all_deps)
.tags(DepListEntryTags::Pointer(new DepListEntryTags::Concrete))
.destinations(RepositoryNameCollection::Pointer(new RepositoryNameCollection::Concrete))
+ .associated_entry(&*_imp->current_merge_list_entry)
.kind(kind)));
if (_imp->current_pde())
@@ -1125,6 +1156,7 @@ DepList::add_suggested_package(const PackageDatabaseEntry & p)
.state(dle_has_all_deps)
.tags(DepListEntryTags::Pointer(new DepListEntryTags::Concrete))
.destinations(RepositoryNameCollection::Pointer(new RepositoryNameCollection::Concrete))
+ .associated_entry(&*_imp->current_merge_list_entry)
.kind(dlk_suggested)));
if (_imp->current_pde())
@@ -1204,6 +1236,7 @@ DepList::add_already_installed_package(const PackageDatabaseEntry & p, DepTag::C
.tags(DepListEntryTags::Pointer(new DepListEntryTags::Concrete))
.state(dle_has_pre_deps)
.destinations(RepositoryNameCollection::Pointer(new RepositoryNameCollection::Concrete))
+ .associated_entry(0)
.kind(dlk_already_installed)));
_imp->merge_list_index.insert(std::make_pair(p.name, our_merge_entry));
@@ -1358,15 +1391,15 @@ DepList::prefer_installed_over_uninstalled(const PackageDatabaseEntry & installe
}
bool
-DepList::already_installed(DepAtom::ConstPointer atom) const
+DepList::already_installed(DepAtom::ConstPointer atom, const bool ignore_current_pde) const
{
- return already_installed(atom.raw_pointer());
+ return already_installed(atom.raw_pointer(), ignore_current_pde);
}
bool
-DepList::already_installed(const DepAtom * const atom) const
+DepList::already_installed(const DepAtom * const atom, const bool ignore_current_pde) const
{
- QueryVisitor visitor(this);
+ QueryVisitor visitor(this, ignore_current_pde);
atom->accept(&visitor);
return visitor.result;
}
diff --git a/paludis/dep_list/dep_list.hh b/paludis/dep_list/dep_list.hh
index 79f0e3a..7a29c86 100644
--- a/paludis/dep_list/dep_list.hh
+++ b/paludis/dep_list/dep_list.hh
@@ -101,12 +101,12 @@ namespace paludis
/**
* Is an atom structure already installed?
*/
- bool already_installed(DepAtom::ConstPointer) const;
+ bool already_installed(DepAtom::ConstPointer, const bool ignore_current_pde = false) const;
/**
* Is an atom structure already installed (overloaded for raw pointer)?
*/
- bool already_installed(const DepAtom * const) const;
+ bool already_installed(const DepAtom * const, const bool ignore_current_pde = false) const;
/**
* Whether we have any errors.
diff --git a/paludis/dep_list/dep_list.sr b/paludis/dep_list/dep_list.sr
index 804b018..d547717 100644
--- a/paludis/dep_list/dep_list.sr
+++ b/paludis/dep_list/dep_list.sr
@@ -50,6 +50,7 @@ make_class_DepListEntry()
key kind DepListEntryKind
key package PackageDatabaseEntry
+ key associated_entry "const DepListEntry *"
key metadata VersionMetadata::ConstPointer
key tags DepListEntryTags::Pointer
key destinations RepositoryNameCollection::Pointer
diff --git a/paludis/dep_list/dep_list_TEST.cc b/paludis/dep_list/dep_list_TEST.cc
index 454aa50..713af8d 100644
--- a/paludis/dep_list/dep_list_TEST.cc
+++ b/paludis/dep_list/dep_list_TEST.cc
@@ -17,124 +17,14 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/dep_list/dep_list.hh>
-#include <paludis/dep_list/exceptions.hh>
-#include <paludis/portage_dep_parser.hh>
-#include <paludis/repositories/fake/fake_repository.hh>
-#include <paludis/repositories/fake/fake_installed_repository.hh>
-#include <paludis/repositories/virtuals/virtuals_repository.hh>
-#include <paludis/repositories/virtuals/installed_virtuals_repository.hh>
-#include <paludis/environment/test/test_environment.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-#include <string>
-#include <list>
-#include <ostream>
+#include "dep_list_TEST.hh"
using namespace paludis;
using namespace test;
-namespace paludis
-{
- std::ostream &
- operator<< (std::ostream & s, const DepListEntry & e)
- {
- s << e.package.name << "-" << e.package.version << ":" <<
- e.metadata->slot << "::" << e.package.repository;
- return s;
- }
-}
-
namespace test_cases
{
/**
- * Convenience base class used by many of the DepList tests.
- *
- */
- class DepListTestCaseBase :
- public TestCase
- {
- protected:
- TestEnvironment env;
- FakeRepository::Pointer repo;
- FakeInstalledRepository::Pointer installed_repo;
- VirtualsRepository::Pointer virtuals_repo;
- InstalledVirtualsRepository::Pointer installed_virtuals_repo;
- std::list<std::string> expected;
- std::string merge_target;
- bool done_populate;
-
- /**
- * Constructor.
- */
- DepListTestCaseBase(const int i) :
- TestCase("dep list " + stringify(i)),
- env(),
- repo(new FakeRepository(RepositoryName("repo"))),
- installed_repo(new FakeInstalledRepository(RepositoryName("installed"))),
- virtuals_repo(new VirtualsRepository(&env)),
- installed_virtuals_repo(new InstalledVirtualsRepository(&env)),
- done_populate(false)
- {
- env.package_database()->add_repository(repo);
- env.package_database()->add_repository(installed_repo);
- env.package_database()->add_repository(virtuals_repo);
- env.package_database()->add_repository(installed_virtuals_repo);
- }
-
- /**
- * Populate our repo member.
- */
- virtual void populate_repo() = 0;
-
- /**
- * Populate our expected member.
- */
- virtual void populate_expected() = 0;
-
- /**
- * Check expected is what we got.
- */
- virtual void check_lists()
- {
- TEST_CHECK(true);
- DepList d(&env, DepListOptions());
- d.add(PortageDepParser::parse(merge_target));
- TEST_CHECK(true);
-
- unsigned n(0);
- std::list<std::string>::const_iterator exp(expected.begin());
- DepList::Iterator got(d.begin());
- while (true)
- {
- TestMessageSuffix s(stringify(n++), true);
-
- TEST_CHECK((exp == expected.end()) == (got == d.end()));
- if (got == d.end())
- break;
- TEST_CHECK_STRINGIFY_EQUAL(*got, *exp);
- ++exp;
- ++got;
- }
-
- d.clear();
- TEST_CHECK(d.begin() == d.end());
- }
-
- public:
- void run()
- {
- if (! done_populate)
- {
- populate_repo();
- populate_expected();
- done_populate = true;
- }
- check_lists();
- }
- };
-
- /**
* Convenience sub base class used by the numbered DepList tests.
*
*/
@@ -145,7 +35,7 @@ namespace test_cases
* Constructor.
*/
DepListTestCase() :
- DepListTestCaseBase(i_)
+ DepListTestCaseBase("dep list " + stringify(i_))
{
}
};
@@ -942,100 +832,6 @@ namespace test_cases
* \test Test DepList resolution behaviour.
*
*/
- struct DepListTestCase38 : DepListTestCase<38>
- {
- void populate_repo()
- {
- repo->add_version("cat", "one", "1")->deps.build_depend_string = "!cat/two";
- repo->add_version("cat", "two", "1");
- }
-
- void populate_expected()
- {
- merge_target = "cat/one";
- expected.push_back("cat/one-1:0::repo");
- }
- } test_dep_list_38;
-
- /**
- * \test Test DepList resolution behaviour.
- *
- */
- struct DepListTestCase39 : DepListTestCase<39>
- {
- void populate_repo()
- {
- repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/two !cat/two";
- repo->add_version("cat", "two", "1");
- }
-
- void populate_expected()
- {
- merge_target = "cat/one";
- }
-
- void check_lists()
- {
- TEST_CHECK(true);
- DepList d(&env, DepListOptions());
- TEST_CHECK_THROWS(d.add(PortageDepParser::parse(merge_target)), DepListError);
- TEST_CHECK(d.begin() == d.end());
- }
- } test_dep_list_39;
-
- /**
- * \test Test DepList resolution behaviour.
- *
- */
- struct DepListTestCase40 : DepListTestCase<40>
- {
- void populate_repo()
- {
- repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/two cat/three";
- repo->add_version("cat", "two", "1");
- repo->add_version("cat", "three", "1")->deps.build_depend_string = "!cat/two";
- }
-
- void populate_expected()
- {
- merge_target="cat/one";
- }
-
- void check_lists()
- {
- TEST_CHECK(true);
- DepList d(&env, DepListOptions());
- TEST_CHECK_THROWS(d.add(PortageDepParser::parse(merge_target)), DepListError);
- TEST_CHECK(d.begin() == d.end());
- }
- } test_dep_list_40;
-
- /**
- * \test Test DepList resolution behaviour.
- *
- */
- struct DepListTestCase41 : DepListTestCase<41>
- {
- void populate_repo()
- {
- repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/three cat/two";
- repo->add_version("cat", "two", "1");
- repo->add_version("cat", "three", "1")->deps.build_depend_string = "!cat/two";
- }
-
- void populate_expected()
- {
- merge_target="cat/one";
- expected.push_back("cat/three-1:0::repo");
- expected.push_back("cat/two-1:0::repo");
- expected.push_back("cat/one-1:0::repo");
- }
- } test_dep_list_41;
-
- /**
- * \test Test DepList resolution behaviour.
- *
- */
struct DepListTestCase42 : DepListTestCase<42>
{
void populate_repo()
@@ -1458,7 +1254,7 @@ namespace test_cases
void run()
{
TestEnvironment env;
- FakeRepository::Pointer repo(new FakeRepository(RepositoryName("repo")));
+ FakeRepository::Pointer repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(repo);
repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/two cat/three";
@@ -1492,7 +1288,7 @@ namespace test_cases
void run()
{
TestEnvironment env;
- FakeRepository::Pointer repo(new FakeRepository(RepositoryName("repo")));
+ FakeRepository::Pointer repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(repo);
repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/two cat/three";
@@ -1527,12 +1323,12 @@ namespace test_cases
{
TestEnvironment env;
- FakeRepository::Pointer repo(new FakeRepository(RepositoryName("repo")));
+ FakeRepository::Pointer repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(repo);
repo->add_version("cat", "one", "1");
FakeInstalledRepository::Pointer installed_repo(
- new FakeInstalledRepository(RepositoryName("installed_repo")));
+ new FakeInstalledRepository(&env, RepositoryName("installed_repo")));
env.package_database()->add_repository(installed_repo);
installed_repo->add_version("cat", "one", "2");
@@ -1553,12 +1349,12 @@ namespace test_cases
{
TestEnvironment env;
- FakeRepository::Pointer repo(new FakeRepository(RepositoryName("repo")));
+ FakeRepository::Pointer repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(repo);
repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/two";
FakeInstalledRepository::Pointer installed_repo(
- new FakeInstalledRepository(RepositoryName("installed_repo")));
+ new FakeInstalledRepository(&env, RepositoryName("installed_repo")));
env.package_database()->add_repository(installed_repo);
installed_repo->add_version("cat", "two", "2");
@@ -1579,12 +1375,12 @@ namespace test_cases
{
TestEnvironment env;
- FakeRepository::Pointer repo(new FakeRepository(RepositoryName("repo")));
+ FakeRepository::Pointer repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(repo);
repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/two";
FakeInstalledRepository::Pointer installed_repo(
- new FakeInstalledRepository(RepositoryName("installed_repo")));
+ new FakeInstalledRepository(&env, RepositoryName("installed_repo")));
env.package_database()->add_repository(installed_repo);
installed_repo->add_version("cat", "two", "2");
@@ -1607,12 +1403,12 @@ namespace test_cases
{
TestEnvironment env;
- FakeRepository::Pointer repo(new FakeRepository(RepositoryName("repo")));
+ FakeRepository::Pointer repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(repo);
repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/two";
FakeInstalledRepository::Pointer installed_repo(
- new FakeInstalledRepository(RepositoryName("installed_repo")));
+ new FakeInstalledRepository(&env, RepositoryName("installed_repo")));
env.package_database()->add_repository(installed_repo);
installed_repo->add_version("cat", "two", "2");
installed_repo->add_version("cat", "three", "3");
@@ -1648,13 +1444,13 @@ namespace test_cases
{
TestEnvironment env;
- FakeRepository::Pointer repo(new FakeRepository(RepositoryName("repo")));
+ FakeRepository::Pointer repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(repo);
repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/two";
repo->add_version("cat", "two", "2");
FakeInstalledRepository::Pointer installed_repo(
- new FakeInstalledRepository(RepositoryName("installed_repo")));
+ new FakeInstalledRepository(&env, RepositoryName("installed_repo")));
env.package_database()->add_repository(installed_repo);
installed_repo->add_version("cat", "two", "0");
@@ -1681,7 +1477,7 @@ namespace test_cases
{
TestEnvironment env;
- FakeRepository::Pointer repo(new FakeRepository(RepositoryName("repo")));
+ FakeRepository::Pointer repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(repo);
repo->add_version("cat", "zero", "1")->deps.build_depend_string =
"( cat/one cat/two cat/three-live cat/four-cvs cat/five-svn )";
@@ -1692,7 +1488,7 @@ namespace test_cases
repo->add_version("cat", "five-svn", "0");
FakeInstalledRepository::Pointer installed_repo(
- new FakeInstalledRepository(RepositoryName("installed_repo")));
+ new FakeInstalledRepository(&env, RepositoryName("installed_repo")));
env.package_database()->add_repository(installed_repo);
installed_repo->add_version("cat", "one", "scm");
installed_repo->add_version("cat", "two", "2");
diff --git a/paludis/dep_list/dep_list_TEST.hh b/paludis/dep_list/dep_list_TEST.hh
new file mode 100644
index 0000000..07ef067
--- /dev/null
+++ b/paludis/dep_list/dep_list_TEST.hh
@@ -0,0 +1,166 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_DEP_LIST_DEP_LIST_TEST_HH
+#define PALUDIS_GUARD_PALUDIS_DEP_LIST_DEP_LIST_TEST_HH 1
+
+#include <paludis/dep_list/dep_list.hh>
+#include <paludis/dep_list/exceptions.hh>
+#include <paludis/portage_dep_parser.hh>
+#include <paludis/repositories/fake/fake_repository.hh>
+#include <paludis/repositories/fake/fake_installed_repository.hh>
+#include <paludis/repositories/virtuals/virtuals_repository.hh>
+#include <paludis/repositories/virtuals/installed_virtuals_repository.hh>
+#include <paludis/environment/test/test_environment.hh>
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+#include <string>
+#include <list>
+#include <ostream>
+
+using namespace paludis;
+using namespace test;
+
+namespace paludis
+{
+ class DepListEntry;
+ std::ostream &
+ operator<< (std::ostream & s, const DepListEntry & e)
+ {
+ s << e.package.name << "-" << e.package.version << ":" <<
+ e.metadata->slot << "::" << e.package.repository;
+
+ switch (e.kind)
+ {
+ case dlk_virtual:
+ case dlk_package:
+ case dlk_provided:
+ case dlk_already_installed:
+ case dlk_subpackage:
+ case dlk_suggested:
+ break;
+
+ case dlk_block:
+ s << "(!)";
+ break;
+
+ case dlk_masked:
+ s << "(M)";
+ break;
+
+ case last_dlk:
+ ;
+ }
+
+ return s;
+ }
+}
+
+namespace test_cases
+{
+ /**
+ * Convenience base class used by many of the DepList tests.
+ *
+ */
+ class DepListTestCaseBase :
+ public TestCase
+ {
+ protected:
+ TestEnvironment env;
+ FakeRepository::Pointer repo;
+ FakeInstalledRepository::Pointer installed_repo;
+ VirtualsRepository::Pointer virtuals_repo;
+ InstalledVirtualsRepository::Pointer installed_virtuals_repo;
+ std::list<std::string> expected;
+ std::string merge_target;
+ bool done_populate;
+
+ /**
+ * Constructor.
+ */
+ DepListTestCaseBase(const std::string & s) :
+ TestCase(s),
+ env(),
+ repo(new FakeRepository(&env, RepositoryName("repo"))),
+ installed_repo(new FakeInstalledRepository(&env, RepositoryName("installed"))),
+ virtuals_repo(new VirtualsRepository(&env)),
+ installed_virtuals_repo(new InstalledVirtualsRepository(&env)),
+ done_populate(false)
+ {
+ env.package_database()->add_repository(repo);
+ env.package_database()->add_repository(installed_repo);
+ env.package_database()->add_repository(virtuals_repo);
+ env.package_database()->add_repository(installed_virtuals_repo);
+ }
+
+ /**
+ * Populate our repo member.
+ */
+ virtual void populate_repo() = 0;
+
+ /**
+ * Populate our expected member.
+ */
+ virtual void populate_expected() = 0;
+
+ /**
+ * Check expected is what we got.
+ */
+ virtual void check_lists()
+ {
+ DepList d(&env, DepListOptions());
+ d.add(PortageDepParser::parse(merge_target));
+ TEST_CHECK(true);
+
+ TestMessageSuffix s("d={ " + join(d.begin(), d.end(), ", ") + " }", false);
+
+ unsigned n(0);
+ std::list<std::string>::const_iterator exp(expected.begin());
+ DepList::Iterator got(d.begin());
+ while (true)
+ {
+ TestMessageSuffix sx(stringify(n++), true);
+
+ TEST_CHECK((exp == expected.end()) == (got == d.end()));
+ if (got == d.end())
+ break;
+ TEST_CHECK_STRINGIFY_EQUAL(*got, *exp);
+ ++exp;
+ ++got;
+ }
+
+ d.clear();
+ TEST_CHECK(d.begin() == d.end());
+ }
+
+ public:
+ void run()
+ {
+ if (! done_populate)
+ {
+ populate_repo();
+ populate_expected();
+ done_populate = true;
+ }
+ check_lists();
+ }
+ };
+}
+
+#endif
diff --git a/paludis/dep_list/dep_list_TEST_blockers.cc b/paludis/dep_list/dep_list_TEST_blockers.cc
new file mode 100644
index 0000000..a315452
--- /dev/null
+++ b/paludis/dep_list/dep_list_TEST_blockers.cc
@@ -0,0 +1,333 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "dep_list_TEST.hh"
+
+using namespace paludis;
+using namespace test;
+
+namespace test_cases
+{
+ struct DepListTestCaseBasicBlock : DepListTestCaseBase
+ {
+ DepListTestCaseBasicBlock() : DepListTestCaseBase("block") { }
+
+ void populate_repo()
+ {
+ repo->add_version("cat", "one", "1")->deps.build_depend_string = "!cat/two";
+ installed_repo->add_version("cat", "two", "1");
+ }
+
+ void populate_expected()
+ {
+ merge_target = "cat/one";
+ }
+
+ void check_lists()
+ {
+ TEST_CHECK(true);
+ DepList d(&env, DepListOptions());
+ d.options()->blocks = dl_blocks_error;
+ TEST_CHECK_THROWS(d.add(PortageDepParser::parse(merge_target)), DepListError);
+ TEST_CHECK(d.begin() == d.end());
+
+ d.options()->blocks = dl_blocks_accumulate;
+ d.add(PortageDepParser::parse(merge_target));
+ TEST_CHECK_EQUAL(std::distance(d.begin(), d.end()), 2);
+ TEST_CHECK_EQUAL(d.begin()->kind, dlk_block);
+ TEST_CHECK_STRINGIFY_EQUAL(d.begin()->package, "cat/two-1::installed");
+ TEST_CHECK_EQUAL(next(d.begin())->kind, dlk_package);
+ TEST_CHECK_STRINGIFY_EQUAL(next(d.begin())->package, "cat/one-1::repo");
+ }
+ } test_dep_list_basic_block;
+
+ struct DepListTestCaseListBlock : DepListTestCaseBase
+ {
+ DepListTestCaseListBlock() : DepListTestCaseBase("block on list ignore") { }
+
+ void populate_repo()
+ {
+ repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/two";
+ repo->add_version("cat", "two", "1")->deps.build_depend_string = "!cat/two";
+ }
+
+ void populate_expected()
+ {
+ merge_target = "cat/one";
+ expected.push_back("cat/two-1:0::repo");
+ expected.push_back("cat/one-1:0::repo");
+ }
+ } test_dep_list_list_block;
+
+ struct DepListTestCaseSelfBlock : DepListTestCaseBase
+ {
+ DepListTestCaseSelfBlock() : DepListTestCaseBase("self block via provide on list") { }
+
+ void populate_repo()
+ {
+ repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/two";
+ VersionMetadata::Pointer two_m(repo->add_version("cat", "two", "1"));
+ two_m->deps.build_depend_string = "!virtual/two";
+ two_m->get_ebuild_interface()->provide_string = "virtual/two";
+ }
+
+ void populate_expected()
+ {
+ merge_target = "cat/one";
+ expected.push_back("cat/two-1:0::repo");
+ expected.push_back("virtual/two-1:0::virtuals");
+ expected.push_back("cat/one-1:0::repo");
+ }
+ } test_dep_list_self_block_list;
+
+ struct DepListTestCaseProvidedBlock : DepListTestCaseBase
+ {
+ DepListTestCaseProvidedBlock() : DepListTestCaseBase("provided block") { }
+
+ void populate_repo()
+ {
+ repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/two";
+ VersionMetadata::Pointer two_m(repo->add_version("cat", "two", "1"));
+ two_m->deps.build_depend_string = "!virtual/two";
+ two_m->get_ebuild_interface()->provide_string = "virtual/two";
+ installed_repo->add_version("other", "two", "1")->get_ebuild_interface()->provide_string = "virtual/two";
+ }
+
+ void populate_expected()
+ {
+ merge_target = "cat/one";
+ }
+
+ void check_lists()
+ {
+ TEST_CHECK(true);
+ DepList d(&env, DepListOptions());
+ d.options()->blocks = dl_blocks_error;
+ TEST_CHECK_THROWS(d.add(PortageDepParser::parse(merge_target)), DepListError);
+ TEST_CHECK(d.begin() == d.end());
+
+ d.options()->blocks = dl_blocks_accumulate;
+ d.add(PortageDepParser::parse(merge_target));
+ TEST_CHECK_EQUAL(std::distance(d.begin(), d.end()), 4);
+ TEST_CHECK_EQUAL(d.begin()->kind, dlk_block);
+ TEST_CHECK_STRINGIFY_EQUAL(d.begin()->package, "virtual/two-1::installed_virtuals");
+ TEST_CHECK_EQUAL(next(d.begin())->kind, dlk_package);
+ TEST_CHECK_STRINGIFY_EQUAL(next(d.begin())->package, "cat/two-1::repo");
+ TEST_CHECK_EQUAL(next(next(d.begin()))->kind, dlk_provided);
+ TEST_CHECK_STRINGIFY_EQUAL(next(next(d.begin()))->package, "virtual/two-1::virtuals");
+ TEST_CHECK_EQUAL(next(next(next(d.begin())))->kind, dlk_package);
+ TEST_CHECK_STRINGIFY_EQUAL(next(next(next(d.begin())))->package, "cat/one-1::repo");
+ }
+ } test_dep_list_provided_block;
+
+ struct DepListTestCaseBlockOnList : DepListTestCaseBase
+ {
+ DepListTestCaseBlockOnList() : DepListTestCaseBase("block on list") { }
+
+ void populate_repo()
+ {
+ repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/two cat/three";
+ repo->add_version("cat", "two", "1");
+ repo->add_version("cat", "three", "1")->deps.build_depend_string = "!cat/two";
+ }
+
+ void populate_expected()
+ {
+ merge_target = "cat/one";
+ }
+
+ void check_lists()
+ {
+ TEST_CHECK(true);
+ DepList d(&env, DepListOptions());
+ d.options()->blocks = dl_blocks_error;
+ TEST_CHECK_THROWS(d.add(PortageDepParser::parse(merge_target)), DepListError);
+ TEST_CHECK(d.begin() == d.end());
+ }
+ } test_dep_list_block_on_list;
+
+ struct DepListTestCaseNoBlockOnReplaced : DepListTestCaseBase
+ {
+ DepListTestCaseNoBlockOnReplaced() : DepListTestCaseBase("no block on replaced") { }
+
+ void populate_repo()
+ {
+ repo->add_version("cat", "one", "1")->deps.build_depend_string = ">=cat/two-2 cat/three";
+ repo->add_version("cat", "two", "2");
+ repo->add_version("cat", "three", "1")->deps.build_depend_string = "!<cat/two-2";
+ installed_repo->add_version("cat", "two", "1");
+ }
+
+ void populate_expected()
+ {
+ merge_target = "cat/one";
+ expected.push_back("cat/two-2:0::repo");
+ expected.push_back("cat/three-1:0::repo");
+ expected.push_back("cat/one-1:0::repo");
+ }
+ } test_dep_list_no_block_on_replaced;
+
+ struct DepListTestCaseNoBlockOnNoUpgrade : DepListTestCaseBase
+ {
+ DepListTestCaseNoBlockOnNoUpgrade() : DepListTestCaseBase("no block on no upgrade") { }
+
+ void populate_repo()
+ {
+ repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/two";
+ repo->add_version("cat", "two", "1")->deps.build_depend_string = "!cat/two";
+ installed_repo->add_version("cat", "two", "1");
+ }
+
+ void populate_expected()
+ {
+ merge_target = "cat/one";
+ expected.push_back("cat/two-1:0::installed");
+ expected.push_back("cat/one-1:0::repo");
+ }
+ } test_dep_list_no_block_on_no_upgrade;
+
+ struct DepListTestCaseNoBlockOnNoUpgradeViaProvided : DepListTestCaseBase
+ {
+ DepListTestCaseNoBlockOnNoUpgradeViaProvided() : DepListTestCaseBase("no block on no upgrade via provided") { }
+
+ void populate_repo()
+ {
+ VersionMetadata::Pointer one_m(repo->add_version("cat", "one", "1"));
+ one_m->get_ebuild_interface()->provide_string = "virtual/one";
+ one_m->deps.build_depend_string = "!virtual/one";
+ one_m->deps.run_depend_string = "!virtual/one";
+ VersionMetadata::Pointer i_one_m(installed_repo->add_version("cat", "one", "1"));
+ i_one_m->get_ebuild_interface()->provide_string = "virtual/one";
+ i_one_m->deps.run_depend_string = "!virtual/one";
+ }
+
+ void populate_expected()
+ {
+ merge_target = "virtual/one";
+ expected.push_back("cat/one-1:0::installed");
+ expected.push_back("virtual/one-1:0::virtuals");
+ }
+ } test_dep_list_no_block_on_no_upgrade_via_provided;
+
+ struct DepListTestCaseNoBlockOnReplacedProvide : DepListTestCaseBase
+ {
+ DepListTestCaseNoBlockOnReplacedProvide() : DepListTestCaseBase("no block on replaced provide") { }
+
+ void populate_repo()
+ {
+ repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/two";
+ VersionMetadata::Pointer two_m(repo->add_version("cat", "two", "2"));
+ two_m->get_ebuild_interface()->provide_string = "virtual/two";
+ two_m->deps.build_depend_string = "!virtual/two";
+ installed_repo->add_version("cat", "two", "1")->get_ebuild_interface()->provide_string = "virtual/two";
+ }
+
+ void populate_expected()
+ {
+ merge_target = "cat/one";
+ expected.push_back("cat/two-2:0::repo");
+ expected.push_back("virtual/two-2:0::virtuals");
+ expected.push_back("cat/one-1:0::repo");
+ }
+ } test_dep_list_no_block_on_replaced_provide;
+
+ struct DepListTestCaseRestrictedOlderSelf : DepListTestCaseBase
+ {
+ DepListTestCaseRestrictedOlderSelf() : DepListTestCaseBase("restricted older self") { }
+
+ void populate_repo()
+ {
+ repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/two";
+ repo->add_version("cat", "two", "2")->deps.build_depend_string = "!<cat/two-2";
+ installed_repo->add_version("cat", "two", "1");
+ }
+
+ void populate_expected()
+ {
+ merge_target = "cat/one";
+ }
+
+ void check_lists()
+ {
+ TEST_CHECK(true);
+ DepList d(&env, DepListOptions());
+ d.options()->blocks = dl_blocks_error;
+ TEST_CHECK_THROWS(d.add(PortageDepParser::parse(merge_target)), DepListError);
+ TEST_CHECK(d.begin() == d.end());
+ }
+ } test_dep_list_restricted_older_self;
+
+ struct DepListTestCaseRestrictedOlderSelfProvide : DepListTestCaseBase
+ {
+ DepListTestCaseRestrictedOlderSelfProvide() : DepListTestCaseBase("restricted older self provide") { }
+
+ void populate_repo()
+ {
+ repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/two";
+ VersionMetadata::Pointer two_m(repo->add_version("cat", "two", "2"));
+ two_m->deps.build_depend_string = "!<virtual/two-2";
+ two_m->get_ebuild_interface()->provide_string = "virtual/two";
+ installed_repo->add_version("cat", "two", "1")->get_ebuild_interface()->provide_string = "virtual/two";
+ }
+
+ void populate_expected()
+ {
+ merge_target = "cat/one";
+ }
+
+ void check_lists()
+ {
+ TEST_CHECK(true);
+ DepList d(&env, DepListOptions());
+ d.options()->blocks = dl_blocks_error;
+ TEST_CHECK_THROWS(d.add(PortageDepParser::parse(merge_target)), DepListError);
+ TEST_CHECK(d.begin() == d.end());
+ }
+ } test_dep_list_restricted_older_self_provide;
+
+ struct DepListTestCaseRestrictedOlderOtherProvide : DepListTestCaseBase
+ {
+ DepListTestCaseRestrictedOlderOtherProvide() : DepListTestCaseBase("restricted older other provide") { }
+
+ void populate_repo()
+ {
+ repo->add_version("cat", "one", "1")->deps.build_depend_string = "cat/two";
+ VersionMetadata::Pointer two_m(repo->add_version("cat", "two", "2"));
+ two_m->deps.build_depend_string = "!<virtual/two-2";
+ two_m->get_ebuild_interface()->provide_string = "virtual/two";
+ installed_repo->add_version("other", "two", "1")->get_ebuild_interface()->provide_string = "virtual/two";
+ }
+
+ void populate_expected()
+ {
+ merge_target = "cat/one";
+ }
+
+ void check_lists()
+ {
+ TEST_CHECK(true);
+ DepList d(&env, DepListOptions());
+ d.options()->blocks = dl_blocks_error;
+ TEST_CHECK_THROWS(d.add(PortageDepParser::parse(merge_target)), DepListError);
+ TEST_CHECK(d.begin() == d.end());
+ }
+ } test_dep_list_restricted_older_other_provide;
+}
+
+
diff --git a/paludis/dep_list/uninstall_list_TEST.cc b/paludis/dep_list/uninstall_list_TEST.cc
index 9b1ad31..eaef0a1 100644
--- a/paludis/dep_list/uninstall_list_TEST.cc
+++ b/paludis/dep_list/uninstall_list_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -66,7 +66,7 @@ namespace test_cases
UninstallListTestCaseBase(const std::string & s) :
TestCase("uninstall list " + s),
env(),
- installed_repo(new FakeInstalledRepository(RepositoryName("installed"))),
+ installed_repo(new FakeInstalledRepository(&env, RepositoryName("installed"))),
virtuals_repo(new VirtualsRepository(&env)),
targets(new PackageDatabaseEntryCollection::Concrete),
done_populate(false)
diff --git a/paludis/package_database_TEST.cc b/paludis/package_database_TEST.cc
index cfe915b..8cdf93b 100644
--- a/paludis/package_database_TEST.cc
+++ b/paludis/package_database_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -46,8 +46,8 @@ namespace test_cases
TestEnvironment e;
PackageDatabase & p(*e.package_database());
- FakeRepository::Pointer r1(new FakeRepository(RepositoryName("repo1")));
- FakeRepository::Pointer r2(new FakeRepository(RepositoryName("repo2")));
+ FakeRepository::Pointer r1(new FakeRepository(&e, RepositoryName("repo1")));
+ FakeRepository::Pointer r2(new FakeRepository(&e, RepositoryName("repo2")));
TEST_CHECK_THROWS(p.fetch_repository(RepositoryName("repo1")), NoSuchRepositoryError);
TEST_CHECK_THROWS(p.fetch_repository(RepositoryName("repo2")), NoSuchRepositoryError);
@@ -98,7 +98,7 @@ namespace test_cases
TestEnvironment e;
PackageDatabase & p(*e.package_database());
- FakeRepository::Pointer r1(new FakeRepository(RepositoryName("repo1")));
+ FakeRepository::Pointer r1(new FakeRepository(&e, RepositoryName("repo1")));
r1->add_version("r1c1", "r1c1p1", "1");
r1->add_version("r1c1", "r1c1p2", "1");
r1->add_version("r1c1", "r1c1p2", "2");
@@ -107,7 +107,7 @@ namespace test_cases
p.add_repository(r1);
TEST_CHECK(true);
- FakeRepository::Pointer r2(new FakeRepository(RepositoryName("repo2")));
+ FakeRepository::Pointer r2(new FakeRepository(&e, RepositoryName("repo2")));
r2->add_version("rac1", "rac1pa", "1");
r2->add_version("rac1", "rac1pa", "3");
p.add_repository(r2);
@@ -156,7 +156,7 @@ namespace test_cases
TestEnvironment e;
PackageDatabase & p(*e.package_database());
- FakeRepository::Pointer r1(new FakeRepository(RepositoryName("repo1")));
+ FakeRepository::Pointer r1(new FakeRepository(&e, RepositoryName("repo1")));
r1->add_version("cat", "pkg", "1")->slot = SlotName("a");
r1->add_version("cat", "pkg", "2")->slot = SlotName("c");
r1->add_version("cat", "pkg", "3")->slot = SlotName("c");
@@ -164,7 +164,7 @@ namespace test_cases
p.add_repository(r1);
TEST_CHECK(true);
- FakeRepository::Pointer r2(new FakeRepository(RepositoryName("repo2")));
+ FakeRepository::Pointer r2(new FakeRepository(&e, RepositoryName("repo2")));
r2->add_version("cat", "pkg", "1")->slot = SlotName("a");
r2->add_version("cat", "pkg", "3")->slot = SlotName("b");
p.add_repository(r2);
@@ -195,7 +195,7 @@ namespace test_cases
TestEnvironment e;
PackageDatabase & p(*e.package_database());
- FakeRepository::Pointer r1(new FakeRepository(RepositoryName("repo1")));
+ FakeRepository::Pointer r1(new FakeRepository(&e, RepositoryName("repo1")));
r1->add_package(CategoryNamePart("cat-one") + PackageNamePart("pkg-one"));
r1->add_package(CategoryNamePart("cat-one") + PackageNamePart("pkg-two"));
r1->add_package(CategoryNamePart("cat-two") + PackageNamePart("pkg-two"));
@@ -203,7 +203,7 @@ namespace test_cases
p.add_repository(r1);
TEST_CHECK(true);
- FakeRepository::Pointer r2(new FakeRepository(RepositoryName("repo2")));
+ FakeRepository::Pointer r2(new FakeRepository(&e, RepositoryName("repo2")));
r1->add_package(CategoryNamePart("cat-three") + PackageNamePart("pkg-three"));
r1->add_package(CategoryNamePart("cat-three") + PackageNamePart("pkg-four"));
p.add_repository(r2);
diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc
index 29f43d5..e369afc 100644
--- a/paludis/repositories/fake/fake_installed_repository.cc
+++ b/paludis/repositories/fake/fake_installed_repository.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -18,11 +18,14 @@
*/
#include "fake_installed_repository.hh"
+#include <paludis/util/collection_concrete.hh>
+#include <paludis/portage_dep_parser.hh>
+#include <paludis/dep_atom_flattener.hh>
using namespace paludis;
-FakeInstalledRepository::FakeInstalledRepository(const RepositoryName & our_name) :
- FakeRepositoryBase(our_name, RepositoryCapabilities::create()
+FakeInstalledRepository::FakeInstalledRepository(const Environment * const e, const RepositoryName & our_name) :
+ FakeRepositoryBase(e, our_name, RepositoryCapabilities::create()
.installable_interface(0)
.installed_interface(this)
.mask_interface(this)
@@ -34,7 +37,7 @@ FakeInstalledRepository::FakeInstalledRepository(const RepositoryName & our_name
.world_interface(0)
.mirrors_interface(0)
.environment_variable_interface(0)
- .provides_interface(0)
+ .provides_interface(this)
.virtuals_interface(0)
.destination_interface(this),
"fake_installed")
@@ -55,4 +58,58 @@ FakeInstalledRepository::is_suitable_destination_for(const PackageDatabaseEntry
return true;
}
+FakeInstalledRepository::ProvidesCollection::ConstPointer
+FakeInstalledRepository::provided_packages() const
+{
+ ProvidesCollection::Pointer result(new ProvidesCollection::Concrete);
+
+ CategoryNamePartCollection::ConstPointer cats(category_names());
+ for (CategoryNamePartCollection::Iterator c(cats->begin()), c_end(cats->end()) ;
+ c != c_end ; ++c)
+ {
+ QualifiedPackageNameCollection::ConstPointer pkgs(package_names(*c));
+ for (QualifiedPackageNameCollection::Iterator p(pkgs->begin()), p_end(pkgs->end()) ;
+ p != p_end ; ++p)
+ {
+ VersionSpecCollection::ConstPointer vers(version_specs(*p));
+ for (VersionSpecCollection::Iterator v(vers->begin()), v_end(vers->end()) ;
+ v != v_end ; ++v)
+ {
+ VersionMetadata::ConstPointer m(version_metadata(*p, *v));
+ if (! m->get_ebuild_interface())
+ continue;
+
+ DepAtom::ConstPointer provide(PortageDepParser::parse(m->get_ebuild_interface()->provide_string,
+ PortageDepParserPolicy<PackageDepAtom, false>::get_instance()));
+ PackageDatabaseEntry dbe(*p, *v, name());
+ DepAtomFlattener f(environment(), &dbe, provide);
+
+ for (DepAtomFlattener::Iterator q(f.begin()), q_end(f.end()) ; q != q_end ; ++q)
+ result->insert(RepositoryProvidesEntry::create()
+ .virtual_name(QualifiedPackageName((*q)->text()))
+ .version(*v)
+ .provided_by_name(*p));
+ }
+ }
+ }
+
+ return result;
+}
+
+VersionMetadata::ConstPointer
+FakeInstalledRepository::provided_package_version_metadata(const RepositoryProvidesEntry & p) const
+{
+ VersionMetadata::ConstPointer m(version_metadata(p.provided_by_name, p.version));
+ VersionMetadata::Virtual::Pointer result(new VersionMetadata::Virtual(
+ PortageDepParser::parse_depend, PackageDatabaseEntry(p.provided_by_name,
+ p.version, name())));
+
+ result->slot = m->slot;
+ result->license_string = m->license_string;
+ result->eapi = m->eapi;
+ result->deps = VersionMetadataDeps(&PortageDepParser::parse_depend,
+ stringify(p.provided_by_name), stringify(p.provided_by_name), "", "");
+
+ return result;
+}
diff --git a/paludis/repositories/fake/fake_installed_repository.hh b/paludis/repositories/fake/fake_installed_repository.hh
index 34a7658..f331e06 100644
--- a/paludis/repositories/fake/fake_installed_repository.hh
+++ b/paludis/repositories/fake/fake_installed_repository.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -32,15 +32,21 @@ namespace paludis
class PALUDIS_VISIBLE FakeInstalledRepository :
public FakeRepositoryBase,
public RepositoryInstalledInterface,
- public RepositoryDestinationInterface
+ public RepositoryDestinationInterface,
+ public RepositoryProvidesInterface
{
protected:
virtual Contents::ConstPointer do_contents(
const QualifiedPackageName &,
const VersionSpec &) const;
+ virtual ProvidesCollection::ConstPointer provided_packages() const;
+
+ virtual VersionMetadata::ConstPointer provided_package_version_metadata(
+ const RepositoryProvidesEntry &) const;
+
public:
- FakeInstalledRepository(const RepositoryName &);
+ FakeInstalledRepository(const Environment * const, const RepositoryName &);
bool is_suitable_destination_for(const PackageDatabaseEntry &) const;
};
diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc
index 0b5caea..1ac4cab 100644
--- a/paludis/repositories/fake/fake_repository.cc
+++ b/paludis/repositories/fake/fake_repository.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -18,11 +18,13 @@
*/
#include "fake_repository.hh"
+#include <paludis/util/collection_concrete.hh>
+#include <paludis/portage_dep_parser.hh>
using namespace paludis;
-FakeRepository::FakeRepository(const RepositoryName & our_name) :
- FakeRepositoryBase(our_name, RepositoryCapabilities::create()
+FakeRepository::FakeRepository(const Environment * const e, const RepositoryName & our_name) :
+ FakeRepositoryBase(e, our_name, RepositoryCapabilities::create()
.installable_interface(this)
.installed_interface(0)
.mask_interface(this)
@@ -35,9 +37,10 @@ FakeRepository::FakeRepository(const RepositoryName & our_name) :
.mirrors_interface(0)
.environment_variable_interface(0)
.provides_interface(0)
- .virtuals_interface(0)
+ .virtuals_interface(this)
.destination_interface(0),
- "fake")
+ "fake"),
+ _virtual_packages(new VirtualsCollection::Concrete)
{
}
@@ -47,6 +50,37 @@ FakeRepository::do_install(const QualifiedPackageName &, const VersionSpec &,
{
}
+FakeRepository::VirtualsCollection::ConstPointer
+FakeRepository::virtual_packages() const
+{
+ return _virtual_packages;
+}
+
+VersionMetadata::ConstPointer
+FakeRepository::virtual_package_version_metadata(
+ const RepositoryVirtualsEntry & p, const VersionSpec & v) const
+{
+ VersionMetadata::ConstPointer m(version_metadata(p.provided_by_atom->package(), v));
+ VersionMetadata::Virtual::Pointer result(new VersionMetadata::Virtual(
+ PortageDepParser::parse_depend, PackageDatabaseEntry(
+ p.provided_by_atom->package(), v, name())));
+
+ result->slot = m->slot;
+ result->license_string = m->license_string;
+ result->eapi = m->eapi;
+ result->deps = VersionMetadataDeps(&PortageDepParser::parse_depend,
+ "=" + stringify(p.provided_by_atom->package()) + "-" + stringify(v),
+ "=" + stringify(p.provided_by_atom->package()) + "-" + stringify(v), "", "");
+
+ return result;
+}
+
+void
+FakeRepository::add_virtual_package(const QualifiedPackageName & q, PackageDepAtom::ConstPointer p)
+{
+ _virtual_packages->insert(RepositoryVirtualsEntry(q, p));
+}
+
#ifndef MONOLITHIC
namespace paludis
diff --git a/paludis/repositories/fake/fake_repository.hh b/paludis/repositories/fake/fake_repository.hh
index fd632d8..94b66a4 100644
--- a/paludis/repositories/fake/fake_repository.hh
+++ b/paludis/repositories/fake/fake_repository.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -31,14 +31,28 @@ namespace paludis
*/
class PALUDIS_VISIBLE FakeRepository :
public FakeRepositoryBase,
- public RepositoryInstallableInterface
+ public RepositoryInstallableInterface,
+ public RepositoryVirtualsInterface
{
+ private:
+ VirtualsCollection::Pointer _virtual_packages;
+
protected:
virtual void do_install(const QualifiedPackageName &, const VersionSpec &,
const InstallOptions &) const;
+ virtual VirtualsCollection::ConstPointer virtual_packages() const;
+
+ virtual VersionMetadata::ConstPointer virtual_package_version_metadata(
+ const RepositoryVirtualsEntry &, const VersionSpec & v) const;
+
public:
- FakeRepository(const RepositoryName &);
+ FakeRepository(const Environment * const, const RepositoryName &);
+
+ void add_virtual_package(const QualifiedPackageName &, PackageDepAtom::ConstPointer);
+
+ typedef CountedPtr<const FakeRepository, count_policy::InternalCountTag> ConstPointer;
+ typedef CountedPtr<FakeRepository, count_policy::InternalCountTag> Pointer;
};
}
diff --git a/paludis/repositories/fake/fake_repository_base.cc b/paludis/repositories/fake/fake_repository_base.cc
index eb7462b..f00c552 100644
--- a/paludis/repositories/fake/fake_repository_base.cc
+++ b/paludis/repositories/fake/fake_repository_base.cc
@@ -63,22 +63,26 @@ namespace paludis
/// (Empty) provides map.
const std::map<QualifiedPackageName, QualifiedPackageName> provide_map;
+ const Environment * const env;
+
/// Constructor.
- Implementation();
+ Implementation(const Environment * const);
};
- Implementation<FakeRepositoryBase>::Implementation() :
- category_names(new CategoryNamePartCollection::Concrete)
+ Implementation<FakeRepositoryBase>::Implementation(const Environment * const e) :
+ category_names(new CategoryNamePartCollection::Concrete),
+ env(e)
{
}
}
-FakeRepositoryBase::FakeRepositoryBase(const RepositoryName & our_name, const RepositoryCapabilities & caps,
+FakeRepositoryBase::FakeRepositoryBase(const Environment * const e,
+ const RepositoryName & our_name, const RepositoryCapabilities & caps,
const std::string & f) :
Repository(our_name, caps, f),
RepositoryMaskInterface(),
RepositoryUseInterface(),
- PrivateImplementationPattern<FakeRepositoryBase>(new Implementation<FakeRepositoryBase>)
+ PrivateImplementationPattern<FakeRepositoryBase>(new Implementation<FakeRepositoryBase>(e))
{
RepositoryInfoSection::Pointer config_info(new RepositoryInfoSection("Configuration information"));
config_info->add_kv("format", "fake");
@@ -294,3 +298,9 @@ FakeRepositoryBase::do_describe_use_flag(const UseFlagName &,
return "";
}
+const Environment *
+FakeRepositoryBase::environment() const
+{
+ return _imp->env;
+}
+
diff --git a/paludis/repositories/fake/fake_repository_base.hh b/paludis/repositories/fake/fake_repository_base.hh
index 8ae1d1f..3675dd6 100644
--- a/paludis/repositories/fake/fake_repository_base.hh
+++ b/paludis/repositories/fake/fake_repository_base.hh
@@ -97,8 +97,8 @@ namespace paludis
/**
* Constructor.
*/
- FakeRepositoryBase(const RepositoryName & name, const RepositoryCapabilities & caps,
- const std::string &);
+ FakeRepositoryBase(const Environment * const env, const RepositoryName & name,
+ const RepositoryCapabilities & caps, const std::string &);
public:
/**
@@ -151,6 +151,8 @@ namespace paludis
typedef CountedPtr<const FakeRepositoryBase, count_policy::InternalCountTag> ConstPointer;
virtual void invalidate();
+
+ const Environment * environment() const;
};
}
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index c1ab7fc..8e92a1f 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -241,8 +241,14 @@ VirtualsRepository::do_version_metadata(
+ stringify(p.first->virtual_name) + "', '" + stringify(p.first->version) + "', '"
+ stringify(p.first->provided_by_name) + "', '" + stringify(p.first->provided_by_repository) + "'");
- return _imp->env->package_database()->fetch_repository(
- p.first->provided_by_repository)->virtuals_interface->virtual_package_version_metadata(
+ const RepositoryVirtualsInterface * const vif(_imp->env->package_database()->fetch_repository(
+ p.first->provided_by_repository)->virtuals_interface);
+ if (! vif)
+ throw InternalError(PALUDIS_HERE, "vif is 0 for do_version_metadata(" + stringify(q) + ", "
+ + stringify(v) + ") using (" + stringify(p.first->virtual_name) + ", "
+ + stringify(p.first->provided_by_name) + ", " + stringify(p.first->provided_by_repository) + ")");
+
+ return vif->virtual_package_version_metadata(
RepositoryVirtualsEntry::create()
.virtual_name(p.first->virtual_name)
.provided_by_atom(PackageDepAtom::Pointer(new PackageDepAtom(p.first->provided_by_name))), v);
diff --git a/paludis/repository_name_cache_TEST.cc b/paludis/repository_name_cache_TEST.cc
index 6942d60..f3cd89a 100644
--- a/paludis/repository_name_cache_TEST.cc
+++ b/paludis/repository_name_cache_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -37,7 +37,7 @@ namespace test_cases
void run()
{
TestEnvironment env;
- FakeRepository::Pointer repo(new FakeRepository(RepositoryName("repo")));
+ FakeRepository::Pointer repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(repo);
RepositoryNameCache cache(FSEntry("/var/empty"), repo.raw_pointer());
@@ -52,7 +52,7 @@ namespace test_cases
void run()
{
TestEnvironment env;
- FakeRepository::Pointer repo(new FakeRepository(RepositoryName("repo")));
+ FakeRepository::Pointer repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(repo);
RepositoryNameCache cache(FSEntry("repository_name_cache_TEST_dir/not_generated"), repo.raw_pointer());
@@ -69,7 +69,7 @@ namespace test_cases
void run()
{
TestEnvironment env;
- FakeRepository::Pointer repo(new FakeRepository(RepositoryName("repo")));
+ FakeRepository::Pointer repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(repo);
RepositoryNameCache cache(FSEntry("repository_name_cache_TEST_dir/not_existing"), repo.raw_pointer());
@@ -86,7 +86,7 @@ namespace test_cases
void run()
{
TestEnvironment env;
- FakeRepository::Pointer repo(new FakeRepository(RepositoryName("repo")));
+ FakeRepository::Pointer repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(repo);
RepositoryNameCache cache(FSEntry("repository_name_cache_TEST_dir/old_format"), repo.raw_pointer());
@@ -103,7 +103,7 @@ namespace test_cases
void run()
{
TestEnvironment env;
- FakeRepository::Pointer repo(new FakeRepository(RepositoryName("repo")));
+ FakeRepository::Pointer repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(repo);
RepositoryNameCache cache(FSEntry("repository_name_cache_TEST_dir/bad_repo"), repo.raw_pointer());
@@ -120,7 +120,7 @@ namespace test_cases
void run()
{
TestEnvironment env;
- FakeRepository::Pointer repo(new FakeRepository(RepositoryName("repo")));
+ FakeRepository::Pointer repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(repo);
RepositoryNameCache cache(FSEntry("repository_name_cache_TEST_dir/good_repo"), repo.raw_pointer());
@@ -145,7 +145,7 @@ namespace test_cases
void run()
{
TestEnvironment env;
- FakeRepository::Pointer repo(new FakeRepository(RepositoryName("repo")));
+ FakeRepository::Pointer repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(repo);
RepositoryNameCache cache(FSEntry("repository_name_cache_TEST_dir/generated"), repo.raw_pointer());