summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico2012-08-31 01:49:10 (GMT)
committerZac Medico2012-08-31 01:49:10 (GMT)
commitbcf4ab871ededc3d535165757ba5597669e33dcb (patch)
treeb80f81f5e018b06903d99fedf43800cc48b72e94
parentf9922394bbb674b04f6bed38c1598e8e2e01906f (diff)
EAPI 5: --host-root option for best/has_version
See bug #401239 and the PMS patch: http://git.overlays.gentoo.org/gitweb/?p=proj/pms.git;a=commit;h=25fb5fca6674215ea8aaa3d0ec3dd3df451eec07
-rw-r--r--bin/phase-helpers.sh68
1 files changed, 56 insertions, 12 deletions
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index db1548e..6899488 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -632,28 +632,50 @@ _eapi5_apply_user_patches() {
}
# @FUNCTION: has_version
-# @USAGE: <DEPEND ATOM>
+# @USAGE: [--host-root] <DEPEND ATOM>
# @DESCRIPTION:
# Return true if given package is installed. Otherwise return false.
# Callers may override the ROOT variable in order to match packages from an
# alternative ROOT.
has_version() {
- local eroot
+ local atom eroot host_root=false root=${ROOT}
+ while [ $# -gt 0 ] ; do
+ case "$1" in
+ --host-root)
+ host_root=true
+ ;;
+ *)
+ [[ -n ${atom} ]] && die "${FUNCNAME[0]}: unused argument: $1"
+ atom=$1
+ ;;
+ esac
+ shift
+ done
+
+ if ${host_root} ; then
+ case "${EAPI}" in
+ 0|1|2|3|4|4-python|4-slot-abi)
+ die "${FUNCNAME[0]}: option --host-root is not supported with EAPI ${EAPI}"
+ ;;
+ esac
+ root=/
+ fi
+
case "$EAPI" in
0|1|2)
[[ " ${FEATURES} " == *" force-prefix "* ]] && \
- eroot=${ROOT%/}${EPREFIX}/ || eroot=${ROOT}
+ eroot=${root%/}${EPREFIX}/ || eroot=${root}
;;
*)
- eroot=${ROOT%/}${EPREFIX}/
+ eroot=${root%/}${EPREFIX}/
;;
esac
if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
- "$PORTAGE_BIN_PATH"/ebuild-ipc has_version "${eroot}" "$1"
+ "$PORTAGE_BIN_PATH"/ebuild-ipc has_version "${eroot}" "${atom}"
else
PYTHONPATH=${PORTAGE_PYM_PATH}${PYTHONPATH:+:}${PYTHONPATH} \
- "${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}/portageq" has_version "${eroot}" "$1"
+ "${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}/portageq" has_version "${eroot}" "${atom}"
fi
local retval=$?
case "${retval}" in
@@ -667,28 +689,50 @@ has_version() {
}
# @FUNCTION: best_version
-# @USAGE: <DEPEND ATOM>
+# @USAGE: [--host-root] <DEPEND ATOM>
# @DESCRIPTION:
# Returns the best/most-current match.
# Callers may override the ROOT variable in order to match packages from an
# alternative ROOT.
best_version() {
- local eroot
+ local atom eroot host_root=false root=${ROOT}
+ while [ $# -gt 0 ] ; do
+ case "$1" in
+ --host-root)
+ host_root=true
+ ;;
+ *)
+ [[ -n ${atom} ]] && die "${FUNCNAME[0]}: unused argument: $1"
+ atom=$1
+ ;;
+ esac
+ shift
+ done
+
+ if ${host_root} ; then
+ case "${EAPI}" in
+ 0|1|2|3|4|4-python|4-slot-abi)
+ die "${FUNCNAME[0]}: option --host-root is not supported with EAPI ${EAPI}"
+ ;;
+ esac
+ root=/
+ fi
+
case "$EAPI" in
0|1|2)
[[ " ${FEATURES} " == *" force-prefix "* ]] && \
- eroot=${ROOT%/}${EPREFIX}/ || eroot=${ROOT}
+ eroot=${root%/}${EPREFIX}/ || eroot=${root}
;;
*)
- eroot=${ROOT%/}${EPREFIX}/
+ eroot=${root%/}${EPREFIX}/
;;
esac
if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
- "$PORTAGE_BIN_PATH"/ebuild-ipc best_version "${eroot}" "$1"
+ "$PORTAGE_BIN_PATH"/ebuild-ipc best_version "${eroot}" "${atom}"
else
PYTHONPATH=${PORTAGE_PYM_PATH}${PYTHONPATH:+:}${PYTHONPATH} \
- "${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}/portageq" best_version "${eroot}" "$1"
+ "${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}/portageq" best_version "${eroot}" "${atom}"
fi
local retval=$?
case "${retval}" in