aboutsummaryrefslogtreecommitdiff
path: root/src/clients/paludis
diff options
context:
space:
mode:
Diffstat (limited to 'src/clients/paludis')
-rw-r--r--src/clients/paludis/applets.cc42
-rw-r--r--src/clients/paludis/applets.hh3
-rw-r--r--src/clients/paludis/command_line.cc1
-rw-r--r--src/clients/paludis/command_line.hh3
-rw-r--r--src/clients/paludis/paludis.cc13
5 files changed, 61 insertions, 1 deletions
diff --git a/src/clients/paludis/applets.cc b/src/clients/paludis/applets.cc
index 296d829..59ac2b6 100644
--- a/src/clients/paludis/applets.cc
+++ b/src/clients/paludis/applets.cc
@@ -99,6 +99,48 @@ int do_best_version(tr1::shared_ptr<Environment> env)
return return_code;
}
+int do_match(tr1::shared_ptr<Environment> env)
+{
+ int return_code(0);
+
+ Context context("When performing match action from command line:");
+
+ std::string query(*CommandLine::get_instance()->begin_parameters());
+ tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(query, pds_pm_permissive));
+ tr1::shared_ptr<const PackageIDSequence> entries(env->package_database()->query(
+ query::Matches(*spec) & query::InstalledAtRoot(env->root()), qo_order_by_version));
+
+ while (! entries->empty())
+ {
+ if (! (*entries->last())->virtual_for_key())
+ break;
+
+ Log::get_instance()->message(ll_qa, lc_context) << "match of '" << query <<
+ "' resolves to '" << **entries->last() << "', which is a virtual for '"
+ << *(*entries->last())->virtual_for_key()->value() << "'. This will break with "
+ "new style virtuals.";
+ tr1::shared_ptr<PackageIDSequence> new_entries(new PackageIDSequence);
+ new_entries->push_back((*entries->last())->virtual_for_key()->value());
+ entries = new_entries;
+ }
+
+ if (entries->empty())
+ return_code = 1;
+ else
+ {
+ for (PackageIDSequence::Iterator i(entries->begin()), i_end(entries->end()) ; i != i_end ; ++i)
+ {
+ // don't include repo, it breaks built_with_use and the like.
+ std::string entry(
+ stringify((*i)->name()) + "-" +
+ stringify((*i)->version()));
+ std::cout << entry << std::endl;
+ }
+ }
+
+ return return_code;
+}
+
int do_environment_variable(tr1::shared_ptr<Environment> env)
{
int return_code(0);
diff --git a/src/clients/paludis/applets.hh b/src/clients/paludis/applets.hh
index 3d5d99c..25d3ecd 100644
--- a/src/clients/paludis/applets.hh
+++ b/src/clients/paludis/applets.hh
@@ -37,6 +37,9 @@ int do_has_version(paludis::tr1::shared_ptr<paludis::Environment>);
/// Handle --best-version.
int do_best_version(paludis::tr1::shared_ptr<paludis::Environment>);
+/// Handle --match.
+int do_match(paludis::tr1::shared_ptr<paludis::Environment>);
+
/// Handle --environment-variable.
int do_environment_variable(paludis::tr1::shared_ptr<paludis::Environment>);
diff --git a/src/clients/paludis/command_line.cc b/src/clients/paludis/command_line.cc
index ef4a5ec..64905d6 100644
--- a/src/clients/paludis/command_line.cc
+++ b/src/clients/paludis/command_line.cc
@@ -47,6 +47,7 @@ CommandLine::CommandLine() :
"Additional actions, mostly for script and internal use."),
a_has_version(&action_args_internal, "has-version", '\0', "Check whether the specified spec is installed"),
a_best_version(&action_args_internal, "best-version", '\0', "Display the best version of the specified spec"),
+ a_match(&action_args_internal, "match", '\0', "Display all installed packages matching the supplied argument"),
a_environment_variable(&action_args_internal, "environment-variable", '\0', "Display the value of an environment "
"variable for a particular package"),
a_configuration_variable(&action_args_internal, "configuration-variable", '\0', "Display the value of a "
diff --git a/src/clients/paludis/command_line.hh b/src/clients/paludis/command_line.hh
index 4a92ce4..55c8c2a 100644
--- a/src/clients/paludis/command_line.hh
+++ b/src/clients/paludis/command_line.hh
@@ -108,6 +108,9 @@ class CommandLine :
/// --best-version
paludis::args::SwitchArg a_best_version;
+ /// --match
+ paludis::args::SwitchArg a_match;
+
/// --environment-variable
paludis::args::SwitchArg a_environment_variable;
diff --git a/src/clients/paludis/paludis.cc b/src/clients/paludis/paludis.cc
index 6e43c19..5f8b3c7 100644
--- a/src/clients/paludis/paludis.cc
+++ b/src/clients/paludis/paludis.cc
@@ -233,7 +233,9 @@ main(int argc, char *argv[])
CommandLine::get_instance()->a_environment_variable.specified() +
CommandLine::get_instance()->a_configuration_variable.specified() +
CommandLine::get_instance()->a_info.specified() +
- CommandLine::get_instance()->a_best_version.specified()))
+ CommandLine::get_instance()->a_best_version.specified() +
+ CommandLine::get_instance()->a_match.specified()
+ ))
{
if ((1 == std::distance(CommandLine::get_instance()->begin_parameters(),
CommandLine::get_instance()->end_parameters())) &&
@@ -481,6 +483,15 @@ main(int argc, char *argv[])
return do_best_version(env);
}
+ if (CommandLine::get_instance()->a_match.specified())
+ {
+ if (1 != std::distance(CommandLine::get_instance()->begin_parameters(),
+ CommandLine::get_instance()->end_parameters()))
+ throw args::DoHelp("match action takes exactly one parameter");
+
+ return do_match(env);
+ }
+
if (CommandLine::get_instance()->a_environment_variable.specified())
{
if (2 != std::distance(CommandLine::get_instance()->begin_parameters(),