From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-650543-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id 3B973138247
	for <garchives@archives.gentoo.org>; Wed, 18 Dec 2013 02:51:03 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 87E22E0AEA;
	Wed, 18 Dec 2013 02:51:01 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 19614E0AEA
	for <gentoo-commits@lists.gentoo.org>; Wed, 18 Dec 2013 02:51:00 +0000 (UTC)
Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163])
	(using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 11FCC33F59D
	for <gentoo-commits@lists.gentoo.org>; Wed, 18 Dec 2013 02:51:00 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by hornbill.gentoo.org (Postfix) with ESMTP id A4C6711024B
	for <gentoo-commits@lists.gentoo.org>; Wed, 18 Dec 2013 02:50:57 +0000 (UTC)
From: "Mike Frysinger" <vapier@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, "Mike Frysinger" <vapier@gentoo.org>
Message-ID: <1387322824.8d4d077d5775c4f1dac724d5e6fbb7cf14db1920.vapier@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: vapier
X-VCS-Committer-Name: Mike Frysinger
X-VCS-Revision: 8d4d077d5775c4f1dac724d5e6fbb7cf14db1920
X-VCS-Branch: master
Date: Wed, 18 Dec 2013 02:50:57 +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-Archives-Salt: 98425087-a846-47db-8383-7ba3aa2a4c77
X-Archives-Hash: 870c98b2e6c657a34772d35014046144

commit:     8d4d077d5775c4f1dac724d5e6fbb7cf14db1920
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 23:23:12 2013 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Dec 17 23:27:04 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8d4d077d

econf: update configure/config.{sub,guess} atomically to avoid races

Use $BASHPID which will be unique even in subshells.

URL: https://bugs.gentoo.org/487478

---
 bin/phase-helpers.sh | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index ec48c94..1a7ae03 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -469,6 +469,7 @@ unpack() {
 
 econf() {
 	local x
+	local pid=${BASHPID}
 
 	if ! ___eapi_has_prefix_variables; then
 		local EPREFIX=
@@ -501,18 +502,22 @@ econf() {
 		if [[ -n $CONFIG_SHELL && \
 			"$(head -n1 "$ECONF_SOURCE/configure")" =~ ^'#!'[[:space:]]*/bin/sh([[:space:]]|$) ]] ; then
 			# preserve timestamp, see bug #440304
-			touch -r "$ECONF_SOURCE/configure" "$ECONF_SOURCE/configure._portage_tmp_.$$" || die
-			sed -e "1s:^#![[:space:]]*/bin/sh:#!$CONFIG_SHELL:" -i "$ECONF_SOURCE/configure" || \
-				die "Substition of shebang in '$ECONF_SOURCE/configure' failed"
-			touch -r "$ECONF_SOURCE/configure._portage_tmp_.$$" "$ECONF_SOURCE/configure" || die
-			rm -f "$ECONF_SOURCE/configure._portage_tmp_.$$"
+			touch -r "${ECONF_SOURCE}/configure" "${ECONF_SOURCE}/configure._portage_tmp_.${pid}" || die
+			sed -i \
+				-e "1s:^#![[:space:]]*/bin/sh:#!$CONFIG_SHELL:" \
+				"${ECONF_SOURCE}/configure" \
+				|| die "Substition of shebang in '${ECONF_SOURCE}/configure' failed"
+			touch -r "${ECONF_SOURCE}/configure._portage_tmp_.${pid}" "${ECONF_SOURCE}/configure" || die
+			rm -f "${ECONF_SOURCE}/configure._portage_tmp_.${pid}"
 		fi
 		if [ -e "${EPREFIX}"/usr/share/gnuconfig/ ]; then
 			find "${WORKDIR}" -type f '(' \
 			-name config.guess -o -name config.sub ')' -print0 | \
 			while read -r -d $'\0' x ; do
 				__vecho " * econf: updating ${x/${WORKDIR}\/} with ${EPREFIX}/usr/share/gnuconfig/${x##*/}"
-				cp -f "${EPREFIX}"/usr/share/gnuconfig/"${x##*/}" "${x}"
+				# Make sure we do this atomically incase we're run in parallel. #487478
+				cp -f "${EPREFIX}"/usr/share/gnuconfig/"${x##*/}" "${x}.${pid}"
+				mv -f "${x}.${pid}" "${x}"
 			done
 		fi