diff options
Diffstat (limited to 'bitbake/lib/bb/ui/buildinfohelper.py')
| -rw-r--r-- | bitbake/lib/bb/ui/buildinfohelper.py | 101 |
1 files changed, 47 insertions, 54 deletions
diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py index 43aa592842..4ee45d67a2 100644 --- a/bitbake/lib/bb/ui/buildinfohelper.py +++ b/bitbake/lib/bb/ui/buildinfohelper.py | |||
| @@ -45,7 +45,7 @@ from pprint import pformat | |||
| 45 | import logging | 45 | import logging |
| 46 | from datetime import datetime, timedelta | 46 | from datetime import datetime, timedelta |
| 47 | 47 | ||
| 48 | from django.db import transaction, connection | 48 | from django.db import transaction |
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | # pylint: disable=invalid-name | 51 | # pylint: disable=invalid-name |
| @@ -227,6 +227,12 @@ class ORMWrapper(object): | |||
| 227 | build.completed_on = timezone.now() | 227 | build.completed_on = timezone.now() |
| 228 | build.outcome = outcome | 228 | build.outcome = outcome |
| 229 | build.save() | 229 | build.save() |
| 230 | |||
| 231 | # We force a sync point here to force the outcome status commit, | ||
| 232 | # which resolves a race condition with the build completion takedown | ||
| 233 | transaction.set_autocommit(True) | ||
| 234 | transaction.set_autocommit(False) | ||
| 235 | |||
| 230 | signal_runbuilds() | 236 | signal_runbuilds() |
| 231 | 237 | ||
| 232 | def update_target_set_license_manifest(self, target, license_manifest_path): | 238 | def update_target_set_license_manifest(self, target, license_manifest_path): |
| @@ -483,14 +489,14 @@ class ORMWrapper(object): | |||
| 483 | 489 | ||
| 484 | # we already created the root directory, so ignore any | 490 | # we already created the root directory, so ignore any |
| 485 | # entry for it | 491 | # entry for it |
| 486 | if len(path) == 0: | 492 | if not path: |
| 487 | continue | 493 | continue |
| 488 | 494 | ||
| 489 | parent_path = "/".join(path.split("/")[:len(path.split("/")) - 1]) | 495 | parent_path = "/".join(path.split("/")[:len(path.split("/")) - 1]) |
| 490 | if len(parent_path) == 0: | 496 | if not parent_path: |
| 491 | parent_path = "/" | 497 | parent_path = "/" |
| 492 | parent_obj = self._cached_get(Target_File, target = target_obj, path = parent_path, inodetype = Target_File.ITYPE_DIRECTORY) | 498 | parent_obj = self._cached_get(Target_File, target = target_obj, path = parent_path, inodetype = Target_File.ITYPE_DIRECTORY) |
| 493 | tf_obj = Target_File.objects.create( | 499 | Target_File.objects.create( |
| 494 | target = target_obj, | 500 | target = target_obj, |
| 495 | path = path, | 501 | path = path, |
| 496 | size = size, | 502 | size = size, |
| @@ -553,9 +559,12 @@ class ORMWrapper(object): | |||
| 553 | # we might have an invalid link; no way to detect this. just set it to None | 559 | # we might have an invalid link; no way to detect this. just set it to None |
| 554 | filetarget_obj = None | 560 | filetarget_obj = None |
| 555 | 561 | ||
| 556 | parent_obj = Target_File.objects.get(target = target_obj, path = parent_path, inodetype = Target_File.ITYPE_DIRECTORY) | 562 | try: |
| 563 | parent_obj = Target_File.objects.get(target = target_obj, path = parent_path, inodetype = Target_File.ITYPE_DIRECTORY) | ||
| 564 | except Target_File.DoesNotExist: | ||
| 565 | parent_obj = None | ||
| 557 | 566 | ||
| 558 | tf_obj = Target_File.objects.create( | 567 | Target_File.objects.create( |
| 559 | target = target_obj, | 568 | target = target_obj, |
| 560 | path = path, | 569 | path = path, |
| 561 | size = size, | 570 | size = size, |
| @@ -571,7 +580,7 @@ class ORMWrapper(object): | |||
| 571 | assert isinstance(build_obj, Build) | 580 | assert isinstance(build_obj, Build) |
| 572 | assert isinstance(target_obj, Target) | 581 | assert isinstance(target_obj, Target) |
| 573 | 582 | ||
| 574 | errormsg = "" | 583 | errormsg = [] |
| 575 | for p in packagedict: | 584 | for p in packagedict: |
| 576 | # Search name swtiches round the installed name vs package name | 585 | # Search name swtiches round the installed name vs package name |
| 577 | # by default installed name == package name | 586 | # by default installed name == package name |
| @@ -633,10 +642,10 @@ class ORMWrapper(object): | |||
| 633 | packagefile_objects.append(Package_File( package = packagedict[p]['object'], | 642 | packagefile_objects.append(Package_File( package = packagedict[p]['object'], |
| 634 | path = targetpath, | 643 | path = targetpath, |
| 635 | size = targetfilesize)) | 644 | size = targetfilesize)) |
| 636 | if len(packagefile_objects): | 645 | if packagefile_objects: |
| 637 | Package_File.objects.bulk_create(packagefile_objects) | 646 | Package_File.objects.bulk_create(packagefile_objects) |
| 638 | except KeyError as e: | 647 | except KeyError as e: |
| 639 | errormsg += " stpi: Key error, package %s key %s \n" % ( p, e ) | 648 | errormsg.append(" stpi: Key error, package %s key %s \n" % (p, e)) |
| 640 | 649 | ||
| 641 | # save disk installed size | 650 | # save disk installed size |
| 642 | packagedict[p]['object'].installed_size = packagedict[p]['size'] | 651 | packagedict[p]['object'].installed_size = packagedict[p]['size'] |
| @@ -673,13 +682,13 @@ class ORMWrapper(object): | |||
| 673 | logger.warning("Could not add dependency to the package %s " | 682 | logger.warning("Could not add dependency to the package %s " |
| 674 | "because %s is an unknown package", p, px) | 683 | "because %s is an unknown package", p, px) |
| 675 | 684 | ||
| 676 | if len(packagedeps_objs) > 0: | 685 | if packagedeps_objs: |
| 677 | Package_Dependency.objects.bulk_create(packagedeps_objs) | 686 | Package_Dependency.objects.bulk_create(packagedeps_objs) |
| 678 | else: | 687 | else: |
| 679 | logger.info("No package dependencies created") | 688 | logger.info("No package dependencies created") |
| 680 | 689 | ||
| 681 | if len(errormsg) > 0: | 690 | if errormsg: |
| 682 | logger.warning("buildinfohelper: target_package_info could not identify recipes: \n%s", errormsg) | 691 | logger.warning("buildinfohelper: target_package_info could not identify recipes: \n%s", "".join(errormsg)) |
| 683 | 692 | ||
| 684 | def save_target_image_file_information(self, target_obj, file_name, file_size): | 693 | def save_target_image_file_information(self, target_obj, file_name, file_size): |
| 685 | Target_Image_File.objects.create(target=target_obj, | 694 | Target_Image_File.objects.create(target=target_obj, |
| @@ -767,7 +776,7 @@ class ORMWrapper(object): | |||
| 767 | packagefile_objects.append(Package_File( package = bp_object, | 776 | packagefile_objects.append(Package_File( package = bp_object, |
| 768 | path = path, | 777 | path = path, |
| 769 | size = package_info['FILES_INFO'][path] )) | 778 | size = package_info['FILES_INFO'][path] )) |
| 770 | if len(packagefile_objects): | 779 | if packagefile_objects: |
| 771 | Package_File.objects.bulk_create(packagefile_objects) | 780 | Package_File.objects.bulk_create(packagefile_objects) |
| 772 | 781 | ||
| 773 | def _po_byname(p): | 782 | def _po_byname(p): |
| @@ -809,7 +818,7 @@ class ORMWrapper(object): | |||
| 809 | packagedeps_objs.append(Package_Dependency( package = bp_object, | 818 | packagedeps_objs.append(Package_Dependency( package = bp_object, |
| 810 | depends_on = _po_byname(p), dep_type = Package_Dependency.TYPE_RCONFLICTS)) | 819 | depends_on = _po_byname(p), dep_type = Package_Dependency.TYPE_RCONFLICTS)) |
| 811 | 820 | ||
| 812 | if len(packagedeps_objs) > 0: | 821 | if packagedeps_objs: |
| 813 | Package_Dependency.objects.bulk_create(packagedeps_objs) | 822 | Package_Dependency.objects.bulk_create(packagedeps_objs) |
| 814 | 823 | ||
| 815 | return bp_object | 824 | return bp_object |
| @@ -826,7 +835,7 @@ class ORMWrapper(object): | |||
| 826 | desc = vardump[root_var]['doc'] | 835 | desc = vardump[root_var]['doc'] |
| 827 | if desc is None: | 836 | if desc is None: |
| 828 | desc = '' | 837 | desc = '' |
| 829 | if len(desc): | 838 | if desc: |
| 830 | HelpText.objects.get_or_create(build=build_obj, | 839 | HelpText.objects.get_or_create(build=build_obj, |
| 831 | area=HelpText.VARIABLE, | 840 | area=HelpText.VARIABLE, |
| 832 | key=k, text=desc) | 841 | key=k, text=desc) |
| @@ -846,7 +855,7 @@ class ORMWrapper(object): | |||
| 846 | file_name = vh['file'], | 855 | file_name = vh['file'], |
| 847 | line_number = vh['line'], | 856 | line_number = vh['line'], |
| 848 | operation = vh['op'])) | 857 | operation = vh['op'])) |
| 849 | if len(varhist_objects): | 858 | if varhist_objects: |
| 850 | VariableHistory.objects.bulk_create(varhist_objects) | 859 | VariableHistory.objects.bulk_create(varhist_objects) |
| 851 | 860 | ||
| 852 | 861 | ||
| @@ -893,9 +902,6 @@ class BuildInfoHelper(object): | |||
| 893 | self.task_order = 0 | 902 | self.task_order = 0 |
| 894 | self.autocommit_step = 1 | 903 | self.autocommit_step = 1 |
| 895 | self.server = server | 904 | self.server = server |
| 896 | # we use manual transactions if the database doesn't autocommit on us | ||
| 897 | if not connection.features.autocommits_when_autocommit_is_off: | ||
| 898 | transaction.set_autocommit(False) | ||
| 899 | self.orm_wrapper = ORMWrapper() | 905 | self.orm_wrapper = ORMWrapper() |
| 900 | self.has_build_history = has_build_history | 906 | self.has_build_history = has_build_history |
| 901 | self.tmp_dir = self.server.runCommand(["getVariable", "TMPDIR"])[0] | 907 | self.tmp_dir = self.server.runCommand(["getVariable", "TMPDIR"])[0] |
| @@ -1059,27 +1065,6 @@ class BuildInfoHelper(object): | |||
| 1059 | 1065 | ||
| 1060 | return recipe_info | 1066 | return recipe_info |
| 1061 | 1067 | ||
| 1062 | def _get_path_information(self, task_object): | ||
| 1063 | self._ensure_build() | ||
| 1064 | |||
| 1065 | assert isinstance(task_object, Task) | ||
| 1066 | build_stats_format = "{tmpdir}/buildstats/{buildname}/{package}/" | ||
| 1067 | build_stats_path = [] | ||
| 1068 | |||
| 1069 | for t in self.internal_state['targets']: | ||
| 1070 | buildname = self.internal_state['build'].build_name | ||
| 1071 | pe, pv = task_object.recipe.version.split(":",1) | ||
| 1072 | if len(pe) > 0: | ||
| 1073 | package = task_object.recipe.name + "-" + pe + "_" + pv | ||
| 1074 | else: | ||
| 1075 | package = task_object.recipe.name + "-" + pv | ||
| 1076 | |||
| 1077 | build_stats_path.append(build_stats_format.format(tmpdir=self.tmp_dir, | ||
| 1078 | buildname=buildname, | ||
| 1079 | package=package)) | ||
| 1080 | |||
| 1081 | return build_stats_path | ||
| 1082 | |||
| 1083 | 1068 | ||
| 1084 | ################################ | 1069 | ################################ |
| 1085 | ## external available methods to store information | 1070 | ## external available methods to store information |
| @@ -1313,12 +1298,11 @@ class BuildInfoHelper(object): | |||
| 1313 | task_information['outcome'] = Task.OUTCOME_FAILED | 1298 | task_information['outcome'] = Task.OUTCOME_FAILED |
| 1314 | del self.internal_state['taskdata'][identifier] | 1299 | del self.internal_state['taskdata'][identifier] |
| 1315 | 1300 | ||
| 1316 | if not connection.features.autocommits_when_autocommit_is_off: | 1301 | # we force a sync point here, to get the progress bar to show |
| 1317 | # we force a sync point here, to get the progress bar to show | 1302 | if self.autocommit_step % 3 == 0: |
| 1318 | if self.autocommit_step % 3 == 0: | 1303 | transaction.set_autocommit(True) |
| 1319 | transaction.set_autocommit(True) | 1304 | transaction.set_autocommit(False) |
| 1320 | transaction.set_autocommit(False) | 1305 | self.autocommit_step += 1 |
| 1321 | self.autocommit_step += 1 | ||
| 1322 | 1306 | ||
| 1323 | self.orm_wrapper.get_update_task_object(task_information, True) # must exist | 1307 | self.orm_wrapper.get_update_task_object(task_information, True) # must exist |
| 1324 | 1308 | ||
| @@ -1404,7 +1388,7 @@ class BuildInfoHelper(object): | |||
| 1404 | assert 'pn' in event._depgraph | 1388 | assert 'pn' in event._depgraph |
| 1405 | assert 'tdepends' in event._depgraph | 1389 | assert 'tdepends' in event._depgraph |
| 1406 | 1390 | ||
| 1407 | errormsg = "" | 1391 | errormsg = [] |
| 1408 | 1392 | ||
| 1409 | # save layer version priorities | 1393 | # save layer version priorities |
| 1410 | if 'layer-priorities' in event._depgraph.keys(): | 1394 | if 'layer-priorities' in event._depgraph.keys(): |
| @@ -1496,7 +1480,7 @@ class BuildInfoHelper(object): | |||
| 1496 | elif dep in self.internal_state['recipes']: | 1480 | elif dep in self.internal_state['recipes']: |
| 1497 | dependency = self.internal_state['recipes'][dep] | 1481 | dependency = self.internal_state['recipes'][dep] |
| 1498 | else: | 1482 | else: |
| 1499 | errormsg += " stpd: KeyError saving recipe dependency for %s, %s \n" % (recipe, dep) | 1483 | errormsg.append(" stpd: KeyError saving recipe dependency for %s, %s \n" % (recipe, dep)) |
| 1500 | continue | 1484 | continue |
| 1501 | recipe_dep = Recipe_Dependency(recipe=target, | 1485 | recipe_dep = Recipe_Dependency(recipe=target, |
| 1502 | depends_on=dependency, | 1486 | depends_on=dependency, |
| @@ -1537,8 +1521,8 @@ class BuildInfoHelper(object): | |||
| 1537 | taskdeps_objects.append(Task_Dependency( task = target, depends_on = dep )) | 1521 | taskdeps_objects.append(Task_Dependency( task = target, depends_on = dep )) |
| 1538 | Task_Dependency.objects.bulk_create(taskdeps_objects) | 1522 | Task_Dependency.objects.bulk_create(taskdeps_objects) |
| 1539 | 1523 | ||
| 1540 | if len(errormsg) > 0: | 1524 | if errormsg: |
| 1541 | logger.warning("buildinfohelper: dependency info not identify recipes: \n%s", errormsg) | 1525 | logger.warning("buildinfohelper: dependency info not identify recipes: \n%s", "".join(errormsg)) |
| 1542 | 1526 | ||
| 1543 | 1527 | ||
| 1544 | def store_build_package_information(self, event): | 1528 | def store_build_package_information(self, event): |
| @@ -1618,7 +1602,7 @@ class BuildInfoHelper(object): | |||
| 1618 | 1602 | ||
| 1619 | if 'backlog' in self.internal_state: | 1603 | if 'backlog' in self.internal_state: |
| 1620 | # if we have a backlog of events, do our best to save them here | 1604 | # if we have a backlog of events, do our best to save them here |
| 1621 | if len(self.internal_state['backlog']): | 1605 | if self.internal_state['backlog']: |
| 1622 | tempevent = self.internal_state['backlog'].pop() | 1606 | tempevent = self.internal_state['backlog'].pop() |
| 1623 | logger.debug("buildinfohelper: Saving stored event %s " | 1607 | logger.debug("buildinfohelper: Saving stored event %s " |
| 1624 | % tempevent) | 1608 | % tempevent) |
| @@ -1765,7 +1749,6 @@ class BuildInfoHelper(object): | |||
| 1765 | 1749 | ||
| 1766 | buildname = self.server.runCommand(['getVariable', 'BUILDNAME'])[0] | 1750 | buildname = self.server.runCommand(['getVariable', 'BUILDNAME'])[0] |
| 1767 | machine = self.server.runCommand(['getVariable', 'MACHINE'])[0] | 1751 | machine = self.server.runCommand(['getVariable', 'MACHINE'])[0] |
| 1768 | image_name = self.server.runCommand(['getVariable', 'IMAGE_NAME'])[0] | ||
| 1769 | 1752 | ||
| 1770 | # location of the manifest files for this build; | 1753 | # location of the manifest files for this build; |
| 1771 | # note that this file is only produced if an image is produced | 1754 | # note that this file is only produced if an image is produced |
| @@ -1786,6 +1769,18 @@ class BuildInfoHelper(object): | |||
| 1786 | # filter out anything which isn't an image target | 1769 | # filter out anything which isn't an image target |
| 1787 | image_targets = [target for target in targets if target.is_image] | 1770 | image_targets = [target for target in targets if target.is_image] |
| 1788 | 1771 | ||
| 1772 | if len(image_targets) > 0: | ||
| 1773 | #if there are image targets retrieve image_name | ||
| 1774 | image_name = self.server.runCommand(['getVariable', 'IMAGE_NAME'])[0] | ||
| 1775 | if not image_name: | ||
| 1776 | #When build target is an image and image_name is not found as an environment variable | ||
| 1777 | logger.info("IMAGE_NAME not found, extracting from bitbake command") | ||
| 1778 | cmd = self.server.runCommand(['getVariable','BB_CMDLINE'])[0] | ||
| 1779 | #filter out tokens that are command line options | ||
| 1780 | cmd = [token for token in cmd if not token.startswith('-')] | ||
| 1781 | image_name = cmd[1].split(':', 1)[0] # remove everything after : in image name | ||
| 1782 | logger.info("IMAGE_NAME found as : %s " % image_name) | ||
| 1783 | |||
| 1789 | for image_target in image_targets: | 1784 | for image_target in image_targets: |
| 1790 | # this is set to True if we find at least one file relating to | 1785 | # this is set to True if we find at least one file relating to |
| 1791 | # this target; if this remains False after the scan, we copy the | 1786 | # this target; if this remains False after the scan, we copy the |
| @@ -1990,8 +1985,6 @@ class BuildInfoHelper(object): | |||
| 1990 | # Do not skip command line build events | 1985 | # Do not skip command line build events |
| 1991 | self.store_log_event(tempevent,False) | 1986 | self.store_log_event(tempevent,False) |
| 1992 | 1987 | ||
| 1993 | if not connection.features.autocommits_when_autocommit_is_off: | ||
| 1994 | transaction.set_autocommit(True) | ||
| 1995 | 1988 | ||
| 1996 | # unset the brbe; this is to prevent subsequent command-line builds | 1989 | # unset the brbe; this is to prevent subsequent command-line builds |
| 1997 | # being incorrectly attached to the previous Toaster-triggered build; | 1990 | # being incorrectly attached to the previous Toaster-triggered build; |
