Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id BAED5E00A30; Tue, 8 Nov 2016 03:33:52 -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=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 X-Spam-HAM-Report: * -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no * trust * [74.125.82.44 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 * 0.5 RCVD_IN_SORBS_SPAM RBL: SORBS: sender is a spam source * [74.125.82.44 listed in dnsbl.sorbs.net] Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 58D19E007A2 for ; Tue, 8 Nov 2016 03:33:48 -0800 (PST) Received: by mail-wm0-f44.google.com with SMTP id t79so233136538wmt.0 for ; Tue, 08 Nov 2016 03:33:48 -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=RN+qry0HHx0IjdaxG+y07zhyr5kLJNkV9ZlzTJaX3Uc=; b=MUO1bMxrTy+N0d75tNvtk3c9Kb7Iy7/ztgkhzjVz/dwIwonTsWQ4YX96iEqiM33Ai4 RolRYKZl0dZ2NWkuZ+e5ZYwo4m/5mu0X2yl0COJ3c35xJ8J6HiqRkbIgb8XVC1K2i8Ny b/8v2yZMDESl6xZepaupc/23DwB2VVX3xRVHlCWugQcRA04UnEPR38e2zTfkUDfv0/e0 4cz+rEEx/bmStBrlevgMXh//Zf7X03KMdjwOjdvAB/+Ey/sYGKFCvwwvnEFdSaYjR/fb DkFEyYrix+vWCs7HAyM22YUmEtTnnMVyyvqGvX1pB5FDc+3ndEBaJPnuyPam0XPXIr3z 50tA== 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=RN+qry0HHx0IjdaxG+y07zhyr5kLJNkV9ZlzTJaX3Uc=; b=e8/HP5X8f/tIXBEsqYyzLzc3qpecb6Q1hYEVLc9YvSmLoNrt50hXBMpSiZROtIC5TV BOdZNnPHJ4/ciIaFu4rHFC4I7Z4+FAZ9BuTxKog09zugfbGiZ+S0gKnfsO3229SpTVYd DSIpCUckkbLalL5uI7uQzEMv2Ui41hWtt6SjM/SAU+KoK9sJuBOU7Vd7XFmkC5AX7IdD OzOtMLXK41CO8XMigmTxdINUt+lPB/XdvuQ8xt9xciCOJ+q2iqJZeMb4xSKjzEbTI64b WsGQ7JKA7Qj94Tr5z0AcBAeyJ2dxRo/+olrmIEnW/V38q3WAgNaudrCdPW0EvlJMsGtt GVWw== X-Gm-Message-State: ABUngvf+Hy2fbUCSAm21Xg6BFNHWq1gtt6pDbEbeZQVEj0xJMcNyyTdo7pYwS1lmKCljYniv X-Received: by 10.194.202.195 with SMTP id kk3mr9736738wjc.37.1478604827704; Tue, 08 Nov 2016 03:33:47 -0800 (PST) Received: from orion.home (host31-48-249-102.range31-48.btcentralplus.com. [31.48.249.102]) by smtp.gmail.com with ESMTPSA id u81sm476744wmu.21.2016.11.08.03.33.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Nov 2016 03:33:46 -0800 (PST) From: Michael Wood To: toaster@yoctoproject.org Date: Tue, 8 Nov 2016 11:33:38 +0000 Message-Id: <1478604820-6239-1-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: Subject: [PATCH v2 1/3] toaster: layerindex updater Take into account layers being predefined 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 Nov 2016 11:33:52 -0000 As we can now provide layer definitions through fixtures we need to be more clever how we update the metadata in the database to avoid duplicate metadata being created. To do this we make more effort to match existing data in the database and update only the fields which will be better provided by the layer index. This removes the need for us to special case layers which are provided as part of poky such as openembedded-core or meta-poky which exist on the layerindex but with different git urls. Signed-off-by: Michael Wood --- .../toaster/orm/management/commands/lsupdates.py | 60 +++++++--------------- 1 file changed, 19 insertions(+), 41 deletions(-) diff --git a/bitbake/lib/toaster/orm/management/commands/lsupdates.py b/bitbake/lib/toaster/orm/management/commands/lsupdates.py index 8ff120e..688918e 100644 --- a/bitbake/lib/toaster/orm/management/commands/lsupdates.py +++ b/bitbake/lib/toaster/orm/management/commands/lsupdates.py @@ -154,41 +154,17 @@ class Command(NoArgsCommand): total = len(layers_info) for i, li in enumerate(layers_info): - # Special case for the openembedded-core layer - if li['name'] == oe_core_layer: - try: - # If we have an existing openembedded-core for example - # from the toasterconf.json augment the info using the - # layerindex rather than duplicate it - oe_core_l = Layer.objects.get(name=oe_core_layer) - # Take ownership of the layer as now coming from the - # layerindex - oe_core_l.summary = li['summary'] - oe_core_l.description = li['description'] - oe_core_l.vcs_web_url = li['vcs_web_url'] - oe_core_l.vcs_web_tree_base_url = \ - li['vcs_web_tree_base_url'] - oe_core_l.vcs_web_file_base_url = \ - li['vcs_web_file_base_url'] - - oe_core_l.save() - li_layer_id_to_toaster_layer_id[li['id']] = oe_core_l.pk - self.mini_progress("layers", i, total) - continue - - except Layer.DoesNotExist: - pass - try: - l, created = Layer.objects.get_or_create(name=li['name'], - vcs_url=li['vcs_url']) + l, created = Layer.objects.get_or_create(name=li['name']) l.up_date = li['updated'] - l.vcs_url = li['vcs_url'] - l.vcs_web_url = li['vcs_web_url'] - l.vcs_web_tree_base_url = li['vcs_web_tree_base_url'] - l.vcs_web_file_base_url = li['vcs_web_file_base_url'] l.summary = li['summary'] l.description = li['description'] + + if created: + l.vcs_url = li['vcs_url'] + l.vcs_web_url = li['vcs_web_url'] + l.vcs_web_tree_base_url = li['vcs_web_tree_base_url'] + l.vcs_web_file_base_url = li['vcs_web_file_base_url'] l.save() except Layer.MultipleObjectsReturned: logger.info("Skipped %s as we found multiple layers and " @@ -211,12 +187,14 @@ class Command(NoArgsCommand): total = len(layerbranches_info) for i, lbi in enumerate(layerbranches_info): + # release as defined by toaster map to layerindex branch + release = li_branch_id_to_toaster_release[lbi['branch']] try: lv, created = Layer_Version.objects.get_or_create( - layer_source=LayerSource.TYPE_LAYERINDEX, layer=Layer.objects.get( - pk=li_layer_id_to_toaster_layer_id[lbi['layer']]) + pk=li_layer_id_to_toaster_layer_id[lbi['layer']]), + release=release ) except KeyError: logger.warning( @@ -224,11 +202,12 @@ class Command(NoArgsCommand): lbi['layer']) continue - lv.release = li_branch_id_to_toaster_release[lbi['branch']] - lv.up_date = lbi['updated'] - lv.commit = lbi['actual_branch'] - lv.dirpath = lbi['vcs_subdir'] - lv.save() + if created: + lv.release = li_branch_id_to_toaster_release[lbi['branch']] + lv.up_date = lbi['updated'] + lv.commit = lbi['actual_branch'] + lv.dirpath = lbi['vcs_subdir'] + lv.save() li_layer_branch_id_to_toaster_lv_id[lbi['id']] =\ lv.pk @@ -255,9 +234,8 @@ class Command(NoArgsCommand): layer_id = li_layer_id_to_toaster_layer_id[ldi['dependency']] dependlist[lv].append( - Layer_Version.objects.get( - layer_source=LayerSource.TYPE_LAYERINDEX, - layer__pk=layer_id)) + Layer_Version.objects.get(layer__pk=layer_id, + release=lv.release)) except Layer_Version.DoesNotExist: logger.warning("Cannot find layer version (ls:%s)," -- 2.7.4