public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Brian Dolbec <dolsen@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Subject: Re: [gentoo-portage-dev] [PATCH] econf: update configure/config.{sub,guess} atomically to avoid races
Date: Tue, 17 Dec 2013 16:26:09 -0800	[thread overview]
Message-ID: <1387326369.3897.178.camel@big_daddy.dol-sen.ca> (raw)
In-Reply-To: <1387322892-13303-1-git-send-email-vapier@gentoo.org>

[-- Attachment #1: Type: text/plain, Size: 2369 bytes --]

On Tue, 2013-12-17 at 18:28 -0500, Mike Frysinger wrote:
> 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
>  


Sorry, my bash skills are not enough to review this stuff. Others will
have to reply :)
-- 
Brian Dolbec <dolsen@gentoo.org>

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 620 bytes --]

  reply	other threads:[~2013-12-18  0:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-17 23:23 [gentoo-portage-dev] [PATCH] econf: update config.{sub,guess} atomically to avoid races Mike Frysinger
2013-12-17 23:28 ` [gentoo-portage-dev] [PATCH] econf: update configure/config.{sub,guess} " Mike Frysinger
2013-12-18  0:26   ` Brian Dolbec [this message]
2013-12-18  1:08     ` Alec Warner
2013-12-18  1:41   ` Greg Turner
2013-12-18  1:58     ` Alec Warner
2013-12-18  2:53       ` Greg Turner
2013-12-18  5:16         ` Alec Warner
2013-12-21  3:07   ` [gentoo-portage-dev] " Ryan Hill
2013-12-21  9:23     ` Mike Frysinger
2013-12-21  9:49     ` [gentoo-portage-dev] [PATCH] add a __bashpid helper for <bash-4.0 versions Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1387326369.3897.178.camel@big_daddy.dol-sen.ca \
    --to=dolsen@gentoo.org \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox