diff options
author | Michael Wood <michael.g.wood@intel.com> | 2015-12-07 18:26:47 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-10 13:29:17 +0000 |
commit | a6e4f94b0164434ebdd3bdad2ea7f69f6ba53ff0 (patch) | |
tree | 819e985d48b5195212e81b10af0b5cba486331dc /bitbake/lib/bb | |
parent | e1bfe1ceb6c3518e1fd46f524cbca5c0550bf773 (diff) | |
download | poky-a6e4f94b0164434ebdd3bdad2ea7f69f6ba53ff0.tar.gz |
bitbake: toaster: buildinfohelper Add the concept of CustomImagePackage
This adds the concept of CustomImagePackage this is similar to the way
layers and recipes work in that we have a set of data which is part of
the build history and a set of data which is part of the configuration
data that toaster uses to guide people in configuring their project. We
create a set of built_packages for every build but only create a package
for configuration purposes if we don't already have one, so that the
CustomImagePackage only ever contains a unique list of packages that are
available to be added and removed from a CustomImageRecipe.
(Bitbake rev: f81bb65883baa6c0f8a4d48a4de3291a10543992)
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/ui/buildinfohelper.py | 105 |
1 files changed, 89 insertions, 16 deletions
diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py index 0cb6f684f9..74e3588982 100644 --- a/bitbake/lib/bb/ui/buildinfohelper.py +++ b/bitbake/lib/bb/ui/buildinfohelper.py | |||
@@ -42,8 +42,8 @@ from orm.models import Variable, VariableHistory | |||
42 | from orm.models import Package, Package_File, Target_Installed_Package, Target_File | 42 | from orm.models import Package, Package_File, Target_Installed_Package, Target_File |
43 | from orm.models import Task_Dependency, Package_Dependency | 43 | from orm.models import Task_Dependency, Package_Dependency |
44 | from orm.models import Recipe_Dependency, Provides | 44 | from orm.models import Recipe_Dependency, Provides |
45 | from orm.models import Project, CustomImagePackage | ||
45 | 46 | ||
46 | from orm.models import Project | ||
47 | from bldcontrol.models import BuildEnvironment, BuildRequest | 47 | from bldcontrol.models import BuildEnvironment, BuildRequest |
48 | 48 | ||
49 | from bb.msg import BBLogFormatter as formatter | 49 | from bb.msg import BBLogFormatter as formatter |
@@ -323,6 +323,11 @@ class ORMWrapper(object): | |||
323 | 323 | ||
324 | def get_update_layer_version_object(self, build_obj, layer_obj, layer_version_information): | 324 | def get_update_layer_version_object(self, build_obj, layer_obj, layer_version_information): |
325 | if isinstance(layer_obj, Layer_Version): | 325 | if isinstance(layer_obj, Layer_Version): |
326 | # Special case the toaster-custom-images layer which is created | ||
327 | # on the fly so don't update the values which may cause the layer | ||
328 | # to be duplicated on a future get_or_create | ||
329 | if layer_obj.layer.name == "toaster-custom-images": | ||
330 | return layer_obj | ||
326 | # We already found our layer version for this build so just | 331 | # We already found our layer version for this build so just |
327 | # update it with the new build information | 332 | # update it with the new build information |
328 | logger.debug("We found our layer from toaster") | 333 | logger.debug("We found our layer from toaster") |
@@ -527,12 +532,14 @@ class ORMWrapper(object): | |||
527 | sym_target = filetarget_obj) | 532 | sym_target = filetarget_obj) |
528 | 533 | ||
529 | 534 | ||
530 | def save_target_package_information(self, build_obj, target_obj, packagedict, pkgpnmap, recipes): | 535 | def save_target_package_information(self, build_obj, target_obj, packagedict, pkgpnmap, recipes, built_package=False): |
531 | assert isinstance(build_obj, Build) | 536 | assert isinstance(build_obj, Build) |
532 | assert isinstance(target_obj, Target) | 537 | assert isinstance(target_obj, Target) |
533 | 538 | ||
534 | errormsg = "" | 539 | errormsg = "" |
535 | for p in packagedict: | 540 | for p in packagedict: |
541 | # Search name swtiches round the installed name vs package name | ||
542 | # by default installed name == package name | ||
536 | searchname = p | 543 | searchname = p |
537 | if p not in pkgpnmap: | 544 | if p not in pkgpnmap: |
538 | logger.warning("Image packages list contains %p, but is" | 545 | logger.warning("Image packages list contains %p, but is" |
@@ -543,11 +550,30 @@ class ORMWrapper(object): | |||
543 | if 'OPKGN' in pkgpnmap[p].keys(): | 550 | if 'OPKGN' in pkgpnmap[p].keys(): |
544 | searchname = pkgpnmap[p]['OPKGN'] | 551 | searchname = pkgpnmap[p]['OPKGN'] |
545 | 552 | ||
546 | packagedict[p]['object'], created = Package.objects.get_or_create( build = build_obj, name = searchname ) | 553 | built_recipe = recipes[pkgpnmap[p]['PN']] |
554 | |||
555 | if built_package: | ||
556 | packagedict[p]['object'], created = Package.objects.get_or_create( build = build_obj, name = searchname ) | ||
557 | recipe = built_recipe | ||
558 | else: | ||
559 | packagedict[p]['object'], created = \ | ||
560 | CustomImagePackage.objects.get_or_create(name=searchname) | ||
561 | try: | ||
562 | recipe = self._cached_get(Recipe, | ||
563 | name=built_recipe.name, | ||
564 | layer_version__build=None, | ||
565 | file_path=built_recipe.file_path, | ||
566 | version=built_recipe.version) | ||
567 | except (Recipe.DoesNotExist, | ||
568 | Recipe.MultipleObjectsReturned) as e: | ||
569 | logger.info("We did not find one recipe for the" | ||
570 | "configuration data package %s %s" % (p, e)) | ||
571 | continue | ||
572 | |||
547 | if created or packagedict[p]['object'].size == -1: # save the data anyway we can, not just if it was not created here; bug [YOCTO #6887] | 573 | if created or packagedict[p]['object'].size == -1: # save the data anyway we can, not just if it was not created here; bug [YOCTO #6887] |
548 | # fill in everything we can from the runtime-reverse package data | 574 | # fill in everything we can from the runtime-reverse package data |
549 | try: | 575 | try: |
550 | packagedict[p]['object'].recipe = recipes[pkgpnmap[p]['PN']] | 576 | packagedict[p]['object'].recipe = recipe |
551 | packagedict[p]['object'].version = pkgpnmap[p]['PV'] | 577 | packagedict[p]['object'].version = pkgpnmap[p]['PV'] |
552 | packagedict[p]['object'].installed_name = p | 578 | packagedict[p]['object'].installed_name = p |
553 | packagedict[p]['object'].revision = pkgpnmap[p]['PR'] | 579 | packagedict[p]['object'].revision = pkgpnmap[p]['PR'] |
@@ -573,7 +599,8 @@ class ORMWrapper(object): | |||
573 | packagedict[p]['object'].installed_size = packagedict[p]['size'] | 599 | packagedict[p]['object'].installed_size = packagedict[p]['size'] |
574 | packagedict[p]['object'].save() | 600 | packagedict[p]['object'].save() |
575 | 601 | ||
576 | Target_Installed_Package.objects.create(target = target_obj, package = packagedict[p]['object']) | 602 | if built_package: |
603 | Target_Installed_Package.objects.create(target = target_obj, package = packagedict[p]['object']) | ||
577 | 604 | ||
578 | packagedeps_objs = [] | 605 | packagedeps_objs = [] |
579 | for p in packagedict: | 606 | for p in packagedict: |
@@ -584,6 +611,21 @@ class ORMWrapper(object): | |||
584 | tdeptype = Package_Dependency.TYPE_TRECOMMENDS | 611 | tdeptype = Package_Dependency.TYPE_TRECOMMENDS |
585 | 612 | ||
586 | try: | 613 | try: |
614 | # If this is a built package we are always going to have | ||
615 | # new package objects as it's part of the build history | ||
616 | # which also means new package dependency for each object. | ||
617 | # However if they are project packages we don't want to | ||
618 | # duplicate these so check if they exist or not first | ||
619 | if built_package == False: | ||
620 | try: | ||
621 | Package_Dependency.objects.get( | ||
622 | package=packagedict[p]['object'], | ||
623 | depends_on=packagedict[px]['object'], | ||
624 | dep_type=tdeptype) | ||
625 | continue | ||
626 | except Package_Dependency.DoesNotExist: | ||
627 | pass | ||
628 | |||
587 | packagedeps_objs.append(Package_Dependency( | 629 | packagedeps_objs.append(Package_Dependency( |
588 | package = packagedict[p]['object'], | 630 | package = packagedict[p]['object'], |
589 | depends_on = packagedict[px]['object'], | 631 | depends_on = packagedict[px]['object'], |
@@ -634,19 +676,37 @@ class ORMWrapper(object): | |||
634 | return log_object.save() | 676 | return log_object.save() |
635 | 677 | ||
636 | 678 | ||
637 | def save_build_package_information(self, build_obj, package_info, recipes): | 679 | def save_build_package_information(self, build_obj, package_info, recipes, |
638 | assert isinstance(build_obj, Build) | 680 | built_package): |
681 | # assert isinstance(build_obj, Build) | ||
639 | 682 | ||
640 | # create and save the object | 683 | # create and save the object |
641 | pname = package_info['PKG'] | 684 | pname = package_info['PKG'] |
685 | built_recipe = recipes[package_info['PN']] | ||
642 | if 'OPKGN' in package_info.keys(): | 686 | if 'OPKGN' in package_info.keys(): |
643 | pname = package_info['OPKGN'] | 687 | pname = package_info['OPKGN'] |
644 | 688 | ||
645 | bp_object, _ = Package.objects.get_or_create( build = build_obj, | 689 | if built_package: |
646 | name = pname ) | 690 | bp_object, _ = Package.objects.get_or_create( build = build_obj, |
691 | name = pname ) | ||
692 | recipe = built_recipe | ||
693 | else: | ||
694 | bp_object, created = \ | ||
695 | CustomImagePackage.objects.get_or_create(name=pname) | ||
696 | try: | ||
697 | recipe = self._cached_get(Recipe, | ||
698 | name=built_recipe.name, | ||
699 | layer_version__build=None, | ||
700 | file_path=built_recipe.file_path, | ||
701 | version=built_recipe.version) | ||
702 | |||
703 | except (Recipe.DoesNotExist, Recipe.MultipleObjectsReturned): | ||
704 | logger.debug("We did not find one recipe for the configuration" | ||
705 | "data package %s" % pname) | ||
706 | return | ||
647 | 707 | ||
648 | bp_object.installed_name = package_info['PKG'] | 708 | bp_object.installed_name = package_info['PKG'] |
649 | bp_object.recipe = recipes[package_info['PN']] | 709 | bp_object.recipe = recipe |
650 | bp_object.version = package_info['PKGV'] | 710 | bp_object.version = package_info['PKGV'] |
651 | bp_object.revision = package_info['PKGR'] | 711 | bp_object.revision = package_info['PKGR'] |
652 | bp_object.summary = package_info['SUMMARY'] | 712 | bp_object.summary = package_info['SUMMARY'] |
@@ -666,7 +726,12 @@ class ORMWrapper(object): | |||
666 | Package_File.objects.bulk_create(packagefile_objects) | 726 | Package_File.objects.bulk_create(packagefile_objects) |
667 | 727 | ||
668 | def _po_byname(p): | 728 | def _po_byname(p): |
669 | pkg, created = Package.objects.get_or_create(build = build_obj, name = p) | 729 | if built_package: |
730 | pkg, created = Package.objects.get_or_create(build=build_obj, | ||
731 | name=p) | ||
732 | else: | ||
733 | pkg, created = CustomImagePackage.objects.get_or_create(name=p) | ||
734 | |||
670 | if created: | 735 | if created: |
671 | pkg.size = -1 | 736 | pkg.size = -1 |
672 | pkg.save() | 737 | pkg.save() |
@@ -1167,7 +1232,8 @@ class BuildInfoHelper(object): | |||
1167 | filedata = BuildInfoHelper._get_data_from_event(event)['filedata'][target.target] | 1232 | filedata = BuildInfoHelper._get_data_from_event(event)['filedata'][target.target] |
1168 | 1233 | ||
1169 | try: | 1234 | try: |
1170 | self.orm_wrapper.save_target_package_information(self.internal_state['build'], target, imgdata, pkgdata, self.internal_state['recipes']) | 1235 | self.orm_wrapper.save_target_package_information(self.internal_state['build'], target, imgdata, pkgdata, self.internal_state['recipes'], built_package=True) |
1236 | self.orm_wrapper.save_target_package_information(self.internal_state['build'], target, imgdata.copy(), pkgdata, self.internal_state['recipes'], built_package=False) | ||
1171 | except KeyError as e: | 1237 | except KeyError as e: |
1172 | logger.warn("KeyError in save_target_package_information" | 1238 | logger.warn("KeyError in save_target_package_information" |
1173 | "%s ", e) | 1239 | "%s ", e) |
@@ -1324,10 +1390,17 @@ class BuildInfoHelper(object): | |||
1324 | 1390 | ||
1325 | def store_build_package_information(self, event): | 1391 | def store_build_package_information(self, event): |
1326 | package_info = BuildInfoHelper._get_data_from_event(event) | 1392 | package_info = BuildInfoHelper._get_data_from_event(event) |
1327 | self.orm_wrapper.save_build_package_information(self.internal_state['build'], | 1393 | self.orm_wrapper.save_build_package_information( |
1328 | package_info, | 1394 | self.internal_state['build'], |
1329 | self.internal_state['recipes'], | 1395 | package_info, |
1330 | ) | 1396 | self.internal_state['recipes'], |
1397 | built_package=True) | ||
1398 | |||
1399 | self.orm_wrapper.save_build_package_information( | ||
1400 | self.internal_state['build'], | ||
1401 | package_info, | ||
1402 | self.internal_state['recipes'], | ||
1403 | built_package=False) | ||
1331 | 1404 | ||
1332 | def _store_build_done(self, errorcode): | 1405 | def _store_build_done(self, errorcode): |
1333 | logger.info("Build exited with errorcode %d", errorcode) | 1406 | logger.info("Build exited with errorcode %d", errorcode) |