summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
diff options
context:
space:
mode:
authorDavid Reyna <David.Reyna@windriver.com>2017-12-01 15:30:15 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-12-18 15:05:36 +0000
commitae7eedd69ebffa9f1368ab639a1593c9e1118dbd (patch)
tree52014f233d06c494c8274f2fb3823f332500bd7b /bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
parent999834c036b8f073de9a55a6eb9361af1fe30101 (diff)
downloadpoky-ae7eedd69ebffa9f1368ab639a1593c9e1118dbd.tar.gz
bitbake: toaster: enable custom env support for shell calls
Allow for custom environment additions for git cloning, for example for anspass support. [YOCTO #12193] (Bitbake rev: 5770a65f4ec0e0c48d11a8b7a7cd297ba6875fd5) Signed-off-by: David Reyna <David.Reyna@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/bldcontrol/localhostbecontroller.py')
-rw-r--r--bitbake/lib/toaster/bldcontrol/localhostbecontroller.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
index 23b2792ed6..4c175625d6 100644
--- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
+++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
@@ -52,12 +52,14 @@ class LocalhostBEController(BuildEnvironmentController):
52 self.pokydirname = None 52 self.pokydirname = None
53 self.islayerset = False 53 self.islayerset = False
54 54
55 def _shellcmd(self, command, cwd=None, nowait=False): 55 def _shellcmd(self, command, cwd=None, nowait=False,env=None):
56 if cwd is None: 56 if cwd is None:
57 cwd = self.be.sourcedir 57 cwd = self.be.sourcedir
58 if env is None:
59 env=os.environ.copy()
58 60
59 logger.debug("lbc_shellcmmd: (%s) %s" % (cwd, command)) 61 logger.debug("lbc_shellcmd: (%s) %s" % (cwd, command))
60 p = subprocess.Popen(command, cwd = cwd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 62 p = subprocess.Popen(command, cwd = cwd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
61 if nowait: 63 if nowait:
62 return 64 return
63 (out,err) = p.communicate() 65 (out,err) = p.communicate()
@@ -98,6 +100,8 @@ class LocalhostBEController(BuildEnvironmentController):
98 100
99 layerlist = [] 101 layerlist = []
100 nongitlayerlist = [] 102 nongitlayerlist = []
103 git_env = os.environ.copy()
104 # (note: add custom environment settings here)
101 105
102 # set layers in the layersource 106 # set layers in the layersource
103 107
@@ -138,7 +142,7 @@ class LocalhostBEController(BuildEnvironmentController):
138 cached_layers = {} 142 cached_layers = {}
139 143
140 try: 144 try:
141 for remotes in self._shellcmd("git remote -v", self.be.sourcedir).split("\n"): 145 for remotes in self._shellcmd("git remote -v", self.be.sourcedir,env=git_env).split("\n"):
142 try: 146 try:
143 remote = remotes.split("\t")[1].split(" ")[0] 147 remote = remotes.split("\t")[1].split(" ")[0]
144 if remote not in cached_layers: 148 if remote not in cached_layers:
@@ -167,7 +171,7 @@ class LocalhostBEController(BuildEnvironmentController):
167 if os.path.exists(localdirname): 171 if os.path.exists(localdirname):
168 try: 172 try:
169 localremotes = self._shellcmd("git remote -v", 173 localremotes = self._shellcmd("git remote -v",
170 localdirname) 174 localdirname,env=git_env)
171 if not giturl in localremotes and commit != 'HEAD': 175 if not giturl in localremotes and commit != 'HEAD':
172 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)) 176 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))
173 except ShellCmdException: 177 except ShellCmdException:
@@ -177,18 +181,18 @@ class LocalhostBEController(BuildEnvironmentController):
177 else: 181 else:
178 if giturl in cached_layers: 182 if giturl in cached_layers:
179 logger.debug("localhostbecontroller git-copying %s to %s" % (cached_layers[giturl], localdirname)) 183 logger.debug("localhostbecontroller git-copying %s to %s" % (cached_layers[giturl], localdirname))
180 self._shellcmd("git clone \"%s\" \"%s\"" % (cached_layers[giturl], localdirname)) 184 self._shellcmd("git clone \"%s\" \"%s\"" % (cached_layers[giturl], localdirname),env=git_env)
181 self._shellcmd("git remote remove origin", localdirname) 185 self._shellcmd("git remote remove origin", localdirname,env=git_env)
182 self._shellcmd("git remote add origin \"%s\"" % giturl, localdirname) 186 self._shellcmd("git remote add origin \"%s\"" % giturl, localdirname,env=git_env)
183 else: 187 else:
184 logger.debug("localhostbecontroller: cloning %s in %s" % (giturl, localdirname)) 188 logger.debug("localhostbecontroller: cloning %s in %s" % (giturl, localdirname))
185 self._shellcmd('git clone "%s" "%s"' % (giturl, localdirname)) 189 self._shellcmd('git clone "%s" "%s"' % (giturl, localdirname),env=git_env)
186 190
187 # branch magic name "HEAD" will inhibit checkout 191 # branch magic name "HEAD" will inhibit checkout
188 if commit != "HEAD": 192 if commit != "HEAD":
189 logger.debug("localhostbecontroller: checking out commit %s to %s " % (commit, localdirname)) 193 logger.debug("localhostbecontroller: checking out commit %s to %s " % (commit, localdirname))
190 ref = commit if re.match('^[a-fA-F0-9]+$', commit) else 'origin/%s' % commit 194 ref = commit if re.match('^[a-fA-F0-9]+$', commit) else 'origin/%s' % commit
191 self._shellcmd('git fetch --all && git reset --hard "%s"' % ref, localdirname) 195 self._shellcmd('git fetch --all && git reset --hard "%s"' % ref, localdirname,env=git_env)
192 196
193 # take the localdirname as poky dir if we can find the oe-init-build-env 197 # take the localdirname as poky dir if we can find the oe-init-build-env
194 if self.pokydirname is None and os.path.exists(os.path.join(localdirname, "oe-init-build-env")): 198 if self.pokydirname is None and os.path.exists(os.path.join(localdirname, "oe-init-build-env")):
@@ -198,7 +202,7 @@ class LocalhostBEController(BuildEnvironmentController):
198 # make sure we have a working bitbake 202 # make sure we have a working bitbake
199 if not os.path.exists(os.path.join(self.pokydirname, 'bitbake')): 203 if not os.path.exists(os.path.join(self.pokydirname, 'bitbake')):
200 logger.debug("localhostbecontroller: checking bitbake into the poky dirname %s " % self.pokydirname) 204 logger.debug("localhostbecontroller: checking bitbake into the poky dirname %s " % self.pokydirname)
201 self._shellcmd("git clone -b \"%s\" \"%s\" \"%s\" " % (bitbake.commit, bitbake.giturl, os.path.join(self.pokydirname, 'bitbake'))) 205 self._shellcmd("git clone -b \"%s\" \"%s\" \"%s\" " % (bitbake.commit, bitbake.giturl, os.path.join(self.pokydirname, 'bitbake')),env=git_env)
202 206
203 # verify our repositories 207 # verify our repositories
204 for name, dirpath in gitrepos[(giturl, commit)]: 208 for name, dirpath in gitrepos[(giturl, commit)]: