aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-10-25 04:27:55 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-10-25 06:33:55 +0100
commitab50405a661d1e8af907aace115823ccd6be8a10 (patch)
tree698dfa9e4ee4934a5347e42b270f668df40ed6e6
parent6354fb6904e671e86c1d12df54315fafee32f41b (diff)
downloadpaludis-ab50405a661d1e8af907aace115823ccd6be8a10.tar.gz
paludis-ab50405a661d1e8af907aace115823ccd6be8a10.tar.xz
Make optionq a pipe command.
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/Makefile.am2
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/conditional_functions_TEST.bash6
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/list_functions.bash10
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/list_functions_TEST.bash80
-rw-r--r--paludis/repositories/e/pipe_command_handler.cc33
5 files changed, 44 insertions, 87 deletions
diff --git a/paludis/repositories/e/ebuild/exheres-0/Makefile.am b/paludis/repositories/e/ebuild/exheres-0/Makefile.am
index 5bf892a..c97b58a 100644
--- a/paludis/repositories/e/ebuild/exheres-0/Makefile.am
+++ b/paludis/repositories/e/ebuild/exheres-0/Makefile.am
@@ -57,7 +57,7 @@ TESTS_ENVIRONMENT = env \
PALUDIS_TMPDIR="`pwd`/" \
bash $(top_srcdir)/test/run_test.sh $(top_srcdir)/paludis/repositories/e/ebuild/run_test.bash
-TESTS = conditional_functions_TEST.bash list_functions_TEST.bash
+TESTS = conditional_functions_TEST.bash
check_SCRIPTS = $(TESTS)
EXTRA_DIST = $(libexecprogexheres_SCRIPTS) $(check_SCRIPTS)
diff --git a/paludis/repositories/e/ebuild/exheres-0/conditional_functions_TEST.bash b/paludis/repositories/e/ebuild/exheres-0/conditional_functions_TEST.bash
index 7eea6d1..7e46327 100644
--- a/paludis/repositories/e/ebuild/exheres-0/conditional_functions_TEST.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/conditional_functions_TEST.bash
@@ -16,6 +16,12 @@
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA
+# the real optionq is a pipe command
+optionq()
+{
+ hasq "$1" $OPTIONS
+}
+
option_with_TEST()
{
export OPTIONS="foo blah:moo" MYOPTIONS="foo bar baz blah:moo"
diff --git a/paludis/repositories/e/ebuild/exheres-0/list_functions.bash b/paludis/repositories/e/ebuild/exheres-0/list_functions.bash
index d22c90f..0c5e076 100644
--- a/paludis/repositories/e/ebuild/exheres-0/list_functions.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/list_functions.bash
@@ -58,15 +58,13 @@ optionv()
optionq()
{
- if ! hasq "${1#!}" "${MYOPTIONS}" ; then
- die "optionq ${1} called but ${1#!} not in \${MYOPTIONS}=${MYOPTIONS}"
- fi
-
+ [[ "${#@}" -ne 1 ]] && die "$0 should take exactly one arg"
if [[ "${1:0:1}" == "!" ]] ; then
- ! hasq "${1#!}" "${OPTIONS}"
+ local r=$(paludis_pipe_command OPTIONQ "$EAPI" "${1#!}" )
else
- hasq "${1}" "${OPTIONS}"
+ local r=$(paludis_pipe_command OPTIONQ "$EAPI" "$1" )
fi
+ return ${r%%;*}
}
has()
diff --git a/paludis/repositories/e/ebuild/exheres-0/list_functions_TEST.bash b/paludis/repositories/e/ebuild/exheres-0/list_functions_TEST.bash
deleted file mode 100644
index bb7c09e..0000000
--- a/paludis/repositories/e/ebuild/exheres-0/list_functions_TEST.bash
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/usr/bin/env bash
-# vim: set sw=4 sts=4 et :
-
-# Copyright (c) 2006, 2008 Ciaran McCreesh
-#
-# 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 optionful, 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
-
-option_TEST()
-{
- export OPTIONS="foo bar" MYOPTIONS="foo bar baz foofoo fo"
-
- option foo ; test_return_code
- option bar ; test_return_code
- ! option baz ; test_return_code
- ! option foofoo ; test_return_code
- ! option fo ; test_return_code
-
- ! option !foo ; test_return_code
- ! option !bar ; test_return_code
- option !baz ; test_return_code
- option !foofoo ; test_return_code
- option !fo ; test_return_code
-}
-
-optionv_TEST()
-{
- export OPTIONS="foo bar moo:oink" MYOPTIONS="foo bar baz moo:oink moo:baah"
- optionv foo 1>/dev/null ; test_return_code
- test_equality "$(optionv foo)" "foo"
-
- optionv bar 1>/dev/null ; test_return_code
- test_equality "$(optionv bar)" "bar"
-
- optionv moo:oink 1>/dev/null ; test_return_code
- test_equality "$(optionv moo:oink )" "oink"
-
- ! optionv moo:baah 1>/dev/null ; test_return_code
- test_equality "$(optionv moo:baah )" ""
-
- ! optionv baz 1>/dev/null ; test_return_code
- test_equality "$(optionv baz)" ""
-
- ! optionv !foo 1>/dev/null ; test_return_code
- test_equality "$(optionv !foo)" ""
-
- ! optionv !bar 1>/dev/null ; test_return_code
- test_equality "$(optionv !bar)" ""
-
- ! optionv baz 1>/dev/null ; test_return_code
- test_equality "$(optionv !baz)" "baz"
-}
-
-optionq_TEST()
-{
- export option="foo bar" MYOPTIONS="foo bar baz foofoo fo"
-
- optionq foo ; test_return_code
- optionq bar ; test_return_code
- ! optionq baz ; test_return_code
- ! optionq foofoo ; test_return_code
- ! optionq fo ; test_return_code
-
- ! optionq !foo ; test_return_code
- ! optionq !bar ; test_return_code
- optionq !baz ; test_return_code
- optionq !foofoo ; test_return_code
- optionq !fo ; test_return_code
-}
-
diff --git a/paludis/repositories/e/pipe_command_handler.cc b/paludis/repositories/e/pipe_command_handler.cc
index a6e28b5..5157c7f 100644
--- a/paludis/repositories/e/pipe_command_handler.cc
+++ b/paludis/repositories/e/pipe_command_handler.cc
@@ -42,6 +42,7 @@
#include <paludis/generator.hh>
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
+#include <paludis/choice.hh>
#include <vector>
using namespace paludis;
@@ -222,6 +223,38 @@ paludis::erepository::pipe_command_handler(const Environment * const environment
return "O0;" + stringify(visitor_cast<const MetadataValueKey<FSEntry> >(**key)->value());
}
}
+ else if (tokens[0] == "OPTIONQ")
+ {
+ if (tokens.size() != 3)
+ {
+ Log::get_instance()->message("e.pipe_commands.has_version.bad", ll_warning, lc_context) << "Got bad OPTIONQ pipe command";
+ return "Ebad OPTIONQ command";
+ }
+ else
+ {
+ std::tr1::shared_ptr<const EAPI> eapi(EAPIData::get_instance()->eapi_from_string(tokens[1]));
+ if (! eapi->supported())
+ return "EOPTIONQ EAPI " + tokens[1] + " unsupported";
+
+ if (! package_id->choices_key())
+ return "EOPTIONQ ID " + stringify(*package_id) + " has no choices";
+
+ ChoiceNameWithPrefix name(tokens[2]);
+ std::tr1::shared_ptr<const ChoiceValue> value(package_id->choices_key()->value()->find_by_name_with_prefix(name));
+ if (! value)
+ {
+ if (package_id->choices_key()->value()->has_matching_contains_every_value_prefix(name))
+ return "O1;";
+
+ return "EOPTIONQ ID " + stringify(*package_id) + " has no choice named '" + stringify(name) + "'";
+ }
+
+ if (value->enabled())
+ return "O0;";
+ else
+ return "O1;";
+ }
+ }
else if (tokens[0] == "REWRITE_VAR")
{
if (tokens.size() < 4)