aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-27 09:27:22 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-27 09:27:22 +0100
commitb3aa56d3b44f81fa2d341d193f0648be4d5f1390 (patch)
tree3655dcf0df49a40537b784b01048657bbdc7886c
parent21e700c5c139d54c1db760d9fadc3ceb513886fa (diff)
downloadpaludis-b3aa56d3b44f81fa2d341d193f0648be4d5f1390.tar.gz
paludis-b3aa56d3b44f81fa2d341d193f0648be4d5f1390.tar.xz
not-usable
-rw-r--r--paludis/resolver/decider.cc20
-rw-r--r--paludis/resolver/decider.hh3
-rw-r--r--paludis/resolver/resolver_functions.hh6
-rw-r--r--paludis/resolver/resolver_test.cc8
-rw-r--r--paludis/resolver/resolver_test.hh3
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.cc5
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.hh3
-rw-r--r--src/clients/cave/resolve_common.cc18
8 files changed, 61 insertions, 5 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 8e127bd..4db6eee 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -1794,7 +1794,7 @@ Decider::resolve()
bool
Decider::_already_met(const SanitisedDependency & dep) const
{
- const std::tr1::shared_ptr<const PackageIDSequence> installed_ids((*_imp->env)[selection::BestVersionOnly(
+ const std::tr1::shared_ptr<const PackageIDSequence> installed_ids((*_imp->env)[selection::AllVersionsUnsorted(
generator::Matches(dep.spec().if_package() ?
*dep.spec().if_package() :
dep.spec().if_block()->blocking(),
@@ -1803,7 +1803,23 @@ Decider::_already_met(const SanitisedDependency & dep) const
if (installed_ids->empty())
return dep.spec().if_block();
else
- return dep.spec().if_package();
+ {
+ if (dep.spec().if_block())
+ return false;
+
+ if (installed_ids->end() == std::find_if(installed_ids->begin(), installed_ids->end(),
+ std::tr1::bind(&Decider::_can_use, this, std::tr1::placeholders::_1)))
+ return false;
+
+ return true;
+ }
+}
+
+bool
+Decider::_can_use(
+ const std::tr1::shared_ptr<const PackageID> & id) const
+{
+ return _imp->fns.can_use_fn()(id);
}
namespace
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index d57b495..fa4dd21 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -236,6 +236,9 @@ namespace paludis
const std::tr1::shared_ptr<const PackageIDSet> _collect_world(
const std::tr1::shared_ptr<const PackageIDSet> & from) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ bool _can_use(
+ 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 16ddf81..da50574 100644
--- a/paludis/resolver/resolver_functions.hh
+++ b/paludis/resolver/resolver_functions.hh
@@ -46,6 +46,7 @@ namespace paludis
namespace n
{
typedef Name<struct allowed_to_remove_fn_name> allowed_to_remove_fn;
+ typedef Name<struct can_use_fn_name> can_use_fn;
typedef Name<struct confirm_fn_name> confirm_fn;
typedef Name<struct find_repository_for_fn_name> find_repository_for_fn;
typedef Name<struct get_constraints_for_dependent_fn_name> get_constraints_for_dependent_fn;
@@ -68,6 +69,10 @@ namespace paludis
)> AllowedToRemoveFunction;
typedef std::tr1::function<bool (
+ const std::tr1::shared_ptr<const PackageID> &
+ )> CanUseFunction;
+
+ typedef std::tr1::function<bool (
const std::tr1::shared_ptr<const Resolution> &,
const std::tr1::shared_ptr<const RequiredConfirmation> &
)> ConfirmFunction;
@@ -132,6 +137,7 @@ namespace paludis
struct ResolverFunctions
{
NamedValue<n::allowed_to_remove_fn, AllowedToRemoveFunction> allowed_to_remove_fn;
+ NamedValue<n::can_use_fn, CanUseFunction> can_use_fn;
NamedValue<n::confirm_fn, ConfirmFunction> confirm_fn;
NamedValue<n::find_repository_for_fn, FindRepositoryForFunction> find_repository_for_fn;
NamedValue<n::get_constraints_for_dependent_fn, GetConstraintsForDependentFunction> get_constraints_for_dependent_fn;
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 8ad242d..04f2e01 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -338,6 +338,13 @@ paludis::resolver::resolver_test::get_constraints_for_purge_fn(
return result;
}
+bool
+paludis::resolver::resolver_test::can_use_fn(
+ const std::tr1::shared_ptr<const PackageID> &)
+{
+ return true;
+}
+
ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s, const std::string & e,
const std::string & l) :
TestCase(s),
@@ -391,6 +398,7 @@ ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraint
return make_named_values<ResolverFunctions>(
n::allowed_to_remove_fn() = std::tr1::bind(&allowed_to_remove_fn,
allowed_to_remove_names, std::tr1::placeholders::_1, std::tr1::placeholders::_2),
+ n::can_use_fn() = &can_use_fn,
n::confirm_fn() = &confirm_fn,
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 8616f36..06bff90 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -116,6 +116,9 @@ namespace paludis
const std::tr1::shared_ptr<const Resolution> &,
const std::tr1::shared_ptr<const RequiredConfirmation> &);
+ bool can_use_fn(
+ const std::tr1::shared_ptr<const PackageID> &);
+
struct ResolverTestCase : test::TestCase
{
TestEnvironment env;
diff --git a/src/clients/cave/cmd_resolve_cmdline.cc b/src/clients/cave/cmd_resolve_cmdline.cc
index 5664738..f5b1805 100644
--- a/src/clients/cave/cmd_resolve_cmdline.cc
+++ b/src/clients/cave/cmd_resolve_cmdline.cc
@@ -206,7 +206,10 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
a_avoid(&g_package_options, "avoid", 'A', "If there is a choice (e.g. || ( ) dependencies), avoid the "
"specified package names"),
-// g_ordering_options(this, "Package Ordering Options", "Control the order in which packages are installed"),
+ g_ordering_options(this, "Package Ordering Options", "Control the order in which packages are installed"),
+ a_not_usable(&g_ordering_options, "not-usable", 'N', "Consider installed packages matching the supplied specification "
+ "as being unusable when breaking dependency cycles. May be specified multiple times. Note that this option "
+ "affects only ordering; it does not also force a reinstall of these packages."),
// a_early(&g_ordering_options, "early", 'E', "Try to install the specified package name as early as possible"),
// a_late(&g_ordering_options, "late", 'L', "Try to install the specified package name as late as possible"),
diff --git a/src/clients/cave/cmd_resolve_cmdline.hh b/src/clients/cave/cmd_resolve_cmdline.hh
index 4ae212d..c3e1178 100644
--- a/src/clients/cave/cmd_resolve_cmdline.hh
+++ b/src/clients/cave/cmd_resolve_cmdline.hh
@@ -82,7 +82,8 @@ namespace paludis
args::StringSetArg a_favour;
args::StringSetArg a_avoid;
-// args::ArgsGroup g_ordering_options;
+ args::ArgsGroup g_ordering_options;
+ args::StringSetArg a_not_usable;
// args::StringSetArg a_early;
// args::StringSetArg a_late;
//
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 84e6fb0..dfef5af 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -1294,6 +1294,14 @@ namespace
return result;
}
+ bool can_use_fn(
+ const Environment * const env,
+ const PackageDepSpecList & list,
+ const std::tr1::shared_ptr<const PackageID> & id)
+ {
+ return ! match_any(env, list, id);
+ }
+
void serialise_resolved(StringListStream & ser_stream, const Resolved & resolved)
{
Serialiser ser(ser_stream);
@@ -1581,7 +1589,7 @@ paludis::cave::resolve_common(
PackageDepSpecList allowed_to_remove_specs, allowed_to_break_specs, remove_if_dependent_specs,
less_restrictive_remove_blockers_specs, purge_specs, with, without,
permit_old_version, permit_downgrade, take, take_from, ignore, ignore_from,
- favour, avoid, no_dependencies_from, no_blockers_from;
+ favour, avoid, no_dependencies_from, no_blockers_from, not_usable_specs;
bool allowed_to_break_system(false);
for (args::StringSetArg::ConstIterator i(resolution_options.a_permit_uninstall.begin_args()),
@@ -1689,6 +1697,12 @@ paludis::cave::resolve_common(
permit_old_version.push_back(parse_user_package_dep_spec(*i, env.get(),
UserPackageDepSpecOptions() + updso_allow_wildcards));
+ for (args::StringSetArg::ConstIterator i(resolution_options.a_not_usable.begin_args()),
+ i_end(resolution_options.a_not_usable.end_args()) ;
+ i != i_end ; ++i)
+ not_usable_specs.push_back(parse_user_package_dep_spec(*i, env.get(),
+ UserPackageDepSpecOptions() + updso_allow_wildcards));
+
std::tr1::shared_ptr<Generator> all_binary_repos_generator;
for (PackageDatabase::RepositoryConstIterator r(env->package_database()->begin_repositories()),
r_end(env->package_database()->end_repositories()) ;
@@ -1742,6 +1756,8 @@ paludis::cave::resolve_common(
ResolverFunctions resolver_functions(make_named_values<ResolverFunctions>(
n::allowed_to_remove_fn() = std::tr1::bind(&allowed_to_remove_fn,
env.get(), std::tr1::cref(allowed_to_remove_specs), _1, _2),
+ n::can_use_fn() = std::tr1::bind(&can_use_fn,
+ env.get(), std::tr1::cref(not_usable_specs), _1),
n::confirm_fn() = std::tr1::bind(&confirm_fn,
env.get(), std::tr1::cref(resolution_options), std::tr1::cref(permit_downgrade),
std::tr1::cref(permit_old_version), std::tr1::cref(allowed_to_break_specs),