diff options
author | Michał Górny <mgorny@gentoo.org> | 2013-04-01 09:17:53 +0000 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2013-04-01 09:17:53 +0000 |
commit | 37c450b30370d97a6eb548289860ea269e9895e5 (patch) | |
tree | e0be1c6178597bb7f84405e7aab8d9a024b828db /eclass | |
parent | Support setting mode of prune_libtool_files through AUTOTOOLS_PRUNE_LIBTOOL_F... (diff) | |
download | historical-37c450b30370d97a6eb548289860ea269e9895e5.tar.gz historical-37c450b30370d97a6eb548289860ea269e9895e5.tar.bz2 historical-37c450b30370d97a6eb548289860ea269e9895e5.zip |
Introduce multibuild_merge_root, as an universal interim-install merging function.
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/ChangeLog | 7 | ||||
-rw-r--r-- | eclass/distutils-r1.eclass | 43 | ||||
-rw-r--r-- | eclass/multibuild.eclass | 54 |
3 files changed, 61 insertions, 43 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog index f3080af4ebd7..ff57e98ec36b 100644 --- a/eclass/ChangeLog +++ b/eclass/ChangeLog @@ -1,6 +1,11 @@ # ChangeLog for eclass directory # Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.761 2013/04/01 09:16:07 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.762 2013/04/01 09:17:53 mgorny Exp $ + + 01 Apr 2013; Michał Górny <mgorny@gentoo.org> distutils-r1.eclass, + multibuild.eclass: + Introduce multibuild_merge_root, as an universal interim-install merging + function. 01 Apr 2013; Michał Górny <mgorny@gentoo.org> autotools-utils.eclass: Support setting mode of prune_libtool_files through diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index 0982e6cb4c5b..74fb014c86a2 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.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/distutils-r1.eclass,v 1.65 2013/03/19 06:13:41 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v 1.66 2013/04/01 09:17:53 mgorny Exp $ # @ECLASS: distutils-r1 # @MAINTAINER: @@ -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: <src-root> <dest-root> -# @INTERNAL -# @DESCRIPTION: -# Merge the directory tree from <src-root> to <dest-root>, removing -# the <src-root> in the process. -_distutils-r1_merge_root() { - local src=${1} - local dest=${2} - - local lockfile=${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, please 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 - [[ ${?} == 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/eclass/multibuild.eclass b/eclass/multibuild.eclass index a3f1402088ab..acfdbbd23745 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.8 2013/03/10 21:44:01 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/multibuild.eclass,v 1.9 2013/04/01 09:17:53 mgorny Exp $ # @ECLASS: multibuild # @MAINTAINER: @@ -238,5 +238,57 @@ run_in_build_dir() { return ${ret} } +# @FUNCTION: multibuild_merge_root +# @USAGE: <src-root> <dest-root> +# @DESCRIPTION: +# Merge the directory tree (fake root) from <src-root> to <dest-root> +# (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=${1} + local dest=${2} + + local lockfile=${T}/multibuild_merge_lock + local ret + + 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}" + [[ ${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 -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 + + if [[ ${ret} -ne 0 ]]; then + die "${MULTIBUILD_VARIANT:-(unknown)}: merging image failed." + fi + + rm -rf "${src}" +} + _MULTIBUILD=1 fi |