From: Robert Yang Date: Sat, 27 Apr 2013 09:32:07 +0000 (-0400) Subject: sstate.bbclass: make hard links for staging files X-Git-Tag: rev_ivi_2015_02_04~12729 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f2bb0b92460a585396de379c210eeea6ebc01240;p=scm%2Fbb%2Ftizen-distro.git sstate.bbclass: make hard links for staging files 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] (From OE-Core rev: 5853e0f482b22258c909268fe71673a29e31989b) Signed-off-by: Robert Yang Signed-off-by: Saul Wold Signed-off-by: Richard Purdie --- diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass index 79d3830..77ec402 100644 --- a/meta/classes/sstate.bbclass +++ b/meta/classes/sstate.bbclass @@ -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) diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py index faa0f61..4f8b66c 100644 --- a/meta/lib/oe/path.py +++ b/meta/lib/oe/path.py @@ -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"""