package.bbclass: Use hard link for package split instead of copy
When doing package split, we use hard link instead of copy, which can save about 10% disk space when building poky-image-minimal. If fail, it will fall back to the copyfile function. [Updated by Richard to use os.link and avoid an exec() call per file] Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
This commit is contained in:
parent
aba80f536f
commit
0d0279a881
|
@ -427,22 +427,13 @@ python populate_packages () {
|
||||||
fpath = os.path.join(root,file)
|
fpath = os.path.join(root,file)
|
||||||
dpath = os.path.dirname(fpath)
|
dpath = os.path.dirname(fpath)
|
||||||
bb.mkdirhier(dpath)
|
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):
|
if not os.path.islink(file):
|
||||||
s = os.stat(file)
|
os.link(file, fpath)
|
||||||
if s.st_nlink > 1:
|
continue
|
||||||
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)
|
ret = bb.copyfile(file, fpath)
|
||||||
if ret is False or ret == 0:
|
if ret is False or ret == 0:
|
||||||
raise bb.build.FuncFailed("File population failed")
|
raise bb.build.FuncFailed("File population failed")
|
||||||
|
|
||||||
del localdata
|
del localdata
|
||||||
os.chdir(workdir)
|
os.chdir(workdir)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue