summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes')
-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")