Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id DD57DE00FBC; Fri, 25 Sep 2015 11:08:25 -0700 (PDT) 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,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.212.176 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 0BD4DE00FFB for ; Fri, 25 Sep 2015 11:07:58 -0700 (PDT) Received: by wiclk2 with SMTP id lk2so29877266wic.1 for ; Fri, 25 Sep 2015 11:07:58 -0700 (PDT) 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=lPO3oEThORv/M9FcjcM1y31iuaBKij8oesIMBQxuEIo=; b=WE9lArYFdkESrNB6IatfbPvnruZJb6ulw3AUVr9gBPiYTFiuntoLY3MTgCrJ0Ydfim q64EjfkRVCPsjFQ7vZgi3CfkPNhben5EtvLMV2qqo0itFmZO3JUjntWBhaZVCCDuwcpa 7/3ivwuAN4U19b284ZaZhw8cjHaiaCdoWBXoxns0q3bgWPf2Htj3JzVyAtiIEBHmlQMb Mme/hvpGh1el6rYQ0HGmw+iqCiPKt/JJtY0I5CVu+8lGHcaaop6nvQyMOHTnIBhatW8a 8fFC60lWeRSyW29CpsDBNc6Pq+Qev9kiuJ4hnt4ToaAu61NilQuIlKV24eYoWeM8W75k ngLQ== X-Gm-Message-State: ALoCoQn2zhvfjKM85/Y4FpbjPI6KZNcJ7z7PdHH6g7WWmV2W6Vj9c1DDofuLjH2y/y6/Wcgybkyz X-Received: by 10.180.188.33 with SMTP id fx1mr5007314wic.31.1443204478411; Fri, 25 Sep 2015 11:07:58 -0700 (PDT) Received: from draco.isw.intel.com ([83.217.123.106]) by smtp.gmail.com with ESMTPSA id uq5sm4511789wjc.3.2015.09.25.11.07.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 Sep 2015 11:07:57 -0700 (PDT) From: Michael Wood To: toaster@yoctoproject.org Date: Fri, 25 Sep 2015 19:07:31 +0100 Message-Id: <1443204452-32244-21-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1443204452-32244-1-git-send-email-michael.g.wood@intel.com> References: <1443204452-32244-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 20/21] toaster: buildinfohelper Create a copy of the built layer and recipe 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: Fri, 25 Sep 2015 18:08:25 -0000 Create a copy of the built layer and the recipes associated with it. This is so that the user can view the historical information about a build. i.e. a snapshot of the layer version and artifacts produced at that build. Signed-off-by: Michael Wood --- bitbake/lib/bb/ui/buildinfohelper.py | 54 +++++++++++++++++++++++++++--------- bitbake/lib/toaster/orm/models.py | 2 +- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py index d0efaa9..e036ef6 100644 --- a/bitbake/lib/bb/ui/buildinfohelper.py +++ b/bitbake/lib/bb/ui/buildinfohelper.py @@ -66,6 +66,7 @@ class ORMWrapper(object): def __init__(self): self.layer_version_objects = [] + self.layer_version_built = [] self.task_objects = {} self.recipe_objects = {} @@ -254,32 +255,59 @@ class ORMWrapper(object): assert not recipe_information['file_path'].startswith("/") # we should have layer-relative paths at all times - recipe_object, created = self._cached_get_or_create(Recipe, layer_version=recipe_information['layer_version'], + + def update_recipe_obj(recipe_object): + object_changed = False + for v in vars(recipe_object): + if v in recipe_information.keys(): + object_changed = True + vars(recipe_object)[v] = recipe_information[v] + + if object_changed: + recipe_object.save() + + recipe, created = self._cached_get_or_create(Recipe, layer_version=recipe_information['layer_version'], file_path=recipe_information['file_path'], pathflags = recipe_information['pathflags']) - if created and must_exist: - raise NotExisting("Recipe object created when expected to exist", recipe_information) - object_changed = False - for v in vars(recipe_object): - if v in recipe_information.keys(): - object_changed = True - vars(recipe_object)[v] = recipe_information[v] + update_recipe_obj(recipe) - if object_changed: - recipe_object.save() + # Create a copy of the recipe for historical puposes and update it + for built_layer in self.layer_version_built: + if built_layer.layer == recipe_information['layer_version'].layer: + built_recipe, c = self._cached_get_or_create(Recipe, + layer_version=built_layer, + file_path=recipe_information['file_path'], + pathflags = recipe_information['pathflags']) + update_recipe_obj(built_recipe) + break - return recipe_object + + + if created and must_exist: + raise NotExisting("Recipe object created when expected to exist", recipe_information) + + return recipe def get_update_layer_version_object(self, build_obj, layer_obj, layer_version_information): if isinstance(layer_obj, Layer_Version): # We already found our layer version for this build so just # update it with the new build information logger.debug("We found our layer from toaster") - layer_obj.build = build_obj layer_obj.local_path = layer_version_information['local_path'] - layer_obj.commit = layer_version_information['commit'] layer_obj.save() self.layer_version_objects.append(layer_obj) + + # create a new copy of this layer version as a snapshot for + # historical purposes + layer_copy, c = Layer_Version.objects.get_or_create(build=build_obj, + layer=layer_obj.layer, + commit=layer_version_information['commit'], + local_path = layer_version_information['local_path'], + ) + logger.warning("created new historical layer version %d", layer_copy.pk) + + self.layer_version_built.append(layer_copy) + return layer_obj assert isinstance(build_obj, Build) diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index e0b31a9..9a052bf 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py @@ -194,7 +194,7 @@ class Project(models.Model): if release == None: release = self.release # layers on the same branch or layers specifically set for this project - queryset = Layer_Version.objects.filter((Q(up_branch__name = release.branch_name) & Q(project = None)) | Q(project = self) | Q(build__project = self)) + queryset = Layer_Version.objects.filter(((Q(up_branch__name = release.branch_name) & Q(project = None)) | Q(project = self)) & Q(build__isnull=True)) if layer_name is not None: # we select only a layer name -- 2.1.4