diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2014-03-06 16:31:40 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-03-11 12:24:30 -0700 |
commit | 00ca499a98a0244d02fca3497fb096b629947c5b (patch) | |
tree | d12130c2fee994b3743b29346baf477b04ebad8e /bitbake/lib/bb/ui/buildinfohelper.py | |
parent | 7a0add74d910ca98d27c31cd96cd5cd2b1cd9e21 (diff) | |
download | poky-00ca499a98a0244d02fca3497fb096b629947c5b.tar.gz |
bitbake: toaster: write files-in-image to the database
Adding code to write files-in-image data from the metadata
event to the database.
(Bitbake rev: f3a69ef7cc536a4b879d60936199a1002584c4f4)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui/buildinfohelper.py')
-rw-r--r-- | bitbake/lib/bb/ui/buildinfohelper.py | 115 |
1 files changed, 113 insertions, 2 deletions
diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py index d7b526a2f2..f9b067fab9 100644 --- a/bitbake/lib/bb/ui/buildinfohelper.py +++ b/bitbake/lib/bb/ui/buildinfohelper.py | |||
@@ -27,7 +27,7 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "toaster.toastermain.settings") | |||
27 | import toaster.toastermain.settings as toaster_django_settings | 27 | import toaster.toastermain.settings as toaster_django_settings |
28 | from toaster.orm.models import Build, Task, Recipe, Layer_Version, Layer, Target, LogMessage | 28 | from toaster.orm.models import Build, Task, Recipe, Layer_Version, Layer, Target, LogMessage |
29 | from toaster.orm.models import Variable, VariableHistory | 29 | from toaster.orm.models import Variable, VariableHistory |
30 | from toaster.orm.models import Package, Package_File, Target_Installed_Package | 30 | from toaster.orm.models import Package, Package_File, Target_Installed_Package, Target_File |
31 | from toaster.orm.models import Task_Dependency, Package_Dependency | 31 | from toaster.orm.models import Task_Dependency, Package_Dependency |
32 | from toaster.orm.models import Recipe_Dependency | 32 | from toaster.orm.models import Recipe_Dependency |
33 | from bb.msg import BBLogFormatter as format | 33 | from bb.msg import BBLogFormatter as format |
@@ -181,6 +181,113 @@ class ORMWrapper(object): | |||
181 | 181 | ||
182 | return layer_object | 182 | return layer_object |
183 | 183 | ||
184 | def save_target_file_information(self, build_obj, target_obj, filedata): | ||
185 | assert isinstance(build_obj, Build) | ||
186 | assert isinstance(target_obj, Target) | ||
187 | dirs = filedata['dirs'] | ||
188 | files = filedata['files'] | ||
189 | syms = filedata['syms'] | ||
190 | |||
191 | # we insert directories, ordered by name depth | ||
192 | for d in sorted(dirs, key=lambda x:len(x[-1].split("/"))): | ||
193 | (user, group, size) = d[1:4] | ||
194 | permission = d[0][1:] | ||
195 | path = d[4].lstrip(".") | ||
196 | if len(path) == 0: | ||
197 | # we create the root directory as a special case | ||
198 | path = "/" | ||
199 | tf_obj = Target_File.objects.create( | ||
200 | target = target_obj, | ||
201 | path = path, | ||
202 | size = size, | ||
203 | inodetype = Target_File.ITYPE_DIRECTORY, | ||
204 | permission = permission, | ||
205 | owner = user, | ||
206 | group = group, | ||
207 | ) | ||
208 | tf_obj.directory = tf_obj | ||
209 | tf_obj.save() | ||
210 | continue | ||
211 | parent_path = "/".join(path.split("/")[:len(path.split("/")) - 1]) | ||
212 | if len(parent_path) == 0: | ||
213 | parent_path = "/" | ||
214 | parent_obj = Target_File.objects.get(target = target_obj, path = parent_path, inodetype = Target_File.ITYPE_DIRECTORY) | ||
215 | tf_obj = Target_File.objects.create( | ||
216 | target = target_obj, | ||
217 | path = path, | ||
218 | size = size, | ||
219 | inodetype = Target_File.ITYPE_DIRECTORY, | ||
220 | permission = permission, | ||
221 | owner = user, | ||
222 | group = group, | ||
223 | directory = parent_obj) | ||
224 | |||
225 | |||
226 | # we insert files | ||
227 | for d in files: | ||
228 | (user, group, size) = d[1:4] | ||
229 | permission = d[0][1:] | ||
230 | path = d[4].lstrip(".") | ||
231 | parent_path = "/".join(path.split("/")[:len(path.split("/")) - 1]) | ||
232 | inodetype = Target_File.ITYPE_REGULAR | ||
233 | if permission.startswith('b'): | ||
234 | inodetype = Target_File.ITYPE_BLOCK | ||
235 | if permission.startswith('c'): | ||
236 | inodetype = Target_File.ITYPE_CHARACTER | ||
237 | if permission.startswith('p'): | ||
238 | inodetype = Target_File.ITYPE_FIFO | ||
239 | |||
240 | tf_obj = Target_File.objects.create( | ||
241 | target = target_obj, | ||
242 | path = path, | ||
243 | size = size, | ||
244 | inodetype = inodetype, | ||
245 | permission = permission, | ||
246 | owner = user, | ||
247 | group = group) | ||
248 | parent_obj = Target_File.objects.get(target = target_obj, path = parent_path, inodetype = Target_File.ITYPE_DIRECTORY) | ||
249 | tf_obj.directory = parent_obj | ||
250 | tf_obj.save() | ||
251 | |||
252 | # we insert symlinks | ||
253 | for d in syms: | ||
254 | (user, group, size) = d[1:4] | ||
255 | permission = d[0][1:] | ||
256 | path = d[4].lstrip(".") | ||
257 | filetarget_path = d[6] | ||
258 | |||
259 | parent_path = "/".join(path.split("/")[:len(path.split("/")) - 1]) | ||
260 | if not filetarget_path.startswith("/"): | ||
261 | # we have a relative path, get a normalized absolute one | ||
262 | filetarget_path = parent_path + "/" + filetarget_path | ||
263 | fcp = filetarget_path.split("/") | ||
264 | fcpl = [] | ||
265 | for i in fcp: | ||
266 | if i == "..": | ||
267 | fcpl.pop() | ||
268 | else: | ||
269 | fcpl.append(i) | ||
270 | filetarget_path = "/".join(fcpl) | ||
271 | |||
272 | try: | ||
273 | filetarget_obj = Target_File.objects.get(target = target_obj, path = filetarget_path) | ||
274 | except Exception as e: | ||
275 | # we might have an invalid link; no way to detect this. just set it to None | ||
276 | filetarget_obj = None | ||
277 | |||
278 | parent_obj = Target_File.objects.get(target = target_obj, path = parent_path, inodetype = Target_File.ITYPE_DIRECTORY) | ||
279 | |||
280 | tf_obj = Target_File.objects.create( | ||
281 | target = target_obj, | ||
282 | path = path, | ||
283 | size = size, | ||
284 | inodetype = Target_File.ITYPE_REGULAR, | ||
285 | permission = permission, | ||
286 | owner = user, | ||
287 | group = group, | ||
288 | directory = parent_obj, | ||
289 | sym_target = filetarget_obj) | ||
290 | |||
184 | 291 | ||
185 | def save_target_package_information(self, build_obj, target_obj, packagedict, pkgpnmap, recipes): | 292 | def save_target_package_information(self, build_obj, target_obj, packagedict, pkgpnmap, recipes): |
186 | assert isinstance(build_obj, Build) | 293 | assert isinstance(build_obj, Build) |
@@ -613,6 +720,10 @@ class BuildInfoHelper(object): | |||
613 | pkgdata = event.data['pkgdata'] | 720 | pkgdata = event.data['pkgdata'] |
614 | imgdata = event.data['imgdata'][target.target] | 721 | imgdata = event.data['imgdata'][target.target] |
615 | self.orm_wrapper.save_target_package_information(self.internal_state['build'], target, imgdata, pkgdata, self.internal_state['recipes']) | 722 | self.orm_wrapper.save_target_package_information(self.internal_state['build'], target, imgdata, pkgdata, self.internal_state['recipes']) |
723 | filedata = event.data['filedata'][target.target] | ||
724 | self.orm_wrapper.save_target_file_information(self.internal_state['build'], target, filedata) | ||
725 | |||
726 | |||
616 | 727 | ||
617 | def store_dependency_information(self, event): | 728 | def store_dependency_information(self, event): |
618 | assert '_depgraph' in vars(event) | 729 | assert '_depgraph' in vars(event) |
@@ -692,7 +803,7 @@ class BuildInfoHelper(object): | |||
692 | task_info['task_name'] = taskname | 803 | task_info['task_name'] = taskname |
693 | task_obj = self.orm_wrapper.get_update_task_object(task_info) | 804 | task_obj = self.orm_wrapper.get_update_task_object(task_info) |
694 | return task_obj | 805 | return task_obj |
695 | 806 | ||
696 | # create tasks | 807 | # create tasks |
697 | tasks = {} | 808 | tasks = {} |
698 | for taskdesc in event._depgraph['tdepends']: | 809 | for taskdesc in event._depgraph['tdepends']: |