diff options
Diffstat (limited to 'bitbake/lib/toaster/bldcontrol/localhostbecontroller.py')
-rw-r--r-- | bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py index 47708d169a..005c464314 100644 --- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | |||
@@ -30,7 +30,7 @@ import subprocess | |||
30 | 30 | ||
31 | from toastermain import settings | 31 | from toastermain import settings |
32 | 32 | ||
33 | from bbcontroller import BuildEnvironmentController, ShellCmdException, BuildSetupException, _get_git_clonedirectory | 33 | from bbcontroller import BuildEnvironmentController, ShellCmdException, BuildSetupException |
34 | 34 | ||
35 | import logging | 35 | import logging |
36 | logger = logging.getLogger("toaster") | 36 | logger = logging.getLogger("toaster") |
@@ -54,6 +54,7 @@ class LocalhostBEController(BuildEnvironmentController): | |||
54 | if cwd is None: | 54 | if cwd is None: |
55 | cwd = self.be.sourcedir | 55 | cwd = self.be.sourcedir |
56 | 56 | ||
57 | #logger.debug("lbc_shellcmmd: (%s) %s" % (cwd, command)) | ||
57 | p = subprocess.Popen(command, cwd = cwd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 58 | p = subprocess.Popen(command, cwd = cwd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
58 | (out,err) = p.communicate() | 59 | (out,err) = p.communicate() |
59 | p.wait() | 60 | p.wait() |
@@ -62,7 +63,7 @@ class LocalhostBEController(BuildEnvironmentController): | |||
62 | err = "command: %s \n%s" % (command, out) | 63 | err = "command: %s \n%s" % (command, out) |
63 | else: | 64 | else: |
64 | err = "command: %s \n%s" % (command, err) | 65 | err = "command: %s \n%s" % (command, err) |
65 | #logger.debug("localhostbecontroller: shellcmd error %s" % err) | 66 | #logger.warn("localhostbecontroller: shellcmd error %s" % err) |
66 | raise ShellCmdException(err) | 67 | raise ShellCmdException(err) |
67 | else: | 68 | else: |
68 | #logger.debug("localhostbecontroller: shellcmd success") | 69 | #logger.debug("localhostbecontroller: shellcmd success") |
@@ -106,19 +107,12 @@ class LocalhostBEController(BuildEnvironmentController): | |||
106 | 107 | ||
107 | logger.debug("localhostbecontroller: running the listener at %s" % own_bitbake) | 108 | logger.debug("localhostbecontroller: running the listener at %s" % own_bitbake) |
108 | 109 | ||
109 | try: | ||
110 | os.remove(os.path.join(self.be.builddir, "toaster_ui.log")) | ||
111 | except OSError as e: | ||
112 | import errno | ||
113 | if e.errno != errno.ENOENT: | ||
114 | raise | ||
115 | |||
116 | 110 | ||
117 | cmd = "bash -c \"source %s/oe-init-build-env %s && bitbake --read conf/toaster-pre.conf --postread conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:0 && DATABASE_URL=%s BBSERVER=0.0.0.0:-1 daemon -d -i -D %s -o toaster_ui.log -- %s --observe-only -u toasterui &\"" % (self.pokydirname, self.be.builddir, | 111 | cmd = "bash -c \"source %s/oe-init-build-env %s && bitbake --read conf/toaster-pre.conf --postread conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:0 && DATABASE_URL=%s BBSERVER=0.0.0.0:-1 daemon -d -i -D %s -o toaster_ui.log -- %s --observe-only -u toasterui &\"" % (self.pokydirname, self.be.builddir, |
118 | self.dburl, self.be.builddir, own_bitbake) | 112 | self.dburl, self.be.builddir, own_bitbake) |
119 | logger.debug("fullcommand |%s| " % cmd) | ||
120 | port = "-1" | 113 | port = "-1" |
121 | for i in self._shellcmd(cmd).split("\n"): | 114 | cmdoutput = self._shellcmd(cmd) |
115 | for i in cmdoutput.split("\n"): | ||
122 | if i.startswith("Bitbake server address"): | 116 | if i.startswith("Bitbake server address"): |
123 | port = i.split(" ")[-1] | 117 | port = i.split(" ")[-1] |
124 | logger.debug("localhostbecontroller: Found bitbake server port %s" % port) | 118 | logger.debug("localhostbecontroller: Found bitbake server port %s" % port) |
@@ -132,10 +126,17 @@ class LocalhostBEController(BuildEnvironmentController): | |||
132 | return True | 126 | return True |
133 | return False | 127 | return False |
134 | 128 | ||
135 | while not _toaster_ui_started(os.path.join(self.be.builddir, "toaster_ui.log")): | 129 | retries = 0 |
130 | started = False | ||
131 | while not started and retries < 10: | ||
132 | started = _toaster_ui_started(os.path.join(self.be.builddir, "toaster_ui.log")) | ||
136 | import time | 133 | import time |
137 | logger.debug("localhostbecontroller: Waiting bitbake server to start") | 134 | logger.debug("localhostbecontroller: Waiting bitbake server to start") |
138 | time.sleep(0.5) | 135 | time.sleep(0.5) |
136 | retries += 1 | ||
137 | |||
138 | if not started: | ||
139 | raise BuildSetupException("localhostbecontroller: Bitbake server did not start in 5 seconds, aborting (Error: '%s')" % (cmdoutput)) | ||
139 | 140 | ||
140 | logger.debug("localhostbecontroller: Started bitbake server") | 141 | logger.debug("localhostbecontroller: Started bitbake server") |
141 | 142 | ||
@@ -163,6 +164,25 @@ class LocalhostBEController(BuildEnvironmentController): | |||
163 | self.be.save() | 164 | self.be.save() |
164 | logger.debug("localhostbecontroller: Stopped bitbake server") | 165 | logger.debug("localhostbecontroller: Stopped bitbake server") |
165 | 166 | ||
167 | def getGitCloneDirectory(self, url, branch): | ||
168 | """ Utility that returns the last component of a git path as directory | ||
169 | """ | ||
170 | import re | ||
171 | components = re.split(r'[:\.\/]', url) | ||
172 | base = components[-2] if components[-1] == "git" else components[-1] | ||
173 | |||
174 | if branch != "HEAD": | ||
175 | return "_%s_%s.toaster_cloned" % (base, branch) | ||
176 | |||
177 | |||
178 | # word of attention; this is a localhost-specific issue; only on the localhost we expect to have "HEAD" releases | ||
179 | # which _ALWAYS_ means the current poky checkout | ||
180 | from os.path import dirname as DN | ||
181 | local_checkout_path = DN(DN(DN(DN(DN(os.path.abspath(__file__)))))) | ||
182 | #logger.debug("localhostbecontroller: using HEAD checkout in %s" % local_checkout_path) | ||
183 | return local_checkout_path | ||
184 | |||
185 | |||
166 | def setLayers(self, bitbakes, layers): | 186 | def setLayers(self, bitbakes, layers): |
167 | """ a word of attention: by convention, the first layer for any build will be poky! """ | 187 | """ a word of attention: by convention, the first layer for any build will be poky! """ |
168 | 188 | ||
@@ -208,15 +228,17 @@ class LocalhostBEController(BuildEnvironmentController): | |||
208 | 228 | ||
209 | layerlist = [] | 229 | layerlist = [] |
210 | 230 | ||
231 | |||
211 | # 3. checkout the repositories | 232 | # 3. checkout the repositories |
212 | for giturl, commit in gitrepos.keys(): | 233 | for giturl, commit in gitrepos.keys(): |
213 | localdirname = os.path.join(self.be.sourcedir, _get_git_clonedirectory(giturl, commit)) | 234 | localdirname = os.path.join(self.be.sourcedir, self.getGitCloneDirectory(giturl, commit)) |
214 | logger.debug("localhostbecontroller: giturl %s:%s checking out in current directory %s" % (giturl, commit, localdirname)) | 235 | logger.debug("localhostbecontroller: giturl %s:%s checking out in current directory %s" % (giturl, commit, localdirname)) |
215 | 236 | ||
216 | # make sure our directory is a git repository | 237 | # make sure our directory is a git repository |
217 | if os.path.exists(localdirname): | 238 | if os.path.exists(localdirname): |
218 | if not giturl in self._shellcmd("git remote -v", localdirname): | 239 | localremotes = self._shellcmd("git remote -v", localdirname) |
219 | raise BuildSetupException("Existing git repository at %s, but with different remotes (not '%s'). Aborting." % (localdirname, giturl)) | 240 | if not giturl in localremotes: |
241 | 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)) | ||
220 | else: | 242 | else: |
221 | if giturl in cached_layers: | 243 | if giturl in cached_layers: |
222 | logger.debug("localhostbecontroller git-copying %s to %s" % (cached_layers[giturl], localdirname)) | 244 | logger.debug("localhostbecontroller git-copying %s to %s" % (cached_layers[giturl], localdirname)) |
@@ -230,7 +252,7 @@ class LocalhostBEController(BuildEnvironmentController): | |||
230 | # branch magic name "HEAD" will inhibit checkout | 252 | # branch magic name "HEAD" will inhibit checkout |
231 | if commit != "HEAD": | 253 | if commit != "HEAD": |
232 | logger.debug("localhostbecontroller: checking out commit %s to %s " % (commit, localdirname)) | 254 | logger.debug("localhostbecontroller: checking out commit %s to %s " % (commit, localdirname)) |
233 | self._shellcmd("git fetch --all && git checkout \"%s\"" % commit , localdirname) | 255 | self._shellcmd("git fetch --all && git checkout \"%s\" && git pull --rebase" % (commit) , localdirname) |
234 | 256 | ||
235 | # take the localdirname as poky dir if we can find the oe-init-build-env | 257 | # take the localdirname as poky dir if we can find the oe-init-build-env |
236 | if self.pokydirname is None and os.path.exists(os.path.join(localdirname, "oe-init-build-env")): | 258 | if self.pokydirname is None and os.path.exists(os.path.join(localdirname, "oe-init-build-env")): |