--- eutils.eclass 2014-01-22 23:36:35.819000000 -0500 +++ eutils.eclass.patched 2014-01-22 23:38:15.538000000 -0500 @@ -1729,4 +1729,71 @@ check_license() { die "you no longer need this as portage supports ACCEPT_LICENSE itself"; } +# @FUNCTION: optfeature +# @USAGE: [other atoms] +# @DESCRIPTION: +# Print out a message suggesting an optional package (or packages) which +# provide the described functionality +# +# The following snippet would suggest app-misc/foo for optional foo support, +# app-misc/bar or app-misc/baz[bar] for optional bar support +# and either both app-misc/a and app-misc/b or app-misc/c for alphabet support. +# @CODE: +# optfeature "foo support" app-misc/foo +# optfeature "bar support" app-misc/bar app-misc/baz[bar] +# optfeature "alphabet support" \( app-misc/a app-misc/b \) app-misc/c +# +optfeature() { + debug-print-function ${FUNCNAME} "$@" + local i + local desc=$1 + local flag=0 + local innercount=0 + local innerflag=0 + shift + for i; do + if [[ "$i" == "(" ]]; then + innercount=0 + innerflag=0 + flag=2 + elif [[ $flag -eq 2 ]]; then + if [[ "$i" == ")" ]]; then + if [[ $innercount -eq $innerflag ]]; then + flag=1 + break + else + flag=0 + fi + else + innercount=$((innercount+1)) + if has_version $i; then + innerflag=$((innerflag+1)) + fi + fi + elif has_version "$i"; then + flag=1 + break + + fi + done + if [[ $flag -eq 0 ]]; then + local andflag=0 + local msg="" + for i in "$@"; do + if [[ "$i" == "(" ]]; then + andflag=1 + msg=" " + elif [[ "$i" == ")" ]]; then + andflag=0 + msg="${msg:0: -4} for ${desc}" + elog "${msg}" + elif [[ $andflag -eq 1 ]]; then + msg="${msg} ${i} and" + else + elog " $i for ${desc}" + fi + done + fi +} + fi