aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-05 15:15:24 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-05 15:33:40 +0000
commitcb3b5488fe3f74a6c1f1f3044a1ae746265b930c (patch)
tree42738f40636a6e1a56d4c6272d4f16dae6bdefe0
parent2f60a9e598fce6821b539b3883d76053933cfb3f (diff)
downloadpaludis-cb3b5488fe3f74a6c1f1f3044a1ae746265b930c.tar.gz
paludis-cb3b5488fe3f74a6c1f1f3044a1ae746265b930c.tar.xz
Allow blockers as resolver targets
-rw-r--r--paludis/resolver/decider.cc94
-rw-r--r--paludis/resolver/decider.hh8
-rw-r--r--paludis/resolver/resolver.cc2
-rw-r--r--paludis/resolver/resolver.hh5
-rw-r--r--paludis/resolver/resolver_test.cc2
-rw-r--r--paludis/resolver/resolver_test.hh2
6 files changed, 71 insertions, 42 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index f1b4f25..8fc3ab2 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -320,28 +320,35 @@ Decider::resolution_for_resolvent(const Resolvent & r) const
const std::tr1::shared_ptr<ConstraintSequence>
Decider::_make_constraints_from_target(
const Resolvent & resolvent,
- const PackageDepSpec & spec,
+ const PackageOrBlockDepSpec & spec,
const std::tr1::shared_ptr<const Reason> & reason) const
{
- const std::tr1::shared_ptr<ConstraintSequence> result(new ConstraintSequence);
- result->push_back(make_shared_ptr(new Constraint(make_named_values<Constraint>(
- value_for<n::destination_type>(resolvent.destination_type()),
- value_for<n::nothing_is_fine_too>(false),
- value_for<n::reason>(reason),
- value_for<n::spec>(spec),
- value_for<n::untaken>(false),
- value_for<n::use_existing>(_imp->fns.get_use_existing_fn()(resolvent, spec, reason))
- ))));
- return result;
+ if (spec.if_package())
+ {
+ const std::tr1::shared_ptr<ConstraintSequence> result(new ConstraintSequence);
+ result->push_back(make_shared_ptr(new Constraint(make_named_values<Constraint>(
+ value_for<n::destination_type>(resolvent.destination_type()),
+ value_for<n::nothing_is_fine_too>(false),
+ value_for<n::reason>(reason),
+ value_for<n::spec>(spec),
+ value_for<n::untaken>(false),
+ value_for<n::use_existing>(_imp->fns.get_use_existing_fn()(resolvent, *spec.if_package(), reason))
+ ))));
+ return result;
+ }
+ else if (spec.if_block())
+ return _make_constraints_from_blocker(resolvent, *spec.if_block(), reason);
+ else
+ throw InternalError(PALUDIS_HERE, "resolver bug: huh? it's not a block and it's not a package");
}
const std::tr1::shared_ptr<ConstraintSequence>
Decider::_make_constraints_from_dependency(const Resolvent & resolvent, const SanitisedDependency & dep,
const std::tr1::shared_ptr<const Reason> & reason) const
{
- const std::tr1::shared_ptr<ConstraintSequence> result(new ConstraintSequence);
if (dep.spec().if_package())
{
+ const std::tr1::shared_ptr<ConstraintSequence> result(new ConstraintSequence);
result->push_back(make_shared_ptr(new Constraint(make_named_values<Constraint>(
value_for<n::destination_type>(resolvent.destination_type()),
value_for<n::nothing_is_fine_too>(false),
@@ -352,28 +359,38 @@ Decider::_make_constraints_from_dependency(const Resolvent & resolvent, const Sa
value_for<n::use_existing>(_imp->fns.get_use_existing_fn()(
resolvent, *dep.spec().if_package(), reason))
))));
+ return result;
}
else if (dep.spec().if_block())
- {
- /* nothing is fine too if there's nothing installed matching the block. */
- const std::tr1::shared_ptr<const PackageIDSequence> ids((*_imp->env)[selection::SomeArbitraryVersion(
- generator::Matches(dep.spec().if_block()->blocking(), MatchPackageOptions()) |
- filter::InstalledAtRoot(FSEntry("/")))]);
-
- DestinationTypes destination_types(_get_destination_types_for_blocker(*dep.spec().if_block()));
- for (EnumIterator<DestinationType> t, t_end(last_dt) ; t != t_end ; ++t)
- if (destination_types[*t])
- result->push_back(make_shared_ptr(new Constraint(make_named_values<Constraint>(
- value_for<n::destination_type>(*t),
- value_for<n::nothing_is_fine_too>(ids->empty()),
- value_for<n::reason>(reason),
- value_for<n::spec>(dep.spec()),
- value_for<n::untaken>(false),
- value_for<n::use_existing>(ue_if_possible)
- ))));
- }
+ return _make_constraints_from_blocker(resolvent, *dep.spec().if_block(), reason);
else
throw InternalError(PALUDIS_HERE, "resolver bug: huh? it's not a block and it's not a package");
+}
+
+const std::tr1::shared_ptr<ConstraintSequence>
+Decider::_make_constraints_from_blocker(
+ const Resolvent &,
+ const BlockDepSpec & spec,
+ const std::tr1::shared_ptr<const Reason> & reason) const
+{
+ const std::tr1::shared_ptr<ConstraintSequence> result(new ConstraintSequence);
+
+ /* nothing is fine too if there's nothing installed matching the block. */
+ const std::tr1::shared_ptr<const PackageIDSequence> ids((*_imp->env)[selection::SomeArbitraryVersion(
+ generator::Matches(spec.blocking(), MatchPackageOptions()) |
+ filter::InstalledAtRoot(FSEntry("/")))]);
+
+ DestinationTypes destination_types(_get_destination_types_for_blocker(spec));
+ for (EnumIterator<DestinationType> t, t_end(last_dt) ; t != t_end ; ++t)
+ if (destination_types[*t])
+ result->push_back(make_shared_ptr(new Constraint(make_named_values<Constraint>(
+ value_for<n::destination_type>(*t),
+ value_for<n::nothing_is_fine_too>(ids->empty()),
+ value_for<n::reason>(reason),
+ value_for<n::spec>(spec),
+ value_for<n::untaken>(false),
+ value_for<n::use_existing>(ue_if_possible)
+ ))));
return result;
}
@@ -1370,14 +1387,13 @@ Decider::rewrite_if_special(
}
void
-Decider::add_target_with_reason(const PackageDepSpec & spec, const std::tr1::shared_ptr<const Reason> & reason)
+Decider::add_target_with_reason(const PackageOrBlockDepSpec & spec, const std::tr1::shared_ptr<const Reason> & reason)
{
Context context("When adding target '" + stringify(spec) + "':");
_imp->env->trigger_notifier_callback(NotifierCallbackResolverStepEvent());
- const std::tr1::shared_ptr<const RewrittenSpec> if_rewritten(
- rewrite_if_special(PackageOrBlockDepSpec(spec), make_null_shared_ptr()));
+ const std::tr1::shared_ptr<const RewrittenSpec> if_rewritten(rewrite_if_special(spec, make_null_shared_ptr()));
if (if_rewritten)
{
for (Sequence<PackageOrBlockDepSpec>::ConstIterator i(if_rewritten->specs()->begin()), i_end(if_rewritten->specs()->end()) ;
@@ -1389,9 +1405,17 @@ Decider::add_target_with_reason(const PackageDepSpec & spec, const std::tr1::sha
}
else
{
- std::tr1::shared_ptr<const Resolvents> resolvents(_get_resolvents_for(spec, reason));
+ PackageDepSpec base_spec(spec.if_package() ? *spec.if_package() : spec.if_block()->blocking());
+ std::tr1::shared_ptr<const Resolvents> resolvents(_get_resolvents_for(base_spec, reason));
if (resolvents->empty())
- resolvents = _get_error_resolvents_for(spec, reason);
+ {
+ if (spec.if_package())
+ resolvents = _get_error_resolvents_for(*spec.if_package(), reason);
+ else
+ {
+ /* blocking on something that doesn't exist is fine */
+ }
+ }
for (Resolvents::ConstIterator r(resolvents->begin()), r_end(resolvents->end()) ;
r != r_end ; ++r)
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index 5c35d6b..98c2b4d 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -73,13 +73,17 @@ namespace paludis
const std::tr1::shared_ptr<ConstraintSequence> _make_constraints_from_target(
const Resolvent &,
- const PackageDepSpec &,
+ const PackageOrBlockDepSpec &,
const std::tr1::shared_ptr<const Reason> &) const;
const std::tr1::shared_ptr<ConstraintSequence> _make_constraints_from_dependency(
const Resolvent &, const SanitisedDependency &,
const std::tr1::shared_ptr<const Reason> &) const;
+ const std::tr1::shared_ptr<ConstraintSequence> _make_constraints_from_blocker(
+ const Resolvent & resolvent, const BlockDepSpec & dep,
+ const std::tr1::shared_ptr<const Reason> & reason) const;
+
void _apply_resolution_constraint(const Resolvent &,
const std::tr1::shared_ptr<Resolution> &,
const std::tr1::shared_ptr<const Constraint> &);
@@ -185,7 +189,7 @@ namespace paludis
void resolve();
- void add_target_with_reason(const PackageDepSpec &, const std::tr1::shared_ptr<const Reason> &);
+ void add_target_with_reason(const PackageOrBlockDepSpec &, const std::tr1::shared_ptr<const Reason> &);
std::pair<AnyChildScore, OperatorScore> find_any_score(const Resolvent &, const SanitisedDependency &) const;
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index 4876cbb..0b308f8 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -84,7 +84,7 @@ Resolver::~Resolver()
}
void
-Resolver::add_target(const PackageDepSpec & spec)
+Resolver::add_target(const PackageOrBlockDepSpec & spec)
{
_imp->decider->add_target_with_reason(spec, make_shared_ptr(new TargetReason));
}
diff --git a/paludis/resolver/resolver.hh b/paludis/resolver/resolver.hh
index 0c98fa8..ce3fd1b 100644
--- a/paludis/resolver/resolver.hh
+++ b/paludis/resolver/resolver.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
@@ -27,6 +27,7 @@
#include <paludis/resolver/orderer-fwd.hh>
#include <paludis/resolver/resolutions-fwd.hh>
#include <paludis/resolver/resolver_lists-fwd.hh>
+#include <paludis/resolver/sanitised_dependencies-fwd.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/package_id-fwd.hh>
#include <paludis/dep_spec-fwd.hh>
@@ -51,7 +52,7 @@ namespace paludis
const ResolverFunctions &);
~Resolver();
- void add_target(const PackageDepSpec &);
+ void add_target(const PackageOrBlockDepSpec &);
void add_target(const SetName &);
void resolve();
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index de44a21..f11dce8 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -320,7 +320,7 @@ ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraint
}
const std::tr1::shared_ptr<const ResolverLists>
-ResolverTestCase::get_resolutions(const PackageDepSpec & target)
+ResolverTestCase::get_resolutions(const PackageOrBlockDepSpec & target)
{
InitialConstraints initial_constraints;
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index 77bc583..52161f4 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -104,7 +104,7 @@ namespace paludis
ResolverTestCase(const std::string & group, const std::string & test_name, const std::string & eapi,
const std::string & layout);
- const std::tr1::shared_ptr<const ResolverLists> get_resolutions(const PackageDepSpec & target);
+ const std::tr1::shared_ptr<const ResolverLists> get_resolutions(const PackageOrBlockDepSpec & target);
const std::tr1::shared_ptr<const ResolverLists> get_resolutions(const std::string & target);