aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-05 13:56:07 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-05 14:55:18 +0000
commit9aa1f49c84aa09c6ff2a81a11f3fc42e16061dbd (patch)
tree12334501926139a8f9b9425b871388cca2bd8374
parent384d849033292d2224af9d4642ab05a7092accd8 (diff)
downloadpaludis-9aa1f49c84aa09c6ff2a81a11f3fc42e16061dbd.tar.gz
paludis-9aa1f49c84aa09c6ff2a81a11f3fc42e16061dbd.tar.xz
allowed_to_remove_fn, always false for now
-rw-r--r--paludis/resolver/decider.cc32
-rw-r--r--paludis/resolver/decider.hh9
-rw-r--r--paludis/resolver/resolver_functions.hh8
-rw-r--r--paludis/resolver/resolver_test.cc7
-rw-r--r--paludis/resolver/resolver_test.hh4
-rw-r--r--src/clients/cave/resolve_common.cc7
6 files changed, 59 insertions, 8 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 9b062f7..d2c70a3 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -1247,14 +1247,36 @@ Decider::_make_unsuitable_candidate(
const std::tr1::shared_ptr<const PackageID>
Decider::_find_existing_id_for(const Resolvent & resolvent, const std::tr1::shared_ptr<const Resolution> & resolution) const
{
- const std::tr1::shared_ptr<const PackageIDSequence> ids((*_imp->env)[selection::AllVersionsSorted(
- _make_destination_filtered_generator(generator::Package(resolvent.package()), resolvent) |
- make_slot_filter(resolvent)
- )]);
-
+ const std::tr1::shared_ptr<const PackageIDSequence> ids(_installed_ids(resolvent));
return _find_id_for_from(resolvent, resolution, ids).first;
}
+bool
+Decider::_installed_but_allowed_to_remove(const Resolvent & resolvent) const
+{
+ const std::tr1::shared_ptr<const PackageIDSequence> ids(_installed_ids(resolvent));
+ if (ids->empty())
+ return false;
+
+ return ids->end() == std::find_if(ids->begin(), ids->end(),
+ std::tr1::bind(std::logical_not<bool>(), std::tr1::bind(&Decider::_allowed_to_remove, this, std::tr1::placeholders::_1)));
+}
+
+bool
+Decider::_allowed_to_remove(const std::tr1::shared_ptr<const PackageID> & id) const
+{
+ return id->supports_action(SupportsActionTest<UninstallAction>()) && _imp->fns.allowed_to_remove_fn()(id);
+}
+
+const std::tr1::shared_ptr<const PackageIDSequence>
+Decider::_installed_ids(const Resolvent & resolvent) const
+{
+ return (*_imp->env)[selection::AllVersionsSorted(
+ _make_destination_filtered_generator(generator::Package(resolvent.package()), resolvent) |
+ make_slot_filter(resolvent)
+ )];
+}
+
const std::tr1::shared_ptr<const PackageIDSequence>
Decider::_find_installable_id_candidates_for(const Resolvent & resolvent,
const std::tr1::shared_ptr<const Resolution> &,
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index 6a91003..5c35d6b 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 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
@@ -170,6 +170,13 @@ namespace paludis
bool _already_met(const SanitisedDependency &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ bool _installed_but_allowed_to_remove(const Resolvent &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ const std::tr1::shared_ptr<const PackageIDSequence> _installed_ids(
+ const Resolvent & resolvent) const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ bool _allowed_to_remove(const std::tr1::shared_ptr<const PackageID> &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+
public:
Decider(const Environment * const,
const ResolverFunctions &,
diff --git a/paludis/resolver/resolver_functions.hh b/paludis/resolver/resolver_functions.hh
index e544282..834cacc 100644
--- a/paludis/resolver/resolver_functions.hh
+++ b/paludis/resolver/resolver_functions.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 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
@@ -38,6 +38,7 @@ namespace paludis
{
namespace n
{
+ struct allowed_to_remove_fn;
struct care_about_dep_fn;
struct find_repository_for_fn;
struct get_destination_types_for_fn;
@@ -51,6 +52,10 @@ namespace paludis
namespace resolver
{
typedef std::tr1::function<bool (
+ const std::tr1::shared_ptr<const PackageID> &
+ )> AllowedToRemoveFunction;
+
+ typedef std::tr1::function<bool (
const Resolvent &,
const std::tr1::shared_ptr<const Resolution> &,
const SanitisedDependency &
@@ -97,6 +102,7 @@ namespace paludis
struct ResolverFunctions
{
+ NamedValue<n::allowed_to_remove_fn, AllowedToRemoveFunction> allowed_to_remove_fn;
NamedValue<n::care_about_dep_fn, CareAboutDepFunction> care_about_dep_fn;
NamedValue<n::find_repository_for_fn, FindRepositoryForFunction> find_repository_for_fn;
NamedValue<n::get_destination_types_for_fn, GetDestinationTypesForFunction> get_destination_types_for_fn;
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 04633e0..9811166 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -244,6 +244,12 @@ paludis::resolver::resolver_test::find_repository_for_fn(
return env->package_database()->fetch_repository(RepositoryName("installed"));
}
+bool
+paludis::resolver::resolver_test::allowed_to_remove_fn(const std::tr1::shared_ptr<const PackageID> &)
+{
+ return false;
+}
+
ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s, const std::string & e,
const std::string & l) :
TestCase(s)
@@ -292,6 +298,7 @@ ResolverFunctions
ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraints)
{
return make_named_values<ResolverFunctions>(
+ value_for<n::allowed_to_remove_fn>(&allowed_to_remove_fn),
value_for<n::care_about_dep_fn>(&care_about_dep_fn),
value_for<n::find_repository_for_fn>(std::tr1::bind(&find_repository_for_fn,
&env, std::tr1::placeholders::_1, std::tr1::placeholders::_2,
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index 9cff289..c118281 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 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
@@ -90,6 +90,8 @@ namespace paludis
const std::tr1::shared_ptr<const PackageID> &,
const std::tr1::shared_ptr<const Reason> &);
+ bool allowed_to_remove_fn(const std::tr1::shared_ptr<const PackageID> &);
+
struct ResolverTestCase : test::TestCase
{
TestEnvironment env;
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index c2a25b8..7d4b8c6 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -918,6 +918,11 @@ namespace
throw InternalError(PALUDIS_HERE, "unhandled dt");
}
+ bool allowed_to_remove_fn(const std::tr1::shared_ptr<const PackageID> &)
+ {
+ return false;
+ }
+
void ser_thread_func(StringListStream & ser_stream, const ResolverLists & resolution_lists)
{
Serialiser ser(ser_stream);
@@ -1151,6 +1156,8 @@ paludis::cave::resolve_common(
InitialConstraints initial_constraints;
ResolverFunctions resolver_functions(make_named_values<ResolverFunctions>(
+ value_for<n::allowed_to_remove_fn>(std::tr1::bind(&allowed_to_remove_fn,
+ std::tr1::placeholders::_1)),
value_for<n::care_about_dep_fn>(std::tr1::bind(&care_about_dep_fn,
env.get(), std::tr1::cref(resolution_options), std::tr1::placeholders::_1,
std::tr1::placeholders::_2, std::tr1::placeholders::_3)),