diff options
author | Michał Górny <mgorny@gentoo.org> | 2013-05-23 20:19:28 +0000 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2013-05-23 20:19:28 +0000 |
commit | 04b8e12f165e5a01f874c6310ed49c13cf24afaa (patch) | |
tree | 00996db32fc735daca04970f8bcec4065ec89534 /eclass | |
parent | Stable channel bump (security bug #470920). v8 has been rolled to an earlier ... (diff) | |
download | historical-04b8e12f165e5a01f874c6310ed49c13cf24afaa.tar.gz historical-04b8e12f165e5a01f874c6310ed49c13cf24afaa.tar.bz2 historical-04b8e12f165e5a01f874c6310ed49c13cf24afaa.zip |
Use portable locking code from Fabian Groffen. Bug #466554.
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/ChangeLog | 5 | ||||
-rw-r--r-- | eclass/multibuild.eclass | 31 |
2 files changed, 20 insertions, 16 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog index 73955437adf6..daae896cb557 100644 --- a/eclass/ChangeLog +++ b/eclass/ChangeLog @@ -1,6 +1,9 @@ # ChangeLog for eclass directory # Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.835 2013/05/22 05:10:29 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.836 2013/05/23 20:19:28 mgorny Exp $ + + 23 May 2013; Michał Górny <mgorny@gentoo.org> multibuild.eclass: + Use portable locking code from Fabian Groffen. Bug #466554. 22 May 2013; Michał Górny <mgorny@gentoo.org> eutils.eclass: Fix the libtool check, bug #470938. diff --git a/eclass/multibuild.eclass b/eclass/multibuild.eclass index acfdbbd23745..f515f7d60e35 100644 --- a/eclass/multibuild.eclass +++ b/eclass/multibuild.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/multibuild.eclass,v 1.9 2013/04/01 09:17:53 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/multibuild.eclass,v 1.10 2013/05/23 20:19:28 mgorny Exp $ # @ECLASS: multibuild # @MAINTAINER: @@ -251,38 +251,39 @@ multibuild_merge_root() { local src=${1} local dest=${2} - local lockfile=${T}/multibuild_merge_lock + local lockfile=${T}/.multibuild_merge_lock + local lockfile_l=${lockfile}.${$} local ret + # Lock the install tree for merge. The touch+ln method ensures race + # condition-free locking with maximum portability. + touch "${lockfile_l}" || die + until ln "${lockfile_l}" "${lockfile}" &>/dev/null; do + sleep 1 + done + rm "${lockfile_l}" || die + if use userland_BSD; then - # Locking is done by 'lockf' which can wrap a command. # 'cp -a -n' is broken: # http://www.freebsd.org/cgi/query-pr.cgi?pr=174489 # using tar instead which is universal but terribly slow. tar -C "${src}" -f - -c . \ - | lockf "${lockfile}" tar -x -f - -C "${dest}" + | tar -x -f - -C "${dest}" [[ ${PIPESTATUS[*]} == '0 0' ]] ret=${?} elif use userland_GNU; then - # GNU has 'flock' which can't wrap commands but can lock - # a fd which is good enough for us. - # and cp works with '-a -n'. - - local lock_fd - redirect_alloc_fd lock_fd "${lockfile}" '>>' - flock ${lock_fd} + # cp works with '-a -n'. cp -a -l -n "${src}"/. "${dest}"/ ret=${?} - - # Close the lock file when we are done with it. - # Prevents deadlock if we aren't in a subshell. - eval "exec ${lock_fd}>&-" else die "Unsupported userland (${USERLAND}), please report." fi + # Remove the lock. + rm "${lockfile}" || die + if [[ ${ret} -ne 0 ]]; then die "${MULTIBUILD_VARIANT:-(unknown)}: merging image failed." fi |