From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1064975-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 04953138334
	for <garchives@archives.gentoo.org>; Thu,  3 Jan 2019 09:24:17 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id B19EBE0A96;
	Thu,  3 Jan 2019 09:24:14 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 78855E0A96
	for <gentoo-commits@lists.gentoo.org>; Thu,  3 Jan 2019 09:24:14 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id A5937335CFD
	for <gentoo-commits@lists.gentoo.org>; Thu,  3 Jan 2019 09:24:12 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id B055A2A7
	for <gentoo-commits@lists.gentoo.org>; Thu,  3 Jan 2019 09:24:10 +0000 (UTC)
From: "Fabian Groffen" <grobian@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, "Fabian Groffen" <grobian@gentoo.org>
Message-ID: <1546507433.6987586f278fd5eb1683fa7e49d75dd7016278fb.grobian@gentoo>
Subject: [gentoo-commits] repo/proj/prefix:master commit in: scripts/
X-VCS-Repository: repo/proj/prefix
X-VCS-Files: scripts/bootstrap-prefix.sh
X-VCS-Directories: scripts/
X-VCS-Committer: grobian
X-VCS-Committer-Name: Fabian Groffen
X-VCS-Revision: 6987586f278fd5eb1683fa7e49d75dd7016278fb
X-VCS-Branch: master
Date: Thu,  3 Jan 2019 09:24:10 +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: 6372c390-3fba-4737-8c68-6e14d0101a6a
X-Archives-Hash: 3f934bd042e1814a554495811ce7928e

commit:     6987586f278fd5eb1683fa7e49d75dd7016278fb
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  3 09:21:08 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jan  3 09:23:53 2019 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=6987586f

scripts/bootstrap-prefix: ensure USE is picked up in stage3

Portage seems to ignore USE= environment for build dependencies in a
different location.  Since we need this to be respected in order to
avoid many cycles, temporarily encode the requested USE-flags in
use.mask and use.force.  We use the profiles/ location which should get
wiped out hereafter, but also remove the files used whilst emerging to
reduce the risk of leaving this behind in someone's setup.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 scripts/bootstrap-prefix.sh | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh
index d393c4d498..9f4f1bbb38 100755
--- a/scripts/bootstrap-prefix.sh
+++ b/scripts/bootstrap-prefix.sh
@@ -1452,6 +1452,22 @@ do_emerge_pkgs() {
 		done
 		myuse=( ${myuse} )
 
+		# Portage seems to ignore USE= for build dependencies.  Since
+		# that's what we're more or less doing all the time, encode the
+		# USE-flags in profiles/use.mask and profiles/use.force which
+		# normally do not exist.
+		rm -f "${EPREFIX}"/usr/portage/profiles/use.{mask,force}
+		for use in "${myuse[@]}" ; do
+			case "${use}" in
+				-*) echo "${use#-}" \
+						>> "${EPREFIX}"/usr/portage/profiles/use.mask
+					;;
+				*)  echo "${use}" \
+						>> "${EPREFIX}"/usr/portage/profiles/use.force
+					;;
+				esac
+		done
+
 		# Disable the STALE warning because the snapshot frequently gets stale.
 		#
 		# Need need to spam the user about news until the emerge -e system
@@ -1472,6 +1488,7 @@ do_emerge_pkgs() {
 			emerge -v --oneshot --root-deps ${opts} "${pkg}" 
 		)
 		[[ $? -eq 0 ]] || return 1
+		rm -f "${EPREFIX}"/usr/portage/profiles/use.{mask,force}
 
 		case ${pkg},${CHOST} in
 		app-shells/bash,*-cygwin*)
@@ -1663,7 +1680,7 @@ bootstrap_stage3() {
 		# PORTAGE_OVERRIDE_EPREFIX as BROOT is needed.
 		PREROOTPATH="${ROOT}"$(echo /{,tmp/}{usr/,}{,lib/llvm/{10,9,8,7,6,5}/}{s,}bin | sed "s, ,:${ROOT},g") \
 		EPREFIX="${ROOT}" PORTAGE_TMPDIR="${PORTAGE_TMPDIR}" \
-		PORTAGE_OVERRIDE_EPREFIX="$(rapx "${ROOT}" "${ROOT}/tmp")" \
+		PORTAGE_OVERRIDE_EPREFIX="$(rapx "${ROOT}" "${ROOT}"/tmp)" \
 		FEATURES="${FEATURES} force-prefix $(rapx "" stacked-prefix)" \
 		EMERGE_LOG_DIR="${ROOT}"/var/log \
 		do_emerge_pkgs "$@"
@@ -1816,7 +1833,7 @@ bootstrap_stage3() {
 		app-admin/eselect
 		$( [[ ${CHOST} == *-cygwin* ]] && echo sys-libs/cygwin-crypt )
 	)
-	# for grep we need to do a little workaround as we use llvm-3.4
+	# for grep we need to do a little workaround as we might use llvm-3.4
 	# here, which doesn't necessarily grok the system headers on newer
 	# OSX, confusing the buildsystem
 	ac_cv_c_decl_report=warning \
@@ -1824,7 +1841,8 @@ bootstrap_stage3() {
 	emerge_pkgs "" "${pkgs[@]}" || return 1
 
 	if [[ ! -x "${ROOT}"/sbin/openrc-run ]]; then
-		echo "We need openrc-run at ${ROOT}/sbin to merge rsync." > "${ROOT}"/sbin/openrc-run
+		echo "We need openrc-run at ${ROOT}/sbin to merge rsync." \
+			> "${ROOT}"/sbin/openrc-run
 		chmod +x "${ROOT}"/sbin/openrc-run
 	fi