aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-29 21:17:31 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-29 21:17:31 +0100
commit8c633c6a6baf8a308bd82ec9b9a167a81ab35698 (patch)
tree5b999c40fddb1ba2623d174e1fb4e52e6653af4d
parent0bb5b18aceff1894ca456d21e836af7d878c87ac (diff)
downloadpaludis-8c633c6a6baf8a308bd82ec9b9a167a81ab35698.tar.gz
paludis-8c633c6a6baf8a308bd82ec9b9a167a81ab35698.tar.xz
cave resolve --early / --late
-rw-r--r--paludis/resolver/orderer.cc11
-rw-r--r--paludis/resolver/orderer.hh2
-rw-r--r--paludis/resolver/resolver.cc2
-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.cc6
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.hh6
-rw-r--r--src/clients/cave/resolve_common.cc36
9 files changed, 70 insertions, 10 deletions
diff --git a/paludis/resolver/orderer.cc b/paludis/resolver/orderer.cc
index 3ce4eaa..f4822a8 100644
--- a/paludis/resolver/orderer.cc
+++ b/paludis/resolver/orderer.cc
@@ -33,6 +33,7 @@
#include <paludis/resolver/destination.hh>
#include <paludis/resolver/orderer_notes.hh>
#include <paludis/resolver/change_by_resolvent.hh>
+#include <paludis/resolver/resolver_functions.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/stringify.hh>
@@ -63,6 +64,7 @@ namespace paludis
struct Implementation<Orderer>
{
const Environment * const env;
+ const ResolverFunctions fns;
const std::tr1::shared_ptr<Resolved> resolved;
ChangeOrRemoveIndices change_or_remove_indices;
FetchJobNumbers fetch_job_numbers;
@@ -70,8 +72,10 @@ namespace paludis
Implementation(
const Environment * const e,
+ const ResolverFunctions & f,
const std::tr1::shared_ptr<Resolved> & r) :
env(e),
+ fns(f),
resolved(r)
{
}
@@ -80,8 +84,9 @@ namespace paludis
Orderer::Orderer(
const Environment * const e,
+ const ResolverFunctions & f,
const std::tr1::shared_ptr<Resolved> & r) :
- PrivateImplementationPattern<Orderer>(new Implementation<Orderer>(e, r))
+ PrivateImplementationPattern<Orderer>(new Implementation<Orderer>(e, f, r))
{
}
@@ -441,9 +446,9 @@ namespace
}
Tribool
-Orderer::_order_early(const NAGIndex &) const
+Orderer::_order_early(const NAGIndex & i) const
{
- return indeterminate;
+ return _imp->fns.order_early_fn()(*_imp->resolved->resolutions_by_resolvent()->find(i.resolvent()));
}
void
diff --git a/paludis/resolver/orderer.hh b/paludis/resolver/orderer.hh
index 72e656f..b944011 100644
--- a/paludis/resolver/orderer.hh
+++ b/paludis/resolver/orderer.hh
@@ -27,6 +27,7 @@
#include <paludis/resolver/strongly_connected_component-fwd.hh>
#include <paludis/resolver/nag-fwd.hh>
#include <paludis/resolver/resolvent-fwd.hh>
+#include <paludis/resolver/resolver_functions-fwd.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/tribool-fwd.hh>
#include <paludis/environment-fwd.hh>
@@ -66,6 +67,7 @@ namespace paludis
public:
Orderer(
const Environment * const,
+ const ResolverFunctions &,
const std::tr1::shared_ptr<Resolved> &);
~Orderer();
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index f35ccae..1bfc955 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -78,7 +78,7 @@ namespace paludis
n::untaken_unable_to_make_decisions() = make_shared_ptr(new Decisions<UnableToMakeDecision>)
))),
decider(new Decider(e, f, resolved->resolutions_by_resolvent())),
- orderer(new Orderer(e, resolved))
+ orderer(new Orderer(e, f, resolved))
{
}
};
diff --git a/paludis/resolver/resolver_functions.hh b/paludis/resolver/resolver_functions.hh
index 1d7ece3..64a3b76 100644
--- a/paludis/resolver/resolver_functions.hh
+++ b/paludis/resolver/resolver_functions.hh
@@ -58,6 +58,7 @@ namespace paludis
typedef Name<struct get_use_existing_fn_name> get_use_existing_fn;
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 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;
}
@@ -128,6 +129,10 @@ namespace paludis
)> MakeDestinationFilteredGeneratorFunction;
typedef std::tr1::function<Tribool (
+ const std::tr1::shared_ptr<const Resolution> &
+ )> OrderEarlyFunction;
+
+ typedef std::tr1::function<Tribool (
const QualifiedPackageName &
)> PreferOrAvoidFunction;
@@ -150,6 +155,7 @@ namespace paludis
NamedValue<n::interest_in_spec_fn, InterestInSpecFunction> interest_in_spec_fn;
NamedValue<n::make_destination_filtered_generator_fn,
MakeDestinationFilteredGeneratorFunction> make_destination_filtered_generator_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 013b12a..6278334 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -269,6 +269,13 @@ paludis::resolver::resolver_test::prefer_or_avoid_fn(
return indeterminate;
}
+Tribool
+paludis::resolver::resolver_test::order_early_fn(
+ const std::tr1::shared_ptr<const Resolution> &)
+{
+ return indeterminate;
+}
+
bool
paludis::resolver::resolver_test::confirm_fn(
const std::tr1::shared_ptr<const Resolution> &,
@@ -413,6 +420,7 @@ ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraint
n::get_use_existing_fn() = &get_use_existing_fn,
n::interest_in_spec_fn() = &interest_in_spec_fn,
n::make_destination_filtered_generator_fn() = &make_destination_filtered_generator_fn,
+ n::order_early_fn() = &order_early_fn,
n::prefer_or_avoid_fn() = std::tr1::bind(&prefer_or_avoid_fn,
prefer_or_avoid_names, std::tr1::placeholders::_1),
n::remove_if_dependent_fn() = std::tr1::bind(&remove_if_dependent_fn,
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index 8d5e4cc..fe50343 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -113,6 +113,9 @@ namespace paludis
const std::tr1::shared_ptr<const Map<QualifiedPackageName, bool> > &,
const QualifiedPackageName &);
+ Tribool order_early_fn(
+ const std::tr1::shared_ptr<const Resolution> &);
+
bool confirm_fn(
const std::tr1::shared_ptr<const Resolution> &,
const std::tr1::shared_ptr<const RequiredConfirmation> &);
diff --git a/src/clients/cave/cmd_resolve_cmdline.cc b/src/clients/cave/cmd_resolve_cmdline.cc
index 2a2b301..bb4acb0 100644
--- a/src/clients/cave/cmd_resolve_cmdline.cc
+++ b/src/clients/cave/cmd_resolve_cmdline.cc
@@ -210,8 +210,10 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
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"),
+ a_early(&g_ordering_options, "early", 'E', "When given a collection of otherwise equally desirable packages to order, "
+ "order packages matching the supplied spec first."),
+ a_late(&g_ordering_options, "late", 'L', "When given a collection of otherwise equally desirable packages to order, "
+ "order packages matching the supplied spec last."),
g_preset_options(this, "Preset Options", "Preset various constraints."),
a_preset(&g_preset_options, "preset", 'p', "Preset a given constraint. For example, --preset =cat/pkg-2.1 will tell "
diff --git a/src/clients/cave/cmd_resolve_cmdline.hh b/src/clients/cave/cmd_resolve_cmdline.hh
index 1c57c13..d872139 100644
--- a/src/clients/cave/cmd_resolve_cmdline.hh
+++ b/src/clients/cave/cmd_resolve_cmdline.hh
@@ -84,9 +84,9 @@ namespace paludis
args::ArgsGroup g_ordering_options;
args::StringSetArg a_not_usable;
-// args::StringSetArg a_early;
-// args::StringSetArg a_late;
-//
+ args::StringSetArg a_early;
+ args::StringSetArg a_late;
+
args::ArgsGroup g_preset_options;
args::StringSetArg a_preset;
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index ee95060..04558ec 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -1170,6 +1170,26 @@ namespace
}
};
+ Tribool order_early_fn(
+ const Environment * const env,
+ const ResolveCommandLineResolutionOptions &,
+ const PackageDepSpecList & early,
+ const PackageDepSpecList & late,
+ const std::tr1::shared_ptr<const Resolution> & r)
+ {
+ const std::tr1::shared_ptr<const PackageID> id(r->decision()->accept_returning<std::tr1::shared_ptr<const PackageID> >(
+ ChosenIDVisitor()));
+ if (id)
+ {
+ if (match_any(env, early, id))
+ return true;
+ if (match_any(env, late, id))
+ return false;
+ }
+
+ return indeterminate;
+ }
+
struct ConfirmFnVisitor
{
const Environment * const env;
@@ -1643,7 +1663,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, not_usable_specs;
+ favour, avoid, early, late, 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()),
@@ -1727,6 +1747,18 @@ paludis::cave::resolve_common(
avoid.push_back(parse_user_package_dep_spec(*i, env.get(),
UserPackageDepSpecOptions() + updso_allow_wildcards));
+ for (args::StringSetArg::ConstIterator i(resolution_options.a_early.begin_args()),
+ i_end(resolution_options.a_early.end_args()) ;
+ i != i_end ; ++i)
+ early.push_back(parse_user_package_dep_spec(*i, env.get(),
+ UserPackageDepSpecOptions() + updso_allow_wildcards));
+
+ for (args::StringSetArg::ConstIterator i(resolution_options.a_late.begin_args()),
+ i_end(resolution_options.a_late.end_args()) ;
+ i != i_end ; ++i)
+ late.push_back(parse_user_package_dep_spec(*i, env.get(),
+ UserPackageDepSpecOptions() + updso_allow_wildcards));
+
for (args::StringSetArg::ConstIterator i(resolution_options.a_no_dependencies_from.begin_args()),
i_end(resolution_options.a_no_dependencies_from.end_args()) ;
i != i_end ; ++i)
@@ -1841,6 +1873,8 @@ paludis::cave::resolve_common(
std::tr1::cref(no_dependencies_from), _1, _2),
n::make_destination_filtered_generator_fn() = std::tr1::bind(&make_destination_filtered_generator,
env.get(), std::tr1::cref(resolution_options), all_binary_repos_generator, _1, _2),
+ n::order_early_fn() = std::tr1::bind(&order_early_fn,
+ env.get(), std::tr1::cref(resolution_options), std::tr1::cref(early), std::tr1::cref(late), _1),
n::prefer_or_avoid_fn() = std::tr1::bind(&prefer_or_avoid_fn,
env.get(), std::tr1::cref(resolution_options), std::tr1::cref(favour), std::tr1::cref(avoid), _1),
n::remove_if_dependent_fn() = std::tr1::bind(&remove_if_dependent_fn,