Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id B797FE00CF5; Wed, 15 Nov 2017 16:57:59 -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=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, * medium trust * [147.11.146.13 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mail1.windriver.com (mail1.windriver.com [147.11.146.13]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id F0310E00C45 for ; Wed, 15 Nov 2017 16:57:58 -0800 (PST) Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail1.windriver.com (8.15.2/8.15.1) with ESMTPS id vAG0vwxr017416 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL) for ; Wed, 15 Nov 2017 16:57:58 -0800 (PST) Received: from ala-dreyna-lx3.corp.ad.wrs.com (147.11.157.78) by ALA-HCA.corp.ad.wrs.com (147.11.189.40) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 15 Nov 2017 16:57:57 -0800 From: David Reyna To: Date: Wed, 15 Nov 2017 16:50:12 -0800 Message-ID: <1510793412-4632-1-git-send-email-david.reyna@windriver.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [147.11.157.78] Subject: [PATCH] toaster: enable custom env support for shell calls 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: Thu, 16 Nov 2017 00:57:59 -0000 Content-Type: text/plain From: David Reyna Allow for custom environment additions for git cloning, for example for anspass support. [YOCTO #12193] --- .../toaster/bldcontrol/localhostbecontroller.py | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py index 83cb703..0ddce71 100644 --- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py @@ -52,12 +52,14 @@ class LocalhostBEController(BuildEnvironmentController): self.pokydirname = None self.islayerset = False - def _shellcmd(self, command, cwd=None, nowait=False): + def _shellcmd(self, command, cwd=None, nowait=False,env=None): if cwd is None: cwd = self.be.sourcedir + if env is None: + env=os.environ.copy() - logger.debug("lbc_shellcmmd: (%s) %s" % (cwd, command)) - p = subprocess.Popen(command, cwd = cwd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + logger.debug("lbc_shellcmd: (%s) %s" % (cwd, command)) + p = subprocess.Popen(command, cwd = cwd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) if nowait: return (out,err) = p.communicate() @@ -98,6 +100,8 @@ class LocalhostBEController(BuildEnvironmentController): layerlist = [] nongitlayerlist = [] + git_env = os.environ.copy() + # (note: add custom environment settings here) # set layers in the layersource @@ -138,7 +142,7 @@ class LocalhostBEController(BuildEnvironmentController): cached_layers = {} try: - for remotes in self._shellcmd("git remote -v", self.be.sourcedir).split("\n"): + for remotes in self._shellcmd("git remote -v", self.be.sourcedir,env=git_env).split("\n"): try: remote = remotes.split("\t")[1].split(" ")[0] if remote not in cached_layers: @@ -167,7 +171,7 @@ class LocalhostBEController(BuildEnvironmentController): if os.path.exists(localdirname): try: localremotes = self._shellcmd("git remote -v", - localdirname) + localdirname,env=git_env) if not giturl in localremotes and commit != 'HEAD': raise BuildSetupException("Existing git repository at %s, but with different remotes ('%s', expected '%s'). Toaster will not continue out of fear of damaging something." % (localdirname, ", ".join(localremotes.split("\n")), giturl)) except ShellCmdException: @@ -177,18 +181,18 @@ class LocalhostBEController(BuildEnvironmentController): else: if giturl in cached_layers: logger.debug("localhostbecontroller git-copying %s to %s" % (cached_layers[giturl], localdirname)) - self._shellcmd("git clone \"%s\" \"%s\"" % (cached_layers[giturl], localdirname)) - self._shellcmd("git remote remove origin", localdirname) - self._shellcmd("git remote add origin \"%s\"" % giturl, localdirname) + self._shellcmd("git clone \"%s\" \"%s\"" % (cached_layers[giturl], localdirname),env=git_env) + self._shellcmd("git remote remove origin", localdirname,env=git_env) + self._shellcmd("git remote add origin \"%s\"" % giturl, localdirname,env=git_env) else: logger.debug("localhostbecontroller: cloning %s in %s" % (giturl, localdirname)) - self._shellcmd('git clone "%s" "%s"' % (giturl, localdirname)) + self._shellcmd('git clone "%s" "%s"' % (giturl, localdirname),env=git_env) # branch magic name "HEAD" will inhibit checkout if commit != "HEAD": logger.debug("localhostbecontroller: checking out commit %s to %s " % (commit, localdirname)) ref = commit if re.match('^[a-fA-F0-9]+$', commit) else 'origin/%s' % commit - self._shellcmd('git fetch --all && git reset --hard "%s"' % ref, localdirname) + self._shellcmd('git fetch --all && git reset --hard "%s"' % ref, localdirname,env=git_env) # take the localdirname as poky dir if we can find the oe-init-build-env if self.pokydirname is None and os.path.exists(os.path.join(localdirname, "oe-init-build-env")): @@ -198,7 +202,7 @@ class LocalhostBEController(BuildEnvironmentController): # make sure we have a working bitbake if not os.path.exists(os.path.join(self.pokydirname, 'bitbake')): logger.debug("localhostbecontroller: checking bitbake into the poky dirname %s " % self.pokydirname) - self._shellcmd("git clone -b \"%s\" \"%s\" \"%s\" " % (bitbake.commit, bitbake.giturl, os.path.join(self.pokydirname, 'bitbake'))) + self._shellcmd("git clone -b \"%s\" \"%s\" \"%s\" " % (bitbake.commit, bitbake.giturl, os.path.join(self.pokydirname, 'bitbake')),env=git_env) # verify our repositories for name, dirpath in gitrepos[(giturl, commit)]: -- 1.9.1