aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-24 13:14:20 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-24 13:14:20 +0100
commit324505b300f4964f84312e113f09f334ab1c350b (patch)
tree36eb1b8cf06aa94b159901fcbfc6afa22ce933eb
parent4fc32662efa9448e750621cba697a40818c6827b (diff)
downloadpaludis-324505b300f4964f84312e113f09f334ab1c350b.tar.gz
paludis-324505b300f4964f84312e113f09f334ab1c350b.tar.xz
Let the decider pick masked packages
-rw-r--r--paludis/resolver/decider.cc31
-rw-r--r--paludis/resolver/decider.hh13
-rw-r--r--paludis/resolver/resolver_functions.hh7
-rw-r--r--paludis/resolver/resolver_test.cc8
-rw-r--r--paludis/resolver/resolver_test.hh3
-rw-r--r--src/clients/cave/resolve_common.cc45
6 files changed, 94 insertions, 13 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index b9b3834..9f93642 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -596,6 +596,12 @@ Decider::_make_origin_filtered_generator(const Generator & g,
return _imp->fns.make_origin_filtered_generator_fn()(g, resolution);
}
+Filter
+Decider::_make_unmaskable_filter(const std::shared_ptr<const Resolution> & resolution) const
+{
+ return _imp->fns.make_unmaskable_filter_fn()(resolution);
+}
+
const std::shared_ptr<const PackageIDSequence>
Decider::_find_replacing(
const std::shared_ptr<const PackageID> & id,
@@ -970,7 +976,7 @@ Decider::_made_wrong_decision(
std::shared_ptr<Resolution> adapted_resolution(std::make_shared<Resolution>(*resolution));
adapted_resolution->constraints()->add(constraint);
- const std::shared_ptr<Decision> decision(_try_to_find_decision_for(adapted_resolution));
+ const std::shared_ptr<Decision> decision(_try_to_find_decision_for(adapted_resolution, true, false));
if (decision)
{
resolution->decision()->accept(WrongDecisionVisitor(std::bind(
@@ -1037,7 +1043,7 @@ Decider::_decide(const std::shared_ptr<Resolution> & resolution)
_copy_other_destination_constraints(resolution);
- std::shared_ptr<Decision> decision(_try_to_find_decision_for(resolution));
+ std::shared_ptr<Decision> decision(_try_to_find_decision_for(resolution, true, false));
if (decision)
resolution->decision() = decision;
else
@@ -1338,7 +1344,7 @@ Decider::find_any_score(
for (ConstraintSequence::ConstIterator c(constraints->begin()), c_end(constraints->end()) ;
c != c_end ; ++c)
resolution->constraints()->add(*c);
- const std::shared_ptr<Decision> decision(_try_to_find_decision_for(resolution));
+ const std::shared_ptr<Decision> decision(_try_to_find_decision_for(resolution, false, false));
if (decision)
return std::make_pair(acs_could_install, operator_bias);
}
@@ -1474,10 +1480,12 @@ Decider::_get_error_resolvents_for(
const std::shared_ptr<Decision>
Decider::_try_to_find_decision_for(
- const std::shared_ptr<const Resolution> & resolution) const
+ const std::shared_ptr<const Resolution> & resolution,
+ const bool also_try_masked,
+ const bool try_masked_this_time) const
{
const std::shared_ptr<const PackageID> existing_id(_find_existing_id_for(resolution));
- std::pair<const std::shared_ptr<const PackageID>, bool> installable_id_best(_find_installable_id_for(resolution));
+ std::pair<const std::shared_ptr<const PackageID>, bool> installable_id_best(_find_installable_id_for(resolution, try_masked_this_time));
const std::shared_ptr<const PackageID> installable_id(installable_id_best.first);
bool best(installable_id_best.second);
@@ -1552,6 +1560,8 @@ Decider::_try_to_find_decision_for(
_installed_ids(resolution),
! resolution->constraints()->all_untaken()
);
+ else if (also_try_masked && ! try_masked_this_time)
+ return _try_to_find_decision_for(resolution, true, true);
else
return make_null_shared_ptr();
}
@@ -1671,7 +1681,7 @@ Decider::_cannot_decide_for(
if (existing_id)
unsuitable_candidates->push_back(_make_unsuitable_candidate(resolution, existing_id, true));
- const std::shared_ptr<const PackageIDSequence> installable_ids(_find_installable_id_candidates_for(resolution, true));
+ const std::shared_ptr<const PackageIDSequence> installable_ids(_find_installable_id_candidates_for(resolution, true, false));
for (PackageIDSequence::ConstIterator i(installable_ids->begin()), i_end(installable_ids->end()) ;
i != i_end ; ++i)
unsuitable_candidates->push_back(_make_unsuitable_candidate(resolution, *i, false));
@@ -1740,20 +1750,21 @@ Decider::_installed_ids(const std::shared_ptr<const Resolution> & resolution) co
const std::shared_ptr<const PackageIDSequence>
Decider::_find_installable_id_candidates_for(
const std::shared_ptr<const Resolution> & resolution,
- const bool include_errors) const
+ const bool include_errors,
+ const bool include_unmaskable) const
{
return (*_imp->env)[selection::AllVersionsSorted(
_make_origin_filtered_generator(generator::Package(resolution->resolvent().package()), resolution) |
make_slot_filter(resolution->resolvent()) |
filter::SupportsAction<InstallAction>() |
- ((! include_errors) ? Filter(filter::NotMasked()) : Filter(filter::All()))
+ (include_errors ? filter::All() : include_unmaskable ? _make_unmaskable_filter(resolution) : filter::NotMasked())
)];
}
const std::pair<const std::shared_ptr<const PackageID>, bool>
-Decider::_find_installable_id_for(const std::shared_ptr<const Resolution> & resolution) const
+Decider::_find_installable_id_for(const std::shared_ptr<const Resolution> & resolution, const bool include_unmaskable) const
{
- return _find_id_for_from(resolution, _find_installable_id_candidates_for(resolution, false));
+ return _find_id_for_from(resolution, _find_installable_id_candidates_for(resolution, false, include_unmaskable));
}
const std::pair<const std::shared_ptr<const PackageID>, bool>
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index 8ee8889..616f3ef 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -175,11 +175,16 @@ namespace paludis
const Generator &,
const std::shared_ptr<const Resolution> &) const;
+ Filter _make_unmaskable_filter(
+ const std::shared_ptr<const Resolution> &) const;
+
void _decide(const std::shared_ptr<Resolution> & resolution);
void _copy_other_destination_constraints(const std::shared_ptr<Resolution> & resolution);
const std::shared_ptr<Decision> _try_to_find_decision_for(
- const std::shared_ptr<const Resolution> & resolution) const;
+ const std::shared_ptr<const Resolution> & resolution,
+ const bool also_try_masked,
+ const bool try_masked_this_time) const;
const std::shared_ptr<Decision> _cannot_decide_for(
const std::shared_ptr<const Resolution> & resolution) const;
@@ -200,9 +205,11 @@ namespace paludis
const std::shared_ptr<const Resolution> &) const;
const std::shared_ptr<const PackageIDSequence> _find_installable_id_candidates_for(
const std::shared_ptr<const Resolution> &,
- const bool include_errors) const;
+ const bool include_errors,
+ const bool include_unmaskable) const;
const std::pair<const std::shared_ptr<const PackageID>, bool> _find_installable_id_for(
- const std::shared_ptr<const Resolution> &) const;
+ const std::shared_ptr<const Resolution> &,
+ const bool include_unmaskable) const;
const std::pair<const std::shared_ptr<const PackageID>, bool> _find_id_for_from(
const std::shared_ptr<const Resolution> &,
const std::shared_ptr<const PackageIDSequence> &) const;
diff --git a/paludis/resolver/resolver_functions.hh b/paludis/resolver/resolver_functions.hh
index dd59d18..9891eb5 100644
--- a/paludis/resolver/resolver_functions.hh
+++ b/paludis/resolver/resolver_functions.hh
@@ -61,6 +61,7 @@ namespace paludis
typedef Name<struct interest_in_spec_fn_name> interest_in_spec_fn;
typedef Name<struct make_destination_filtered_generator_fn_name> make_destination_filtered_generator_fn;
typedef Name<struct make_origin_filtered_generator_fn_name> make_origin_filtered_generator_fn;
+ typedef Name<struct make_unmaskable_filter_fn_name> make_unmaskable_filter_fn;
typedef Name<struct order_early_fn_name> order_early_fn;
typedef Name<struct prefer_or_avoid_fn_name> prefer_or_avoid_fn;
typedef Name<struct remove_if_dependent_fn_name> remove_if_dependent_fn;
@@ -145,6 +146,10 @@ namespace paludis
const std::shared_ptr<const Resolution> &
)> MakeOriginFilteredGeneratorFunction;
+ typedef std::function<Filter (
+ const std::shared_ptr<const Resolution> &
+ )> MakeUnmaskableFilterFunction;
+
typedef std::function<Tribool (
const std::shared_ptr<const Resolution> &
)> OrderEarlyFunction;
@@ -176,6 +181,8 @@ namespace paludis
MakeDestinationFilteredGeneratorFunction> make_destination_filtered_generator_fn;
NamedValue<n::make_origin_filtered_generator_fn,
MakeOriginFilteredGeneratorFunction> make_origin_filtered_generator_fn;
+ NamedValue<n::make_unmaskable_filter_fn,
+ MakeUnmaskableFilterFunction> make_unmaskable_filter_fn;
NamedValue<n::order_early_fn, OrderEarlyFunction> order_early_fn;
NamedValue<n::prefer_or_avoid_fn, PreferOrAvoidFunction> prefer_or_avoid_fn;
NamedValue<n::remove_if_dependent_fn, RemoveIfDependentFunction> remove_if_dependent_fn;
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index e553cfe..ba37e13 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -120,6 +120,13 @@ paludis::resolver::resolver_test::make_origin_filtered_generator_fn(const Genera
return g;
}
+Filter
+paludis::resolver::resolver_test::make_unmaskable_filter_fn(
+ const std::shared_ptr<const Resolution> &)
+{
+ return filter::NotMasked();
+}
+
DestinationTypes
paludis::resolver::resolver_test::get_destination_types_for_fn(const PackageDepSpec &,
const std::shared_ptr<const PackageID> &,
@@ -393,6 +400,7 @@ ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraint
n::interest_in_spec_fn() = &interest_in_spec_fn,
n::make_destination_filtered_generator_fn() = &make_destination_filtered_generator_fn,
n::make_origin_filtered_generator_fn() = &make_origin_filtered_generator_fn,
+ n::make_unmaskable_filter_fn() = &make_unmaskable_filter_fn,
n::order_early_fn() = &order_early_fn,
n::prefer_or_avoid_fn() = std::bind(&prefer_or_avoid_fn,
prefer_or_avoid_names, std::placeholders::_1),
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index 8cac1bd..e1be281 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -103,6 +103,9 @@ namespace paludis
FilteredGenerator make_origin_filtered_generator_fn(const Generator &,
const std::shared_ptr<const Resolution> &);
+ Filter make_unmaskable_filter_fn(
+ const std::shared_ptr<const Resolution> &);
+
DestinationTypes get_destination_types_for_fn(const PackageDepSpec &,
const std::shared_ptr<const PackageID> &,
const std::shared_ptr<const Reason> &);
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index da77f7a..f9432a8 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -25,6 +25,7 @@
#include "exceptions.hh"
#include "command_command_line.hh"
#include "match_qpns.hh"
+#include "not_strongly_masked.hh"
#include <paludis/util/mutex.hh>
#include <paludis/util/stringify.hh>
@@ -40,6 +41,7 @@
#include <paludis/util/make_shared_copy.hh>
#include <paludis/util/simple_visitor_cast.hh>
#include <paludis/util/sequence-impl.hh>
+#include <paludis/util/set-impl.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/args/do_help.hh>
@@ -63,6 +65,7 @@
#include <paludis/notifier_callback.hh>
#include <paludis/generator.hh>
#include <paludis/filter.hh>
+#include <paludis/filter_handler.hh>
#include <paludis/selection.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/version_spec.hh>
@@ -248,6 +251,46 @@ namespace
throw InternalError(PALUDIS_HERE, "bad dt");
}
+ struct UnmaskableFilterHandler :
+ AllFilterHandlerBase
+ {
+ virtual std::shared_ptr<const PackageIDSet> ids(
+ const Environment * const,
+ const std::shared_ptr<const PackageIDSet> & id) const
+ {
+ std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>());
+
+ for (PackageIDSet::ConstIterator i(id->begin()), i_end(id->end()) ;
+ i != i_end ; ++i)
+ if (not_strongly_masked(*i))
+ result->insert(*i);
+
+ return result;
+ }
+
+ virtual std::string as_string() const
+ {
+ return "unmaskable";
+ }
+ };
+
+ struct UnmaskableFilter :
+ Filter
+ {
+ UnmaskableFilter() :
+ Filter(std::make_shared<UnmaskableFilterHandler>())
+ {
+ }
+ };
+
+ Filter make_unmaskable_filter_fn(
+ const Environment * const,
+ const ResolveCommandLineResolutionOptions &,
+ const std::shared_ptr<const Resolution> &)
+ {
+ return UnmaskableFilter();
+ }
+
const std::shared_ptr<const Sequence<std::string> > add_resolver_targets(
const std::shared_ptr<Environment> & env,
const std::shared_ptr<Resolver> & resolver,
@@ -1848,6 +1891,8 @@ paludis::cave::resolve_common(
env.get(), std::cref(resolution_options), all_binary_repos_generator, _1, _2),
n::make_origin_filtered_generator_fn() = std::bind(&make_origin_filtered_generator,
env.get(), std::cref(resolution_options), not_binary_repos_generator, _1, _2),
+ n::make_unmaskable_filter_fn() = std::bind(&make_unmaskable_filter_fn,
+ env.get(), std::cref(resolution_options), _1),
n::order_early_fn() = std::bind(&order_early_fn,
env.get(), std::cref(resolution_options), std::cref(early), std::cref(late), _1),
n::prefer_or_avoid_fn() = std::bind(&prefer_or_avoid_fn,