]> code.ossystems Code Review - openembedded-core.git/commitdiff
sstate/path.py: Add copyhardlinktree() function and use for performance optimisation
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 3 Feb 2013 17:34:54 +0000 (17:34 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 6 Feb 2013 13:11:19 +0000 (13:11 +0000)
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@linuxfoundation.org>
meta/classes/sstate.bbclass
meta/lib/oe/path.py

index a79d2b557ebd32510ebfedb1c1e2203c9a09bf0d..6f77bb90130f4c21e1577101b8a1cf3f7bfbed6d 100644 (file)
@@ -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)
index 7197b236504e848b0786ba3ab18df8000b6649f9..ea58bedc8b47f85a7388d88bf4cd7a461e91ca33 100644 (file)
@@ -83,6 +83,14 @@ 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):
+        if not len(os.listdir(src)):
+            return     
+        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"""