From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 9EF93138247 for ; Tue, 17 Dec 2013 23:28:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DE9A0E09EA; Tue, 17 Dec 2013 23:28:11 +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 65FB1E09DA for ; Tue, 17 Dec 2013 23:28:11 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 88BCF33F077 for ; Tue, 17 Dec 2013 23:28:10 +0000 (UTC) From: Mike Frysinger To: gentoo-portage-dev@lists.gentoo.org Subject: [gentoo-portage-dev] [PATCH] econf: update configure/config.{sub,guess} atomically to avoid races Date: Tue, 17 Dec 2013 18:28:12 -0500 Message-Id: <1387322892-13303-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1387322606-3867-1-git-send-email-vapier@gentoo.org> References: <1387322606-3867-1-git-send-email-vapier@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Archives-Salt: 823b8b42-3356-485a-8c8f-a739dd823857 X-Archives-Hash: ad09cf20cb7157062a73cb65b3b8b6ac 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 -- 1.8.4.3