diff options
author | Mark Hatle <mark.hatle@windriver.com> | 2011-02-08 21:49:36 -0600 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2011-02-09 22:46:30 +0000 |
commit | 3e6d91ece0556fa1c9c84bef60678d8148b789f4 (patch) | |
tree | 56b7fe19c0c7f00bbadd0f29267352eca9e040d2 /meta/classes | |
parent | 58ae42cbc386a8cd59f12527d3e47bea82d9b36f (diff) | |
download | openembedded-core-3e6d91ece0556fa1c9c84bef60678d8148b789f4.tar.gz openembedded-core-3e6d91ece0556fa1c9c84bef60678d8148b789f4.tar.bz2 openembedded-core-3e6d91ece0556fa1c9c84bef60678d8148b789f4.tar.xz openembedded-core-3e6d91ece0556fa1c9c84bef60678d8148b789f4.zip |
package.bbclass: Preserve hard links!
Hard links were not being preserved in the move from the install image
-> package copy. Again they were being discarded in the package ->
packages-split copy as well.
By preserving the hard links we have the potential to save a ton of rootfs
space.
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/package.bbclass | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index 8f58ad03f..0698f6451 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass @@ -323,7 +323,8 @@ python perform_packagecopy () { # Start by package population by taking a copy of the installed # files to operate on os.system('rm -rf %s/*' % (dvar)) - os.system('cp -pPR %s/* %s/' % (dest, dvar)) + # Preserve sparse files and hard links + os.system('tar -cf - -C %s -ps . | tar -xf - -C %s' % (dest, dvar)) } python populate_packages () { @@ -383,6 +384,7 @@ python populate_packages () { filesvar = bb.data.getVar('FILES', localdata, True) or "" files = filesvar.split() + file_links = {} for file in files: if os.path.isabs(file): file = '.' + file @@ -406,9 +408,23 @@ python populate_packages () { bb.mkdirhier(os.path.join(root,file)) os.chmod(os.path.join(root,file), os.stat(file).st_mode) continue + fpath = os.path.join(root,file) dpath = os.path.dirname(fpath) bb.mkdirhier(dpath) + + # Check if this is a hardlink to something... if it is + # attempt to preserve the link information, instead of copy. + if not os.path.islink(file): + s = os.stat(file) + if s.st_nlink > 1: + file_reference = "%d_%d" % (s.st_dev, s.st_ino) + if file_reference not in file_links: + # Save the reference for next time... + file_links[file_reference] = fpath + else: + os.link(file_links[file_reference], fpath) + continue ret = bb.copyfile(file, fpath) if ret is False or ret == 0: raise bb.build.FuncFailed("File population failed") |