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 C179A198005 for ; Sat, 23 Mar 2013 17:45:05 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8C043E0767; Sat, 23 Mar 2013 17:45:02 +0000 (UTC) Received: from mail-vb0-f51.google.com (mail-vb0-f51.google.com [209.85.212.51]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 92DB5E0653 for ; Sat, 23 Mar 2013 17:45:00 +0000 (UTC) Received: by mail-vb0-f51.google.com with SMTP id fq11so3125267vbb.24 for ; Sat, 23 Mar 2013 10:45:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:sender:x-originating-ip:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:content-transfer-encoding:x-gm-message-state; bh=PCF0ybAuU8bjml/7qeMmHM7AHwjF2YpcKFKv/c8Mgiw=; b=Qq4QPR9Hgaub/fKdI20UysIopyUCPwH+5uIy58B6lmhqqxtHC+dCWJnnU5pB2N4IAM plqHUtmIkDaCOXGm8onmMua4cfx6UGjXPdetlwPrGPXGdRZmlj9FJav6CMFbanHgoZPH mUVmfZ1EO1T5I5YGwKyOboEq00SIH0ESc53oxjQRge1Pwijc+eJvmQnAHpwWJqUF8iCP 50PHEeGddDLHOAbj3P6kt16OLjTCXAQqyVYOVM7eMrWgUW3cW+teQsbl2w7PGs0tx6AL 0DSK9Ch5QBzCnDiINxpdCAmK2xIETXDL3i/n+DtIPT/PSi6bKhMRgiOauYEIX9uyVZVS SqaQ== Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 X-Received: by 10.58.43.169 with SMTP id x9mr8114299vel.13.1364060700017; Sat, 23 Mar 2013 10:45:00 -0700 (PDT) Sender: antarus@scriptkitty.com Received: by 10.220.164.202 with HTTP; Sat, 23 Mar 2013 10:44:59 -0700 (PDT) X-Originating-IP: [75.147.136.182] In-Reply-To: <1364055998-23674-1-git-send-email-mgorny@gentoo.org> References: <20130323172532.1b1100e2@pomiocik.lan> <1364055998-23674-1-git-send-email-mgorny@gentoo.org> Date: Sat, 23 Mar 2013 10:44:59 -0700 X-Google-Sender-Auth: b2o2OstTCeNlSwfUDNJDjIviT-Y Message-ID: Subject: Re: [gentoo-dev] [PATCH 1/2] Introduce multibuild_merge_root() to merge interim installs. From: Alec Warner To: gentoo-dev@lists.gentoo.org Cc: =?UTF-8?B?TWljaGHFgiBHw7Nybnk=?= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQkUJmKl4NGg+AFYINd39cpUYfsZ4rz4g/SEDp1LYm095IWD1Q2Zx0GidR9LD/4gfvvbfQsy X-Archives-Salt: 61022bde-b13f-47b8-ad84-e9693801f745 X-Archives-Hash: 238dae0eee8e946f04253887c8eeb2ee On Sat, Mar 23, 2013 at 9:26 AM, Micha=C5=82 G=C3=B3rny = wrote: > This is mostly a copy from distutils-r1. The function does copy all the > files from one location onto another, preserving whatever possible. It > can be run in parallel too without the risk of race conditions. > --- > gx86/eclass/distutils-r1.eclass | 41 +----------------------------------= -- > gx86/eclass/multibuild.eclass | 45 +++++++++++++++++++++++++++++++++++= ++++++ > 2 files changed, 46 insertions(+), 40 deletions(-) > > diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.e= class > index 0982e6c..3c21741 100644 > --- a/gx86/eclass/distutils-r1.eclass > +++ b/gx86/eclass/distutils-r1.eclass > @@ -449,49 +449,10 @@ distutils-r1_python_install() { > > if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then > _distutils-r1_rename_scripts "${root}" > - _distutils-r1_merge_root "${root}" "${D}" > + multibuild_merge_root "${root}" "${D}" > fi > } > > -# @FUNCTION: distutils-r1_merge_root > -# @USAGE: > -# @INTERNAL > -# @DESCRIPTION: > -# Merge the directory tree from to , removing > -# the in the process. > -_distutils-r1_merge_root() { > - local src=3D${1} > - local dest=3D${2} > - > - local lockfile=3D${T}/distutils-r1-merge-lock > - > - if type -P lockf &>/dev/null; then > - # On BSD, we have 'lockf' wrapper. > - tar -C "${src}" -f - -c . \ > - | lockf "${lockfile}" tar -x -f - -C "${dest}" > - else > - local lock_fd > - if type -P flock &>/dev/null; then > - # On Linux, we have 'flock' which can lock fd. > - redirect_alloc_fd lock_fd "${lockfile}" '>>' > - flock ${lock_fd} > - else > - ewarn "distutils-r1: no locking service found, pl= ease report." > - fi > - > - cp -a -l -n "${src}"/. "${dest}"/ > - > - if [[ ${lock_fd} ]]; then > - # Close the lock file when we are done with it. > - # Prevents deadlock if we aren't in a subshell. > - eval "exec ${lock_fd}>&-" > - fi > - fi > - [[ ${?} =3D=3D 0 ]] || die "Merging ${EPYTHON} image failed." > - > - rm -rf "${src}" > -} > - > # @FUNCTION: distutils-r1_python_install_all > # @DESCRIPTION: > # The default python_install_all(). It installs the documentation. > diff --git a/gx86/eclass/multibuild.eclass b/gx86/eclass/multibuild.eclas= s > index a3f1402..ed837d3 100644 > --- a/gx86/eclass/multibuild.eclass > +++ b/gx86/eclass/multibuild.eclass > @@ -238,5 +238,50 @@ run_in_build_dir() { > return ${ret} > } > > +# @FUNCTION: multibuild_merge_root > +# @USAGE: > +# @DESCRIPTION: > +# Merge the directory tree (fake root) from to > +# (the real root). Both directories have to be real, absolute paths > +# (i.e. including ${D}). Source root will be removed. > +# > +# This functions uses locking to support merging during parallel > +# installs. > +multibuild_merge_root() { > + local src=3D${1} > + local dest=3D${2} > + > + local lockfile=3D${T}/multibuild_merge_lock > + > + if type -P lockf &>/dev/null; then > + # On BSD, we have 'lockf' wrapper. > + tar -C "${src}" -f - -c . \ > + | lockf "${lockfile}" tar -x -f - -C "${dest}" > + else > + local lock_fd > + if type -P flock &>/dev/null; then > + # On Linux, we have 'flock' which can lock fd. > + redirect_alloc_fd lock_fd "${lockfile}" '>>' > + flock ${lock_fd} > + else > + ewarn "multibuild: no locking service found, plea= se report." > + fi > + > + cp -a -l -n "${src}"/. "${dest}"/ > + > + if [[ ${lock_fd} ]]; then > + # Close the lock file when we are done with it. > + # Prevents deadlock if we aren't in a subshell. > + eval "exec ${lock_fd}>&-" Not following this bit. The bash manpage says N>&DIGIT- redirects fd DIGIT to fd N. N may be unspecified and defaults to 1. It doesn't say what happens if DIGIT is unspecified. Nor does it say it closes any file descriptors. -A > + fi > + fi > + > + if [[ ${?} -ne 0 ]]; then > + die "${MULTIBUILD_VARIANT:-(unknown)}: merging image fail= ed." > + fi > + > + rm -rf "${src}" > +} > + > _MULTIBUILD=3D1 > fi > -- > 1.8.1.5 > >