aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Mike Kelly <pioto@pioto.org> 2009-10-14 00:47:14 -0400
committerAvatar Mike Kelly <pioto@pioto.org> 2009-10-14 00:47:14 -0400
commit62ac75677e819b3fadf4ca35b682b4f875b8395f (patch)
treea7a392fd5fcd1cb6da5dc632cc2a914c3e9a2d95
parentd0be18dc7459b552d673a883c64c9927b7e5fade (diff)
downloadpaludis-62ac75677e819b3fadf4ca35b682b4f875b8395f.tar.gz
paludis-62ac75677e819b3fadf4ca35b682b4f875b8395f.tar.xz
cave resolve --{take,discard}{,-from}
-rw-r--r--src/clients/cave/cmd_resolve.cc51
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.cc16
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.hh8
3 files changed, 59 insertions, 16 deletions
diff --git a/src/clients/cave/cmd_resolve.cc b/src/clients/cave/cmd_resolve.cc
index b168b1d..2599ef4 100644
--- a/src/clients/cave/cmd_resolve.cc
+++ b/src/clients/cave/cmd_resolve.cc
@@ -23,6 +23,7 @@
#include "cmd_resolve_dump.hh"
#include "exceptions.hh"
#include "command_command_line.hh"
+#include "match_qpns.hh"
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/mutex.hh>
@@ -710,13 +711,55 @@ namespace
}
bool
- take_dependency_fn(const Environment * const,
+ take_dependency_fn(const Environment * const env,
const ResolveCommandLine & cmdline,
- const Resolvent &,
+ const Resolvent & resolvent,
const SanitisedDependency & dep,
const std::tr1::shared_ptr<const Reason> &)
{
- if (is_suggestion(dep))
+ bool suggestion(is_suggestion(dep)), recommendation(is_recommendation(dep));
+
+ if (suggestion || recommendation)
+ {
+ for (args::StringSetArg::ConstIterator a(cmdline.resolution_options.a_take.begin_args()),
+ a_end(cmdline.resolution_options.a_take.end_args()) ;
+ a != a_end ; ++a)
+ {
+ PackageDepSpec user_spec(parse_user_package_dep_spec(*a, env, UserPackageDepSpecOptions() + updso_allow_wildcards));
+ PackageDepSpec spec(*dep.spec().if_package());
+ if (match_qpns(*env, user_spec, *spec.package_ptr()))
+ return true;
+ }
+
+ for (args::StringSetArg::ConstIterator a(cmdline.resolution_options.a_take_from.begin_args()),
+ a_end(cmdline.resolution_options.a_take_from.end_args()) ;
+ a != a_end ; ++a)
+ {
+ PackageDepSpec user_spec(parse_user_package_dep_spec(*a, env, UserPackageDepSpecOptions() + updso_allow_wildcards));
+ if (match_qpns(*env, user_spec, resolvent.package()))
+ return true;
+ }
+
+ for (args::StringSetArg::ConstIterator a(cmdline.resolution_options.a_discard.begin_args()),
+ a_end(cmdline.resolution_options.a_discard.end_args()) ;
+ a != a_end ; ++a)
+ {
+ PackageDepSpec user_spec(parse_user_package_dep_spec(*a, env, UserPackageDepSpecOptions() + updso_allow_wildcards));
+ PackageDepSpec spec(*dep.spec().if_package());
+ if (match_qpns(*env, user_spec, *spec.package_ptr()))
+ return false;
+ }
+
+ for (args::StringSetArg::ConstIterator a(cmdline.resolution_options.a_discard_from.begin_args()),
+ a_end(cmdline.resolution_options.a_discard_from.end_args()) ;
+ a != a_end ; ++a)
+ {
+ PackageDepSpec user_spec(parse_user_package_dep_spec(*a, env, UserPackageDepSpecOptions() + updso_allow_wildcards));
+ if (match_qpns(*env, user_spec, resolvent.package()))
+ return false;
+ }
+ }
+ if (suggestion)
{
if (cmdline.resolution_options.a_suggestions.argument() == "take")
{
@@ -724,7 +767,7 @@ namespace
}
return false;
}
- if (is_recommendation(dep))
+ if (recommendation)
{
if (cmdline.resolution_options.a_recommendations.argument() == "take")
{
diff --git a/src/clients/cave/cmd_resolve_cmdline.cc b/src/clients/cave/cmd_resolve_cmdline.cc
index 612cf5b..6cf0c5d 100644
--- a/src/clients/cave/cmd_resolve_cmdline.cc
+++ b/src/clients/cave/cmd_resolve_cmdline.cc
@@ -137,14 +137,14 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
("display", "Display recommendations, but do not take them unless explicitly told to do so")
("take", "Take all recommendations"),
"take"),
-// a_take(&g_suggestion_options, "take", '\0', "Take any suggestion matching the supplied package specification"
-// " (e.g. --take 'app-vim/securemodelines' or --take 'app-vim/*')"),
-// a_take_from(&g_suggestion_options, "take-from", '\0', "Take all suggestions made by any package matching the "
-// "supplied package specification"),
-// a_discard(&g_suggestion_options, "discard", '\0', "Discard any suggestion matching the supplied package specification"),
-// a_discard_from(&g_suggestion_options, "discard-from", '\0', "Discard all suggestions made by any package matching the "
-// "supplied package specification"),
-//
+ a_take(&g_suggestion_options, "take", '\0', "Take any suggestion matching the supplied package specification"
+ " (e.g. --take 'app-vim/securemodelines' or --take 'app-vim/*')"),
+ a_take_from(&g_suggestion_options, "take-from", '\0', "Take all suggestions made by any package matching the "
+ "supplied package specification"),
+ a_discard(&g_suggestion_options, "discard", '\0', "Discard any suggestion matching the supplied package specification"),
+ a_discard_from(&g_suggestion_options, "discard-from", '\0', "Discard all suggestions made by any package matching the "
+ "supplied package specification"),
+
// g_package_options(this, "Package Selection Options", "Control which packages are selected."),
// a_prefer(&g_package_options, "prefer", '\0', "If there is a choice, prefer the specified package names"),
// a_avoid(&g_package_options, "avoid", '\0', "If there is a choice, avoid the specified package names"),
diff --git a/src/clients/cave/cmd_resolve_cmdline.hh b/src/clients/cave/cmd_resolve_cmdline.hh
index d89675e..66c7a09 100644
--- a/src/clients/cave/cmd_resolve_cmdline.hh
+++ b/src/clients/cave/cmd_resolve_cmdline.hh
@@ -66,10 +66,10 @@ namespace paludis
args::ArgsGroup g_suggestion_options;
args::EnumArg a_suggestions;
args::EnumArg a_recommendations;
- // args::StringSetArg a_take;
- // args::StringSetArg a_take_from;
- // args::StringSetArg a_discard;
- // args::StringSetArg a_discard_from;
+ args::StringSetArg a_take;
+ args::StringSetArg a_take_from;
+ args::StringSetArg a_discard;
+ args::StringSetArg a_discard_from;
// args::ArgsGroup g_package_options;
// args::StringSetArg a_prefer;