summaryrefslogtreecommitdiffstats
path: root/meta/classes/package.bbclass
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2011-02-08 21:49:36 -0600
committerRichard Purdie <rpurdie@linux.intel.com>2011-02-09 22:46:30 +0000
commit3e6d91ece0556fa1c9c84bef60678d8148b789f4 (patch)
tree56b7fe19c0c7f00bbadd0f29267352eca9e040d2 /meta/classes/package.bbclass
parent58ae42cbc386a8cd59f12527d3e47bea82d9b36f (diff)
downloadpoky-3e6d91ece0556fa1c9c84bef60678d8148b789f4.tar.gz
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/package.bbclass')
-rw-r--r--meta/classes/package.bbclass18
1 files changed, 17 insertions, 1 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 8f58ad03f1..0698f64515 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -323,7 +323,8 @@ python perform_packagecopy () {
323 # Start by package population by taking a copy of the installed 323 # Start by package population by taking a copy of the installed
324 # files to operate on 324 # files to operate on
325 os.system('rm -rf %s/*' % (dvar)) 325 os.system('rm -rf %s/*' % (dvar))
326 os.system('cp -pPR %s/* %s/' % (dest, dvar)) 326 # Preserve sparse files and hard links
327 os.system('tar -cf - -C %s -ps . | tar -xf - -C %s' % (dest, dvar))
327} 328}
328 329
329python populate_packages () { 330python populate_packages () {
@@ -383,6 +384,7 @@ python populate_packages () {
383 384
384 filesvar = bb.data.getVar('FILES', localdata, True) or "" 385 filesvar = bb.data.getVar('FILES', localdata, True) or ""
385 files = filesvar.split() 386 files = filesvar.split()
387 file_links = {}
386 for file in files: 388 for file in files:
387 if os.path.isabs(file): 389 if os.path.isabs(file):
388 file = '.' + file 390 file = '.' + file
@@ -406,9 +408,23 @@ python populate_packages () {
406 bb.mkdirhier(os.path.join(root,file)) 408 bb.mkdirhier(os.path.join(root,file))
407 os.chmod(os.path.join(root,file), os.stat(file).st_mode) 409 os.chmod(os.path.join(root,file), os.stat(file).st_mode)
408 continue 410 continue
411
409 fpath = os.path.join(root,file) 412 fpath = os.path.join(root,file)
410 dpath = os.path.dirname(fpath) 413 dpath = os.path.dirname(fpath)
411 bb.mkdirhier(dpath) 414 bb.mkdirhier(dpath)
415
416 # Check if this is a hardlink to something... if it is
417 # attempt to preserve the link information, instead of copy.
418 if not os.path.islink(file):
419 s = os.stat(file)
420 if s.st_nlink > 1:
421 file_reference = "%d_%d" % (s.st_dev, s.st_ino)
422 if file_reference not in file_links:
423 # Save the reference for next time...
424 file_links[file_reference] = fpath
425 else:
426 os.link(file_links[file_reference], fpath)
427 continue
412 ret = bb.copyfile(file, fpath) 428 ret = bb.copyfile(file, fpath)
413 if ret is False or ret == 0: 429 if ret is False or ret == 0:
414 raise bb.build.FuncFailed("File population failed") 430 raise bb.build.FuncFailed("File population failed")