From: Zac Medico Date: Mon, 7 Nov 2011 20:19:53 +0000 (-0800) Subject: Only support ROOT override for best/has_version. X-Git-Tag: v2.2.0_alpha73~14 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d00e6b124b8709269de1c66d889c79bd8f91fa88;p=portage.git Only support ROOT override for best/has_version. In the context of ebuilds, ROOT=/ override is the only common case, so it makes sense to only support ROOT overrides. --- diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh index 5d2d5dd3a..6609dc77a 100644 --- a/bin/phase-helpers.sh +++ b/bin/phase-helpers.sh @@ -599,25 +599,19 @@ _eapi4_src_install() { # @FUNCTION: has_version # @USAGE: # @DESCRIPTION: -# Returns the best/most-current match. Callers may override the ROOT -# variable in order match packages from an alternative ROOT. In -# EAPI 3 and later, override EROOT instead (ROOT override is supported -# in this case only if EPREFIX is empty). +# Return true if given package is installed. Otherwise return false. +# Callers may override the ROOT variable in order match packages from an +# alternative ROOT. has_version() { - local eroot=${EROOT} + local eroot case "$EAPI" in 0|1|2) eroot=${ROOT} ;; *) - if [[ -z ${EPREFIX} && ${EROOT} != ${ROOT} ]] ; then - # Handle ROOT environment override, which ebuilds - # sometimes use for stage1/cross-compiling. - # In order to support prefix, they'll have to - # override EROOT instead. - eroot=${ROOT} - fi + eroot=${ROOT%/}${EPREFIX#/}/ + ;; esac if [[ -n $PORTAGE_IPC_DAEMON ]] ; then "$PORTAGE_BIN_PATH"/ebuild-ipc has_version "${eroot}" "$1" @@ -639,25 +633,19 @@ has_version() { # @FUNCTION: best_version # @USAGE: # @DESCRIPTION: -# Returns the best/most-current match. Callers may override the ROOT -# variable in order match packages from an alternative ROOT. In -# EAPI 3 and later, override EROOT instead (ROOT override is supported -# in this case only if EPREFIX is empty). +# Returns the best/most-current match. +# Callers may override the ROOT variable in order match packages from an +# alternative ROOT. best_version() { - local eroot=${EROOT} + local eroot case "$EAPI" in 0|1|2) eroot=${ROOT} ;; *) - if [[ -z ${EPREFIX} && ${EROOT} != ${ROOT} ]] ; then - # Handle ROOT environment override, which ebuilds - # sometimes use for stage1/cross-compiling. - # In order to support prefix, they'll have to - # override EROOT instead. - eroot=${ROOT} - fi + eroot=${ROOT%/}${EPREFIX#/}/ + ;; esac if [[ -n $PORTAGE_IPC_DAEMON ]] ; then "$PORTAGE_BIN_PATH"/ebuild-ipc best_version "${eroot}" "$1"