Add eapi.sh with ___eapi_*() functions and use these functions in other files.
authorArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Wed, 26 Sep 2012 20:31:20 +0000 (22:31 +0200)
committerArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Wed, 26 Sep 2012 20:31:20 +0000 (22:31 +0200)
34 files changed:
bin/eapi.sh [new file with mode: 0644]
bin/ebuild-helpers/dobin
bin/ebuild-helpers/dodir
bin/ebuild-helpers/dodoc
bin/ebuild-helpers/doexe
bin/ebuild-helpers/dohard
bin/ebuild-helpers/doheader
bin/ebuild-helpers/doinfo
bin/ebuild-helpers/doins
bin/ebuild-helpers/dolib
bin/ebuild-helpers/doman
bin/ebuild-helpers/domo
bin/ebuild-helpers/dosbin
bin/ebuild-helpers/dosed
bin/ebuild-helpers/dosym
bin/ebuild-helpers/ecompressdir
bin/ebuild-helpers/fowners
bin/ebuild-helpers/fperms
bin/ebuild-helpers/newins
bin/ebuild-helpers/prepall
bin/ebuild-helpers/prepalldocs
bin/ebuild-helpers/prepallinfo
bin/ebuild-helpers/prepallman
bin/ebuild-helpers/prepallstrip
bin/ebuild-helpers/prepinfo
bin/ebuild-helpers/preplib
bin/ebuild-helpers/prepman
bin/ebuild-helpers/prepstrip
bin/ebuild.sh
bin/isolated-functions.sh
bin/misc-functions.sh
bin/phase-functions.sh
bin/phase-helpers.sh
bin/save-ebuild-env.sh

diff --git a/bin/eapi.sh b/bin/eapi.sh
new file mode 100644 (file)
index 0000000..a561c1c
--- /dev/null
@@ -0,0 +1,113 @@
+#!/bin/bash
+# Copyright 2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# PHASES
+
+___eapi_has_pkg_pretend() {
+       [[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+}
+
+___eapi_has_src_prepare() {
+       [[ ! ${1-${EAPI}} =~ ^(0|1)$ ]]
+}
+
+___eapi_has_src_configure() {
+       [[ ! ${1-${EAPI}} =~ ^(0|1)$ ]]
+}
+
+___eapi_default_src_test_disables_parallel_jobs() {
+       [[ ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
+}
+
+___eapi_has_S_WORKDIR_fallback() {
+       [[ ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+}
+
+# VARIABLES
+
+___eapi_has_prefix_variables() {
+       [[ ! ${1-${EAPI}} =~ ^(0|1|2)$ || " ${FEATURES} " == *" force-prefix "* ]]
+}
+
+___eapi_has_HDEPEND() {
+       [[ ${1-${EAPI}} =~ ^(5-hdepend)$ ]]
+}
+
+___eapi_has_RDEPEND_DEPEND_fallback() {
+       [[ ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+}
+
+# HELPERS PRESENCE
+
+___eapi_has_dohard() {
+       [[ ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+}
+
+___eapi_has_dosed() {
+       [[ ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+}
+
+___eapi_has_docompress() {
+       [[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+}
+
+___eapi_has_nonfatal() {
+       [[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+}
+
+___eapi_has_doheader() {
+       [[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
+}
+
+___eapi_has_usex() {
+       [[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
+}
+
+# HELPERS BEHAVIOR
+
+___eapi_best_version_and_has_version_support_--host-root() {
+       [[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
+}
+
+___eapi_unpack_supports_xz() {
+       [[ ! ${1-${EAPI}} =~ ^(0|1|2)$ ]]
+}
+
+___eapi_econf_passes_--disable-dependency-tracking() {
+       [[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+}
+
+___eapi_econf_passes_--disable-silent-rules() {
+       [[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
+}
+
+___eapi_use_enable_and_use_with_support_empty_third_argument() {
+       [[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+}
+
+___eapi_dodoc_supports_-r() {
+       [[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+}
+
+___eapi_doins_and_newins_preserve_symlinks() {
+       [[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+}
+
+___eapi_newins_supports_reading_from_standard_input() {
+       [[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
+}
+
+___eapi_helpers_can_die() {
+       [[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+}
+
+___eapi_disallows_helpers_in_global_scope() {
+       [[ ${1-${EAPI}} =~ ^(4-python|5-progress)$ ]]
+}
+
+# OTHERS
+
+___eapi_enables_globstar() {
+       [[ ${1-${EAPI}} =~ ^(4-python|5-progress)$ ]]
+}
index 06ae0c779e16f4df0a3036657759cc3b043fdffb..0ba1eb0c4e1055d1cf2c38c4b489025231150c55 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
@@ -9,8 +9,9 @@ if [[ $# -lt 1 ]] ; then
        exit 1
 fi
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 if [[ ! -d ${ED}${DESTTREE}/bin ]] ; then
        install -d "${ED}${DESTTREE}/bin" || { __helpers_die "${0##*/}: failed to install ${ED}${DESTTREE}/bin"; exit 2; }
index c8f763deb08c8c98ddba50bcb36c655c09245752..e03ba9a58085e954e2f27c1c94d327b179961ba7 100755 (executable)
@@ -1,11 +1,12 @@
 #!/bin/bash
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 install -d ${DIROPTIONS} "${@/#/${ED}/}"
 ret=$?
index 2b0533febbd1fbbda2e8e3c4efb04c0c1df69057..bba7903847b294a15e9b50ea2c9e7a576187550e 100755 (executable)
@@ -2,16 +2,12 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-case "${EAPI}" in
-       0|1|2|3)
-               ;;
-       *)
-               exec \
-               env \
-               __PORTAGE_HELPER="dodoc" \
-               doins "$@"
-               ;;
-esac
+if ___eapi_dodoc_supports_-r; then
+       exec \
+       env \
+       __PORTAGE_HELPER="dodoc" \
+       doins "$@"
+fi
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
@@ -20,8 +16,9 @@ if [ $# -lt 1 ] ; then
        exit 1  
 fi
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 dir="${ED}usr/share/doc/${PF}/${_E_DOCDESTTREE_}"
 if [ ! -d "${dir}" ] ; then
index efbf638fc9227f63ec460d95ebd4a1c699700c00..aa050e9ed417591fc0332756ce0b4d7d466de264 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
@@ -9,8 +9,9 @@ if [[ $# -lt 1 ]] ; then
        exit 1
 fi
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 if [[ ! -d ${ED}${_E_EXEDESTTREE_} ]] ; then
        install -d "${ED}${_E_EXEDESTTREE_}"
index 6ae93d240de061d6f504d1dce9e3acc0a2e7d006..e0a44faf1f4c0bee7658d105e687cdc629e9417d 100755 (executable)
@@ -2,22 +2,21 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-case "${EAPI}" in
-       0|1|2|3)
-               ;;
-       *)
-               die "'${0##*/}' has been banned for EAPI '$EAPI'"
-               exit 1
-               ;;
-esac
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+if ! ___eapi_has_dohard; then
+       die "'${0##*/}' has been banned for EAPI '$EAPI'"
+       exit 1
+fi
 
 if [[ $# -ne 2 ]] ; then
        echo "$0: two arguments needed" 1>&2
        exit 1
 fi
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 destdir=${2%/*}
 [[ ! -d ${ED}${destdir} ]] && dodir "${destdir}"
index db3a02d09e8f3edc4bce2af00d49b14a85c7983a..37953658b47d18a57045dfbe279691c214905372 100755 (executable)
@@ -4,11 +4,9 @@
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-case "${EAPI}" in
-       0|1|2|3|4|4-python|4-slot-abi)
-               die "${0##*/} is not supported in EAPI ${EAPI}"
-               ;;
-esac
+if ! ___eapi_has_doheader; then
+       die "${0##*/} is not supported in EAPI ${EAPI}"
+fi
 
 if [[ $# -lt 1 ]] || [[ $1 == -r && $# -lt 2 ]] ; then
        __helpers_die "${0##*/}: at least one argument needed"
index e4ccc90d99202aeb4380cfd706b9a675ffe0626a..355047f73068b8bf7293ab42f181931b5eca6095 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
@@ -9,8 +9,9 @@ if [[ -z $1 ]] ; then
        exit 1  
 fi
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 if [[ ! -d ${ED}usr/share/info ]] ; then
        install -d "${ED}usr/share/info" || { __helpers_die "${0##*/}: failed to install ${ED}usr/share/info"; exit 1; }
index c534f3f397bc42da84ea42a7f5faef6528e46dd3..4679e83a9a7140e100da733cb34faad384991a64 100755 (executable)
@@ -29,8 +29,9 @@ else
        DOINSRECUR=n
 fi
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) export ED="${D}" ;; esac
+if ! ___eapi_has_prefix_variables; then
+       export ED="${D}"
+fi
 
 if [[ ${INSDESTTREE#${ED}} != "${INSDESTTREE}" ]]; then
        __vecho "-------------------------------------------------------" 1>&2
@@ -41,14 +42,11 @@ if [[ ${INSDESTTREE#${ED}} != "${INSDESTTREE}" ]]; then
        exit 1
 fi
 
-case "$EAPI" in
-       0|1|2|3)
-               PRESERVE_SYMLINKS=n
-               ;;
-       *)
-               PRESERVE_SYMLINKS=y
-               ;;
-esac
+if ___eapi_doins_and_newins_preserve_symlinks; then
+       PRESERVE_SYMLINKS=y
+else
+       PRESERVE_SYMLINKS=n
+fi
 
 export TMP=$T/.doins_tmp
 # Use separate directories to avoid potential name collisions.
index 402965de7be9657c9efc0378c3bdb3dee94b7b8e..fd92d7f03fa2bf99e4380ed8be975e69bd97fd3f 100755 (executable)
@@ -1,11 +1,12 @@
 #!/bin/bash
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 # Setup ABI cruft
 LIBDIR_VAR="LIBDIR_${ABI}"
index c10296b34139fafe75713488a378fd993386c9f6..d6808597ab32d57bea18a10f15ba0c2893ce3648 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
@@ -9,8 +9,9 @@ if [[ $# -lt 1 ]] ; then
        exit 1
 fi
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 i18n=""
 
index 840b2de4c96e468208b35c8b1808f048c3f7441c..9a8dda38a41a397f14cab2c0203372fe090627c2 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
@@ -10,8 +10,9 @@ if [ ${mynum} -lt 1 ] ; then
        exit 1
 fi
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 if [ ! -d "${ED}${DESTTREE}/share/locale" ] ; then
        install -d "${ED}${DESTTREE}/share/locale/"
index edc45846507c6f7816767f0f0f34aca3e4e5ff25..361ca83ca04c294bd2198cdf795c28bc761b486b 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
@@ -9,8 +9,9 @@ if [[ $# -lt 1 ]] ; then
        exit 1
 fi
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 if [[ ! -d ${ED}${DESTTREE}/sbin ]] ; then
        install -d "${ED}${DESTTREE}/sbin" || { __helpers_die "${0##*/}: failed to install ${ED}${DESTTREE}/sbin"; exit 2; }
index 24ec20587907eaee1ba2e2b0eacdc4a3203726b5..7db0629635fab2889e86740f56fedba96927cfb9 100755 (executable)
@@ -2,22 +2,21 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-case "${EAPI}" in
-       0|1|2|3)
-               ;;
-       *)
-               die "'${0##*/}' has been banned for EAPI '$EAPI'"
-               exit 1
-               ;;
-esac
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+if ! ___eapi_has_dosed; then
+       die "'${0##*/}' has been banned for EAPI '$EAPI'"
+       exit 1
+fi
 
 if [[ $# -lt 1 ]] ; then
        echo "!!! ${0##*/}: at least one argument needed" >&2
        exit 1
 fi
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 ret=0
 file_found=0
index 34637c2f78886c06d59f2b71a557627d2876333d..649b100de0a20e2cab7f21aa148f031187b325a2 100755 (executable)
@@ -9,8 +9,9 @@ if [[ $# -ne 2 ]] ; then
        exit 1
 fi
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 if [[ ${2} == */ ]] || \
        [[ -d ${ED}${2} && ! -L ${ED}${2} ]] ; then
index 097ade2bc10934699e9b7b2182e0214972974514..75f3e3a2516679b06fb0a86aa4a9f5f271df0b2f 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/helper-functions.sh
@@ -9,8 +9,9 @@ if [[ -z $1 ]] ; then
        exit 1
 fi
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} EPREFIX= ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D} EPREFIX=
+fi
 
 case $1 in
        --ignore)
index 5b93fd3c37829930c562e9160f5a079d728c58e9..b664ec7667677f9f73aa49408f3b5f4e534ada73 100755 (executable)
@@ -4,8 +4,9 @@
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) EPREFIX= ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       EPREFIX= ED=${D}
+fi
 
 # we can't prefix all arguments because
 # chown takes random options
index 668e905a2cf5bb6a1689add4e973081a5f6d0a31..d854ebbdfc1567a5c699fb45d28e1ae27e2684c7 100755 (executable)
@@ -1,11 +1,12 @@
 #!/bin/bash
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 # we can't prefix all arguments because
 # chmod takes random options
index 20c68a1e25c1cc9385f15a344d95d3fa1298ce98..3538f70603c1c76d0d85880b736750139c440713 100755 (executable)
@@ -15,10 +15,9 @@ fi
        eqawarn "QA Notice: ${helper} called with more than 2 arguments: ${@:3}"
 
 stdin=
-case "${EAPI}" in
-       0|1|2|3|4|4-python|4-slot-abi) ;;
-       *) [[ $1 = "-" ]] && stdin=yes ;;
-esac
+if ___eapi_newins_supports_reading_from_standard_input && [[ $1 == "-" ]]; then
+       stdin=yes
+fi
 
 rm -rf "${T}/$2"
 
@@ -37,13 +36,9 @@ else
 
        cp_args="-f"
        if [[ ${helper} == newins ]] ; then
-               case "${EAPI}" in
-                       0|1|2|3)
-                               ;;
-                       *)
-                               cp_args+=" -P"
-                               ;;
-               esac
+               if ___eapi_doins_and_newins_preserve_symlinks; then
+                       cp_args+=" -P"
+               fi
        fi
 
        cp ${cp_args} "$1" "${T}/$2"
index 49e646cd280081c9979a4f069291cda86922698b..fb5c2db55f960b65892ea3742e91671489e58fde 100755 (executable)
@@ -1,11 +1,12 @@
 #!/bin/bash
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 if has chflags $FEATURES ; then
        # Save all the file flags for restoration at the end of prepall.
index 50b0c7070b65ef8180793873a9a80b6dfd459cf9..b76f0843992d532b0c71929cd4f54ed07c3b1ce3 100755 (executable)
@@ -4,21 +4,18 @@
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-case "${EAPI}" in
-       0|1|2|3)
-               ;;
-       *)
-               die "'${0##*/}' has been banned for EAPI '$EAPI'"
-               exit 1
-               ;;
-esac
+if ! ___eapi_has_docompress; then
+       die "'${0##*/}' has been banned for EAPI '$EAPI'"
+       exit 1
+fi
 
 if [[ -n $1 ]] ; then
        __vecho "${0##*/}: invalid usage; takes no arguments" 1>&2
 fi
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 [[ -d ${ED}usr/share/doc ]] || exit 0
 
index db9bbfacb0e8f1c021c15e04402b43485cfaf551..1a20275801248b918137271648d7907ca5184ca7 100755 (executable)
@@ -1,11 +1,12 @@
 #!/bin/bash
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 [[ -d ${ED}usr/share/info ]] || exit 0
 
index dee1c7236e4466e0b92fbf9b5cfa64378473ee7c..7c78324cd83b4faff36cbfc2b118daadeb1a0e1f 100755 (executable)
@@ -1,14 +1,15 @@
 #!/bin/bash
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
 # replaced by controllable compression in EAPI 4
-has "${EAPI}" 0 1 2 3 || exit 0
+___eapi_has_docompress && exit 0
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 ret=0
 
index 28320d975ae9b5035cd32f91102e552191060901..1aa6686cda3e8e758d5aefa39276d5f740c7f246 100755 (executable)
@@ -1,8 +1,11 @@
 #!/bin/bash
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 exec prepstrip "${ED}"
index e213f32d16d856c73888da624b3e29c4409229ca..5afc18a7164b4ed2e76961a2953ae0c67de21ed3 100755 (executable)
@@ -1,11 +1,12 @@
 #!/bin/bash
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 if [[ -z $1 ]] ; then
        infodir="/usr/share/info"
@@ -33,5 +34,5 @@ find "${ED}${infodir}" -type d -print0 | while read -r -d $'\0' x ; do
        rm -f "${x}"/dir{,.info}{,.gz,.bz2}
 done
 
-has "${EAPI}" 0 1 2 3 || exit 0
+___eapi_has_docompress && exit 0
 exec ecompressdir --queue "${infodir}"
index 6e91cf33d02a15015b4a493a31ee6569d6c770be..764261d9888ad8f6993bb5aaf8feb7c6cc26f069 100755 (executable)
@@ -1,13 +1,14 @@
 #!/bin/bash
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
 eqawarn "QA Notice: Deprecated call to 'preplib'"
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 LIBDIR_VAR="LIBDIR_${ABI}"
 if [ -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then
index f96b64147dbcccce1a65cace7f3ad0c17028e78f..142d40443a46dccd41bf0eadb421a152c51e35e8 100755 (executable)
@@ -1,11 +1,12 @@
 #!/bin/bash
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "$EAPI" in 0|1|2) ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       ED=${D}
+fi
 
 if [[ -z $1 ]] ; then 
        mandir="${ED}usr/share/man"
@@ -19,7 +20,7 @@ if [[ ! -d ${mandir} ]] ; then
 fi
 
 # replaced by controllable compression in EAPI 4
-has "${EAPI}" 0 1 2 3 || exit 0
+___eapi_has_docompress && exit 0
 
 shopt -s nullglob
 
index 802fdd826c6f04b803f4497c08a493c605f78e95..0d1ce5a092b66f98689bdb7b0e2651232c59fbae 100755 (executable)
@@ -18,8 +18,9 @@ exp_tf() {
 exp_tf FEATURES compressdebug installsources nostrip splitdebug
 exp_tf RESTRICT binchecks installsources strip
 
-[[ " ${FEATURES} " == *" force-prefix "* ]] || \
-       case "${EAPI}" in 0|1|2) EPREFIX= ED=${D} ;; esac
+if ! ___eapi_has_prefix_variables; then
+       EPREFIX= ED=${D}
+fi
 
 banner=false
 SKIP_STRIP=false
index 06e2c66f622406beaa6ea04986222191496c3e8a..aa3dcdd28c34119d89a2c914912273c8766119b2 100755 (executable)
@@ -26,16 +26,16 @@ else
                __strip_duplicate_slashes \
                use_with use_enable ; do
                eval "${x}() {
-                       if has \"\${EAPI:-0}\" 4-python 5-progress; then
+                       if ___eapi_disallows_helpers_in_global_scope; then
                                die \"\${FUNCNAME}() calls are not allowed in global scope\"
                        fi
                }"
        done
-       # These dummy functions return false in older EAPIs, in order to ensure that
+       # These dummy functions return false in non-strict EAPIs, in order to ensure that
        # `use multislot` is false for the "depend" phase.
        for x in use useq usev usex ; do
                eval "${x}() {
-                       if has \"\${EAPI:-0}\" 4-python 5-progress; then
+                       if ___eapi_disallows_helpers_in_global_scope; then
                                die \"\${FUNCNAME}() calls are not allowed in global scope\"
                        else
                                return 1
@@ -512,7 +512,7 @@ if ! has "$EBUILD_PHASE" clean cleanrm depend && \
        [[ -n $EAPI ]] || EAPI=0
 fi
 
-if has "${EAPI:-0}" 4-python 5-progress; then
+if ___eapi_enables_globstar; then
        shopt -s globstar
 fi
 
@@ -557,7 +557,7 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then
                # export EAPI for helpers (especially since we unset it above)
                export EAPI
 
-               if has "$EAPI" 0 1 2 3 ; then
+               if ___eapi_has_RDEPEND_DEPEND_fallback; then
                        export RDEPEND=${RDEPEND-${DEPEND}}
                        debug-print "RDEPEND: not set... Setting to: ${DEPEND}"
                fi
@@ -675,13 +675,9 @@ if [[ $EBUILD_PHASE = depend ]] ; then
                PROPERTIES DEFINED_PHASES HDEPEND UNUSED_04
                UNUSED_03 UNUSED_02 UNUSED_01"
 
-       case ${EAPI} in
-               5-hdepend)
-                       ;;
-               *)
-                       unset HDEPEND
-                       ;;
-       esac
+       if ! ___eapi_has_HDEPEND; then
+               unset HDEPEND
+       fi
 
        # The extra $(echo) commands remove newlines.
        if [ -n "${dbkey}" ] ; then
@@ -700,15 +696,9 @@ else
        # Note: readonly variables interfere with __preprocess_ebuild_env(), so
        # declare them only after it has already run.
        declare -r $PORTAGE_READONLY_METADATA $PORTAGE_READONLY_VARS
-       case ${EAPI} in
-               0|1|2)
-                       [[ " ${FEATURES} " == *" force-prefix "* ]] && \
-                               declare -r ED EPREFIX EROOT
-                       ;;
-               *)
-                       declare -r ED EPREFIX EROOT
-                       ;;
-       esac
+       if ___eapi_has_prefix_variables; then
+               declare -r ED EPREFIX EROOT
+       fi
 
        if [[ -n $EBUILD_SH_ARGS ]] ; then
                (
index fa84c7ee3c1f627a66314778c0fdea786f6f2477..f8e7862ee5025601adce8a5d4e983ea8bf2e2fab 100644 (file)
@@ -2,6 +2,8 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}/eapi.sh"
+
 # We need this next line for "die" and "assert". It expands
 # It _must_ preceed all the calls to die and assert.
 shopt -s expand_aliases
@@ -86,7 +88,7 @@ __dump_trace() {
 }
 
 nonfatal() {
-       if has "${EAPI:-0}" 0 1 2 3 ; then
+       if ! ___eapi_has_nonfatal; then
                die "$FUNCNAME() not supported in this EAPI"
        fi
        if [[ $# -lt 1 ]]; then
@@ -97,14 +99,11 @@ nonfatal() {
 }
 
 __helpers_die() {
-       case "${EAPI:-0}" in
-               0|1|2|3)
-                       echo -e "$@" >&2
-                       ;;
-               *)
-                       die "$@"
-                       ;;
-       esac
+       if ___eapi_helpers_can_die; then
+               die "$@"
+       else
+               echo -e "$@" >&2
+       fi
 }
 
 die() {
index 55d37f29d2ac4e7de8becead69a731cf795ae79f..986264ed8de3f237ed8b1b81c07f19db211dd828 100755 (executable)
@@ -17,8 +17,9 @@ shift $#
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}/ebuild.sh"
 
 install_symlink_html_docs() {
-       [[ " ${FEATURES} " == *" force-prefix "* ]] || \
-               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+       if ! ___eapi_has_prefix_variables; then
+               local ED=${D}
+       fi
        cd "${ED}" || die "cd failed"
        #symlink the html documentation (if DOC_SYMLINKS_DIR is set in make.conf)
        if [ -n "${DOC_SYMLINKS_DIR}" ] ; then
@@ -79,8 +80,9 @@ canonicalize() {
 prepcompress() {
        local -a include exclude incl_d incl_f
        local f g i real_f real_d
-       [[ " ${FEATURES} " == *" force-prefix "* ]] || \
-               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+       if ! ___eapi_has_prefix_variables; then
+               local ED=${D}
+       fi
 
        # Canonicalize path names and check for their existence.
        real_d=$(canonicalize "${ED}")
@@ -162,8 +164,9 @@ prepcompress() {
 
 install_qa_check() {
        local f i qa_var x
-       [[ " ${FEATURES} " == *" force-prefix "* ]] || \
-               case "$EAPI" in 0|1|2) local EPREFIX= ED=${D} ;; esac
+       if ! ___eapi_has_prefix_variables; then
+               local EPREFIX= ED=${D}
+       fi
 
        cd "${ED}" || die "cd failed"
 
@@ -228,7 +231,7 @@ install_qa_check() {
 
        export STRIP_MASK
        prepall
-       has "${EAPI}" 0 1 2 3 || prepcompress
+       ___eapi_has_docompress && prepcompress
        ecompressdir --dequeue
        ecompress --dequeue
 
@@ -958,8 +961,9 @@ preinst_mask() {
                 return 1
        fi
 
-       [[ " ${FEATURES} " == *" force-prefix "* ]] || \
-               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+       if ! ___eapi_has_prefix_variables; then
+               local ED=${D}
+       fi
 
        # Make sure $PWD is not ${D} so that we don't leave gmon.out files
        # in there in case any tools were built with -pg in CFLAGS.
@@ -987,8 +991,9 @@ preinst_sfperms() {
                 return 1
        fi
 
-       [[ " ${FEATURES} " == *" force-prefix "* ]] || \
-               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+       if ! ___eapi_has_prefix_variables; then
+               local ED=${D}
+       fi
 
        # Smart FileSystem Permissions
        if has sfperms $FEATURES; then
@@ -1026,8 +1031,9 @@ preinst_suid_scan() {
                 return 1
        fi
 
-       [[ " ${FEATURES} " == *" force-prefix "* ]] || \
-               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+       if ! ___eapi_has_prefix_variables; then
+               local ED=${D}
+       fi
 
        # total suid control.
        if has suidctl $FEATURES; then
@@ -1095,8 +1101,9 @@ preinst_selinux_labels() {
 __dyn_package() {
        local PROOT
 
-       [[ " ${FEATURES} " == *" force-prefix "* ]] || \
-               case "$EAPI" in 0|1|2) local EPREFIX= ED=${D} ;; esac
+       if ! ___eapi_has_prefix_variables; then
+               local EPREFIX= ED=${D}
+       fi
 
        # Make sure $PWD is not ${D} so that we don't leave gmon.out files
        # in there in case any tools were built with -pg in CFLAGS.
@@ -1193,9 +1200,9 @@ __END1__
 }
 
 __dyn_rpm() {
-
-       [[ " ${FEATURES} " == *" force-prefix "* ]] || \
-               case "$EAPI" in 0|1|2) local EPREFIX= ;; esac
+       if ! ___eapi_has_prefix_variables; then
+               local EPREFIX=
+       fi
 
        cd "${T}" || die "cd failed"
        local machine_name=$(uname -m)
index 97e762a39f53032a1b5067c1a45192969867b949..7a0baf4532be8bc792a63a0332b02a10bf0bb1c9 100644 (file)
@@ -100,15 +100,9 @@ __filter_readonly_variables() {
 
        # Don't filter/interfere with prefix variables unless they are
        # supported by the current EAPI.
-       case "${EAPI:-0}" in
-               0|1|2)
-                       [[ " ${FEATURES} " == *" force-prefix "* ]] && \
-                               filtered_vars+=" ED EPREFIX EROOT"
-                       ;;
-               *)
-                       filtered_vars+=" ED EPREFIX EROOT"
-                       ;;
-       esac
+       if ___eapi_has_prefix_variables; then
+               filtered_vars+=" ED EPREFIX EROOT"
+       fi
 
        if has --filter-sandbox $* ; then
                filtered_vars="${filtered_vars} SANDBOX_.*"
@@ -364,7 +358,7 @@ __dyn_prepare() {
 
        if [[ -d $S ]] ; then
                cd "${S}"
-       elif has $EAPI 0 1 2 3 ; then
+       elif ___eapi_has_S_WORKDIR_fallback; then
                cd "${WORKDIR}"
        elif [[ -z ${A} ]] && ! __has_phase_defined_up_to prepare; then
                cd "${WORKDIR}"
@@ -395,7 +389,7 @@ __dyn_configure() {
 
        if [[ -d $S ]] ; then
                cd "${S}"
-       elif has $EAPI 0 1 2 3 ; then
+       elif ___eapi_has_S_WORKDIR_fallback; then
                cd "${WORKDIR}"
        elif [[ -z ${A} ]] && ! __has_phase_defined_up_to configure; then
                cd "${WORKDIR}"
@@ -428,7 +422,7 @@ __dyn_compile() {
 
        if [[ -d $S ]] ; then
                cd "${S}"
-       elif has $EAPI 0 1 2 3 ; then
+       elif ___eapi_has_S_WORKDIR_fallback; then
                cd "${WORKDIR}"
        elif [[ -z ${A} ]] && ! __has_phase_defined_up_to compile; then
                cd "${WORKDIR}"
@@ -510,16 +504,18 @@ __dyn_install() {
        trap "__abort_install" SIGINT SIGQUIT
        __ebuild_phase pre_src_install
 
-       _x=${ED}
-       [[ " ${FEATURES} " == *" force-prefix "* ]] || \
-               case "$EAPI" in 0|1|2) _x=${D} ;; esac
+       if ___eapi_has_prefix_variables; then
+               _x=${ED}
+       else
+               _x=${D}
+       fi
        rm -rf "${D}"
        mkdir -p "${_x}"
        unset _x
 
        if [[ -d $S ]] ; then
                cd "${S}"
-       elif has $EAPI 0 1 2 3 ; then
+       elif ___eapi_has_S_WORKDIR_fallback; then
                cd "${WORKDIR}"
        elif [[ -z ${A} ]] && ! __has_phase_defined_up_to install; then
                cd "${WORKDIR}"
@@ -571,15 +567,9 @@ __dyn_install() {
        # Save EPREFIX, since it makes it easy to use chpathtool to
        # adjust the content of a binary package so that it will
        # work in a different EPREFIX from the one is was built for.
-       case "${EAPI:-0}" in
-               0|1|2)
-                       [[ " ${FEATURES} " == *" force-prefix "* ]] && \
-                               [ -n "${EPREFIX}" ] && echo "${EPREFIX}" > EPREFIX
-                       ;;
-               *)
-                       [ -n "${EPREFIX}" ] && echo "${EPREFIX}" > EPREFIX
-                       ;;
-       esac
+       if ___eapi_has_prefix_variables && [[ -n ${EPREFIX} ]]; then
+               echo "${EPREFIX}" > EPREFIX
+       fi
 
        set +f
 
@@ -669,14 +659,13 @@ __dyn_help() {
 # Translate a known ebuild(1) argument into the precise
 # name of it's corresponding ebuild phase.
 __ebuild_arg_to_phase() {
-       [ $# -ne 2 ] && die "expected exactly 2 args, got $#: $*"
-       local eapi=$1
-       local arg=$2
+       [ $# -ne 1 ] && die "expected exactly 1 arg, got $#: $*"
+       local arg=$1
        local phase_func=""
 
        case "$arg" in
                pretend)
-                       ! has $eapi 0 1 2 3 && \
+                       ___eapi_has_pkg_pretend && \
                                phase_func=pkg_pretend
                        ;;
                setup)
@@ -689,11 +678,11 @@ __ebuild_arg_to_phase() {
                        phase_func=src_unpack
                        ;;
                prepare)
-                       ! has $eapi 0 1 && \
+                       ___eapi_has_src_prepare && \
                                phase_func=src_prepare
                        ;;
                configure)
-                       ! has $eapi 0 1 && \
+                       ___eapi_has_src_configure && \
                                phase_func=src_configure
                        ;;
                compile)
@@ -853,7 +842,7 @@ __ebuild_main() {
        # respect FEATURES="-ccache".
        has ccache $FEATURES || export CCACHE_DISABLE=1
 
-       local phase_func=$(__ebuild_arg_to_phase "$EAPI" "$EBUILD_PHASE")
+       local phase_func=$(__ebuild_arg_to_phase "$EBUILD_PHASE")
        [[ -n $phase_func ]] && __ebuild_phase_funcs "$EAPI" "$phase_func"
        unset phase_func
 
index 157725ff3c52f1284ed8732fab8d7dc0a429ba51..dc70de658553c8acd9d1e56d3c866352ab454f54 100644 (file)
@@ -19,8 +19,9 @@ into() {
                export DESTTREE=""
        else
                export DESTTREE=$1
-               [[ " ${FEATURES} " == *" force-prefix "* ]] || \
-                       case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+               if ! ___eapi_has_prefix_variables; then
+                       local ED=${D}
+               fi
                if [ ! -d "${ED}${DESTTREE}" ]; then
                        install -d "${ED}${DESTTREE}"
                        local ret=$?
@@ -37,8 +38,9 @@ insinto() {
                export INSDESTTREE=""
        else
                export INSDESTTREE=$1
-               [[ " ${FEATURES} " == *" force-prefix "* ]] || \
-                       case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+               if ! ___eapi_has_prefix_variables; then
+                       local ED=${D}
+               fi
                if [ ! -d "${ED}${INSDESTTREE}" ]; then
                        install -d "${ED}${INSDESTTREE}"
                        local ret=$?
@@ -55,8 +57,9 @@ exeinto() {
                export _E_EXEDESTTREE_=""
        else
                export _E_EXEDESTTREE_="$1"
-               [[ " ${FEATURES} " == *" force-prefix "* ]] || \
-                       case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+               if ! ___eapi_has_prefix_variables; then
+                       local ED=${D}
+               fi
                if [ ! -d "${ED}${_E_EXEDESTTREE_}" ]; then
                        install -d "${ED}${_E_EXEDESTTREE_}"
                        local ret=$?
@@ -73,8 +76,9 @@ docinto() {
                export _E_DOCDESTTREE_=""
        else
                export _E_DOCDESTTREE_="$1"
-               [[ " ${FEATURES} " == *" force-prefix "* ]] || \
-                       case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+               if ! ___eapi_has_prefix_variables; then
+                       local ED=${D}
+               fi
                if [ ! -d "${ED}usr/share/doc/${PF}/${_E_DOCDESTTREE_}" ]; then
                        install -d "${ED}usr/share/doc/${PF}/${_E_DOCDESTTREE_}"
                        local ret=$?
@@ -112,7 +116,7 @@ libopts() {
 }
 
 docompress() {
-       has "${EAPI}" 0 1 2 3 && die "'docompress' not supported in this EAPI"
+       ___eapi_has_docompress || die "'docompress' not supported in this EAPI"
 
        local f g
        if [[ $1 = "-x" ]]; then
@@ -141,8 +145,9 @@ docompress() {
 keepdir() {
        dodir "$@"
        local x
-       [[ " ${FEATURES} " == *" force-prefix "* ]] || \
-               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+       if ! ___eapi_has_prefix_variables; then
+               local ED=${D}
+       fi
        if [ "$1" == "-R" ] || [ "$1" == "-r" ]; then
                shift
                find "$@" -type d -printf "${ED}%p/.keep_${CATEGORY}_${PN}-${SLOT}\n" \
@@ -174,19 +179,16 @@ usev() {
        return 1
 }
 
-case "${EAPI}" in
-       0|1|2|3|4|4-python|4-slot-abi) ;;
-       *)
-               usex() {
-                       if use "$1"; then
-                               echo "${2-yes}$4"
-                       else
-                               echo "${3-no}$5"
-                       fi
-                       return 0
-               }
-               ;;
-esac
+if ___eapi_has_usex; then
+       usex() {
+               if use "$1"; then
+                       echo "${2-yes}$4"
+               else
+                       echo "${3-no}$5"
+               fi
+               return 0
+       }
+fi
 
 use() {
        local u=$1
@@ -233,7 +235,7 @@ use_with() {
                return 1
        fi
 
-       if ! has "${EAPI:-0}" 0 1 2 3 ; then
+       if ___eapi_use_enable_and_use_with_support_empty_third_argument; then
                local UW_SUFFIX=${3+=$3}
        else
                local UW_SUFFIX=${3:+=$3}
@@ -255,7 +257,7 @@ use_enable() {
                return 1
        fi
 
-       if ! has "${EAPI:-0}" 0 1 2 3 ; then
+       if ___eapi_use_enable_and_use_with_support_empty_third_argument; then
                local UE_SUFFIX=${3+=$3}
        else
                local UE_SUFFIX=${3:+=$3}
@@ -377,10 +379,10 @@ unpack() {
                                __unpack_tar "lzma -d"
                                ;;
                        xz)
-                               if has $eapi 0 1 2 ; then
-                                       __vecho "unpack ${x}: file format not recognized. Ignoring."
-                               else
+                               if ___eapi_unpack_supports_xz; then
                                        __unpack_tar "xz -d"
+                               else
+                                       __vecho "unpack ${x}: file format not recognized. Ignoring."
                                fi
                                ;;
                        *)
@@ -397,8 +399,9 @@ unpack() {
 econf() {
        local x
 
-       [[ " ${FEATURES} " == *" force-prefix "* ]] || \
-               case "$EAPI" in 0|1|2) local EPREFIX= ;; esac
+       if ! ___eapi_has_prefix_variables; then
+               local EPREFIX=
+       fi
 
        __hasg() {
                local x s=$1
@@ -409,9 +412,9 @@ econf() {
 
        __hasgq() { __hasg "$@" >/dev/null ; }
 
-       local phase_func=$(__ebuild_arg_to_phase "$EAPI" "$EBUILD_PHASE")
+       local phase_func=$(__ebuild_arg_to_phase "$EBUILD_PHASE")
        if [[ -n $phase_func ]] ; then
-               if has "$EAPI" 0 1 ; then
+               if ! ___eapi_has_src_configure; then
                        [[ $phase_func != src_compile ]] && \
                                eqawarn "QA Notice: econf called in" \
                                        "$phase_func instead of src_compile"
@@ -438,30 +441,25 @@ econf() {
                        done
                fi
 
-               # EAPI=4 adds --disable-dependency-tracking to econf
-               case "${EAPI}" in
-                       0|1|2|3)
-                               ;;
-                       *)
-                               local conf_help=$("${ECONF_SOURCE}/configure" --help 2>/dev/null)
+               if ___eapi_econf_passes_--disable-dependency-tracking || ___eapi_econf_passes_--disable-silent-rules; then
+                       local conf_help=$("${ECONF_SOURCE}/configure" --help 2>/dev/null)
+
+                       if ___eapi_econf_passes_--disable-dependency-tracking; then
                                case "${conf_help}" in
                                        *--disable-dependency-tracking*)
                                                set -- --disable-dependency-tracking "$@"
                                                ;;
                                esac
-                               case "${EAPI}" in
-                                       4|4-python|4-slot-abi)
-                                               ;;
-                                       *)
-                                               case "${conf_help}" in
-                                                       *--disable-silent-rules*)
-                                                               set -- --disable-silent-rules "$@"
-                                                               ;;
-                                               esac
+                       fi
+
+                       if ___eapi_econf_passes_--disable-silent-rules; then
+                               case "${conf_help}" in
+                                       *--disable-silent-rules*)
+                                               set -- --disable-silent-rules "$@"
                                                ;;
                                esac
-                               ;;
-               esac
+                       fi
+               fi
 
                # if the profile defines a location to install libs to aside from default, pass it on.
                # if the ebuild passes in --libdir, they're responsible for the conf_libdir fun.
@@ -512,8 +510,9 @@ econf() {
 einstall() {
        # CONF_PREFIX is only set if they didn't pass in libdir above.
        local LOCAL_EXTRA_EINSTALL="${EXTRA_EINSTALL}"
-       [[ " ${FEATURES} " == *" force-prefix "* ]] || \
-               case "$EAPI" in 0|1|2) local ED=${D} ;; esac
+       if ! ___eapi_has_prefix_variables; then
+               local ED=${D}
+       fi
        LIBDIR_VAR="LIBDIR_${ABI}"
        if [ -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then
                CONF_LIBDIR="${!LIBDIR_VAR}"
@@ -581,11 +580,9 @@ __eapi0_src_test() {
        # to emulate the desired parts of emake behavior.
        local emake_cmd="${MAKE:-make} ${MAKEOPTS} ${EXTRA_EMAKE}"
        local internal_opts=
-       case "$EAPI" in
-               0|1|2|3|4|4-python|4-slot-abi)
-                       internal_opts+=" -j1"
-                       ;;
-       esac
+       if ___eapi_default_src_test_disables_parallel_jobs; then
+               internal_opts+=" -j1"
+       fi
        if $emake_cmd ${internal_opts} check -n &> /dev/null; then
                __vecho ">>> Test phase [check]: ${CATEGORY}/${PF}"
                $emake_cmd ${internal_opts} check || \
@@ -652,23 +649,17 @@ has_version() {
        [ $# -gt 0 ] && die "${FUNCNAME[0]}: unused argument(s): $*"
 
        if ${host_root} ; then
-               case "${EAPI}" in
-                       0|1|2|3|4|4-python|4-slot-abi)
-                               die "${FUNCNAME[0]}: option --host-root is not supported with EAPI ${EAPI}"
-                               ;;
-               esac
+               if ! ___eapi_best_version_and_has_version_support_--host-root; then
+                       die "${FUNCNAME[0]}: option --host-root is not supported with EAPI ${EAPI}"
+               fi
                root=/
        fi
 
-       case "$EAPI" in
-               0|1|2)
-                       [[ " ${FEATURES} " == *" force-prefix "* ]] && \
-                               eroot=${root%/}${EPREFIX}/ || eroot=${root}
-                       ;;
-               *)
-                       eroot=${root%/}${EPREFIX}/
-                       ;;
-       esac
+       if ___eapi_has_prefix_variables; then
+               eroot=${root%/}${EPREFIX}/
+       else
+               eroot=${root}
+       fi
        if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
                "$PORTAGE_BIN_PATH"/ebuild-ipc has_version "${eroot}" "${atom}"
        else
@@ -704,23 +695,17 @@ best_version() {
        [ $# -gt 0 ] && die "${FUNCNAME[0]}: unused argument(s): $*"
 
        if ${host_root} ; then
-               case "${EAPI}" in
-                       0|1|2|3|4|4-python|4-slot-abi)
-                               die "${FUNCNAME[0]}: option --host-root is not supported with EAPI ${EAPI}"
-                               ;;
-               esac
+               if ! ___eapi_best_version_and_has_version_support_--host-root; then
+                       die "${FUNCNAME[0]}: option --host-root is not supported with EAPI ${EAPI}"
+               fi
                root=/
        fi
 
-       case "$EAPI" in
-               0|1|2)
-                       [[ " ${FEATURES} " == *" force-prefix "* ]] && \
-                               eroot=${root%/}${EPREFIX}/ || eroot=${root}
-                       ;;
-               *)
-                       eroot=${root%/}${EPREFIX}/
-                       ;;
-       esac
+       if ___eapi_has_prefix_variables; then
+               eroot=${root%/}${EPREFIX}/
+       else
+               eroot=${root}
+       fi
        if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
                "$PORTAGE_BIN_PATH"/ebuild-ipc best_version "${eroot}" "${atom}"
        else
index 7ae3938cee9d1bc9cacbc7dc826c0b8d3302d03b..92cc692dbc558b436e222742e6d5113681f04898 100644 (file)
@@ -76,10 +76,11 @@ __save_ebuild_env() {
                __unpack_tar __unset_colors \
                ${QA_INTERCEPTORS}
 
-       case "${EAPI}" in
-               0|1|2|3|4|4-python|4-slot-abi) ;;
-               *) unset -f usex ;;
-       esac
+       if ___eapi_has_usex; then
+               unset -f usex
+       fi
+
+       unset -f $(compgen -A function ___eapi_)
 
        # portage config variables and variables set directly by portage
        unset ACCEPT_LICENSE BAD BRACKET BUILD_PREFIX COLS \