summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliot Smith <elliot.smith@intel.com>2016-07-12 15:54:50 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-19 08:56:51 +0100
commit587275eefd744032f00ebdce35134b2ab2bb7572 (patch)
treef8f178cdeacf3122df1ab7abd4550fbf8b4374c0
parent150e5588a01b1334ae3158c9b13e28bec428af37 (diff)
downloadpoky-587275eefd744032f00ebdce35134b2ab2bb7572.tar.gz
bitbake: toaster: use has_images() methods to display images correctly
In the build dashboard, we had issues with showing images correctly, as we were using the is_image property of targets to determine whether a target would have image files. This property can be set to True if a target refers to an image recipe (e.g. "core-image-minimal"), even if the task used in the build didn't produce any image files. By adding has_images() methods to the Target and Build objects, which count associated Target_Image_File objects, we can correctly determine whether a target has image files associated with it, and if any of the targets for a build has image files. This means that we can screen out the left-hand "Images" menu options for builds which contained image-related targets (e.g. "core-image-minimal") but which didn't produce any images (e.g. "rootfs" task). [YOCTO #9500] [YOCTO #9784] (Bitbake rev: f6bba0ff254d5ed3163151d4b938f3a43c9acb0a) Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: bavery <brian.avery@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/toaster/orm/models.py28
-rw-r--r--bitbake/lib/toaster/toastergui/templates/basebuildpage.html8
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py9
3 files changed, 33 insertions, 12 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 61f6a2072e..0443a4589d 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -436,17 +436,32 @@ class Build(models.Model):
436 eta += ((eta - self.started_on)*(100-completeper))/completeper 436 eta += ((eta - self.started_on)*(100-completeper))/completeper
437 return eta 437 return eta
438 438
439 def has_images(self):
440 """
441 Returns True if at least one of the targets for this build has an
442 image file associated with it, False otherwise
443 """
444 targets = Target.objects.filter(build_id=self.id)
445 has_images = False
446 for target in targets:
447 if target.has_images():
448 has_images = True
449 break
450 return has_images
451
439 def get_image_file_extensions(self): 452 def get_image_file_extensions(self):
440 """ 453 """
441 Get list of file name extensions for images produced by this build; 454 Get string of file name extensions for images produced by this build;
442 note that this is the actual list of extensions stored on Target objects 455 note that this is the actual list of extensions stored on Target objects
443 for this build, and not the value of IMAGE_FSTYPES. 456 for this build, and not the value of IMAGE_FSTYPES.
457
458 Returns comma-separated string, e.g. "vmdk, ext4"
444 """ 459 """
445 extensions = [] 460 extensions = []
446 461
447 targets = Target.objects.filter(build_id = self.id) 462 targets = Target.objects.filter(build_id = self.id)
448 for target in targets: 463 for target in targets:
449 if (not target.is_image): 464 if not target.is_image:
450 continue 465 continue
451 466
452 target_image_files = Target_Image_File.objects.filter( 467 target_image_files = Target_Image_File.objects.filter(
@@ -739,6 +754,12 @@ class Target(models.Model):
739 sdk_file.target = self 754 sdk_file.target = self
740 sdk_file.save() 755 sdk_file.save()
741 756
757 def has_images(self):
758 """
759 Returns True if this target has one or more image files attached to it.
760 """
761 return self.target_image_file_set.all().count() > 0
762
742# kernel artifacts for a target: bzImage and modules* 763# kernel artifacts for a target: bzImage and modules*
743class TargetKernelFile(models.Model): 764class TargetKernelFile(models.Model):
744 target = models.ForeignKey(Target) 765 target = models.ForeignKey(Target)
@@ -775,6 +796,9 @@ class Target_Image_File(models.Model):
775 796
776 @property 797 @property
777 def suffix(self): 798 def suffix(self):
799 """
800 Suffix for image file, minus leading "."
801 """
778 for suffix in Target_Image_File.SUFFIXES: 802 for suffix in Target_Image_File.SUFFIXES:
779 if self.file_name.endswith(suffix): 803 if self.file_name.endswith(suffix):
780 return suffix 804 return suffix
diff --git a/bitbake/lib/toaster/toastergui/templates/basebuildpage.html b/bitbake/lib/toaster/toastergui/templates/basebuildpage.html
index 856259a69d..e9927ebbaa 100644
--- a/bitbake/lib/toaster/toastergui/templates/basebuildpage.html
+++ b/bitbake/lib/toaster/toastergui/templates/basebuildpage.html
@@ -33,7 +33,7 @@
33 33
34 $("#build-menu li a").each(function(){ 34 $("#build-menu li a").each(function(){
35 /* Set the page active state in the Build menu */ 35 /* Set the page active state in the Build menu */
36 var currentUrl = window.location.href.split('?')[0]; 36 var currentUrl = window.location.href.split('?')[0];
37 if (currentUrl === $(this).prop("href")){ 37 if (currentUrl === $(this).prop("href")){
38 $(this).parent().addClass("active"); 38 $(this).parent().addClass("active");
39 } else { 39 } else {
@@ -62,11 +62,13 @@
62 {% endif %} > 62 {% endif %} >
63 <a href="{% url 'builddashboard' build.pk %}">Build summary</a> 63 <a href="{% url 'builddashboard' build.pk %}">Build summary</a>
64 </li> 64 </li>
65 {% if build.target_set.all.0.is_image and build.outcome == 0 %} 65 {% if build.has_images and build.outcome == build.SUCCEEDED %}
66 <li class="nav-header">Images</li> 66 <li class="nav-header">Images</li>
67 {% block nav-target %} 67 {% block nav-target %}
68 {% for t in build.get_sorted_target_list %} 68 {% for t in build.get_sorted_target_list %}
69 <li id="menu-{{t.target}}"><a href="{% url 'target' build.pk t.pk %}">{{t.target}}</a><li> 69 {% if t.has_images %}
70 <li id="menu-{{t.target}}"><a href="{% url 'target' build.pk t.pk %}">{{t.target}}</a><li>
71 {% endif %}
70 {% endfor %} 72 {% endfor %}
71 {% endblock %} 73 {% endblock %}
72 {% endif %} 74 {% endif %}
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index a82a261e0d..02caf54d50 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -471,19 +471,14 @@ def builddashboard( request, build_id ):
471 recipeCount = Recipe.objects.filter( layer_version__id__in = layerVersionId ).count( ); 471 recipeCount = Recipe.objects.filter( layer_version__id__in = layerVersionId ).count( );
472 tgts = Target.objects.filter( build_id = build_id ).order_by( 'target' ); 472 tgts = Target.objects.filter( build_id = build_id ).order_by( 'target' );
473 473
474 ##
475 # set up custom target list with computed package and image data 474 # set up custom target list with computed package and image data
476 #
477
478 targets = [ ] 475 targets = [ ]
479 ntargets = 0 476 ntargets = 0
480 hasImages = False 477
481 targetHasNoImages = False 478 targetHasNoImages = False
482 for t in tgts: 479 for t in tgts:
483 elem = { } 480 elem = { }
484 elem[ 'target' ] = t 481 elem[ 'target' ] = t
485 if t.is_image:
486 hasImages = True
487 npkg = 0 482 npkg = 0
488 pkgsz = 0 483 pkgsz = 0
489 package = None 484 package = None
@@ -533,7 +528,7 @@ def builddashboard( request, build_id ):
533 context = { 528 context = {
534 'build' : build, 529 'build' : build,
535 'project' : build.project, 530 'project' : build.project,
536 'hasImages' : hasImages, 531 'hasImages' : build.has_images(),
537 'ntargets' : ntargets, 532 'ntargets' : ntargets,
538 'targets' : targets, 533 'targets' : targets,
539 'recipecount' : recipeCount, 534 'recipecount' : recipeCount,