From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 8D94313838B for ; Thu, 11 Sep 2014 23:45:29 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DFF0BE0941; Thu, 11 Sep 2014 23:45:27 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A128DE0938 for ; Thu, 11 Sep 2014 23:45:26 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9010B33DF72 for ; Thu, 11 Sep 2014 23:45:25 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 0166D5401 for ; Thu, 11 Sep 2014 23:45:23 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1410479065.772ed29fd9e7cf722aed943adbe33a27f250e1ff.dol-sen@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/phase-functions.sh bin/save-ebuild-env.sh X-VCS-Directories: bin/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 772ed29fd9e7cf722aed943adbe33a27f250e1ff X-VCS-Branch: master Date: Thu, 11 Sep 2014 23:45:23 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 6d081ccb-27f6-4058-9c4d-6fc50f858fd3 X-Archives-Hash: 51d7f2fb28181d7e906c79938b376e96 commit: 772ed29fd9e7cf722aed943adbe33a27f250e1ff Author: Michał Górny gentoo org> AuthorDate: Mon Aug 18 11:54:15 2014 +0000 Commit: Brian Dolbec gmail com> CommitDate: Thu Sep 11 23:44:25 2014 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=772ed29f Rewrite default ebuild phase setting code Replace the ebuild phase setting code for EAPI 2 and newer with a simpler approach; first set proper default_* functions, and call them within the phase. Disallow calling default_* for other phase functions than the one being run. --- bin/phase-functions.sh | 117 ++++++++++++++++++++++--------------------------- bin/save-ebuild-env.sh | 2 +- 2 files changed, 53 insertions(+), 66 deletions(-) diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index df385b8..9bc3eb5 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -750,91 +750,78 @@ __ebuild_phase_funcs() { [ $# -ne 2 ] && die "expected exactly 2 args, got $#: $*" local eapi=$1 local phase_func=$2 - local default_phases="pkg_nofetch src_unpack src_prepare src_configure - src_compile src_install src_test" - local x y default_func="" - - for x in pkg_nofetch src_unpack src_test ; do - declare -F $x >/dev/null || \ - eval "$x() { __eapi0_$x \"\$@\" ; }" + local all_phases="src_compile pkg_config src_configure pkg_info + src_install pkg_nofetch pkg_postinst pkg_postrm pkg_preinst + src_prepare pkg_prerm pkg_pretend pkg_setup src_test src_unpack" + local x + + # First, set up the error handlers for default* + for x in ${all_phases} ; do + eval "default_${x}() { + die \"default_${x}() is not supported in EAPI='${eapi}' in phase ${phase_func}\" + }" done + # We can just call the specific handler -- it will either error out + # on invalid phase or run it. + eval "default() { + default_${phase_func} + }" + case "$eapi" in + 0|1) # EAPIs not supporting 'default' - 0|1) + for x in pkg_nofetch src_unpack src_test ; do + declare -F $x >/dev/null || \ + eval "$x() { __eapi0_$x; }" + done if ! declare -F src_compile >/dev/null ; then case "$eapi" in 0) - src_compile() { __eapi0_src_compile "$@" ; } + src_compile() { __eapi0_src_compile; } ;; *) - src_compile() { __eapi1_src_compile "$@" ; } + src_compile() { __eapi1_src_compile; } ;; esac fi - - for x in $default_phases ; do - eval "default_$x() { - die \"default_$x() is not supported with EAPI='$eapi' during phase $phase_func\" - }" - done - - eval "default() { - die \"default() is not supported with EAPI='$eapi' during phase $phase_func\" - }" - ;; - *) - + *) # EAPIs supporting 'default' + + # defaults starting with EAPI 0 + [[ ${phase_func} == pkg_nofetch ]] && \ + default_pkg_nofetch() { __eapi0_pkg_nofetch; } + [[ ${phase_func} == src_unpack ]] && \ + default_src_unpack() { __eapi0_src_unpack; } + [[ ${phase_func} == src_test ]] && \ + default_src_test() { __eapi0_src_test; } + + # defaults starting with EAPI 2 + [[ ${phase_func} == src_configure ]] && \ + default_src_configure() { __eapi2_src_configure; } + [[ ${phase_func} == src_compile ]] && \ + default_src_compile() { __eapi2_src_compile; } + + # bind supported phases to the defaults + declare -F src_unpack >/dev/null || \ + src_unpack() { default; } declare -F src_configure >/dev/null || \ - src_configure() { __eapi2_src_configure "$@" ; } - + src_configure() { default; } declare -F src_compile >/dev/null || \ - src_compile() { __eapi2_src_compile "$@" ; } - - has $eapi 2 3 || declare -F src_install >/dev/null || \ - src_install() { __eapi4_src_install "$@" ; } + src_compile() { default; } + declare -F src_test >/dev/null || \ + src_test() { default; } - if has $phase_func $default_phases ; then - - __eapi2_pkg_nofetch () { __eapi0_pkg_nofetch "$@" ; } - __eapi2_src_unpack () { __eapi0_src_unpack "$@" ; } - __eapi2_src_prepare () { true ; } - __eapi2_src_test () { __eapi0_src_test "$@" ; } - __eapi2_src_install () { die "$FUNCNAME is not supported" ; } - - for x in $default_phases ; do - eval "default_$x() { __eapi2_$x \"\$@\" ; }" - done - - eval "default() { __eapi2_$phase_func \"\$@\" ; }" - - case "$eapi" in - 2|3) - ;; - *) - eval "default_src_install() { __eapi4_src_install \"\$@\" ; }" - [[ $phase_func = src_install ]] && \ - eval "default() { __eapi4_$phase_func \"\$@\" ; }" - ;; - esac - - else - - for x in $default_phases ; do - eval "default_$x() { - die \"default_$x() is not supported in phase $default_func\" - }" - done - - eval "default() { - die \"default() is not supported with EAPI='$eapi' during phase $phase_func\" - }" + # defaults starting with EAPI 4 + if ! has ${eapi} 2 3; then + [[ ${phase_func} == src_install ]] && \ + default_src_install() { __eapi4_src_install; } + declare -F src_install >/dev/null || \ + src_install() { default; } fi - ;; esac } diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh index 98cff83..de0c499 100644 --- a/bin/save-ebuild-env.sh +++ b/bin/save-ebuild-env.sh @@ -42,7 +42,7 @@ __save_ebuild_env() { for x in pkg_setup pkg_nofetch src_unpack src_prepare src_configure \ src_compile src_test src_install pkg_preinst pkg_postinst \ - pkg_prerm pkg_postrm ; do + pkg_prerm pkg_postrm pkg_config pkg_info pkg_pretend ; do unset -f default_$x __eapi{0,1,2,3,4}_$x done unset x