aboutsummaryrefslogtreecommitdiffstats
path: root/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:25:11 +0100
commit296c83cc22ce281223fe91ef84bc89034cd141e7 (patch)
treec4bcf253b08ea9760c9d805ebdda1d94841ef3d9 /bin
parent115b89fa279b64e79da0f72caf7b30965a83fab1 (diff)
downloadbitbake-296c83cc22ce281223fe91ef84bc89034cd141e7.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 Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/bitbake-layers59
1 files changed, 59 insertions, 0 deletions
diff --git a/bin/bitbake-layers b/bin/bitbake-layers
index fced88ef3..110e3c8ee 100755
--- a/bin/bitbake-layers
+++ b/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')