From ab46499322311c1faa710c63d0a5339e49a9061a Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Wed, 26 Sep 2012 22:31:20 +0200 Subject: [PATCH] Add eapi.sh with ___eapi_*() functions and use these functions in other files. --- bin/eapi.sh | 113 +++++++++++++++++++++++ bin/ebuild-helpers/dobin | 7 +- bin/ebuild-helpers/dodir | 7 +- bin/ebuild-helpers/dodoc | 21 ++--- bin/ebuild-helpers/doexe | 7 +- bin/ebuild-helpers/dohard | 19 ++-- bin/ebuild-helpers/doheader | 8 +- bin/ebuild-helpers/doinfo | 7 +- bin/ebuild-helpers/doins | 18 ++-- bin/ebuild-helpers/dolib | 7 +- bin/ebuild-helpers/doman | 7 +- bin/ebuild-helpers/domo | 7 +- bin/ebuild-helpers/dosbin | 7 +- bin/ebuild-helpers/dosed | 19 ++-- bin/ebuild-helpers/dosym | 5 +- bin/ebuild-helpers/ecompressdir | 7 +- bin/ebuild-helpers/fowners | 5 +- bin/ebuild-helpers/fperms | 7 +- bin/ebuild-helpers/newins | 17 ++-- bin/ebuild-helpers/prepall | 7 +- bin/ebuild-helpers/prepalldocs | 17 ++-- bin/ebuild-helpers/prepallinfo | 7 +- bin/ebuild-helpers/prepallman | 9 +- bin/ebuild-helpers/prepallstrip | 9 +- bin/ebuild-helpers/prepinfo | 9 +- bin/ebuild-helpers/preplib | 7 +- bin/ebuild-helpers/prepman | 9 +- bin/ebuild-helpers/prepstrip | 5 +- bin/ebuild.sh | 32 +++---- bin/isolated-functions.sh | 17 ++-- bin/misc-functions.sh | 43 +++++---- bin/phase-functions.sh | 53 +++++------ bin/phase-helpers.sh | 155 +++++++++++++++----------------- bin/save-ebuild-env.sh | 9 +- 34 files changed, 386 insertions(+), 297 deletions(-) create mode 100644 bin/eapi.sh diff --git a/bin/eapi.sh b/bin/eapi.sh new file mode 100644 index 000000000..a561c1cf8 --- /dev/null +++ b/bin/eapi.sh @@ -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)$ ]] +} diff --git a/bin/ebuild-helpers/dobin b/bin/ebuild-helpers/dobin index 06ae0c779..0ba1eb0c4 100755 --- a/bin/ebuild-helpers/dobin +++ b/bin/ebuild-helpers/dobin @@ -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; } diff --git a/bin/ebuild-helpers/dodir b/bin/ebuild-helpers/dodir index c8f763deb..e03ba9a58 100755 --- a/bin/ebuild-helpers/dodir +++ b/bin/ebuild-helpers/dodir @@ -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=$? diff --git a/bin/ebuild-helpers/dodoc b/bin/ebuild-helpers/dodoc index 2b0533feb..bba790384 100755 --- a/bin/ebuild-helpers/dodoc +++ b/bin/ebuild-helpers/dodoc @@ -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 diff --git a/bin/ebuild-helpers/doexe b/bin/ebuild-helpers/doexe index efbf638fc..aa050e9ed 100755 --- a/bin/ebuild-helpers/doexe +++ b/bin/ebuild-helpers/doexe @@ -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_}" diff --git a/bin/ebuild-helpers/dohard b/bin/ebuild-helpers/dohard index 6ae93d240..e0a44faf1 100755 --- a/bin/ebuild-helpers/dohard +++ b/bin/ebuild-helpers/dohard @@ -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}" diff --git a/bin/ebuild-helpers/doheader b/bin/ebuild-helpers/doheader index db3a02d09..37953658b 100755 --- a/bin/ebuild-helpers/doheader +++ b/bin/ebuild-helpers/doheader @@ -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" diff --git a/bin/ebuild-helpers/doinfo b/bin/ebuild-helpers/doinfo index e4ccc90d9..355047f73 100755 --- a/bin/ebuild-helpers/doinfo +++ b/bin/ebuild-helpers/doinfo @@ -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; } diff --git a/bin/ebuild-helpers/doins b/bin/ebuild-helpers/doins index c534f3f39..4679e83a9 100755 --- a/bin/ebuild-helpers/doins +++ b/bin/ebuild-helpers/doins @@ -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. diff --git a/bin/ebuild-helpers/dolib b/bin/ebuild-helpers/dolib index 402965de7..fd92d7f03 100755 --- a/bin/ebuild-helpers/dolib +++ b/bin/ebuild-helpers/dolib @@ -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}" diff --git a/bin/ebuild-helpers/doman b/bin/ebuild-helpers/doman index c10296b34..d6808597a 100755 --- a/bin/ebuild-helpers/doman +++ b/bin/ebuild-helpers/doman @@ -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="" diff --git a/bin/ebuild-helpers/domo b/bin/ebuild-helpers/domo index 840b2de4c..9a8dda38a 100755 --- a/bin/ebuild-helpers/domo +++ b/bin/ebuild-helpers/domo @@ -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/" diff --git a/bin/ebuild-helpers/dosbin b/bin/ebuild-helpers/dosbin index edc458465..361ca83ca 100755 --- a/bin/ebuild-helpers/dosbin +++ b/bin/ebuild-helpers/dosbin @@ -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; } diff --git a/bin/ebuild-helpers/dosed b/bin/ebuild-helpers/dosed index 24ec20587..7db062963 100755 --- a/bin/ebuild-helpers/dosed +++ b/bin/ebuild-helpers/dosed @@ -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 diff --git a/bin/ebuild-helpers/dosym b/bin/ebuild-helpers/dosym index 34637c2f7..649b100de 100755 --- a/bin/ebuild-helpers/dosym +++ b/bin/ebuild-helpers/dosym @@ -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 diff --git a/bin/ebuild-helpers/ecompressdir b/bin/ebuild-helpers/ecompressdir index 097ade2bc..75f3e3a25 100755 --- a/bin/ebuild-helpers/ecompressdir +++ b/bin/ebuild-helpers/ecompressdir @@ -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) diff --git a/bin/ebuild-helpers/fowners b/bin/ebuild-helpers/fowners index 5b93fd3c3..b664ec766 100755 --- a/bin/ebuild-helpers/fowners +++ b/bin/ebuild-helpers/fowners @@ -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 diff --git a/bin/ebuild-helpers/fperms b/bin/ebuild-helpers/fperms index 668e905a2..d854ebbdf 100755 --- a/bin/ebuild-helpers/fperms +++ b/bin/ebuild-helpers/fperms @@ -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 diff --git a/bin/ebuild-helpers/newins b/bin/ebuild-helpers/newins index 20c68a1e2..3538f7060 100755 --- a/bin/ebuild-helpers/newins +++ b/bin/ebuild-helpers/newins @@ -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" diff --git a/bin/ebuild-helpers/prepall b/bin/ebuild-helpers/prepall index 49e646cd2..fb5c2db55 100755 --- a/bin/ebuild-helpers/prepall +++ b/bin/ebuild-helpers/prepall @@ -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. diff --git a/bin/ebuild-helpers/prepalldocs b/bin/ebuild-helpers/prepalldocs index 50b0c7070..b76f08439 100755 --- a/bin/ebuild-helpers/prepalldocs +++ b/bin/ebuild-helpers/prepalldocs @@ -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 diff --git a/bin/ebuild-helpers/prepallinfo b/bin/ebuild-helpers/prepallinfo index db9bbfacb..1a2027580 100755 --- a/bin/ebuild-helpers/prepallinfo +++ b/bin/ebuild-helpers/prepallinfo @@ -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 diff --git a/bin/ebuild-helpers/prepallman b/bin/ebuild-helpers/prepallman index dee1c7236..7c78324cd 100755 --- a/bin/ebuild-helpers/prepallman +++ b/bin/ebuild-helpers/prepallman @@ -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 diff --git a/bin/ebuild-helpers/prepallstrip b/bin/ebuild-helpers/prepallstrip index 28320d975..1aa6686cd 100755 --- a/bin/ebuild-helpers/prepallstrip +++ b/bin/ebuild-helpers/prepallstrip @@ -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}" diff --git a/bin/ebuild-helpers/prepinfo b/bin/ebuild-helpers/prepinfo index e213f32d1..5afc18a71 100755 --- a/bin/ebuild-helpers/prepinfo +++ b/bin/ebuild-helpers/prepinfo @@ -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}" diff --git a/bin/ebuild-helpers/preplib b/bin/ebuild-helpers/preplib index 6e91cf33d..764261d98 100755 --- a/bin/ebuild-helpers/preplib +++ b/bin/ebuild-helpers/preplib @@ -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 diff --git a/bin/ebuild-helpers/prepman b/bin/ebuild-helpers/prepman index f96b64147..142d40443 100755 --- a/bin/ebuild-helpers/prepman +++ b/bin/ebuild-helpers/prepman @@ -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 diff --git a/bin/ebuild-helpers/prepstrip b/bin/ebuild-helpers/prepstrip index 802fdd826..0d1ce5a09 100755 --- a/bin/ebuild-helpers/prepstrip +++ b/bin/ebuild-helpers/prepstrip @@ -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 diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 06e2c66f6..aa3dcdd28 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -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 ( diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index fa84c7ee3..f8e7862ee 100644 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -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() { diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh index 55d37f29d..986264ed8 100755 --- a/bin/misc-functions.sh +++ b/bin/misc-functions.sh @@ -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) diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index 97e762a39..7a0baf453 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -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 diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh index 157725ff3..dc70de658 100644 --- a/bin/phase-helpers.sh +++ b/bin/phase-helpers.sh @@ -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 diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh index 7ae3938ce..92cc692db 100644 --- a/bin/save-ebuild-env.sh +++ b/bin/save-ebuild-env.sh @@ -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 \ -- 2.26.2