From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org)
	by finch.gentoo.org with esmtp (Exim 4.60)
	(envelope-from <gentoo-commits+bounces-399331-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1RNUgE-0000BQ-NS
	for garchives@archives.gentoo.org; Mon, 07 Nov 2011 19:16:30 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 5EC2621C068;
	Mon,  7 Nov 2011 19:16:18 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by pigeon.gentoo.org (Postfix) with ESMTP id 2FCC321C068
	for <gentoo-commits@lists.gentoo.org>; Mon,  7 Nov 2011 19:16:18 +0000 (UTC)
Received: from pelican.gentoo.org (unknown [66.219.59.40])
	(using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id A8F201B4031
	for <gentoo-commits@lists.gentoo.org>; Mon,  7 Nov 2011 19:16:17 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by pelican.gentoo.org (Postfix) with ESMTP id 1C7C380042
	for <gentoo-commits@lists.gentoo.org>; Mon,  7 Nov 2011 19:16:17 +0000 (UTC)
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" <zmedico@gentoo.org>
Message-ID: <b58e5fd407c8726fd2ffe674444255aab9ae0010.zmedico@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: bin/
X-VCS-Repository: proj/portage
X-VCS-Files: bin/phase-helpers.sh
X-VCS-Directories: bin/
X-VCS-Committer: zmedico
X-VCS-Committer-Name: Zac Medico
X-VCS-Revision: b58e5fd407c8726fd2ffe674444255aab9ae0010
Date: Mon,  7 Nov 2011 19:16:17 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: quoted-printable
X-Archives-Salt: 391783b6-0bad-44c6-ac39-4b1622b8df78
X-Archives-Hash: 5a69df715f58ffab9cb692e20d55dd08

commit:     b58e5fd407c8726fd2ffe674444255aab9ae0010
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Nov  7 19:16:09 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Nov  7 19:16:09 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a=
=3Dcommit;h=3Db58e5fd4

Fix best/has_version ROOT override for EAPI 3-4.

This has been broken since commit
ab484dc9a2612aa6709fad3ff926c8589a706637. In order to support prefix,
callers will have to override EROOT instead.

---
 bin/phase-helpers.sh |   46 ++++++++++++++++++++++++++++++++++++++++----=
--
 1 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index a47064e..5d2d5dd 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -596,12 +596,29 @@ _eapi4_src_install() {
 	fi
 }
=20
-# Return true if given package is installed. Otherwise return false.
-# Takes single depend-type atoms.
+# @FUNCTION: has_version
+# @USAGE: <DEPEND ATOM>
+# @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).
 has_version() {
=20
 	local eroot=3D${EROOT}
-	case "$EAPI" in 0|1|2) eroot=3D${ROOT} ;; esac
+	case "$EAPI" in
+		0|1|2)
+			eroot=3D${ROOT}
+			;;
+		*)
+			if [[ -z ${EPREFIX} && ${EROOT} !=3D ${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=3D${ROOT}
+			fi
+	esac
 	if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
 		"$PORTAGE_BIN_PATH"/ebuild-ipc has_version "${eroot}" "$1"
 	else
@@ -619,12 +636,29 @@ has_version() {
 	esac
 }
=20
-# Returns the best/most-current match.
-# Takes single depend-type atoms.
+# @FUNCTION: best_version
+# @USAGE: <DEPEND ATOM>
+# @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).
 best_version() {
=20
 	local eroot=3D${EROOT}
-	case "$EAPI" in 0|1|2) eroot=3D${ROOT} ;; esac
+	case "$EAPI" in
+		0|1|2)
+			eroot=3D${ROOT}
+			;;
+		*)
+			if [[ -z ${EPREFIX} && ${EROOT} !=3D ${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=3D${ROOT}
+			fi
+	esac
 	if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
 		"$PORTAGE_BIN_PATH"/ebuild-ipc best_version "${eroot}" "$1"
 	else