diff options
author | Michael Wood <michael.g.wood@intel.com> | 2015-12-08 16:25:49 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-10 13:29:19 +0000 |
commit | a9668eeb743f02b78a1c5c50eac3454288b8d493 (patch) | |
tree | 4efbb321b577f1ec0425374b8fae6063af787e0d | |
parent | 439314c1b29f1bd835f91133fa3cda1305e70b70 (diff) | |
download | poky-a9668eeb743f02b78a1c5c50eac3454288b8d493.tar.gz |
bitbake: toaster: xhr_customrecipe_id change to use CustomImagePackage
Instead of doing a shallow copy of the package into the
CustomImageRecipe when we add packages we can now use the
CustomImagePackage as a M2M field on the Package to CustomImageRecipe.
Also switch to using Target_Installed_Package as the method to retrieve
the package list from the build.
(Bitbake rev: 4ebc81823b3aec6ecf38835acad5263a81eb41c5)
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>
-rwxr-xr-x | bitbake/lib/toaster/toastergui/views.py | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index b8f0c23de8..c7a782005b 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py | |||
@@ -30,7 +30,7 @@ from django.db import IntegrityError, Error | |||
30 | from django.shortcuts import render, redirect, get_object_or_404 | 30 | from django.shortcuts import render, redirect, get_object_or_404 |
31 | from orm.models import Build, Target, Task, Layer, Layer_Version, Recipe, LogMessage, Variable | 31 | from orm.models import Build, Target, Task, Layer, Layer_Version, Recipe, LogMessage, Variable |
32 | from orm.models import Task_Dependency, Recipe_Dependency, Package, Package_File, Package_Dependency | 32 | from orm.models import Task_Dependency, Recipe_Dependency, Package, Package_File, Package_Dependency |
33 | from orm.models import Target_Installed_Package, Target_File, Target_Image_File, BuildArtifact | 33 | from orm.models import Target_Installed_Package, Target_File, Target_Image_File, BuildArtifact, CustomImagePackage |
34 | from orm.models import BitbakeVersion, CustomImageRecipe | 34 | from orm.models import BitbakeVersion, CustomImageRecipe |
35 | from bldcontrol import bbcontroller | 35 | from bldcontrol import bbcontroller |
36 | from django.views.decorators.cache import cache_control | 36 | from django.views.decorators.cache import cache_control |
@@ -2411,32 +2411,36 @@ if True: | |||
2411 | return {"error": "Can't create custom recipe: %s" % err} | 2411 | return {"error": "Can't create custom recipe: %s" % err} |
2412 | 2412 | ||
2413 | # Find the package list from the last build of this recipe/target | 2413 | # Find the package list from the last build of this recipe/target |
2414 | build = Build.objects.filter(target__target=params['base'].name, | 2414 | target = Target.objects.filter(Q(build__outcome=Build.SUCCEEDED) & |
2415 | project=params['project']).last() | 2415 | Q(build__project=params['project']) & |
2416 | 2416 | (Q(target=params['base'].name) | | |
2417 | if build: | 2417 | Q(target=recipe.name))).last() |
2418 | if target: | ||
2418 | # Copy in every package | 2419 | # Copy in every package |
2419 | # We don't want these packages to be linked to anything because | 2420 | # We don't want these packages to be linked to anything because |
2420 | # that underlying data may change e.g. delete a build | 2421 | # that underlying data may change e.g. delete a build |
2421 | for package in build.package_set.all(): | 2422 | for tpackage in target.target_installed_package_set.all(): |
2422 | _copy_packge_to_recipe(recipe, package) | 2423 | try: |
2423 | else: | 2424 | built_package = tpackage.package |
2424 | logger.debug("No packages found for this base recipe") | 2425 | # The package had no recipe information so is a ghost |
2426 | # package skip it | ||
2427 | if built_package.recipe == None: | ||
2428 | continue; | ||
2429 | |||
2430 | config_package = CustomImagePackage.objects.get( | ||
2431 | name=built_package.name) | ||
2432 | |||
2433 | recipe.includes_set.add(config_package) | ||
2434 | except Exception as e: | ||
2435 | logger.warning("Error adding package %s %s" % | ||
2436 | (tpackage.package.name, e)) | ||
2437 | pass | ||
2425 | 2438 | ||
2426 | return {"error": "ok", | 2439 | return {"error": "ok", |
2440 | "packages" : recipe.get_all_packages().count(), | ||
2427 | "url": reverse('customrecipe', args=(params['project'].pk, | 2441 | "url": reverse('customrecipe', args=(params['project'].pk, |
2428 | recipe.id))} | 2442 | recipe.id))} |
2429 | 2443 | ||
2430 | def _copy_packge_to_recipe(recipe, package): | ||
2431 | """ copy a package from another recipe """ | ||
2432 | package.pk = None | ||
2433 | package.save() | ||
2434 | # Disassociate the package from the build | ||
2435 | package.build = None | ||
2436 | package.recipe = recipe | ||
2437 | package.save() | ||
2438 | return package | ||
2439 | |||
2440 | @xhr_response | 2444 | @xhr_response |
2441 | def xhr_customrecipe_id(request, recipe_id): | 2445 | def xhr_customrecipe_id(request, recipe_id): |
2442 | """ | 2446 | """ |