From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1576341-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id DC67A158013
	for <garchives@archives.gentoo.org>; Mon,  4 Dec 2023 06:45:51 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id B1EF32BC014;
	Mon,  4 Dec 2023 06:45:50 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 954112BC014
	for <gentoo-commits@lists.gentoo.org>; Mon,  4 Dec 2023 06:45:50 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 88151335D63
	for <gentoo-commits@lists.gentoo.org>; Mon,  4 Dec 2023 06:45:49 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id AF070AF5
	for <gentoo-commits@lists.gentoo.org>; Mon,  4 Dec 2023 06:45:47 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1701672345.632fea4f4aa4bdca63bf6d8db266b09a6954e313.sam@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: /, bin/
X-VCS-Repository: proj/portage
X-VCS-Files: NEWS bin/phase-helpers.sh
X-VCS-Directories: / bin/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 632fea4f4aa4bdca63bf6d8db266b09a6954e313
X-VCS-Branch: master
Date: Mon,  4 Dec 2023 06:45:47 +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
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 6e1efc95-5975-40f3-b13c-79371f90ca2f
X-Archives-Hash: e7791d8064328f74092441a06681ea71

commit:     632fea4f4aa4bdca63bf6d8db266b09a6954e313
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Sat Dec  2 22:53:49 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Dec  4 06:45:45 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=632fea4f

Set SYSROOT for has/best_version so that they work when IPC is disabled

This issue broke cross-compiling.

Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/1198
Signed-off-by: Sam James <sam <AT> gentoo.org>

 NEWS                 |  7 +++++++
 bin/phase-helpers.sh | 10 +++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index ce9ed282b5..5561c7fe40 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,13 @@ Release notes take the form of the following optional categories:
 * Bug fixes
 * Cleanups
 
+portage-3.0.57 (UNRELEASED)
+--------------
+
+Bug fixes:
+* Set SYSROOT appropriately for best_version and has_version so that they work
+  when cross-compiling and IPC is disabled.
+
 portage-3.0.56 (2023-12-01)
 --------------
 

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index ec634e536d..45a1639c42 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -907,7 +907,11 @@ __eapi8_src_prepare() {
 
 ___best_version_and_has_version_common() {
 	local atom root root_arg
-	local -a cmd=()
+
+	# If ROOT is set to / below then SYSROOT cannot point elsewhere. Even if
+	# ROOT is untouched, setting SYSROOT=/ for this command will always work.
+	local -a cmd=(env SYSROOT=/)
+
 	case $1 in
 		--host-root|-r|-d|-b)
 			root_arg=$1
@@ -932,7 +936,7 @@ ___best_version_and_has_version_common() {
 				# Since portageq requires the root argument be consistent
 				# with EPREFIX, ensure consistency here (bug #655414).
 				root=/${PORTAGE_OVERRIDE_EPREFIX#/}
-				cmd+=(env EPREFIX="${PORTAGE_OVERRIDE_EPREFIX}")
+				cmd+=(EPREFIX="${PORTAGE_OVERRIDE_EPREFIX}")
 			else
 				root=/
 			fi ;;
@@ -948,7 +952,7 @@ ___best_version_and_has_version_common() {
 						# Use /${PORTAGE_OVERRIDE_EPREFIX#/} to support older
 						# EAPIs, as it is equivalent to BROOT.
 						root=/${PORTAGE_OVERRIDE_EPREFIX#/}
-						cmd+=(env EPREFIX="${PORTAGE_OVERRIDE_EPREFIX}")
+						cmd+=(EPREFIX="${PORTAGE_OVERRIDE_EPREFIX}")
 						;;
 				esac
 			else