Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id D7F00E00BE0; Fri, 4 Nov 2016 09:42: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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham 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.54 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-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 8B0BCE00ACE for ; Fri, 4 Nov 2016 09:42:22 -0700 (PDT) Received: by mail-wm0-f54.google.com with SMTP id t79so61032383wmt.0 for ; Fri, 04 Nov 2016 09:42:21 -0700 (PDT) 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; bh=RN+qry0HHx0IjdaxG+y07zhyr5kLJNkV9ZlzTJaX3Uc=; b=Owc73FmLstCiqx+O/N5vqfosFcdjO2xF9uH15Op92QbqgAk/vxtIi01hf/4Z/jTmjg +trlaUVbyFYc7HCX/adRZfbVkYQkdWhRrsRkfv+swGaAMdiLTtsq78i/RvPBQQr2RMCe d732YNrkjICLduvFd1BOOZP+Qov2tTCahiUYNDH8HYs0sggXg0CA4BQR4es4oWnFHxjY AoLdXn7A5QdgjLjxl+aa/VIzaNVKhTko9NSEWdTB/U3lB2SfQK55VEIP8OSeJXFfodRc IeStD7SPd/celeseZziPUU6VxnjdLUl4I2+8i+HbUOJKgxZxwGjMZh99h1ENMOrSC8il 6q0w== 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; bh=RN+qry0HHx0IjdaxG+y07zhyr5kLJNkV9ZlzTJaX3Uc=; b=YNIgeg0FaV+cN+9x7qQY9EVTTZW8CLkV46YCzz5Px7WOYe+Fu+fBwoDQJLqGKpHDhS XvZQGYUmRUgYK5bmiQzhOdEMTtcajCR7VeKQqxCTRZ2bpw961jmoAgc8ZSUt9Knqwf6T BZKrk6deTMqXirHxZ7NwVDCxb+B1wzNnYEHPbWzIKMUTUNwR9JO8Kqzqh9mWZqTmG6+v ZXVAIywHAzRDHdQ9tE8mzn+mkRpUPN5yO988r3GfgfVgX35ML9bQPB41ZlBLpWNs3y43 Jxw9FXsQwIysfXF97pc70rWZAnzGBP1hGnNUx8lp+iwdp0sogwCe/2BvJDfIckh6jbRg XLvg== X-Gm-Message-State: ABUngvf7n12TouzSIp5RGYzYui2jIQ90dzg3lWpKCBylcJws6sYwJl1tUyjUQWFFldpVrD+W X-Received: by 10.28.62.141 with SMTP id l135mr4134797wma.121.1478277741052; Fri, 04 Nov 2016 09:42:21 -0700 (PDT) Received: from orion.home (host31-48-249-102.range31-48.btcentralplus.com. [31.48.249.102]) by smtp.gmail.com with ESMTPSA id ma5sm15100237wjb.47.2016.11.04.09.42.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Nov 2016 09:42:20 -0700 (PDT) From: Michael Wood To: toaster@yoctoproject.org Date: Fri, 4 Nov 2016 16:42:18 +0000 Message-Id: <1478277739-15869-1-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [PATCH 1/2] 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: Fri, 04 Nov 2016 16:42:25 -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