Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 1C26CE00BE2; Tue, 8 Dec 2015 13:18:08 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [209.85.192.177 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Received: from mail-pf0-f177.google.com (mail-pf0-f177.google.com [209.85.192.177]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 1473CE00BFD for ; Tue, 8 Dec 2015 13:17:53 -0800 (PST) Received: by pfu207 with SMTP id 207so17960718pfu.2 for ; Tue, 08 Dec 2015 13:17:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OwQtIB4P0odkbCgRdwwIiiIcxmNYe9zo4ohongIEUbg=; b=bqrXroJMXJxCQRXKRvHHYiO55mMp4XsnZ0y5jFqhQFW8Y/FdxhFYrm4CGBNyA5kTpr C+ptgTiqFtr57yqnIoCXtAcNeQZEV32uFnlRjtGJy0jF5NmYHEvlOOOkPPLp3Y11MM5o HjMiaBwCIIlYBY7w+hGfhfmEmtQiWH1IzgLQbuUvzSfp4BiiPXcHmiCB1aLYDy1c41px Qhnt95sLVamZCTT9wUcBHyhhqw+p5BROExJHRXeBrbEOnnaKypesKsUDKUd/JzUwJzkC vhIF5NH9b42UzjKGikpShl97hqvBxLvGMybqTok0FX7gvsIz40hXwhZ2hX/9YnKVDi3U lb0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OwQtIB4P0odkbCgRdwwIiiIcxmNYe9zo4ohongIEUbg=; b=Ymyjfvy4QpQ00XQoOGIr0Nsh+WoKxl2zP74142Vkwbv0/PZtsPwyNgtOE/R36VbQ0g qYezSy8M65dyfG7QR6YHOCKJtNkjuxltyvsd0BJZjXsYHCCCCrhuEw7Cg5F63aN3eTLU YX0Xe8e0qswFaxTkXsBF5ddhsRY5XSxPI91dmJVyS+9QlIr8Xz0KTgA7yHdrJveNxUZY vzes0dH+W+roa0fmpNyZQz76vamCDxleIVwrbRQB0otamQ7jerfXKMXIW8Og5Qlf8MWX wmQ0G+iJEc+6td74J9VefFhlPXxKdq7aUbeksXHO5hjOLRl+5zDuhyPhcn03QpmGPZLl Ww1Q== X-Gm-Message-State: ALoCoQlMMWHajJPSr+Out1zUQnlOelYkTSJFRsMuiQAZgFn/sOJJ70KKKp5vZ9O0wNoIg0PMPkqbiZqI7/BymEOlHPq0n8p9YA== X-Received: by 10.98.69.157 with SMTP id n29mr7955061pfi.36.1449609472960; Tue, 08 Dec 2015 13:17:52 -0800 (PST) Received: from draco.ger.corp.intel.com ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id v64sm6675766pfi.50.2015.12.08.13.17.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Dec 2015 13:17:51 -0800 (PST) From: Michael Wood To: toaster@yoctoproject.org Date: Tue, 8 Dec 2015 21:16:15 +0000 Message-Id: <1449609380-11073-30-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1449609380-11073-1-git-send-email-michael.g.wood@intel.com> References: <1449609380-11073-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 29/34] toaster: xhr_customrecipe_id change to use ProjectPackage X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Dec 2015 21:18:08 -0000 Instead of doing a shallow copy of the package into the CustomImageRecipe when we add packages we can now use the ProjectPackage 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. Signed-off-by: Michael Wood --- bitbake/lib/toaster/toastergui/views.py | 54 ++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index 270229f..50d5afe 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 from django.shortcuts import render, redirect, get_object_or_404 from orm.models import Build, Target, Task, Layer, Layer_Version, Recipe, LogMessage, Variable from orm.models import Task_Dependency, Recipe_Dependency, Package, Package_File, Package_Dependency -from orm.models import Target_Installed_Package, Target_File, Target_Image_File, BuildArtifact +from orm.models import Target_Installed_Package, Target_File, Target_Image_File, BuildArtifact, ProjectPackage from orm.models import BitbakeVersion, CustomImageRecipe from bldcontrol import bbcontroller from django.views.decorators.cache import cache_control @@ -2698,31 +2698,49 @@ if True: return {"error": "Can't create custom recipe: %s" % err} # Find the package list from the last build of this recipe/target - build = Build.objects.filter(target__target=params['base'].name, - project=params['project']).last() - - if build: + target = Target.objects.filter(Q(build__outcome=Build.SUCCEEDED) & + Q(build__project=params['project']) & + (Q(target=params['base'].name) | + Q(target=recipe.name))).last() + if target: # Copy in every package # We don't want these packages to be linked to anything because # that underlying data may change e.g. delete a build - for package in build.package_set.all(): - _copy_packge_to_recipe(recipe, package) - else: - logger.debug("No packages found for this base recipe") + for tpackage in target.target_installed_package_set.all(): + try: + built_package = tpackage.package + # The package had no recipe information so is a ghost + # package skip it + if built_package.recipe == None: + continue; + + config_package = ProjectPackage.objects.get( + name=built_package.name, + version=built_package.version, + project=params['project']) + + recipe.includes_set.add(config_package) + except Exception as e: + logger.warning("Error adding package %s %s" % + (tpackage.package.name, e)) + pass return {"error": "ok", + "packages" : recipe.get_all_packages().count(), "url": reverse('customrecipe', args=(params['project'].pk, recipe.id))} - def _copy_packge_to_recipe(recipe, package): - """ copy a package from another recipe """ - package.pk = None - package.save() - # Disassociate the package from the build - package.build = None - package.recipe = recipe - package.save() - return package + def _get_config_packge(built_package, project): + """ Find a package from the project configuration data based on a built + package (i.e. one produced from a build) + """ + if built_package.recipe == None: + raise Exception("The package had no recipe information so it has " + "been skipped as it appears to be a ghost package") + # Find the package from the configuration data + return ProjectPackage.objects.get(name=built_package.name, + version=built_package.version, + project=project) @xhr_response def xhr_customrecipe_id(request, recipe_id): -- 2.1.4