mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 12:29:55 +00:00
sstate/path.py: Add copyhardlinktree() function and use for performance optimisation
Add a function which copys a tree as a set of hardlinks to the original files, then use this in sstate to reduce some of the overhead of sstate package creation since the file isn't actually copied. (From OE-Core rev: 8e373e69acac853213a62afb8bbdf0adc0c5045a) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -458,14 +458,14 @@ def sstate_package(ss, d):
|
|||||||
dstpath = srcpath.replace(state[1], sstatebuild + state[0])
|
dstpath = srcpath.replace(state[1], sstatebuild + state[0])
|
||||||
make_relative_symlink(srcpath, dstpath, d)
|
make_relative_symlink(srcpath, dstpath, d)
|
||||||
bb.debug(2, "Preparing tree %s for packaging at %s" % (state[1], sstatebuild + state[0]))
|
bb.debug(2, "Preparing tree %s for packaging at %s" % (state[1], sstatebuild + state[0]))
|
||||||
oe.path.copytree(state[1], sstatebuild + state[0])
|
oe.path.copyhardlinktree(state[1], sstatebuild + state[0])
|
||||||
|
|
||||||
workdir = d.getVar('WORKDIR', True)
|
workdir = d.getVar('WORKDIR', True)
|
||||||
for plain in ss['plaindirs']:
|
for plain in ss['plaindirs']:
|
||||||
pdir = plain.replace(workdir, sstatebuild)
|
pdir = plain.replace(workdir, sstatebuild)
|
||||||
bb.mkdirhier(plain)
|
bb.mkdirhier(plain)
|
||||||
bb.mkdirhier(pdir)
|
bb.mkdirhier(pdir)
|
||||||
oe.path.copytree(plain, pdir)
|
oe.path.copyhardlinktree(plain, pdir)
|
||||||
|
|
||||||
d.setVar('SSTATE_BUILDDIR', sstatebuild)
|
d.setVar('SSTATE_BUILDDIR', sstatebuild)
|
||||||
d.setVar('SSTATE_PKG', sstatepkg)
|
d.setVar('SSTATE_PKG', sstatepkg)
|
||||||
|
|||||||
@@ -83,6 +83,14 @@ def copytree(src, dst):
|
|||||||
cmd = 'tar -cf - -C %s -ps . | tar -xf - -C %s' % (src, dst)
|
cmd = 'tar -cf - -C %s -ps . | tar -xf - -C %s' % (src, dst)
|
||||||
check_output(cmd, shell=True, stderr=subprocess.STDOUT)
|
check_output(cmd, shell=True, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
|
def copyhardlinktree(src, dst):
|
||||||
|
bb.utils.mkdirhier(dst)
|
||||||
|
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)
|
||||||
|
|
||||||
def remove(path, recurse=True):
|
def remove(path, recurse=True):
|
||||||
"""Equivalent to rm -f or rm -rf"""
|
"""Equivalent to rm -f or rm -rf"""
|
||||||
|
|||||||
Reference in New Issue
Block a user