Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id C73EBE00B18; Fri, 21 Aug 2015 01:41:51 -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.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider * (sujith.h[at]gmail.com) * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [209.85.220.43 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's * domain * 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-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 76EB2E00B01 for ; Fri, 21 Aug 2015 01:41:48 -0700 (PDT) Received: by pawq9 with SMTP id q9so48149582paw.3 for ; Fri, 21 Aug 2015 01:41:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=h4ryewmBagrJCU335OcAiqzAeSXJflxtqIhvMl+sw0U=; b=mdwb86HnIEwaANgl73ivyU6kyQrzvvQEfvGhV2C4J69HBfYsz7xEKt1zkT0hirr+rV ezoyZwZZl/8a1s5y4xDDscJ5fZ1FSB8xxDLGUDgL42beWnN18bxeB4iQGh9bIn56FROD REJjvnc6Alo3sJ8I5U5vEv/eeG8cISrT7s1/YQa/eiQ6rIosXbiDDW/XE9q1Ya/fA89l e+qWh6xuvjbG3ys/NP694L9Iyr/k073c/+Qi+Pfjca0xpEIl9J3Ec+Uq6H/xiae/5SzP 3SejzTsfVrsaHM6s+0oiRKYAF0ksPwmKL7C+bEqbLMx4hRhEjTNT4Q8tQjHS9SxTlcVc PRgw== X-Received: by 10.68.249.36 with SMTP id yr4mr15006824pbc.18.1440146508353; Fri, 21 Aug 2015 01:41:48 -0700 (PDT) Received: from kdekidd0.inp.mentorg.com ([139.181.35.34]) by smtp.gmail.com with ESMTPSA id xg3sm6898519pbb.64.2015.08.21.01.41.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 21 Aug 2015 01:41:47 -0700 (PDT) From: Sujith H To: toaster@yoctoproject.org Date: Fri, 21 Aug 2015 14:11:26 +0530 Message-Id: <1440146486-19324-1-git-send-email-sujith.h@gmail.com> X-Mailer: git-send-email 1.9.1 Subject: [review-request][PATCH] toaster: Fix import of custom layers from toasterjson.conf 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, 21 Aug 2015 08:41:51 -0000 This patch fixes import of custom layers from toasterjson.conf file. For example it was verified using layers like meta-mentor, meta-fsl-arm, meta-sourcery etc. Signed-off-by: Sujith Haridasan --- .../toaster/bldcontrol/localhostbecontroller.py | 49 ++++++++++++++++++++-- .../bldcontrol/management/commands/loadconf.py | 12 ++++-- 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py index 231a7d3..c43f33f 100644 --- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py @@ -178,7 +178,7 @@ class LocalhostBEController(BuildEnvironmentController): self.be.save() logger.debug("localhostbecontroller: Stopped bitbake server") - def getGitCloneDirectory(self, url, branch): + def getGitCloneDirectory(self, url, branch, cached_layers=None): """ Utility that returns the last component of a git path as directory """ import re @@ -191,6 +191,17 @@ class LocalhostBEController(BuildEnvironmentController): # word of attention; this is a localhost-specific issue; only on the localhost we expect to have "HEAD" releases # which _ALWAYS_ means the current poky checkout + if cached_layers: + if not url.endswith('.git'): + from os.path import dirname + extractDir = dirname(url) + for key, val in cached_layers.iteritems(): + if val == extractDir: + local_checkout_path = key + return cached_layers[local_checkout_path] + else: + local_checkout_path = cached_layers[url] + return local_checkout_path from os.path import dirname as DN local_checkout_path = DN(DN(DN(DN(DN(os.path.abspath(__file__)))))) #logger.debug("localhostbecontroller: using HEAD checkout in %s" % local_checkout_path) @@ -245,7 +256,14 @@ class LocalhostBEController(BuildEnvironmentController): # 3. checkout the repositories for giturl, commit in gitrepos.keys(): - localdirname = os.path.join(self.be.sourcedir, self.getGitCloneDirectory(giturl, commit)) + if not giturl.endswith('.git'): + for key, val in cached_layers.iteritems(): + if os.path.dirname(giturl) == val: + tmpKey = key + tmpVal = gitrepos[(giturl, commit)] + gitrepos[(tmpKey, commit)] += tmpVal + giturl = tmpKey + localdirname = os.path.join(self.be.sourcedir, self.getGitCloneDirectory(giturl, commit, cached_layers)) logger.debug("localhostbecontroller: giturl %s:%s checking out in current directory %s" % (giturl, commit, localdirname)) # make sure our directory is a git repository @@ -280,13 +298,36 @@ class LocalhostBEController(BuildEnvironmentController): # verify our repositories for name, dirpath in gitrepos[(giturl, commit)]: - localdirpath = os.path.join(localdirname, dirpath) + localdirpath = localdirname logger.debug("localhostbecontroller: localdirpath expected '%s'" % localdirpath) if not os.path.exists(localdirpath): raise BuildSetupException("Cannot find layer git path '%s' in checked out repository '%s:%s'. Aborting." % (localdirpath, giturl, commit)) + layerlisturl, layerlistdir = "", "" + layerlisturl = [localurl for localurl, localpath in cached_layers.iteritems() if localpath == localdirpath] + if len(layerlisturl) != 0: + layerlisturl = layerlisturl[0] + if len(layerlisturl) == 0: + if os.path.basename(localdirpath).startswith("_"): + layerlisturl = localdirpath if name != "bitbake": - layerlist.append(localdirpath.rstrip("/")) + for gitlocal, localpath in gitrepos.iteritems(): + if layerlisturl in gitlocal: + if len(localpath) > 2: + for paths in localpath: + if "bitbake" not in paths[1]: + layerlistdir = localdirpath +"/" + str(paths[1]) + if layerlistdir not in layerlist: + layerlist.append(layerlistdir.rstrip("/")) + else: + layerlist.append(localdirpath.rstrip("/")) + break + if len(layerlist) == 0: + for gitlocal, localpath in gitrepos.iteritems(): + for paths in localpath: + if "bitbake" not in paths: + layerlist.append(layerlisturl + "/" + str(paths[1])) + logger.debug("localhostbecontroller: current layer list %s " % pformat(layerlist)) diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py b/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py index 5022b59..a22f744 100644 --- a/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py +++ b/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py @@ -45,12 +45,14 @@ class Command(BaseCommand): for i in ['bitbake', 'releases', 'defaultrelease', 'config', 'layersources']: assert i in data - def _read_git_url_from_local_repository(address): + def _read_git_url_from_local_repository(address, path = None): url = None + if not path: + path = os.path.dirname(filepath) # we detect the remote name at runtime import subprocess (remote, remote_name) = address.split(":", 1) - cmd = subprocess.Popen("git remote -v", shell=True, cwd = os.path.dirname(filepath), stdout=subprocess.PIPE, stderr = subprocess.PIPE) + cmd = subprocess.Popen("git remote -v", shell=True, cwd = path, stdout=subprocess.PIPE, stderr = subprocess.PIPE) (out,err) = cmd.communicate() if cmd.returncode != 0: logging.warning("Error while importing layer vcs_url: git error: %s" % err) @@ -121,7 +123,11 @@ class Command(BaseCommand): logger.error("Local layer path %s must exists. Are you trying to import a layer that does not exist ? Check your local toasterconf.json" % lo.local_path) if layerinfo['vcs_url'].startswith("remote:"): - lo.vcs_url = _read_git_url_from_local_repository(layerinfo['vcs_url']) + if layerinfo['local_path'] not in ["meta", "meta-yocto", "meta-yocto-bsp"]: + repo_path = layerinfo['local_path'] + else: + repo_path = None + lo.vcs_url = _read_git_url_from_local_repository(layerinfo['vcs_url'], repo_path) 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']) -- 1.9.1