summaryrefslogtreecommitdiffstats
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
parent3bf2d2103e4b600b01ef99dca7ba1a47bd4438f1 (diff)
downloadpoky-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>
-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 fced88ef35..110e3c8ee5 100755
--- a/bitbake/bin/bitbake-layers
+++ b/bitbake/bin/bitbake-layers
@@ -18,6 +18,7 @@ sys.path[0:0] = [os.path.join(topdir, 'lib')]
18import bb.cache 18import bb.cache
19import bb.cooker 19import bb.cooker
20import bb.providers 20import bb.providers
21import bb.utils
21from bb.cooker import state 22from bb.cooker import state
22 23
23 24
@@ -83,6 +84,64 @@ class Commands(cmd.Cmd):
83 else: 84 else:
84 logger.info('No overlayed recipes found') 85 logger.info('No overlayed recipes found')
85 86
87 def do_flatten(self, args):
88 arglist = args.split()
89 if len(arglist) != 1:
90 logger.error('syntax: flatten <outputdir>')
91 return
92
93 if os.path.exists(arglist[0]) and os.listdir(arglist[0]):
94 logger.error('Directory %s exists and is non-empty, please clear it out first' % arglist[0])
95 return
96
97 layers = (self.config_data.getVar('BBLAYERS', True) or "").split()
98 for layer in layers:
99 overlayed = []
100 for f in self.cooker.overlayed.iterkeys():
101 for of in self.cooker.overlayed[f]:
102 if of.startswith(layer):
103 overlayed.append(of)
104
105 logger.info('Copying files from %s...' % layer )
106 for root, dirs, files in os.walk(layer):
107 for f1 in files:
108 f1full = os.sep.join([root, f1])
109 if f1full in overlayed:
110 logger.info(' Skipping overlayed file %s' % f1full )
111 else:
112 ext = os.path.splitext(f1)[1]
113 if ext != '.bbappend':
114 fdest = f1full[len(layer):]
115 fdest = os.path.normpath(os.sep.join([arglist[0],fdest]))
116 bb.utils.mkdirhier(os.path.dirname(fdest))
117 if os.path.exists(fdest):
118 if f1 == 'layer.conf' and root.endswith('/conf'):
119 logger.info(' Skipping layer config file %s' % f1full )
120 continue
121 else:
122 logger.warn('Overwriting file %s', fdest)
123 bb.utils.copyfile(f1full, fdest)
124 if ext == '.bb':
125 if f1 in self.cooker_data.appends:
126 appends = self.cooker_data.appends[f1]
127 if appends:
128 logger.info(' Applying appends to %s' % fdest )
129 for appendname in appends:
130 self.apply_append(appendname, fdest)
131
132 def get_append_layer(self, appendname):
133 for layer, _, regex, _ in self.cooker.status.bbfile_config_priorities:
134 if regex.match(appendname):
135 return layer
136 return "?"
137
138 def apply_append(self, appendname, recipename):
139 appendfile = open(appendname, 'r')
140 recipefile = open(recipename, 'a')
141 recipefile.write('\n')
142 recipefile.write('##### bbappended from %s #####\n' % self.get_append_layer(appendname))
143 recipefile.writelines(appendfile.readlines())
144
86 def do_show_appends(self, args): 145 def do_show_appends(self, args):
87 if not self.cooker_data.appends: 146 if not self.cooker_data.appends:
88 logger.info('No append files found') 147 logger.info('No append files found')