summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-09-11 15:50:07 -0700
committerZac Medico <zmedico@gentoo.org>2011-09-11 15:50:07 -0700
commite40e2bce40464dace057d91f0a24ba682928814a (patch)
tree1dc9e22c9045938bbad6b03f86f97d5af2b328ff
parentfdd2bc1c1fdf8f20732749d44c39c3cab3cc2d52 (diff)
downloadportage-e40e2bce40464dace057d91f0a24ba682928814a.tar.gz
portage-e40e2bce40464dace057d91f0a24ba682928814a.tar.bz2
portage-e40e2bce40464dace057d91f0a24ba682928814a.zip
build.sh: has/best_version to phase-helpers.sh
-rwxr-xr-xbin/ebuild.sh59
-rw-r--r--bin/phase-helpers.sh42
2 files changed, 47 insertions, 54 deletions
diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 6bcc6b314..4dd29216a 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -127,30 +127,6 @@ esyslog() {
return 0
}
-# Return true if given package is installed. Otherwise return false.
-# Takes single depend-type atoms.
-has_version() {
- if [ "${EBUILD_PHASE}" == "depend" ]; then
- die "portageq calls (has_version calls portageq) are not allowed in the global scope"
- fi
-
- if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
- "$PORTAGE_BIN_PATH"/ebuild-ipc has_version "$ROOT" "$1"
- else
- PYTHONPATH=${PORTAGE_PYM_PATH}${PYTHONPATH:+:}${PYTHONPATH} \
- "${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}/portageq" has_version "${ROOT}" "$1"
- fi
- local retval=$?
- case "${retval}" in
- 0|1)
- return ${retval}
- ;;
- *)
- die "unexpected portageq exit code: ${retval}"
- ;;
- esac
-}
-
portageq() {
if [ "${EBUILD_PHASE}" == "depend" ]; then
die "portageq calls are not allowed in the global scope"
@@ -160,36 +136,6 @@ portageq() {
"${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}/portageq" "$@"
}
-
-# ----------------------------------------------------------------------------
-# ----------------------------------------------------------------------------
-# ----------------------------------------------------------------------------
-
-
-# Returns the best/most-current match.
-# Takes single depend-type atoms.
-best_version() {
- if [ "${EBUILD_PHASE}" == "depend" ]; then
- die "portageq calls (best_version calls portageq) are not allowed in the global scope"
- fi
-
- if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
- "$PORTAGE_BIN_PATH"/ebuild-ipc best_version "$ROOT" "$1"
- else
- PYTHONPATH=${PORTAGE_PYM_PATH}${PYTHONPATH:+:}${PYTHONPATH} \
- "${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}/portageq" 'best_version' "${ROOT}" "$1"
- fi
- local retval=$?
- case "${retval}" in
- 0|1)
- return ${retval}
- ;;
- *)
- die "unexpected portageq exit code: ${retval}"
- ;;
- esac
-}
-
register_die_hook() {
local x
for x in $* ; do
@@ -793,6 +739,11 @@ else
keepdir libopts use useq usev use_with use_enable ; do
eval "${x}() { : ; }"
done
+ # These functions die because calls to them during the "depend" phase
+ # are considered to be severe QA violations.
+ for x in best_version has_version ; do
+ eval "${x}() { die \"\${FUNCNAME} calls are not allowed in global scope\"; }"
+ done
unset x
fi
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 6064346be..1f39c7556 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -571,3 +571,45 @@ _eapi4_src_install() {
dodoc ${DOCS}
fi
}
+
+# Return true if given package is installed. Otherwise return false.
+# Takes single depend-type atoms.
+has_version() {
+
+ if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
+ "$PORTAGE_BIN_PATH"/ebuild-ipc has_version "$ROOT" "$1"
+ else
+ PYTHONPATH=${PORTAGE_PYM_PATH}${PYTHONPATH:+:}${PYTHONPATH} \
+ "${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}/portageq" has_version "${ROOT}" "$1"
+ fi
+ local retval=$?
+ case "${retval}" in
+ 0|1)
+ return ${retval}
+ ;;
+ *)
+ die "unexpected portageq exit code: ${retval}"
+ ;;
+ esac
+}
+
+# Returns the best/most-current match.
+# Takes single depend-type atoms.
+best_version() {
+
+ if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
+ "$PORTAGE_BIN_PATH"/ebuild-ipc best_version "$ROOT" "$1"
+ else
+ PYTHONPATH=${PORTAGE_PYM_PATH}${PYTHONPATH:+:}${PYTHONPATH} \
+ "${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}/portageq" best_version "${ROOT}" "$1"
+ fi
+ local retval=$?
+ case "${retval}" in
+ 0|1)
+ return ${retval}
+ ;;
+ *)
+ die "unexpected portageq exit code: ${retval}"
+ ;;
+ esac
+}