From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1330189-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 35B48158086
	for <garchives@archives.gentoo.org>; Thu, 14 Oct 2021 08:39:31 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 3DF47E0918;
	Thu, 14 Oct 2021 08:39:30 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183])
	(using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id E43EFE0918
	for <gentoo-commits@lists.gentoo.org>; Thu, 14 Oct 2021 08:39:29 +0000 (UTC)
Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84])
	(using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id D219634318A
	for <gentoo-commits@lists.gentoo.org>; Thu, 14 Oct 2021 08:39:28 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 18CEB132
	for <gentoo-commits@lists.gentoo.org>; Thu, 14 Oct 2021 08:39:27 +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: <1634200758.8a5fe775294ede43387a38ef04a707cd1e2f9801.sam@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/readline/
X-VCS-Repository: repo/gentoo
X-VCS-Files: sys-libs/readline/readline-8.1_p1-r1.ebuild
X-VCS-Directories: sys-libs/readline/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 8a5fe775294ede43387a38ef04a707cd1e2f9801
X-VCS-Branch: master
Date: Thu, 14 Oct 2021 08:39:27 +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: 92b9a89e-b2d2-47db-a8b9-4d6eeb1e60d0
X-Archives-Hash: 6d96b98cb16f219400a8bad340b97aef

commit:     8a5fe775294ede43387a38ef04a707cd1e2f9801
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 14 08:38:36 2021 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Oct 14 08:39:18 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8a5fe775

sys-libs/readline: avoid underlinking libreadline in prefix bootstrap

There's no guarantee we have pkg-config around super early
on in the process and we need readline for bash.

Closes: https://bugs.gentoo.org/818103
Signed-off-by: Sam James <sam <AT> gentoo.org>

 sys-libs/readline/readline-8.1_p1-r1.ebuild | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/sys-libs/readline/readline-8.1_p1-r1.ebuild b/sys-libs/readline/readline-8.1_p1-r1.ebuild
index 89f31e17eb1..d6352244675 100644
--- a/sys-libs/readline/readline-8.1_p1-r1.ebuild
+++ b/sys-libs/readline/readline-8.1_p1-r1.ebuild
@@ -70,9 +70,24 @@ src_prepare() {
 	[[ ${PLEVEL} -gt 0 ]] && eapply -p0 $(patches -s)
 	default
 
-	# Force ncurses linking. #71420
-	# Use pkg-config to get the right values. #457558
-	local ncurses_libs=$($(tc-getPKG_CONFIG) ncurses$(usex unicode w '') --libs)
+	if use prefix && [[ ! -e "${BROOT}"/usr/bin/pkg-config ]] ; then
+		# If we're bootstrapping, make a guess. We don't have pkg-config
+		# around yet. bug #818103.
+		# Incorrectly populating this leads to underlinked libreadline.
+		local ncurses_libs
+		local ncurses_libs_suffix=$(usex unicode w '')
+
+		ncurses_libs="-lncurses${ncurses_libs_suffix}"
+
+		if has_version "sys-libs/ncurses[tinfo(+)]" ; then
+			ncurses_libs+=" -ltinfo${ncurses_libs_suffix}"
+		fi
+	else
+		# Force ncurses linking. #71420
+		# Use pkg-config to get the right values. #457558
+		local ncurses_libs=$($(tc-getPKG_CONFIG) ncurses$(usex unicode w '') --libs)
+	fi
+
 	sed -i \
 		-e "/^SHLIB_LIBS=/s:=.*:='${ncurses_libs}':" \
 		support/shobj-conf || die