aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-06 21:36:51 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-08 10:53:07 +0100
commitfa61d33cd6b9892df41e1c32a97553bea4cde42e (patch)
tree05fe70532ff6fc11787cc6fef2f5d9fbbd33f56f
parent5a8863f83642e85ca797d9e2efe943b3488d6654 (diff)
downloadpaludis-fa61d33cd6b9892df41e1c32a97553bea4cde42e.tar.gz
paludis-fa61d33cd6b9892df41e1c32a97553bea4cde42e.tar.xz
GetConstraintsForDependentHelper
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/get_constraints_for_dependent_helper-fwd.hh31
-rw-r--r--paludis/resolver/get_constraints_for_dependent_helper.cc108
-rw-r--r--paludis/resolver/get_constraints_for_dependent_helper.hh57
-rw-r--r--paludis/resolver/resolver_test.cc38
-rw-r--r--paludis/resolver/resolver_test.hh8
-rw-r--r--src/clients/cave/resolve_common.cc60
7 files changed, 213 insertions, 91 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index f0b8438..ea42175 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -43,6 +43,7 @@ noinst_HEADERS = \
destination.hh destination-fwd.hh \
destination_types.hh destination_types-fwd.hh destination_types-se.hh \
find_repository_for_helper.hh find_repository_for_helper-fwd.hh \
+ get_constraints_for_dependent_helper.hh get_constraints_for_dependent_helper-fwd.hh \
job.hh job-fwd.hh \
job_list.hh job_list-fwd.hh \
job_lists.hh job_lists-fwd.hh \
@@ -85,6 +86,7 @@ libpaludisresolver_a_SOURCES = \
destination.cc \
destination_types.cc \
find_repository_for_helper.cc \
+ get_constraints_for_dependent_helper.cc \
job.cc \
job_list.cc \
job_lists.cc \
diff --git a/paludis/resolver/get_constraints_for_dependent_helper-fwd.hh b/paludis/resolver/get_constraints_for_dependent_helper-fwd.hh
new file mode 100644
index 0000000..968ae28
--- /dev/null
+++ b/paludis/resolver/get_constraints_for_dependent_helper-fwd.hh
@@ -0,0 +1,31 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_GET_CONSTRAINTS_FOR_DEPENDENT_HELPER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_GET_CONSTRAINTS_FOR_DEPENDENT_HELPER_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct GetConstraintsForDependentHelper;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/get_constraints_for_dependent_helper.cc b/paludis/resolver/get_constraints_for_dependent_helper.cc
new file mode 100644
index 0000000..1309f62
--- /dev/null
+++ b/paludis/resolver/get_constraints_for_dependent_helper.cc
@@ -0,0 +1,108 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/resolver/get_constraints_for_dependent_helper.hh>
+#include <paludis/resolver/reason.hh>
+#include <paludis/resolver/constraint.hh>
+#include <paludis/resolver/resolvent.hh>
+#include <paludis/resolver/resolution.hh>
+#include <paludis/resolver/decision.hh>
+#include <paludis/util/pimp-impl.hh>
+#include <paludis/util/simple_visitor_cast.hh>
+#include <paludis/util/make_shared_copy.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/package_id.hh>
+#include <paludis/package_dep_spec_collection.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
+#include <paludis/elike_slot_requirement.hh>
+#include <paludis/metadata_key.hh>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+namespace paludis
+{
+ template <>
+ struct Imp<GetConstraintsForDependentHelper>
+ {
+ const Environment * const env;
+ PackageDepSpecCollection less_restrictive_remove_blockers_specs;
+
+ Imp(const Environment * const e) :
+ env(e)
+ {
+ }
+ };
+}
+
+GetConstraintsForDependentHelper::GetConstraintsForDependentHelper(const Environment * const e) :
+ Pimp<GetConstraintsForDependentHelper>(e)
+{
+}
+
+GetConstraintsForDependentHelper::~GetConstraintsForDependentHelper() = default;
+
+void
+GetConstraintsForDependentHelper::add_less_restrictive_remove_blockers_spec(const PackageDepSpec & spec)
+{
+ _imp->less_restrictive_remove_blockers_specs.insert(spec);
+}
+
+const std::shared_ptr<ConstraintSequence>
+GetConstraintsForDependentHelper::operator() (
+ const std::shared_ptr<const Resolution> &,
+ const std::shared_ptr<const PackageID> & id,
+ const std::shared_ptr<const ChangeByResolventSequence> & dependent_upon_ids) const
+{
+ auto result(std::make_shared<ConstraintSequence>());
+
+ std::shared_ptr<PackageDepSpec> spec;
+ if (_imp->less_restrictive_remove_blockers_specs.match_any(_imp->env, id, { }))
+ spec = make_shared_copy(id->uniquely_identifying_spec());
+ else
+ {
+ PartiallyMadePackageDepSpec partial_spec({ });
+ partial_spec.package(id->name());
+ if (id->slot_key())
+ partial_spec.slot_requirement(std::make_shared<ELikeSlotExactRequirement>(id->slot_key()->value(), false));
+ spec = std::make_shared<PackageDepSpec>(partial_spec);
+ }
+
+ for (auto i(dependent_upon_ids->begin()), i_end(dependent_upon_ids->end()) ;
+ i != i_end ; ++i)
+ {
+ auto reason(std::make_shared<DependentReason>(*i));
+
+ result->push_back(std::make_shared<Constraint>(make_named_values<Constraint>(
+ n::destination_type() = dt_install_to_slash,
+ n::nothing_is_fine_too() = true,
+ n::reason() = reason,
+ n::spec() = BlockDepSpec("!" + stringify(*spec), *spec, false),
+ n::untaken() = false,
+ n::use_existing() = ue_if_possible
+ )));
+ }
+
+ return result;
+}
+
+template class Pimp<GetConstraintsForDependentHelper>;
+
diff --git a/paludis/resolver/get_constraints_for_dependent_helper.hh b/paludis/resolver/get_constraints_for_dependent_helper.hh
new file mode 100644
index 0000000..478819d
--- /dev/null
+++ b/paludis/resolver/get_constraints_for_dependent_helper.hh
@@ -0,0 +1,57 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_GET_CONSTRAINTS_FOR_DEPENDENT_HELPER_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_GET_CONSTRAINTS_FOR_DEPENDENT_HELPER_HH 1
+
+#include <paludis/resolver/get_constraints_for_dependent_helper-fwd.hh>
+#include <paludis/resolver/resolution-fwd.hh>
+#include <paludis/resolver/change_by_resolvent-fwd.hh>
+#include <paludis/resolver/constraint-fwd.hh>
+#include <paludis/util/pimp.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <memory>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class PALUDIS_VISIBLE GetConstraintsForDependentHelper :
+ private Pimp<GetConstraintsForDependentHelper>
+ {
+ public:
+ explicit GetConstraintsForDependentHelper(const Environment * const);
+ ~GetConstraintsForDependentHelper();
+
+ void add_less_restrictive_remove_blockers_spec(const PackageDepSpec &);
+
+ const std::shared_ptr<ConstraintSequence> operator() (
+ const std::shared_ptr<const Resolution> &,
+ const std::shared_ptr<const PackageID> &,
+ const std::shared_ptr<const ChangeByResolventSequence> &) const;
+ };
+ }
+
+ extern template class Pimp<resolver::GetConstraintsForDependentHelper>;
+}
+
+#endif
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 141004f..9dd0cc5 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -223,39 +223,6 @@ paludis::resolver::resolver_test::order_early_fn(
}
const std::shared_ptr<ConstraintSequence>
-paludis::resolver::resolver_test::get_constraints_for_dependent_fn(
- const std::shared_ptr<const Resolution> &,
- const std::shared_ptr<const PackageID> & id,
- const std::shared_ptr<const ChangeByResolventSequence> & ids)
-{
- const std::shared_ptr<ConstraintSequence> result(std::make_shared<ConstraintSequence>());
-
- PartiallyMadePackageDepSpec partial_spec({ });
- partial_spec.package(id->name());
- if (id->slot_key())
- partial_spec.slot_requirement(std::make_shared<ELikeSlotExactRequirement>(
- id->slot_key()->value(), false));
- PackageDepSpec spec(partial_spec);
-
- for (ChangeByResolventSequence::ConstIterator i(ids->begin()), i_end(ids->end()) ;
- i != i_end ; ++i)
- {
- const std::shared_ptr<DependentReason> reason(std::make_shared<DependentReason>(*i));
-
- result->push_back(std::make_shared<Constraint>(make_named_values<Constraint>(
- n::destination_type() = dt_install_to_slash,
- n::nothing_is_fine_too() = true,
- n::reason() = reason,
- n::spec() = BlockDepSpec("!" + stringify(spec), spec, false),
- n::untaken() = false,
- n::use_existing() = ue_if_possible
- )));
- }
-
- return result;
-}
-
-const std::shared_ptr<ConstraintSequence>
paludis::resolver::resolver_test::get_constraints_for_purge_fn(
const std::shared_ptr<const Resolution> &,
const std::shared_ptr<const PackageID> & id,
@@ -316,7 +283,8 @@ ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s,
always_via_binary_helper(&env),
can_use_helper(&env),
confirm_helper(&env),
- find_repository_for_helper(&env)
+ find_repository_for_helper(&env),
+ get_constraints_for_dependent_helper(&env)
{
std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
keys->insert("format", "e");
@@ -368,7 +336,7 @@ ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraint
n::can_use_fn() = std::cref(can_use_helper),
n::confirm_fn() = std::cref(confirm_helper),
n::find_repository_for_fn() = std::cref(find_repository_for_helper),
- n::get_constraints_for_dependent_fn() = &get_constraints_for_dependent_fn,
+ n::get_constraints_for_dependent_fn() = std::cref(get_constraints_for_dependent_helper),
n::get_constraints_for_purge_fn() = &get_constraints_for_purge_fn,
n::get_constraints_for_via_binary_fn() = &get_constraints_for_via_binary_fn,
n::get_destination_types_for_error_fn() = &get_destination_types_for_error_fn,
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index aa21978..1851924 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -41,6 +41,7 @@
#include <paludis/resolver/can_use_helper.hh>
#include <paludis/resolver/confirm_helper.hh>
#include <paludis/resolver/find_repository_for_helper.hh>
+#include <paludis/resolver/get_constraints_for_dependent_helper.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
@@ -80,12 +81,6 @@ namespace paludis
const Resolvent & resolvent);
const std::shared_ptr<ConstraintSequence>
- get_constraints_for_dependent_fn(
- const std::shared_ptr<const Resolution> &,
- const std::shared_ptr<const PackageID> & id,
- const std::shared_ptr<const ChangeByResolventSequence> & ids);
-
- const std::shared_ptr<ConstraintSequence>
get_constraints_for_purge_fn(
const std::shared_ptr<const Resolution> &,
const std::shared_ptr<const PackageID> & id,
@@ -144,6 +139,7 @@ namespace paludis
CanUseHelper can_use_helper;
ConfirmHelper confirm_helper;
FindRepositoryForHelper find_repository_for_helper;
+ GetConstraintsForDependentHelper get_constraints_for_dependent_helper;
ResolverTestCase(const std::string & group, const std::string & test_name, const std::string & eapi,
const std::string & layout);
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index dcc28eb..0ec0e08 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -71,6 +71,7 @@
#include <paludis/resolver/can_use_helper.hh>
#include <paludis/resolver/confirm_helper.hh>
#include <paludis/resolver/find_repository_for_helper.hh>
+#include <paludis/resolver/get_constraints_for_dependent_helper.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/notifier_callback.hh>
@@ -1166,46 +1167,6 @@ namespace
return indeterminate;
}
- const std::shared_ptr<ConstraintSequence> get_constraints_for_dependent_fn(
- const Environment * const env,
- const PackageDepSpecList & list,
- const std::shared_ptr<const Resolution> &,
- const std::shared_ptr<const PackageID> & id,
- const std::shared_ptr<const ChangeByResolventSequence> & ids)
- {
- const std::shared_ptr<ConstraintSequence> result(std::make_shared<ConstraintSequence>());
-
- std::shared_ptr<PackageDepSpec> spec;
- if (match_any(env, list, id))
- spec = make_shared_copy(id->uniquely_identifying_spec());
- else
- {
- PartiallyMadePackageDepSpec partial_spec({ });
- partial_spec.package(id->name());
- if (id->slot_key())
- partial_spec.slot_requirement(std::make_shared<ELikeSlotExactRequirement>(
- id->slot_key()->value(), false));
- spec = std::make_shared<PackageDepSpec>(partial_spec);
- }
-
- for (ChangeByResolventSequence::ConstIterator i(ids->begin()), i_end(ids->end()) ;
- i != i_end ; ++i)
- {
- const std::shared_ptr<DependentReason> reason(std::make_shared<DependentReason>(*i));
-
- result->push_back(std::make_shared<Constraint>(make_named_values<Constraint>(
- n::destination_type() = dt_install_to_slash,
- n::nothing_is_fine_too() = true,
- n::reason() = reason,
- n::spec() = BlockDepSpec("!" + stringify(*spec), *spec, false),
- n::untaken() = false,
- n::use_existing() = ue_if_possible
- )));
- }
-
- return result;
- }
-
const std::shared_ptr<ConstraintSequence> get_constraints_for_purge_fn(
const Environment * const env,
const PackageDepSpecList & list,
@@ -1574,8 +1535,7 @@ paludis::cave::resolve_common(
int retcode(0);
InitialConstraints initial_constraints;
- PackageDepSpecList remove_if_dependent_specs,
- less_restrictive_remove_blockers_specs, purge_specs, with, without,
+ PackageDepSpecList remove_if_dependent_specs, purge_specs, with, without,
take, take_from, ignore, ignore_from,
favour, avoid, early, late, no_dependencies_from, no_blockers_from;
@@ -1585,12 +1545,6 @@ paludis::cave::resolve_common(
remove_if_dependent_specs.push_back(parse_user_package_dep_spec(*i, env.get(),
{ updso_allow_wildcards }));
- for (args::StringSetArg::ConstIterator i(resolution_options.a_less_restrictive_remove_blockers.begin_args()),
- i_end(resolution_options.a_less_restrictive_remove_blockers.end_args()) ;
- i != i_end ; ++i)
- less_restrictive_remove_blockers_specs.push_back(parse_user_package_dep_spec(*i, env.get(),
- { updso_allow_wildcards }));
-
for (args::StringSetArg::ConstIterator i(resolution_options.a_purge.begin_args()),
i_end(resolution_options.a_purge.end_args()) ;
i != i_end ; ++i)
@@ -1768,6 +1722,13 @@ paludis::cave::resolve_common(
FindRepositoryForHelper find_repository_for_helper(env.get());
+ GetConstraintsForDependentHelper get_constraints_for_dependent_helper(env.get());
+ for (args::StringSetArg::ConstIterator i(resolution_options.a_less_restrictive_remove_blockers.begin_args()),
+ i_end(resolution_options.a_less_restrictive_remove_blockers.end_args()) ;
+ i != i_end ; ++i)
+ get_constraints_for_dependent_helper.add_less_restrictive_remove_blockers_spec(
+ parse_user_package_dep_spec(*i, env.get(), { updso_allow_wildcards }));
+
ResolverFunctions resolver_functions(make_named_values<ResolverFunctions>(
n::allow_choice_changes_fn() = std::cref(allow_choice_changes_helper),
n::allowed_to_remove_fn() = std::cref(allowed_to_remove_helper),
@@ -1775,8 +1736,7 @@ paludis::cave::resolve_common(
n::can_use_fn() = std::cref(can_use_helper),
n::confirm_fn() = std::cref(confirm_helper),
n::find_repository_for_fn() = std::cref(find_repository_for_helper),
- n::get_constraints_for_dependent_fn() = std::bind(&get_constraints_for_dependent_fn,
- env.get(), std::cref(less_restrictive_remove_blockers_specs), _1, _2, _3),
+ n::get_constraints_for_dependent_fn() = std::cref(get_constraints_for_dependent_helper),
n::get_constraints_for_purge_fn() = std::bind(&get_constraints_for_purge_fn,
env.get(), std::cref(purge_specs), _1, _2, _3),
n::get_constraints_for_via_binary_fn() = std::bind(&get_constraints_for_via_binary_fn,