]> code.ossystems Code Review - openembedded-core.git/commitdiff
sstate.bbclass: make hard links for staging files
authorRobert Yang <liezhi.yang@windriver.com>
Sat, 27 Apr 2013 09:32:07 +0000 (05:32 -0400)
committerSaul Wold <sgw@linux.intel.com>
Wed, 1 May 2013 18:09:17 +0000 (11:09 -0700)
Make hard links for staging files instead of copy to save the disk space
(3G will be saved for a core-image-sato build), and it doesn't affect
much on the build time.

The following directories are affected:
1) The sysroot
2) The DEPLOY_DIR
3) The pkgdata

[YOCTO #4372]

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
meta/classes/sstate.bbclass
meta/lib/oe/path.py

index 79d38304fd8978b223f6a1453cdd19394adae590..77ec402704a184d2b743fbdaacf70409dc5dfe77 100644 (file)
@@ -198,7 +198,7 @@ def sstate_install(ss, d):
     # Run the actual file install
     for state in ss['dirs']:
         if os.path.exists(state[1]):
-            oe.path.copytree(state[1], state[2])
+            oe.path.copyhardlinktree(state[1], state[2])
 
     for postinst in (d.getVar('SSTATEPOSTINSTFUNCS', True) or '').split():
         bb.build.exec_func(postinst, d)
index faa0f61fab0113d1bb1fdc8f4255bcaf852ad391..4f8b66c2f362f074fd987115dabd7d3a31e9b080 100644 (file)
@@ -85,13 +85,18 @@ def copytree(src, dst):
     check_output(cmd, shell=True, stderr=subprocess.STDOUT)
 
 def copyhardlinktree(src, dst):
+    """ Make the hard link when possible, otherwise copy. """
     bb.utils.mkdirhier(dst)
+    src_bak = src
     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)
+    if (os.stat(src_bak).st_dev ==  os.stat(dst).st_dev):
+        cmd = 'cp -afl %s %s' % (src, dst)
+        check_output(cmd, shell=True, stderr=subprocess.STDOUT)
+    else:
+        copytree(src_bak, dst)
 
 def remove(path, recurse=True):
     """Equivalent to rm -f or rm -rf"""