aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2009-07-16 19:39:10 +0100
committerAvatar David Leverton <levertond@googlemail.com> 2009-07-16 19:39:10 +0100
commitc6854af474b8260ef3225d1b6dcf5663af9201f1 (patch)
tree9ab7b9f92f84c5a68c8788c728c7d10fb23f0711
parent5724416dbdd008b44a6a1c27f0b3a7790e9a125a (diff)
downloadpaludis-c6854af474b8260ef3225d1b6dcf5663af9201f1.tar.gz
paludis-c6854af474b8260ef3225d1b6dcf5663af9201f1.tar.xz
Support (my)exparam -b
-rw-r--r--paludis/repositories/e/e_repository_TEST_exlibs.cc7
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_exlibs_setup.sh82
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash28
3 files changed, 116 insertions, 1 deletions
diff --git a/paludis/repositories/e/e_repository_TEST_exlibs.cc b/paludis/repositories/e/e_repository_TEST_exlibs.cc
index c1e3f70..4a81724 100644
--- a/paludis/repositories/e/e_repository_TEST_exlibs.cc
+++ b/paludis/repositories/e/e_repository_TEST_exlibs.cc
@@ -195,5 +195,12 @@ namespace test_cases
ExlibsTest test_array_required("array-required", throws_UnsupportedActionError);
ExlibsTest test_illegal_in_global_scope("illegal-in-global-scope", throws_UnsupportedActionError);
ExlibsTest test_illegal_in_global_scope_in_func("illegal-in-global-scope-in-func", success);
+ ExlibsTest test_boolean("boolean", success);
+ ExlibsTest test_boolean_badvalue("boolean-badvalue", throws_UnsupportedActionError);
+ ExlibsTest test_boolean_blankvalue("boolean-blankvalue", throws_UnsupportedActionError);
+ ExlibsTest test_boolean_badvaluewithdefault("boolean-badvaluewithdefault", throws_UnsupportedActionError);
+ ExlibsTest test_boolean_baddefault("boolean-baddefault", throws_UnsupportedActionError);
+ ExlibsTest test_boolean_blankdefault("boolean-blankdefault", throws_UnsupportedActionError);
+ ExlibsTest test_boolean_nodefault("boolean-nodefault", throws_UnsupportedActionError);
}
diff --git a/paludis/repositories/e/e_repository_TEST_exlibs_setup.sh b/paludis/repositories/e/e_repository_TEST_exlibs_setup.sh
index 250c5f0..c5f3e63 100755
--- a/paludis/repositories/e/e_repository_TEST_exlibs_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_exlibs_setup.sh
@@ -415,6 +415,88 @@ pkg_setup() {
[[ ${SUMMARY} == "baz" ]] || die "Bad SUMMARY"
}
END
+mkdir -p "packages/cat/boolean"
+cat <<'END' > packages/cat/boolean/boolean.exlib || exit 1
+myexparam -b t
+myexparam -b f
+myexparam -b t2=true
+myexparam -b f2=false
+myexparam -b t3=true
+myexparam -b f3=false
+tellme () {
+ exparam "${@}"
+}
+END
+cat <<'END' > packages/cat/boolean/boolean-1.ebuild || exit 1
+SLOT="0"
+require boolean [ t=true f=false t2=false f2=true ]
+tellme -b t || die
+tellme -b f && die
+tellme -b t2 && die
+tellme -b f2 || die
+tellme -b t3 || die
+tellme -b f3 && die
+[[ -n $(tellme -b t) ]] && die
+[[ -n $(tellme -b f) ]] && die
+[[ -n $(tellme -b t2) ]] && die
+[[ -n $(tellme -b f2) ]] && die
+[[ -n $(tellme -b t3) ]] && die
+[[ -n $(tellme -b f3) ]] && die
+[[ $(tellme t) == true ]] || die
+[[ $(tellme f) == false ]] || die
+[[ $(tellme t2) == false ]] || die
+[[ $(tellme f2) == true ]] || die
+[[ $(tellme t3) == true ]] || die
+[[ $(tellme f3) == false ]] || die
+END
+mkdir -p "packages/cat/boolean-badvalue"
+cat <<'END' > packages/cat/boolean-badvalue/boolean-badvalue.exlib || exit 1
+myexparam -b t
+END
+cat <<'END' > packages/cat/boolean-badvalue/boolean-badvalue-1.ebuild || exit 1
+SLOT="0"
+require boolean-badvalue [ t=monkey ]
+END
+mkdir -p "packages/cat/boolean-blankvalue"
+cat <<'END' > packages/cat/boolean-blankvalue/boolean-blankvalue.exlib || exit 1
+myexparam -b t
+END
+cat <<'END' > packages/cat/boolean-blankvalue/boolean-blankvalue-1.ebuild || exit 1
+SLOT="0"
+require boolean-blankvalue [ t= ]
+END
+mkdir -p "packages/cat/boolean-badvaluewithdefault"
+cat <<'END' > packages/cat/boolean-badvaluewithdefault/boolean-badvaluewithdefault.exlib || exit 1
+myexparam -b t=true
+END
+cat <<'END' > packages/cat/boolean-badvaluewithdefault/boolean-badvaluewithdefault-1.ebuild || exit 1
+SLOT="0"
+require boolean-badvaluewithdefault [ t=monkey ]
+END
+mkdir -p "packages/cat/boolean-baddefault"
+cat <<'END' > packages/cat/boolean-baddefault/boolean-baddefault.exlib || exit 1
+myexparam -b t=monkey
+END
+cat <<'END' > packages/cat/boolean-baddefault/boolean-baddefault-1.ebuild || exit 1
+SLOT="0"
+require boolean-baddefault
+END
+mkdir -p "packages/cat/boolean-blankdefault"
+cat <<'END' > packages/cat/boolean-blankdefault/boolean-blankdefault.exlib || exit 1
+myexparam -b t=
+END
+cat <<'END' > packages/cat/boolean-blankdefault/boolean-blankdefault-1.ebuild || exit 1
+SLOT="0"
+require boolean-blankdefault
+END
+mkdir -p "packages/cat/boolean-nodefault"
+cat <<'END' > packages/cat/boolean-nodefault/boolean-nodefault.exlib || exit 1
+myexparam -b t
+END
+cat <<'END' > packages/cat/boolean-nodefault/boolean-nodefault-1.ebuild || exit 1
+SLOT="0"
+require boolean-nodefault
+END
mkdir -p "packages/cat/illegal-in-global-scope"
cat <<'END' > packages/cat/illegal-in-global-scope/illegal-in-global-scope-1.ebuild || exit 1
DESCRIPTION="The Long Description"
diff --git a/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash b/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash
index 37f5d95..a5727e9 100644
--- a/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash
@@ -51,8 +51,21 @@ exparam_print()
exparam_internal()
{
- local i e=${1} a to_var v a_v=$(exparam_var_name ${1})__ALLDECLS__
+ local i e=${1} a to_var v a_v=$(exparam_var_name ${1})__ALLDECLS__ b_v=$(exparam_var_name ${1})__BOOLEANS__
shift
+
+ if [[ ${1} == -b ]]; then
+ [[ ${#} -eq 2 ]] || die "exparam ${1} requires exactly two arguments"
+ shift
+ has "${1}" ${!b_v} || die "${e}.exlib has no ${1} boolean"
+ v=$(exparam_var_name ${e})_${1}
+ if ${!v}; then
+ return 0
+ else
+ return 1
+ fi
+ fi
+
if [[ ${1} == -v ]]; then
[[ ${#} -eq 3 ]] || die "exparam ${1} requires exactly three arguments"
a=${1}
@@ -61,6 +74,7 @@ exparam_internal()
else
[[ ${#} -eq 1 ]] || die "exparam requires exactly one argument"
fi
+
v=$(exparam_var_name ${e})_${1%\[*}
if [[ ${1} == *\[*\] ]]; then
has "${1%\[*}[]" ${!a_v} || die "${e}.exlib has no ${1%\[*} array"
@@ -82,9 +96,19 @@ myexparam()
{
[[ -z "${CURRENT_EXLIB}" ]] && die "myexparam called but CURRENT_EXLIB undefined"
+ local bool=false
+ if [[ ${1} == -b ]]; then
+ bool=true
+ shift
+ fi
+
local v=${1%%=*} a_v="$(exparam_var_name ${CURRENT_EXLIB})__ALLDECLS__"
[[ ${1} == *=\[ && ${#} -gt 1 ]] && v+="[]"
printf -v "${a_v}" "%s %s" "${!a_v}" "${v}"
+ if ${bool}; then
+ local b_v="$(exparam_var_name ${CURRENT_EXLIB})__BOOLEANS__"
+ printf -v "${b_v}" "%s %s" "${!b_v}" "${v}"
+ fi
v=$(exparam_var_name ${CURRENT_EXLIB})_${v%\[\]}
if [[ -z ${!v+set} && ${1} == *=* ]]; then
@@ -101,6 +125,8 @@ myexparam()
printf -v "${v}" "%s" "${1#*=}"
fi
fi
+
+ ${bool} && ! has "${!v}" true false && die "exparam ${1%%=*} for exlib ${CURRENT_EXLIB} must be 'true' or 'false'"
}
require()