* [gentoo-dev] [PATCH 1/2] Introduce multibuild_merge_root() to merge interim installs.
@ 2013-03-23 16:26 99% ` Michał Górny
0 siblings, 0 replies; 1+ results
From: Michał Górny @ 2013-03-23 16:26 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
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.eclass
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: <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/gx86/eclass/multibuild.eclass b/gx86/eclass/multibuild.eclass
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: <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
+
+ 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, 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
+
+ if [[ ${?} -ne 0 ]]; then
+ die "${MULTIBUILD_VARIANT:-(unknown)}: merging image failed."
+ fi
+
+ rm -rf "${src}"
+}
+
_MULTIBUILD=1
fi
--
1.8.1.5
^ permalink raw reply related [relevance 99%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2013-03-23 16:25 [gentoo-dev] [PATCHES] Header wrapping support for multilib Michał Górny
2013-03-23 16:26 99% ` [gentoo-dev] [PATCH 1/2] Introduce multibuild_merge_root() to merge interim installs Michał Górny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox