aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-06 16:17:50 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-06 16:17:50 +0000
commit0684b88b371a7e9059ce207ba9f9fd702378ba7d (patch)
treefd02ccada52a2bc448fadb99b89185607bf1e958
parent992b06a0a6360dfd0d0788b4b004c9204198e490 (diff)
downloadpaludis-0684b88b371a7e9059ce207ba9f9fd702378ba7d.tar.gz
paludis-0684b88b371a7e9059ce207ba9f9fd702378ba7d.tar.xz
Simple --preset support
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.cc9
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.hh6
-rw-r--r--src/clients/cave/resolve_common.cc40
3 files changed, 45 insertions, 10 deletions
diff --git a/src/clients/cave/cmd_resolve_cmdline.cc b/src/clients/cave/cmd_resolve_cmdline.cc
index 68de0e0..6a53b65 100644
--- a/src/clients/cave/cmd_resolve_cmdline.cc
+++ b/src/clients/cave/cmd_resolve_cmdline.cc
@@ -174,10 +174,11 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
// 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"),
-// 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::/ will tell "
-// "the resolver to use the installed cat/pkg. Note that this may lead to errors, if the installed cat/pkg "
-// "does not satisfy other constraints."),
+ 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 "
+ "the resolver to use that particular version. Note that this may lead to errors, if the specified version "
+ "does not satisfy other constraints. Also note that specifying a preset will not force a package to be "
+ "considered if it would otherwise not be part of the resolution set."),
g_destination_options(this, "Destination Options", "Control to which destinations packages are installed. "
"If no options from this group are selected, install only to /. Otherwise, install to all of the "
diff --git a/src/clients/cave/cmd_resolve_cmdline.hh b/src/clients/cave/cmd_resolve_cmdline.hh
index 8700ba6..2dc3f7b 100644
--- a/src/clients/cave/cmd_resolve_cmdline.hh
+++ b/src/clients/cave/cmd_resolve_cmdline.hh
@@ -78,9 +78,9 @@ namespace paludis
// args::StringSetArg a_early;
// args::StringSetArg a_late;
//
-// args::ArgsGroup g_preset_options;
-// args::StringSetArg a_preset;
-//
+ args::ArgsGroup g_preset_options;
+ args::StringSetArg a_preset;
+
args::ArgsGroup g_destination_options;
// args::SwitchArg a_fetch;
args::StringSetArg a_create_binaries;
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 334b9ea..db973e9 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -294,7 +294,7 @@ namespace
{
}
- DestinationTypes visit(const TargetReason &) const
+ DestinationTypes common_target() const
{
DestinationTypes result;
@@ -329,6 +329,11 @@ namespace
return result;
}
+ DestinationTypes visit(const TargetReason &) const
+ {
+ return common_target();
+ }
+
DestinationTypes visit(const DependencyReason & reason) const
{
DestinationTypes result;
@@ -350,9 +355,9 @@ namespace
return result;
}
- DestinationTypes visit(const PresetReason &) const PALUDIS_ATTRIBUTE((noreturn))
+ DestinationTypes visit(const PresetReason &) const
{
- throw InternalError(PALUDIS_HERE, "not sure what to do here yet");
+ return common_target();
}
DestinationTypes visit(const SetReason & r) const
@@ -1185,6 +1190,35 @@ paludis::cave::resolve_common(
allowed_to_remove_specs.push_back(parse_user_package_dep_spec(*i, env.get(),
UserPackageDepSpecOptions() + updso_allow_wildcards));
+ for (args::StringSetArg::ConstIterator i(resolution_options.a_preset.begin_args()),
+ i_end(resolution_options.a_preset.end_args()) ;
+ i != i_end ; ++i)
+ {
+ const std::tr1::shared_ptr<const Reason> reason(new PresetReason(make_shared_ptr(new TargetReason)));
+ PackageDepSpec spec(parse_user_package_dep_spec(*i, env.get(), UserPackageDepSpecOptions()));
+ const std::tr1::shared_ptr<const Resolvents> resolvents(get_resolvents_for_fn(
+ env.get(), resolution_options, spec, make_null_shared_ptr(), reason));
+
+ if (resolvents->empty())
+ throw args::DoHelp("Preset '" + *i + "' has no resolvents");
+
+ for (Resolvents::ConstIterator r(resolvents->begin()), r_end(resolvents->end()) ;
+ r != r_end ; ++r)
+ {
+ const std::tr1::shared_ptr<Constraint> constraint(new Constraint(make_named_values<Constraint>(
+ value_for<n::destination_type>(r->destination_type()),
+ value_for<n::nothing_is_fine_too>(true),
+ value_for<n::reason>(reason),
+ value_for<n::spec>(spec),
+ value_for<n::untaken>(false),
+ value_for<n::use_existing>(ue_if_possible)
+ )));
+ initial_constraints.insert(std::make_pair(*r, make_initial_constraints_for(
+ env.get(), resolution_options, *r))).first->second->add(
+ constraint);
+ }
+ }
+
ResolverFunctions resolver_functions(make_named_values<ResolverFunctions>(
value_for<n::allowed_to_remove_fn>(std::tr1::bind(&allowed_to_remove_fn,
env.get(),