diff options
Diffstat (limited to 'bitbake/bin/bitbake-layers')
-rwxr-xr-x | bitbake/bin/bitbake-layers | 59 |
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')] | |||
18 | import bb.cache | 18 | import bb.cache |
19 | import bb.cooker | 19 | import bb.cooker |
20 | import bb.providers | 20 | import bb.providers |
21 | import bb.utils | ||
21 | from bb.cooker import state | 22 | from 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') |