From 234da6d6cdc68042e13752283dccd1df6563d61c Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Sat, 9 Aug 2008 09:07:42 +0000 Subject: [PATCH] Merged from trunk 11349:11354 | 11350 | Implement eapi$EAPI_* default phase functions that are | | zmedico | equivalent to the default_* functions for the given EAPI. | | | For example, a function named eapi0_src_compile provides | | | access to the default src_compile implementation that EAPI 0 | | | provides. This feature is supported only when EAPI=2_pre2 is | | | set. Thanks to Brian Harring for suggesting this idea. | | 11351 | Rename the eapi2_pre2_* functions to just eapi2_* and | | zmedico | document all the new eapi* functions. | | 11352 | Fix default phase functions in EAPI 2_pre2, since they | | zmedico | should be labeled as "2" instead of "2_pre2. Thanks to | | | Arfrever for reporting. | | 11353 | Add missing default_src_configure() function to table. | | zmedico | Thanks to Arfrever. | | 11354 | Fix broken quoting in eval statements. Thanks to Arfrever. | | zmedico | | svn path=/main/branches/prefix/; revision=11361 --- bin/ebuild.sh | 163 ++++++++++++++++++++---------- bin/isolated-functions.sh | 2 +- doc/package/ebuild/eapi/2.docbook | 90 ++++++++++++++++- 3 files changed, 197 insertions(+), 58 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index cff8a0dfc..8d125d621 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -583,7 +583,7 @@ einstall() { fi } -_default_pkg_nofetch() { +_eapi0_pkg_nofetch() { [ -z "${SRC_URI}" ] && return echo "!!! The following are listed in SRC_URI for ${PN}:" @@ -593,25 +593,18 @@ _default_pkg_nofetch() { done } -_default_src_unpack() { +_eapi0_src_unpack() { [[ -n ${A} ]] && unpack ${A} } -_default_src_configure() { - if [ "${EAPI:-0}" == 0 ] ; then - [ -x ./configure ] && econf - elif [ -x "${ECONF_SOURCE:-.}/configure" ] ; then +_eapi0_src_compile() { + if [ -x ./configure ] ; then econf fi + _eapi2_src_compile } -_default_src_compile() { - if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ]; then - emake || die "emake failed" - fi -} - -_default_src_test() { +_eapi0_src_test() { if emake -j1 check -n &> /dev/null; then vecho ">>> Test phase [check]: ${CATEGORY}/${PF}" if ! emake -j1 check; then @@ -629,19 +622,31 @@ _default_src_test() { fi } -pkg_nofetch() { - _default_pkg_nofetch +_eapi1_src_compile() { + if [[ -x ${ECONF_SOURCE:-.}/configure ]] ; then + econf + fi + _eapi2_src_compile } -src_unpack() { - _default_src_unpack +_eapi2_src_configure() { + if [[ -x ${ECONF_SOURCE:-.}/configure ]] ; then + econf + fi } -src_compile() { - hasq "$EAPI" 0 1 2_pre1 && \ - _default_src_configure +_eapi2_src_compile() { + if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ]; then + emake || die "emake failed" + fi +} + +pkg_nofetch() { + _eapi0_pkg_nofetch +} - _default_src_compile +src_unpack() { + _eapi0_src_unpack } src_install() { @@ -654,7 +659,7 @@ src_install() { } src_test() { - _default_src_test + _eapi0_src_test } ebuild_phase() { @@ -1269,7 +1274,7 @@ EXPORT_FUNCTIONS() { fi while [ "$1" ]; do debug-print "EXPORT_FUNCTIONS: ${1} -> ${ECLASS}_${1}" - eval "$1() { ${ECLASS}_$1 "\$@" ; }" > /dev/null + eval "$1() { ${ECLASS}_$1 \"\$@\" ; }" > /dev/null shift done } @@ -1412,57 +1417,105 @@ _ebuild_phase_funcs() { [ $# -ne 2 ] && die "expected exactly 2 args, got $#: $*" local eapi=$1 local phase_func=$2 - local eapi_has_default_fns=$(hasq $eapi 0 1 2_pre1 && echo 0 || echo 1) local default_phases="pkg_nofetch src_unpack src_configure - src_compile src_test" - local x default_func="" + src_compile src_install src_test" + local x y default_func="" - [[ $eapi_has_default_fns = 1 ]] && \ - hasq $phase_func $default_phases && \ - default_func=$phase_func - - if [[ $eapi_has_default_fns = 1 ]] ; then - - if [[ -n $default_func ]] ; then - - for x in $default_phases ; do - eval "default_$x() { _default_$x \"\$@\" ; }" - done + for x in pkg_nofetch src_unpack src_test ; do + [[ $(type -t $x) = function ]] || \ + eval "$x() { _eapi0_$x \"\$@\" ; }" + done - [[ $(type -t src_configure) = function ]] || \ - src_configure() { _default_src_configure "$@" ; } + case $eapi in - eval "default() { - _default_$default_func "$@" - }" + 0|1|2_pre1) - else + if [[ $(type -t src_compile) != function ]] ; then + case $eapi in + 0) + src_compile() { _eapi0_src_compile "$@" ; } + ;; + *) + src_compile() { _eapi1_src_compile "$@" ; } + ;; + esac + fi for x in $default_phases ; do eval "default_$x() { - die \"default_$x() is not supported in phase $default_func\" + die \"default_$x() is not supported with EAPI='$eapi' during phase $phase_func\" }" + for y in 0 1 2 ; do + eval "eapi${y}_$x() { + die \"eapi${y}_$x() is not supported with EAPI='$eapi' during phase $phase_func\" + }" + done done eval "default() { die \"default() is not supported with EAPI='$eapi' during phase $phase_func\" }" - fi + ;; - else + *) - for x in $default_phases ; do - eval "default_$x() { - die \"default_$x() is not supported with EAPI='$eapi' during phase $phase_func\" - }" - done + [[ $(type -t src_configure) = function ]] || \ + src_configure() { _eapi2_src_configure "$@" ; } + + [[ $(type -t src_compile) = function ]] || \ + src_compile() { _eapi2_src_compile "$@" ; } + + if hasq $phase_func $default_phases ; then + + eapi0_pkg_nofetch () { _eapi0_pkg_nofetch "$@" ; } + eapi0_src_unpack () { _eapi0_src_unpack "$@" ; } + eapi0_src_configure () { die "$FUNCNAME is not supported" ; } + eapi0_src_compile () { _eapi0_src_compile "$@" ; } + eapi0_src_test () { _eapi0_src_test "$@" ; } + eapi0_src_install () { _eapi0_src_install "$@" ; } + + eapi1_pkg_nofetch () { _eapi0_pkg_nofetch "$@" ; } + eapi1_src_unpack () { _eapi0_src_unpack "$@" ; } + eapi1_src_configure () { die "$FUNCNAME is not supported" ; } + eapi1_src_compile () { _eapi1_src_compile "$@" ; } + eapi1_src_test () { _eapi0_src_test "$@" ; } + eapi1_src_install () { _eapi0_src_install "$@" ; } + + eapi2_pkg_nofetch () { _eapi0_pkg_nofetch "$@" ; } + eapi2_src_unpack () { _eapi0_src_unpack "$@" ; } + eapi2_src_configure () { _eapi2_src_configure "$@" ; } + eapi2_src_compile () { _eapi2_src_compile "$@" ; } + eapi2_src_test () { _eapi0_src_test "$@" ; } + eapi2_src_install () { _eapi0_src_install "$@" ; } + + for x in $default_phases ; do + eval "default_$x() { eapi2_$x \"\$@\" ; }" + done - default() { - die "default() is not supported with EAPI='$eapi' during phase $phase_func" - } + eval "default() { eapi2_$phase_func \"\$@\" ; }" - fi + else + + for x in $default_phases ; do + eval "default_$x() { + die \"default_$x() is not supported in phase $default_func\" + }" + for y in 0 1 2 ; do + eval "eapi${y}_$x() { + die \"eapi${y}_$x() is not supported with EAPI='$eapi' during phase $phase_func\" + }" + done + done + + eval "default() { + die \"default() is not supported with EAPI='$eapi' during phase $phase_func\" + }" + + fi + + ;; + esac } # @FUNCTION: source_all_bashrcs diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index fb4754381..931aec2f7 100755 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -561,7 +561,7 @@ save_ebuild_env() { for x in pkg_setup pkg_nofetch src_unpack src_configure \ src_compile src_test src_install pkg_preinst pkg_postinst \ pkg_prerm pkg_postrm ; do - unset -f {,_}default_$x + unset -f {,_}default_$x {,_}eapi{0,1,2}_$x done unset x diff --git a/doc/package/ebuild/eapi/2.docbook b/doc/package/ebuild/eapi/2.docbook index 275ab71ef..1bd1c986c 100644 --- a/doc/package/ebuild/eapi/2.docbook +++ b/doc/package/ebuild/eapi/2.docbook @@ -155,13 +155,99 @@ Default Phase Functions - Each of the default src_* phase functions is now accessible - via a function having a name that begins with default_ and + The default pkg_nofetch and src_* phase functions are now + accessible via a function having a name + that begins with default_ and ends with the respective phase function name. For example, a call to a function with the name default_src_compile is equivalent to a call to the default src_compile implementation. + Default Phase Functions + + + + + Function Name + + + + + default_pkg_nofetch + + + default_src_unpack + + + default_src_configure + + + default_src_compile + + + default_src_test + + + +
+ + The default phase functions for a particular EAPI are also + accessible as functions having names that start with 'eapi' + followed by the EAPI value. For example, a call to a function + named eapi0_src_compile is equivalent to a call to the + default src_compile implementation that is provided with EAPI 0. + + Default EAPI Phase Functions + + + + + Function Name + + + + + eapi0_pkg_nofetch + + + eapi0_src_unpack + + + eapi0_src_compile + + + eapi0_src_test + + + eapi1_pkg_nofetch + + + eapi1_src_unpack + + + eapi1_src_compile + + + eapi1_src_test + + + eapi2_pkg_nofetch + + + eapi2_src_unpack + + + eapi2_src_configure + + + eapi2_src_compile + + + eapi2_src_test + + + +
Default Phase Function Alias -- 2.26.2