aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-09-11 17:39:44 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-09-11 17:39:44 +0000
commit281da830d6be844e5e9b297adec7c956cdbf083e (patch)
tree71e66bf10e79b329a7e8040743b219cc3d415390
parent4f7b119192e1441a42406aa8d5f4100d20797844 (diff)
downloadpaludis-281da830d6be844e5e9b297adec7c956cdbf083e.tar.gz
paludis-281da830d6be844e5e9b297adec7c956cdbf083e.tar.xz
Implement portageq match. Ban portageq in exheres. Fixes: ticket:364
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/Makefile.am3
-rwxr-xr-xpaludis/repositories/e/ebuild/exheres-0/portage_stubs.bash62
-rw-r--r--paludis/repositories/e/ebuild/portage_stubs.bash10
-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
8 files changed, 134 insertions, 3 deletions
diff --git a/paludis/repositories/e/ebuild/exheres-0/Makefile.am b/paludis/repositories/e/ebuild/exheres-0/Makefile.am
index ff65f9a..1107108 100644
--- a/paludis/repositories/e/ebuild/exheres-0/Makefile.am
+++ b/paludis/repositories/e/ebuild/exheres-0/Makefile.am
@@ -8,7 +8,8 @@ libexecprogexheres_SCRIPTS = \
builtin_fetch.bash \
pkg_nofetch.bash \
list_functions.bash \
- echo_functions.bash
+ echo_functions.bash \
+ portage_stubs.bash
TESTS_ENVIRONMENT = env \
PALUDIS_EBUILD_DIR="$(top_srcdir)/paludis/repositories/e/ebuild/" \
diff --git a/paludis/repositories/e/ebuild/exheres-0/portage_stubs.bash b/paludis/repositories/e/ebuild/exheres-0/portage_stubs.bash
new file mode 100755
index 0000000..447b2c1
--- /dev/null
+++ b/paludis/repositories/e/ebuild/exheres-0/portage_stubs.bash
@@ -0,0 +1,62 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et :
+
+# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+#
+# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005
+# Gentoo Foundation and distributed under the terms of the GNU General
+# Public License v2.
+#
+# This file is part of the Paludis package manager. Paludis is free software;
+# you can redistribute it and/or modify it under the terms of the GNU General
+# Public License, version 2, as published by the Free Software Foundation.
+#
+# Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place, Suite 330, Boston, MA 02111-1307 USA
+
+has_version()
+{
+ ${PALUDIS_COMMAND} --has-version "$@"
+}
+
+portageq()
+{
+ die "Function 'portageq' banned in this EAPI"
+}
+
+best_version()
+{
+ ${PALUDIS_COMMAND} --best-version "$@"
+}
+
+vdb_path()
+{
+ die "Function 'vdb_path' banned in this EAPI"
+}
+
+check_KV()
+{
+ die "check_KV not implemented"
+}
+
+debug-print()
+{
+ die "Function 'debug-print' banned in this EAPI"
+}
+
+debug-print-function()
+{
+ die "Function 'debug-print-function' banned in this EAPI"
+}
+
+debug-print-section()
+{
+ die "Function 'debug-print-section' banned in this EAPI"
+}
+
diff --git a/paludis/repositories/e/ebuild/portage_stubs.bash b/paludis/repositories/e/ebuild/portage_stubs.bash
index 5fc6840..b69457d 100644
--- a/paludis/repositories/e/ebuild/portage_stubs.bash
+++ b/paludis/repositories/e/ebuild/portage_stubs.bash
@@ -1,7 +1,7 @@
#!/bin/bash
# vim: set sw=4 sts=4 et :
-# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
#
# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005
# Gentoo Foundation and distributed under the terms of the GNU General
@@ -46,6 +46,14 @@ portageq()
fi
elif [[ "$1" == "vdb_path" ]] ; then
vdb_path
+ elif [[ "$1" == "match" ]] ; then
+ if [[ "$(canonicalise $2 )" != "$(canonicalise $ROOT )" ]] ; then
+ eerror "Error emulating 'portageq $@':"
+ die "portageq match emulation only works on current ROOT"
+ else
+ shift ; shift
+ ${PALUDIS_COMMAND} --match "$@"
+ fi
else
eerror "Error emulating 'portageq $@':"
die "portageq emulation for $1 not implemented"
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(),