Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 20988E00951; Wed, 20 Jul 2016 06:48:35 -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,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 * [74.125.82.52 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-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id B70E6E009C3 for ; Wed, 20 Jul 2016 06:48:28 -0700 (PDT) Received: by mail-wm0-f52.google.com with SMTP id o80so70041220wme.1 for ; Wed, 20 Jul 2016 06:48:28 -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:in-reply-to:references; bh=jIzuukZ4u0A78EOKwYXuG89mPV7n0nHSsSzJ5PUaofw=; b=YbbsNcTabPrNu4PLWWNrgwjeb4n1IpgMTCnqfIyIVhDdL0PVsFku1eezurZjQd7BCp WbGGv5Rubl+Vm1MOmAI6caY0jsIwMebxiwr2EHwgQRXmuLUsCZ70vgOVvdehD4xktteG RXm3qxihifCbGSFbpDJoKgQN/D1HgdSiE+ORdR6U6gq5PCBAbFYZ4VXQQ1Dp7g7fY3mA kP6g1Aj9vz2LwC21wd67tfC8CnBuoxjBmjNjHjaBsHeoqD7QRCVPx/JmFXXLML3O5plU 7BmGdlMM1Nsy9tgvYzpRnuuGMSJ7VhI+7fOOM1MfrO4gezvSxpbdMvkZ2jzZiq9v1dUp L4hw== 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=jIzuukZ4u0A78EOKwYXuG89mPV7n0nHSsSzJ5PUaofw=; b=nF9b3RhU2cUa5RkNscxrCnd9l3HyKdGehKV764oERSVOBPoL0nT12Bmh9wlOlmE43p PPwLqmKht2IWwIx+9cEP7C8edBPfsZLkgzI3dOXAPdsl1SVqwFoKcufEQkQ/6WhRv7yT j39jaRWFwzRivqnPa6725UkNnmDOCAxe+Zu0EavXhw78dzl886nuyZxkXuY9ruJ7jNrl HTb3PL1gWnQRgUtf+clTYiI6SZWeRvqjGJIqZgG7HAF951MFWtgKJeDWtrBLV5akl2kE RKoZacYB/eV6bNesdOCLzV1UVjjhh8zEJxMWQK0/GTV/kZ1hv3SIwUXZM0oWXFHBcVDl IM0Q== X-Gm-Message-State: ALyK8tKgpPsHeRPFZNjB5RtvV5cnEgJWc8xIr8lHv6jeEn9CgjowCGtrhy44xaDt7QaIQ+Z6 X-Received: by 10.194.138.75 with SMTP id qo11mr1478198wjb.44.1469022507428; Wed, 20 Jul 2016 06:48:27 -0700 (PDT) Received: from localhost.localdomain (host109-153-40-30.range109-153.btcentralplus.com. [109.153.40.30]) by smtp.gmail.com with ESMTPSA id d64sm5206662wmc.22.2016.07.20.06.48.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Jul 2016 06:48:26 -0700 (PDT) From: Michael Wood To: toaster@yoctoproject.org Date: Wed, 20 Jul 2016 14:48:12 +0100 Message-Id: <1469022492-19823-11-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1469022492-19823-1-git-send-email-michael.g.wood@intel.com> References: <1469022492-19823-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH v3 10/10] toaster: loadconf Partially add back some of the layerSource parsing 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: Wed, 20 Jul 2016 13:48:35 -0000 Partially add back a revised version of the layersource handling so that we can continue to support the old toasterconf.json and it's setup of the local project. Signed-off-by: Michael Wood --- .../bldcontrol/management/commands/loadconf.py | 85 +++++++++++++++++++++- 1 file changed, 82 insertions(+), 3 deletions(-) diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py b/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py index 59324ac..4f8c9c6 100644 --- a/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py +++ b/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py @@ -9,6 +9,20 @@ from .checksettings import DN import logging logger = logging.getLogger("toaster") +# Temporary old code to support old toasterconf.json +def _reduce_canon_path(path): + components = [] + for c in path.split("/"): + if c == "..": + del components[-1] + elif c == ".": + pass + else: + components.append(c) + if len(components) < 2: + components.append('') + return "/".join(components) +# End temp code class Command(BaseCommand): help = "Loads a toasterconf.json file in the database" @@ -76,6 +90,74 @@ class Command(BaseCommand): # find layers with the same name ReleaseDefaultLayer.objects.get_or_create( release = ro, layer_name = dli) + # NOTE Temporary old code to handle old toasterconf.json. All this to + # be removed after rewrite of config loading mechanism + for lsi in data['layersources']: + assert 'sourcetype' in lsi + assert 'apiurl' in lsi + assert 'name' in lsi + assert 'branches' in lsi + + if "local" in lsi['sourcetype']: + ls = LayerSource.TYPE_LOCAL + else: + ls = LayerSource.TYPE_LAYERINDEX + + layer_releases = [] + for branchname in lsi['branches']: + try: + release = Release.objects.get(branch_name=branchname) + layer_releases.append(release) + except Release.DoesNotExist: + logger.error("Layer set for %s but no release matches this" + "in the config" % branchname) + + apiurl = _reduce_canon_path( + os.path.join(DN(os.path.abspath(filepath)), lsi['apiurl'])) + + if 'layers' in lsi: + for layerinfo in lsi['layers']: + lo, created = Layer.objects.get_or_create( + name=layerinfo['name'], + vcs_url=layerinfo['vcs_url'], + ) + if layerinfo['local_path'].startswith("/"): + lo.local_path = layerinfo['local_path'] + else: + lo.local_path = _reduce_canon_path( + os.path.join(apiurl, layerinfo['local_path'])) + + if layerinfo['vcs_url'].startswith("remote:"): + lo.vcs_url = _read_git_url_from_local_repository( + layerinfo['vcs_url']) + if lo.vcs_url is None: + logger.error("The toaster config file references" + " the local git repo, but Toaster " + "cannot detect it.\nYour local " + "configuration for layer %s is " + "invalid. Make sure that the " + "toasterconf.json file is correct." + % layerinfo['name']) + + if lo.vcs_url is None: + lo.vcs_url = layerinfo['vcs_url'] + + if 'layer_index_url' in layerinfo: + lo.layer_index_url = layerinfo['layer_index_url'] + lo.save() + + for release in layer_releases: + lvo, created = Layer_Version.objects.get_or_create( + layer_source=ls, + release=release, + commit=release.branch_name, + branch=release.branch_name, + layer=lo) + lvo.dirpath = layerinfo['dirpath'] + lvo.save() + # END temporary code + + # set default release if ToasterSetting.objects.filter(name = "DEFAULT_RELEASE").count() > 0: ToasterSetting.objects.filter(name = "DEFAULT_RELEASE").update(value = data['defaultrelease']) @@ -95,6 +177,3 @@ class Command(BaseCommand): raise CommandError("Need a path to the toasterconf.json file") filepath = args[0] self._import_layer_config(filepath) - - - -- 2.7.4