summaryrefslogtreecommitdiffstats
path: root/bin/ebuild.sh
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-08-08 11:24:31 +0000
committerZac Medico <zmedico@gentoo.org>2008-08-08 11:24:31 +0000
commit07103829a1bf0d6faed52a5ac3bf7130967e3726 (patch)
tree5b70d29241edca4e112cab7cda5141ee7e8da3cf /bin/ebuild.sh
parent2e5c28ed64b7e870bc2d0799efcf786e2577fdc3 (diff)
downloadportage-07103829a1bf0d6faed52a5ac3bf7130967e3726.tar.gz
portage-07103829a1bf0d6faed52a5ac3bf7130967e3726.tar.bz2
portage-07103829a1bf0d6faed52a5ac3bf7130967e3726.zip
Implement eapi$EAPI_* default phase functions that are 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. svn path=/main/trunk/; revision=11350
Diffstat (limited to 'bin/ebuild.sh')
-rwxr-xr-xbin/ebuild.sh161
1 files changed, 107 insertions, 54 deletions
diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 6cd69b7e2..734dd0ad6 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,23 +622,35 @@ _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_test() {
- _default_src_test
+ _eapi0_src_test
}
ebuild_phase() {
@@ -1402,57 +1407,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_pre1 ; 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_pre2_pkg_nofetch () { _eapi0_pkg_nofetch "$@" ; }
+ eapi2_pre2_src_unpack () { _eapi0_src_unpack "$@" ; }
+ eapi2_pre2_src_configure () { _eapi2_src_configure "$@" ; }
+ eapi2_pre2_src_compile () { _eapi2_src_compile "$@" ; }
+ eapi2_pre2_src_test () { _eapi0_src_test "$@" ; }
+ eapi2_pre2_src_install () { _eapi0_src_install "$@" ; }
+
+ for x in $default_phases ; do
+ eval "default_$x() { eapi${eapi}_$x \"\$@\" ; }"
+ done
- default() {
- die "default() is not supported with EAPI='$eapi' during phase $phase_func"
- }
+ eval "default() { eapi${eapi}_$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_pre2 ; 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