From bcf4ab871ededc3d535165757ba5597669e33dcb Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 30 Aug 2012 18:49:10 -0700 Subject: [PATCH] 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 --- bin/phase-helpers.sh | 68 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 12 deletions(-) diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh index db1548ee2..6899488d3 100644 --- a/bin/phase-helpers.sh +++ b/bin/phase-helpers.sh @@ -632,28 +632,50 @@ _eapi5_apply_user_patches() { } # @FUNCTION: has_version -# @USAGE: +# @USAGE: [--host-root] # @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: +# @USAGE: [--host-root] # @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 -- 2.26.2