summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-02-05 11:59:17 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-10 13:29:22 +0000
commit8d5b61e495b1862ee775bc75ff4babb4a62cca6c (patch)
treeeef2bf55058779a0ff400fe800988097e2e2f582 /bitbake
parent86db0bd7f213c192214b4e3dc4d42b0374004fc6 (diff)
downloadpoky-8d5b61e495b1862ee775bc75ff4babb4a62cca6c.tar.gz
bitbake: toaster: models Add update_package_list for CustomImageRecipe
Add a method to update the packages included list from the last build, this effectively "synchronises" the package list from what we think will happen at the Customise image stage with what actually was produced with a build. It's not ideal to have this function here but we also need to make sure that no race condition of the user accessing this list and it being updated occurs. (Bitbake rev: 8cf6e67a955574b33856a082bdadf3194f2b6ba4) 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')
-rw-r--r--bitbake/lib/toaster/orm/models.py50
1 files changed, 48 insertions, 2 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index ee8f1f7166..5e715e302f 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -1455,11 +1455,57 @@ class CustomImageRecipe(Recipe):
1455 Q(build__project=self.project) & 1455 Q(build__project=self.project) &
1456 Q(target=self.name)).last() 1456 Q(target=self.name)).last()
1457 1457
1458 def update_package_list(self):
1459 """ Update the package list from the last good build of this
1460 CustomImageRecipe
1461 """
1462 # Check if we're aldready up-to-date or not
1463 target = self.get_last_successful_built_target()
1464 if target == None:
1465 # So we've never actually built this Custom recipe but what about
1466 # the recipe it's based on?
1467 target = \
1468 Target.objects.filter(Q(build__outcome=Build.SUCCEEDED) &
1469 Q(build__project=self.project) &
1470 Q(target=self.base_recipe.name)).last()
1471 if target == None:
1472 return
1473
1474 if target.build.completed_on == self.last_updated:
1475 return
1476
1477 self.includes_set.clear()
1478
1479 excludes_list = self.excludes_set.values_list('name', flat=True)
1480 appends_list = self.appends_set.values_list('name', flat=True)
1481
1482 built_packages_list = \
1483 target.target_installed_package_set.values_list('package__name',
1484 flat=True)
1485 for built_package in built_packages_list:
1486 # Is the built package in the custom packages list?
1487 if built_package in excludes_list:
1488 continue
1489
1490 if built_package in appends_list:
1491 continue
1492
1493 cust_img_p = \
1494 CustomImagePackage.objects.get(name=built_package)
1495 self.includes_set.add(cust_img_p)
1496
1497
1498 self.last_updated = target.build.completed_on
1499 self.save()
1500
1458 def get_all_packages(self): 1501 def get_all_packages(self):
1459 """Get the included packages and any appended packages""" 1502 """Get the included packages and any appended packages"""
1503 self.update_package_list()
1504
1460 return CustomImagePackage.objects.filter((Q(recipe_appends=self) | 1505 return CustomImagePackage.objects.filter((Q(recipe_appends=self) |
1461 Q(recipe_includes=self)) & 1506 Q(recipe_includes=self)) &
1462 ~Q(recipe_excludes=self)) 1507 ~Q(recipe_excludes=self))
1508
1463 1509
1464 def generate_recipe_file_contents(self): 1510 def generate_recipe_file_contents(self):
1465 """Generate the contents for the recipe file.""" 1511 """Generate the contents for the recipe file."""