aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-15 16:50:14 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-15 16:50:14 +0000
commit58e21d0873763bfa2b563204447066e3d02a2aa6 (patch)
tree356903450d1edc26ca7413187d22f69e9d0169dc
parentaa90df29b89764996c6bd4216153d9a021792e62 (diff)
downloadpaludis-58e21d0873763bfa2b563204447066e3d02a2aa6.tar.gz
paludis-58e21d0873763bfa2b563204447066e3d02a2aa6.tar.xz
Better handling of || ( a >=b-2 ) when b-1 is installed. Fixes: ticket:15
-rw-r--r--paludis/dep_atom.cc14
-rw-r--r--paludis/dep_atom.hh10
-rw-r--r--paludis/dep_list/dep_list.cc43
-rw-r--r--paludis/dep_list/dep_list_TEST.cc53
4 files changed, 117 insertions, 3 deletions
diff --git a/paludis/dep_atom.cc b/paludis/dep_atom.cc
index 95de32d..7e5c866 100644
--- a/paludis/dep_atom.cc
+++ b/paludis/dep_atom.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,6 +46,12 @@ DepAtom::as_use_dep_atom() const
return 0;
}
+const PackageDepAtom *
+DepAtom::as_package_dep_atom() const
+{
+ return 0;
+}
+
namespace paludis
{
/**
@@ -108,6 +114,12 @@ UseDepAtom::as_use_dep_atom() const
return this;
}
+const PackageDepAtom *
+PackageDepAtom::as_package_dep_atom() const
+{
+ return this;
+}
+
BlockDepAtom::BlockDepAtom(PackageDepAtom::ConstPointer a) :
StringDepAtom("!" + a->text()),
_atom(a)
diff --git a/paludis/dep_atom.hh b/paludis/dep_atom.hh
index 3f799c3..1ea2fe7 100644
--- a/paludis/dep_atom.hh
+++ b/paludis/dep_atom.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
@@ -88,6 +88,12 @@ namespace paludis
*/
virtual const UseDepAtom * as_use_dep_atom() const;
+ /**
+ * Return us as a PackageDepAtom, or 0 if we are not a
+ * UseDepAtom.
+ */
+ virtual const PackageDepAtom * as_package_dep_atom() const;
+
///\}
};
@@ -426,6 +432,8 @@ namespace paludis
* Fetch a copy of ourself without the USE requirements.
*/
Pointer without_use_requirements() const;
+
+ virtual const PackageDepAtom * as_package_dep_atom() const;
};
/**
diff --git a/paludis/dep_list/dep_list.cc b/paludis/dep_list/dep_list.cc
index 2688512..bdc7be2 100644
--- a/paludis/dep_list/dep_list.cc
+++ b/paludis/dep_list/dep_list.cc
@@ -254,6 +254,28 @@ namespace
return true;
}
};
+
+ struct IsInterestingPDADepAtomChild
+ {
+ const Environment * const env;
+
+ IsInterestingPDADepAtomChild(const Environment * const e) :
+ env(e)
+ {
+ }
+
+ bool operator() (PackageDepAtom::ConstPointer atom)
+ {
+ const PackageDepAtom * const u(atom->as_package_dep_atom());
+ if (0 != u)
+ {
+ return ! env->package_database()->query(PackageDepAtom(u->package()),
+ is_installed_only, qo_whatever)->empty();
+ }
+ else
+ return false;
+ }
+ };
}
struct DepList::QueryVisitor :
@@ -635,6 +657,27 @@ DepList::AddVisitor::visit(const AnyDepAtom * const a)
}
}
+ /* if we have something like || ( a >=b-2 ) and b-1 is installed, try to go for
+ * the b-2 bit first */
+ std::list<DepAtom::ConstPointer> pda_children;
+ std::copy(viable_children.begin(), viable_children.end(),
+ filter_inserter(std::back_inserter(pda_children), IsInterestingPDADepAtomChild(d->_imp->env)));
+
+ for (std::list<DepAtom::ConstPointer>::const_iterator c(pda_children.begin()),
+ c_end(pda_children.end()) ; c != c_end ; ++c)
+ {
+ try
+ {
+ Save<bool> save_t(&d->_imp->throw_on_blocker, true);
+ Save<DepListOverrideMasks> save_o(&d->_imp->opts.override_masks, DepListOverrideMasks());
+ d->add(*c);
+ return;
+ }
+ catch (const DepListError &)
+ {
+ }
+ }
+
/* install first available viable option */
for (std::list<DepAtom::ConstPointer>::const_iterator c(viable_children.begin()),
c_end(viable_children.end()) ; c != c_end ; ++c)
diff --git a/paludis/dep_list/dep_list_TEST.cc b/paludis/dep_list/dep_list_TEST.cc
index 21c19f4..ea99644 100644
--- a/paludis/dep_list/dep_list_TEST.cc
+++ b/paludis/dep_list/dep_list_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
@@ -23,6 +23,7 @@
#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>
@@ -56,7 +57,9 @@ namespace test_cases
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;
@@ -68,11 +71,15 @@ namespace test_cases
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);
}
/**
@@ -1397,6 +1404,50 @@ namespace test_cases
} test_dep_list_58;
/**
+ * \test Test DepList resolution behaviour.
+ *
+ */
+ struct DepListTestCase59 : DepListTestCase<59>
+ {
+ void populate_repo()
+ {
+ repo->add_version("cat", "one", "1")->deps.build_depend_string = "|| ( cat/two >=cat/three-2 )";
+ repo->add_version("cat", "two", "1");
+ repo->add_version("cat", "three", "2");
+ installed_repo->add_version("cat", "three", "1");
+ }
+
+ void populate_expected()
+ {
+ merge_target = "cat/one";
+ expected.push_back("cat/three-2:0::repo");
+ expected.push_back("cat/one-1:0::repo");
+ }
+ } test_dep_list_59;
+
+ /**
+ * \test Test DepList resolution behaviour.
+ *
+ */
+ struct DepListTestCase60 : DepListTestCase<60>
+ {
+ void populate_repo()
+ {
+ repo->add_version("cat", "one", "1")->deps.build_depend_string = "|| ( cat/two >=cat/three-3 )";
+ repo->add_version("cat", "two", "1");
+ repo->add_version("cat", "three", "2");
+ installed_repo->add_version("cat", "three", "1");
+ }
+
+ 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_60;
+
+ /**
* \test Test DepList transactional add behaviour.
*
*/