From: Zac Medico Date: Fri, 31 Aug 2012 01:49:10 +0000 (-0700) Subject: EAPI 5: --host-root option for best/has_version X-Git-Tag: v2.2.0_alpha124~25 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bcf4ab871ededc3d535165757ba5597669e33dcb;p=portage.git 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 --- 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