aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-07 09:11:34 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-08 10:53:07 +0100
commit1d8ee4cd7de4608dbbaa8ef207da80a6ca819b6a (patch)
tree865816dc6c3252b6c940d75d8e33d585133d9047
parentfa61d33cd6b9892df41e1c32a97553bea4cde42e (diff)
downloadpaludis-1d8ee4cd7de4608dbbaa8ef207da80a6ca819b6a.tar.gz
paludis-1d8ee4cd7de4608dbbaa8ef207da80a6ca819b6a.tar.xz
GetConstraintsForPurgeHelper
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/get_constraints_for_purge_helper-fwd.hh31
-rw-r--r--paludis/resolver/get_constraints_for_purge_helper.cc98
-rw-r--r--paludis/resolver/get_constraints_for_purge_helper.hh57
-rw-r--r--paludis/resolver/resolver_TEST_continue_on_failure.cc11
-rw-r--r--paludis/resolver/resolver_TEST_purges.cc4
-rw-r--r--paludis/resolver/resolver_test.cc34
-rw-r--r--paludis/resolver/resolver_test.hh8
-rw-r--r--src/clients/cave/resolve_common.cc49
9 files changed, 208 insertions, 86 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index ea42175..6da5b94 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -44,6 +44,7 @@ noinst_HEADERS = \
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 \
+ get_constraints_for_purge_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 \
@@ -87,6 +88,7 @@ libpaludisresolver_a_SOURCES = \
destination_types.cc \
find_repository_for_helper.cc \
get_constraints_for_dependent_helper.cc \
+ get_constraints_for_purge_helper.cc \
job.cc \
job_list.cc \
job_lists.cc \
diff --git a/paludis/resolver/get_constraints_for_purge_helper-fwd.hh b/paludis/resolver/get_constraints_for_purge_helper-fwd.hh
new file mode 100644
index 0000000..03b1a12
--- /dev/null
+++ b/paludis/resolver/get_constraints_for_purge_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_PURGE_HELPER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_GET_CONSTRAINTS_FOR_PURGE_HELPER_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct GetConstraintsForPurgeHelper;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/get_constraints_for_purge_helper.cc b/paludis/resolver/get_constraints_for_purge_helper.cc
new file mode 100644
index 0000000..507290a
--- /dev/null
+++ b/paludis/resolver/get_constraints_for_purge_helper.cc
@@ -0,0 +1,98 @@
+/* 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_purge_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<GetConstraintsForPurgeHelper>
+ {
+ const Environment * const env;
+ PackageDepSpecCollection purge_specs;
+
+ Imp(const Environment * const e) :
+ env(e)
+ {
+ }
+ };
+}
+
+GetConstraintsForPurgeHelper::GetConstraintsForPurgeHelper(const Environment * const e) :
+ Pimp<GetConstraintsForPurgeHelper>(e)
+{
+}
+
+GetConstraintsForPurgeHelper::~GetConstraintsForPurgeHelper() = default;
+
+void
+GetConstraintsForPurgeHelper::add_purge_spec(const PackageDepSpec & spec)
+{
+ _imp->purge_specs.insert(spec);
+}
+
+const std::shared_ptr<ConstraintSequence>
+GetConstraintsForPurgeHelper::operator() (
+ const std::shared_ptr<const Resolution> &,
+ const std::shared_ptr<const PackageID> & id,
+ const std::shared_ptr<const ChangeByResolventSequence> & was_used_by_ids) const
+{
+ 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);
+
+ const std::shared_ptr<WasUsedByReason> reason(std::make_shared<WasUsedByReason>(was_used_by_ids));
+
+ 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() = ! _imp->purge_specs.match_any(_imp->env, id, { }),
+ n::use_existing() = ue_if_possible
+ )));
+
+ return result;
+}
+
+template class Pimp<GetConstraintsForPurgeHelper>;
+
diff --git a/paludis/resolver/get_constraints_for_purge_helper.hh b/paludis/resolver/get_constraints_for_purge_helper.hh
new file mode 100644
index 0000000..3fdebb0
--- /dev/null
+++ b/paludis/resolver/get_constraints_for_purge_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_PURGE_HELPER_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_GET_CONSTRAINTS_FOR_PURGE_HELPER_HH 1
+
+#include <paludis/resolver/get_constraints_for_purge_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 GetConstraintsForPurgeHelper :
+ private Pimp<GetConstraintsForPurgeHelper>
+ {
+ public:
+ explicit GetConstraintsForPurgeHelper(const Environment * const);
+ ~GetConstraintsForPurgeHelper();
+
+ void add_purge_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::GetConstraintsForPurgeHelper>;
+}
+
+#endif
diff --git a/paludis/resolver/resolver_TEST_continue_on_failure.cc b/paludis/resolver/resolver_TEST_continue_on_failure.cc
index f823930..90d061d 100644
--- a/paludis/resolver/resolver_TEST_continue_on_failure.cc
+++ b/paludis/resolver/resolver_TEST_continue_on_failure.cc
@@ -169,14 +169,11 @@ namespace test_cases
install("continue-on-failure-uninstall", "target", "1")->build_dependencies_key()->set_from_string("continue-on-failure-uninstall/dep");
install("continue-on-failure-uninstall", "needs-target", "1")->build_dependencies_key()->set_from_string("continue-on-failure-uninstall/target");
- allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/dep-of-dep", &env, { }));
- allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/dep", &env, { }));
- allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/target", &env, { }));
- allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/needs-target", &env, { }));
+ get_constraints_for_purge_helper.add_purge_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/dep-of-dep", &env, { }));
+ get_constraints_for_purge_helper.add_purge_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/dep", &env, { }));
+ get_constraints_for_purge_helper.add_purge_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/target", &env, { }));
- remove_if_dependent_names->insert(QualifiedPackageName("continue-on-failure-uninstall/dep-of-dep"));
- remove_if_dependent_names->insert(QualifiedPackageName("continue-on-failure-uninstall/dep"));
- remove_if_dependent_names->insert(QualifiedPackageName("continue-on-failure-uninstall/target"));
+ allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/needs-target", &env, { }));
remove_if_dependent_names->insert(QualifiedPackageName("continue-on-failure-uninstall/needs-target"));
}
diff --git a/paludis/resolver/resolver_TEST_purges.cc b/paludis/resolver/resolver_TEST_purges.cc
index 435e4a6..1ca4b93 100644
--- a/paludis/resolver/resolver_TEST_purges.cc
+++ b/paludis/resolver/resolver_TEST_purges.cc
@@ -90,7 +90,7 @@ namespace test_cases
install("purges", "unrelated-dep", "0");
install("purges", "unrelated", "0")->build_dependencies_key()->set_from_string("purges/unrelated-dep");
- allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("purges/old-dep", &env, { }));
+ get_constraints_for_purge_helper.add_purge_spec(parse_user_package_dep_spec("purges/old-dep", &env, { }));
}
virtual ResolverFunctions get_resolver_functions(InitialConstraints & initial_constraints)
@@ -134,7 +134,7 @@ namespace test_cases
install("star-slot-purges", "uses", "1")->build_dependencies_key()->set_from_string("star-slot-purges/target:*");
- allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("star-slot-purges/target", &env, { }));
+ get_constraints_for_purge_helper.add_purge_spec(parse_user_package_dep_spec("star-slot-purges/target", &env, { }));
}
virtual ResolverFunctions get_resolver_functions(InitialConstraints & initial_constraints)
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 9dd0cc5..9c018dd 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -223,35 +223,6 @@ paludis::resolver::resolver_test::order_early_fn(
}
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,
- 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);
-
- const std::shared_ptr<WasUsedByReason> reason(std::make_shared<WasUsedByReason>(ids));
-
- 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_via_binary_fn(
const std::shared_ptr<const Resolution> & resolution,
const std::shared_ptr<const Resolution> & because_resolution)
@@ -284,7 +255,8 @@ ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s,
can_use_helper(&env),
confirm_helper(&env),
find_repository_for_helper(&env),
- get_constraints_for_dependent_helper(&env)
+ get_constraints_for_dependent_helper(&env),
+ get_constraints_for_purge_helper(&env)
{
std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
keys->insert("format", "e");
@@ -337,7 +309,7 @@ ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraint
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::cref(get_constraints_for_dependent_helper),
- n::get_constraints_for_purge_fn() = &get_constraints_for_purge_fn,
+ n::get_constraints_for_purge_fn() = std::cref(get_constraints_for_purge_helper),
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,
n::get_initial_constraints_for_fn() =
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index 1851924..31d3686 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -42,6 +42,7 @@
#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/resolver/get_constraints_for_purge_helper.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
@@ -81,12 +82,6 @@ namespace paludis
const Resolvent & resolvent);
const std::shared_ptr<ConstraintSequence>
- get_constraints_for_purge_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_via_binary_fn(
const std::shared_ptr<const Resolution> &,
const std::shared_ptr<const Resolution> &);
@@ -140,6 +135,7 @@ namespace paludis
ConfirmHelper confirm_helper;
FindRepositoryForHelper find_repository_for_helper;
GetConstraintsForDependentHelper get_constraints_for_dependent_helper;
+ GetConstraintsForPurgeHelper get_constraints_for_purge_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 0ec0e08..fbd974f 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -72,6 +72,7 @@
#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/resolver/get_constraints_for_purge_helper.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/notifier_callback.hh>
@@ -1167,36 +1168,6 @@ namespace
return indeterminate;
}
- const std::shared_ptr<ConstraintSequence> get_constraints_for_purge_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>());
-
- 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);
-
- const std::shared_ptr<WasUsedByReason> reason(std::make_shared<WasUsedByReason>(ids));
-
- 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() = ! match_any(env, list, id),
- n::use_existing() = ue_if_possible
- )));
-
- return result;
- }
-
const std::shared_ptr<ConstraintSequence> get_constraints_for_via_binary_fn(
const Environment * const,
const std::shared_ptr<const Resolution> & resolution,
@@ -1535,8 +1506,7 @@ paludis::cave::resolve_common(
int retcode(0);
InitialConstraints initial_constraints;
- PackageDepSpecList remove_if_dependent_specs, purge_specs, with, without,
- take, take_from, ignore, ignore_from,
+ PackageDepSpecList remove_if_dependent_specs, with, without, take, take_from, ignore, ignore_from,
favour, avoid, early, late, no_dependencies_from, no_blockers_from;
for (args::StringSetArg::ConstIterator i(resolution_options.a_remove_if_dependent.begin_args()),
@@ -1545,12 +1515,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_purge.begin_args()),
- i_end(resolution_options.a_purge.end_args()) ;
- i != i_end ; ++i)
- purge_specs.push_back(parse_user_package_dep_spec(*i, env.get(),
- { updso_allow_wildcards }));
-
for (args::StringSetArg::ConstIterator i(resolution_options.a_without.begin_args()),
i_end(resolution_options.a_without.end_args()) ;
i != i_end ; ++i)
@@ -1729,6 +1693,12 @@ paludis::cave::resolve_common(
get_constraints_for_dependent_helper.add_less_restrictive_remove_blockers_spec(
parse_user_package_dep_spec(*i, env.get(), { updso_allow_wildcards }));
+ GetConstraintsForPurgeHelper get_constraints_for_purge_helper(env.get());
+ for (args::StringSetArg::ConstIterator i(resolution_options.a_purge.begin_args()),
+ i_end(resolution_options.a_purge.end_args()) ;
+ i != i_end ; ++i)
+ get_constraints_for_purge_helper.add_purge_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),
@@ -1737,8 +1707,7 @@ paludis::cave::resolve_common(
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::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_purge_fn() = std::cref(get_constraints_for_purge_helper),
n::get_constraints_for_via_binary_fn() = std::bind(&get_constraints_for_via_binary_fn,
env.get(), _1, _2),
n::get_destination_types_for_error_fn() = std::bind(&get_destination_types_for_fn,