From d00e6b124b8709269de1c66d889c79bd8f91fa88 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 7 Nov 2011 12:19:53 -0800 Subject: 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. --- bin/phase-helpers.sh | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) 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" -- cgit v1.2.3-1-g7c22