diff options
author | Randy Witt <randy.e.witt@linux.intel.com> | 2015-02-23 17:00:37 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-02-23 18:00:11 +0000 |
commit | 3dc52164fb560ccbe5c203a4587f6286c8fc0389 (patch) | |
tree | 303ab2279373de833e5b671a29baa4385398cde6 /meta | |
parent | ed4287a60b33cb597eb7fa13b3855a528315b3b0 (diff) | |
download | openembedded-core-3dc52164fb560ccbe5c203a4587f6286c8fc0389.tar.gz openembedded-core-3dc52164fb560ccbe5c203a4587f6286c8fc0389.tar.bz2 openembedded-core-3dc52164fb560ccbe5c203a4587f6286c8fc0389.zip |
copy_buildsystem.py: Add a way to copy buildsystem to a directory.
This file provides a way to take bitbake and the layers in the
current build and copy them to a target specified.
Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oe/copy_buildsystem.py | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/meta/lib/oe/copy_buildsystem.py b/meta/lib/oe/copy_buildsystem.py new file mode 100644 index 0000000000..5a4d8c332e --- /dev/null +++ b/meta/lib/oe/copy_buildsystem.py @@ -0,0 +1,70 @@ +# This class should provide easy access to the different aspects of the +# buildsystem such as layers, bitbake location, etc. +import stat +import shutil + +def _smart_copy(src, dest): + # smart_copy will choose the correct function depending on whether the + # source is a file or a directory. + mode = os.stat(src).st_mode + if stat.S_ISDIR(mode): + shutil.copytree(src, dest, symlinks=True) + else: + shutil.copyfile(src, dest) + shutil.copymode(src, dest) + +class BuildSystem(object): + def __init__(self, d): + self.d = d + self.layerdirs = d.getVar('BBLAYERS', True).split() + + def copy_bitbake_and_layers(self, destdir): + # Copy in all metadata layers + bitbake (as repositories) + layers_copied = [] + bb.utils.mkdirhier(destdir) + layers = list(self.layerdirs) + + corebase = self.d.getVar('COREBASE', True) + layers.append(corebase) + + corebase_files = self.d.getVar('COREBASE_FILES', True).split() + + # bitbake belongs in corebase so make sure it goes there + if "bitbake" not in corebase_files: + corebase_files.append("bitbake") + corebase_files = [corebase + '/' +x for x in corebase_files] + + for layer in layers: + layerconf = os.path.join(layer, 'conf', 'layer.conf') + if os.path.exists(layerconf): + with open(layerconf, 'r') as f: + if f.readline().startswith("# ### workspace layer auto-generated by devtool ###"): + bb.warn("Skipping local workspace layer %s" % layer) + continue + + # If the layer was already under corebase, leave it there + # since layers such as meta have issues when moved. + layerdestpath = destdir + if corebase == os.path.dirname(layer): + layerdestpath += '/' + os.path.basename(corebase) + layerdestpath += '/' + os.path.basename(layer) + + layer_relative = os.path.relpath(layerdestpath, + destdir) + layers_copied.append(layer_relative) + + # Treat corebase as special since it typically will contain + # build directories or other custom items. + if corebase == layer: + bb.utils.mkdirhier(layerdestpath) + for f in corebase_files: + f_basename = os.path.basename(f) + destname = os.path.join(layerdestpath, f_basename) + _smart_copy(f, destname) + else: + if os.path.exists(layerdestpath): + bb.note("Skipping layer %s, already handled" % layer) + else: + _smart_copy(layer, layerdestpath) + + return layers_copied |