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-24 17:41:43 +0000 |
commit | d5d4b70a5db1ab5588151764dedb926e304420be (patch) | |
tree | 957d27007f56217c8f5092e7c3440643b5f77409 /meta/lib/oe | |
parent | 91a9b3f114e379ffb45287593307282e8bc1b0a6 (diff) | |
download | poky-d5d4b70a5db1ab5588151764dedb926e304420be.tar.gz |
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.
(From OE-Core rev: 3dc52164fb560ccbe5c203a4587f6286c8fc0389)
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/lib/oe')
-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 @@ | |||
1 | # This class should provide easy access to the different aspects of the | ||
2 | # buildsystem such as layers, bitbake location, etc. | ||
3 | import stat | ||
4 | import shutil | ||
5 | |||
6 | def _smart_copy(src, dest): | ||
7 | # smart_copy will choose the correct function depending on whether the | ||
8 | # source is a file or a directory. | ||
9 | mode = os.stat(src).st_mode | ||
10 | if stat.S_ISDIR(mode): | ||
11 | shutil.copytree(src, dest, symlinks=True) | ||
12 | else: | ||
13 | shutil.copyfile(src, dest) | ||
14 | shutil.copymode(src, dest) | ||
15 | |||
16 | class BuildSystem(object): | ||
17 | def __init__(self, d): | ||
18 | self.d = d | ||
19 | self.layerdirs = d.getVar('BBLAYERS', True).split() | ||
20 | |||
21 | def copy_bitbake_and_layers(self, destdir): | ||
22 | # Copy in all metadata layers + bitbake (as repositories) | ||
23 | layers_copied = [] | ||
24 | bb.utils.mkdirhier(destdir) | ||
25 | layers = list(self.layerdirs) | ||
26 | |||
27 | corebase = self.d.getVar('COREBASE', True) | ||
28 | layers.append(corebase) | ||
29 | |||
30 | corebase_files = self.d.getVar('COREBASE_FILES', True).split() | ||
31 | |||
32 | # bitbake belongs in corebase so make sure it goes there | ||
33 | if "bitbake" not in corebase_files: | ||
34 | corebase_files.append("bitbake") | ||
35 | corebase_files = [corebase + '/' +x for x in corebase_files] | ||
36 | |||
37 | for layer in layers: | ||
38 | layerconf = os.path.join(layer, 'conf', 'layer.conf') | ||
39 | if os.path.exists(layerconf): | ||
40 | with open(layerconf, 'r') as f: | ||
41 | if f.readline().startswith("# ### workspace layer auto-generated by devtool ###"): | ||
42 | bb.warn("Skipping local workspace layer %s" % layer) | ||
43 | continue | ||
44 | |||
45 | # If the layer was already under corebase, leave it there | ||
46 | # since layers such as meta have issues when moved. | ||
47 | layerdestpath = destdir | ||
48 | if corebase == os.path.dirname(layer): | ||
49 | layerdestpath += '/' + os.path.basename(corebase) | ||
50 | layerdestpath += '/' + os.path.basename(layer) | ||
51 | |||
52 | layer_relative = os.path.relpath(layerdestpath, | ||
53 | destdir) | ||
54 | layers_copied.append(layer_relative) | ||
55 | |||
56 | # Treat corebase as special since it typically will contain | ||
57 | # build directories or other custom items. | ||
58 | if corebase == layer: | ||
59 | bb.utils.mkdirhier(layerdestpath) | ||
60 | for f in corebase_files: | ||
61 | f_basename = os.path.basename(f) | ||
62 | destname = os.path.join(layerdestpath, f_basename) | ||
63 | _smart_copy(f, destname) | ||
64 | else: | ||
65 | if os.path.exists(layerdestpath): | ||
66 | bb.note("Skipping layer %s, already handled" % layer) | ||
67 | else: | ||
68 | _smart_copy(layer, layerdestpath) | ||
69 | |||
70 | return layers_copied | ||