aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Bo ├śrsted Andresen <zlin@exherbo.org> 2008-06-22 00:20:56 +0200
committerAvatar Bo ├śrsted Andresen <zlin@exherbo.org> 2008-06-22 12:59:06 +0200
commit21a249d3486b31eb0dae37f87e9028ae6aead55e (patch)
tree655dbb5b7d482dfa6e059e3a5f578a7a774a7cf0
parent568b7fed55079220d7400f7ec65775a7cd5fa04c (diff)
downloadpaludis-21a249d3486b31eb0dae37f87e9028ae6aead55e.tar.gz
paludis-21a249d3486b31eb0dae37f87e9028ae6aead55e.tar.xz
Make default() usable in exlibs and other functions whose name don't match $EBUILD_PHASE.
-rwxr-xr-xpaludis/repositories/e/ebuild/ebuild.bash45
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash5
2 files changed, 27 insertions, 23 deletions
diff --git a/paludis/repositories/e/ebuild/ebuild.bash b/paludis/repositories/e/ebuild/ebuild.bash
index 3cea0a8..001a5cf 100755
--- a/paludis/repositories/e/ebuild/ebuild.bash
+++ b/paludis/repositories/e/ebuild/ebuild.bash
@@ -391,6 +391,29 @@ perform_hook()
true
}
+paludis_phase_to_function_name() {
+ case "${1}" in
+ metadata|variable|init|initmisc|initrm|killold|killoldmisc|killoldrm|merge|\
+ unmerge|tidyup|tidyupmisc|tidyuprm|loadenv|saveenv|initbin|\
+ unpackbin|infovars|pivotbin|installbin)
+ echo builtin_${1}
+ ;;
+
+ unpack|prepare|configure|compile|install|test)
+ echo src_${1}
+ ;;
+
+ setup|config|nofetch|preinst|postinst|prerm|postrm|pretend|info)
+ echo pkg_${1}
+ ;;
+
+ *)
+ die "Usage error: Unknown phase '${1}'"
+ exit 1
+ ;;
+ esac
+}
+
ebuild_main()
{
if ! [[ -e /proc/self ]] && [[ "$(uname -s)" == Linux ]] ; then
@@ -411,27 +434,7 @@ ebuild_main()
fi
for action in $@ ; do
- case ${action} in
- metadata|variable|init|initmisc|initrm|killold|killoldmisc|killoldrm|merge|\
- unmerge|tidyup|tidyupmisc|tidyuprm|loadenv|saveenv|initbin|\
- unpackbin|infovars|pivotbin|installbin)
- ebuild_load_module builtin_${action}
- ;;
-
- unpack|prepare|configure|compile|install|test)
- ebuild_load_module src_${action}
- ;;
-
- setup|config|nofetch|preinst|postinst|prerm|postrm|pretend|info)
- ebuild_load_module pkg_${action}
- ;;
-
- *)
- ebuild_load_module usage_error
- ebuild_f_usage_error "Unknown action '${action}'"
- exit 1
- ;;
- esac
+ ebuild_load_module $(paludis_phase_to_function_name "${action}")
done
if [[ $1 == metadata ]] || [[ $1 == variable ]] || [[ $1 == pretend ]] ; then
diff --git a/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash b/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash
index 7fd495d..c5fe63f 100644
--- a/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash
@@ -81,6 +81,7 @@ require()
default()
{
- [[ $(type -t "default_${FUNCNAME[1]}" ) == "function" ]] || die "default_${FUNCNAME[1]} not a function"
- default_${FUNCNAME[1]} "$@"
+ [[ $(type -t "default_$(paludis_phase_to_function_name "${EBUILD_PHASE}")" ) == "function" ]] || \
+ die "default_$(paludis_phase_to_function_name "${EBUILD_PHASE}") is not a function"
+ default_$(paludis_phase_to_function_name "${EBUILD_PHASE}") "$@"
}