summaryrefslogtreecommitdiffstats
path: root/bitbake/bin
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2011-06-29 19:37:40 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-07-05 13:36:52 +0100
commit1164b7698313c5dcdc2aa3c65c35e2e1903286c6 (patch)
treed502327a98658755ac428a3beddfe64e2ca2f6e1 /bitbake/bin
parent3bf2d2103e4b600b01ef99dca7ba1a47bd4438f1 (diff)
downloadast2050-yocto-poky-1164b7698313c5dcdc2aa3c65c35e2e1903286c6.zip
ast2050-yocto-poky-1164b7698313c5dcdc2aa3c65c35e2e1903286c6.tar.gz
bitbake-layers: add command to flatten layers into one
Takes the current layer configuration and builds a "flattened" directory containing the contents of all layers, with any overlayed recipes removed and bbappends appended to the corresponding recipes. Note that some manual cleanup may still be necessary afterwards, in particular: * where non-recipe files (such as patches) are overwritten (the flatten command will show a warning for these) * where anything beyond the normal layer setup has been added to layer.conf (only the lowest priority layer's layer.conf is used) * Overridden/appended items from bbappends will need to be tidied up (Bitbake rev: 296c83cc22ce281223fe91ef84bc89034cd141e7) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/bin')
-rwxr-xr-xbitbake/bin/bitbake-layers59
1 files changed, 59 insertions, 0 deletions
diff --git a/bitbake/bin/bitbake-layers b/bitbake/bin/bitbake-layers
index fced88e..110e3c8 100755
--- a/bitbake/bin/bitbake-layers
+++ b/bitbake/bin/bitbake-layers
@@ -18,6 +18,7 @@ sys.path[0:0] = [os.path.join(topdir, 'lib')]
import bb.cache
import bb.cooker
import bb.providers
+import bb.utils
from bb.cooker import state
@@ -83,6 +84,64 @@ class Commands(cmd.Cmd):
else:
logger.info('No overlayed recipes found')
+ def do_flatten(self, args):
+ arglist = args.split()
+ if len(arglist) != 1:
+ logger.error('syntax: flatten <outputdir>')
+ return
+
+ if os.path.exists(arglist[0]) and os.listdir(arglist[0]):
+ logger.error('Directory %s exists and is non-empty, please clear it out first' % arglist[0])
+ return
+
+ layers = (self.config_data.getVar('BBLAYERS', True) or "").split()
+ for layer in layers:
+ overlayed = []
+ for f in self.cooker.overlayed.iterkeys():
+ for of in self.cooker.overlayed[f]:
+ if of.startswith(layer):
+ overlayed.append(of)
+
+ logger.info('Copying files from %s...' % layer )
+ for root, dirs, files in os.walk(layer):
+ for f1 in files:
+ f1full = os.sep.join([root, f1])
+ if f1full in overlayed:
+ logger.info(' Skipping overlayed file %s' % f1full )
+ else:
+ ext = os.path.splitext(f1)[1]
+ if ext != '.bbappend':
+ fdest = f1full[len(layer):]
+ fdest = os.path.normpath(os.sep.join([arglist[0],fdest]))
+ bb.utils.mkdirhier(os.path.dirname(fdest))
+ if os.path.exists(fdest):
+ if f1 == 'layer.conf' and root.endswith('/conf'):
+ logger.info(' Skipping layer config file %s' % f1full )
+ continue
+ else:
+ logger.warn('Overwriting file %s', fdest)
+ bb.utils.copyfile(f1full, fdest)
+ if ext == '.bb':
+ if f1 in self.cooker_data.appends:
+ appends = self.cooker_data.appends[f1]
+ if appends:
+ logger.info(' Applying appends to %s' % fdest )
+ for appendname in appends:
+ self.apply_append(appendname, fdest)
+
+ def get_append_layer(self, appendname):
+ for layer, _, regex, _ in self.cooker.status.bbfile_config_priorities:
+ if regex.match(appendname):
+ return layer
+ return "?"
+
+ def apply_append(self, appendname, recipename):
+ appendfile = open(appendname, 'r')
+ recipefile = open(recipename, 'a')
+ recipefile.write('\n')
+ recipefile.write('##### bbappended from %s #####\n' % self.get_append_layer(appendname))
+ recipefile.writelines(appendfile.readlines())
+
def do_show_appends(self, args):
if not self.cooker_data.appends:
logger.info('No append files found')
OpenPOWER on IntegriCloud