[oe-commits] Richard Purdie : sstate/path.py: Add copyhardlinktree() function and use for performance optimisation
git at git.openembedded.org
git at git.openembedded.org
Mon Feb 4 16:43:44 UTC 2013
Module: openembedded-core.git
Branch: master-next
Commit: 798ae0ed2e6bae02622b328f0b5763bad70f39dc
URL: http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=798ae0ed2e6bae02622b328f0b5763bad70f39dc
Author: Richard Purdie <richard.purdie at linuxfoundation.org>
Date: Sun Feb 3 17:34:54 2013 +0000
sstate/path.py: Add copyhardlinktree() function and use for performance optimisation
Add a function which copys a tree as a set of hardlinks to the original
files, then use this in sstate to reduce some of the overhead of sstate
package creation since the file isn't actually copied.
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
meta/classes/sstate.bbclass | 4 ++--
meta/lib/oe/path.py | 6 ++++++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index a79d2b5..6f77bb9 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -458,14 +458,14 @@ def sstate_package(ss, d):
dstpath = srcpath.replace(state[1], sstatebuild + state[0])
make_relative_symlink(srcpath, dstpath, d)
bb.debug(2, "Preparing tree %s for packaging at %s" % (state[1], sstatebuild + state[0]))
- oe.path.copytree(state[1], sstatebuild + state[0])
+ oe.path.copyhardlinktree(state[1], sstatebuild + state[0])
workdir = d.getVar('WORKDIR', True)
for plain in ss['plaindirs']:
pdir = plain.replace(workdir, sstatebuild)
bb.mkdirhier(plain)
bb.mkdirhier(pdir)
- oe.path.copytree(plain, pdir)
+ oe.path.copyhardlinktree(plain, pdir)
d.setVar('SSTATE_BUILDDIR', sstatebuild)
d.setVar('SSTATE_PKG', sstatepkg)
diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py
index 7197b23..dfec453 100644
--- a/meta/lib/oe/path.py
+++ b/meta/lib/oe/path.py
@@ -83,6 +83,12 @@ def copytree(src, dst):
cmd = 'tar -cf - -C %s -ps . | tar -xf - -C %s' % (src, dst)
check_output(cmd, shell=True, stderr=subprocess.STDOUT)
+def copyhardlinktree(src, dst):
+ bb.utils.mkdirhier(dst)
+ if os.path.isdir(src):
+ src = src + "/*"
+ cmd = 'cp -al %s %s' % (src, dst)
+ check_output(cmd, shell=True, stderr=subprocess.STDOUT)
def remove(path, recurse=True):
"""Equivalent to rm -f or rm -rf"""
More information about the Openembedded-commits
mailing list