diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-09-11 14:29:04 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-09-11 14:29:04 -0700 |
commit | fc4e3c9cae17a0dc0867c7e5ccefbb47eb5e36f7 (patch) | |
tree | 2cff5bea908b58615ef4b7fd88c12e1bca10ffe3 /bin/phase-helpers.sh | |
parent | 6a1a8397003edc599c3916d284676a81a02af0e0 (diff) | |
download | portage-fc4e3c9cae17a0dc0867c7e5ccefbb47eb5e36f7.tar.gz portage-fc4e3c9cae17a0dc0867c7e5ccefbb47eb5e36f7.tar.bz2 portage-fc4e3c9cae17a0dc0867c7e5ccefbb47eb5e36f7.zip |
ebuild.sh: move use* funcs to phase-helpers.sh
Diffstat (limited to 'bin/phase-helpers.sh')
-rw-r--r-- | bin/phase-helpers.sh | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh index 337639f45..6064346be 100644 --- a/bin/phase-helpers.sh +++ b/bin/phase-helpers.sh @@ -149,6 +149,55 @@ keepdir() { fi } + +useq() { + has $EBUILD_PHASE prerm postrm || eqawarn \ + "QA Notice: The 'useq' function is deprecated (replaced by 'use')" + use ${1} +} + +usev() { + if use ${1}; then + echo "${1#!}" + return 0 + fi + return 1 +} + +use() { + local u=$1 + local found=0 + + # if we got something like '!flag', then invert the return value + if [[ ${u:0:1} == "!" ]] ; then + u=${u:1} + found=1 + fi + + if [[ $EBUILD_PHASE = depend ]] ; then + # TODO: Add a registration interface for eclasses to register + # any number of phase hooks, so that global scope eclass + # initialization can by migrated to phase hooks in new EAPIs. + # Example: add_phase_hook before pkg_setup $ECLASS_pre_pkg_setup + #if [[ -n $EAPI ]] && ! has "$EAPI" 0 1 2 3 ; then + # die "use() called during invalid phase: $EBUILD_PHASE" + #fi + true + + # Make sure we have this USE flag in IUSE + elif [[ -n $PORTAGE_IUSE && -n $EBUILD_PHASE ]] ; then + [[ $u =~ $PORTAGE_IUSE ]] || \ + eqawarn "QA Notice: USE Flag '${u}' not" \ + "in IUSE for ${CATEGORY}/${PF}" + fi + + if has ${u} ${USE} ; then + return ${found} + else + return $((!found)) + fi +} + use_with() { if [ -z "$1" ]; then echo "!!! use_with() called without a parameter." >&2 |