per project build directory + build cancel + DL_DIR/SSTATE_DIR
v6 cover per project build directory + build cancel + DL_DIR/SSTATE_DIR
Hi,
Default build directory is not going to be used for project builds anymore. It can be used only for command line builds. Toaster will use build-toaster-<project id> directories for project builds.
The patchset also contains implementation of build cancelation(#6787) and setting of DL_DIR and SSTATE_DIR project variables. This work was done by Sujith and Michael.
This patchset fixes the following bugs:
7880 2.1M3 Medium+/Normal: Toaster uses the same /tmp dir across releases
9058 2.1 Medium/Normal: Bad project MACHINE setting in conf/toaster.conf causes command line builds to fail
8958 2.1M3 Medium/Normal: Toaster does not build with the Jethro release
6787 2.1 Medium/Enhancement: Cancelling builds at any point in the build process
8422 2.1 Medium/Enhancement: we currently don't allow setting of sstate_dir or dl_dir
This is how to test this:
- run toaster
- run command line build: build zlib
- check if it's shown in Toaster UI
- create project for Yocto master
- trigger project build from UI
- wait until it succeeds
- create project for Jethro
- check that DL_DIR and SSTATE_DIR variables point to the same location for both projects
- trigger project build from UI
- wait until it succeds
- check that 2 build directories build-toaster-<project id> exist and contain correct conf/toaster.conf and conf/bblayers.conf
- trigger any build from UI again and try to cancel it
Changes in v2: stop bitbake server after the build
Changes in v3: fixed '/bin/sh: 1: source: not found' dash issue
used project id in build directory name
added 'INHERIT+='toaster buildhistory' to conf/local.conf on toaster start
Changes in v4: fixed builds on Ubuntu caused by dash being default shell Changes in v5: fixed nasty bug in toasterui causing it to stuck in event loop Changes in v6: added fix for 6787 build cancelation patchset
added fix for 8422 (DL_DIR and SSTATE_DIR) patchset
run bitbake client from sourcedir/bitbake/bin
fixed empty image data
fixed couple of crashes in buildinfohelper code
rebased on top of toaster-next@March 23rd 10:20 GMT
The following changes since commit 59805259d6d41e5b33dee70a74a6892be37d253d:
toaster: orm generate CustomImageRecipe contents try secondary path (2016-03-23 08:19:19 +0000)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib ed/toaster/project-build-dir-cancel-dldir_sstatedir
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=ed/toaster/project-build-dir-cancel-dldir_sstatedir
Ed Bartosh (24):
toaster: don't start bitbake server
toaster: get rid of noui option
toaster: set BITBAKE_UI environment variable
toasterui: add brbe parameter to buildinfohelper
uievent: improve BBUIEventQueue code
buildinfohelper: improve handling of providermap
toasterui: fix brbe reporting
toaster: remove startBBServer API
toaster: remove release API
toaster: add brbe parameter to triggerBuild
toaster: modified setLayers API
toaster: reimplement triggerBuild
toaster: add new parameter to _shellcmd
toaster: stop bitbake server after the build
toaster: update conf/local.conf
toaster: fix jethro build
toaster: use bash explicitly
toasterui: shutdown on BuildCompleted event
toaster: fix conflicting migrations
toaster: use empty token
toaster: add DL_DIR and SSTATE_DIR to oe toasterconf
toaster: use bitbake from sourcedir/bitbake/bin
buildinfohelper: fix KeyError
toasterui: fix warning 'Unknown event'
Elliot Smith (1):
toasterui: detect build run start correctly on Jethro
Michael Wood (9):
toaster: Move xhr calls for starting and stopping builds
toaster: xhr Update the implementation of the build cancellation
request
toaster: libtoaster Update implementation of startABuild and
cancelABuild
toaster: bldcontrol models Add a cancelling state the BuildRequest
buildinfohelper: Add handler for cancelling a build
toaster: mrb_section template Add build cancel button
toaster: models Exclude the CANCELLED builds from get_number_of_builds
toaster: runbuilds Make runbuilds aware of the build CANCELLED state
toaster: runbuilds Clean up runbuilds
Sujith H (7):
toaster: bldcontrol Add forceShutDown function to BitbakeController
toaster: update BuildEnvironmentController and BitbakeController
toaster: models Add cancelled state to build outcome
toaster: tables BuildsTable exclude cancelled builds
toaster: add DL_DIR and SSTATE_DIR to poky toasterconf
toaster: update view to support DL_DIR and SSTATE_DIR
toaster: update projectconf.html for DL_DIR and SSTATE_DIR
bitbake/bin/toaster | 79 ++-------- bitbake/lib/bb/ui/buildinfohelper.py | 57 +++++--- bitbake/lib/bb/ui/toasterui.py | 54 ++++--- bitbake/lib/bb/ui/uievent.py | 10 +- bitbake/lib/toaster/bldcontrol/bbcontroller.py | 62 +------- .../toaster/bldcontrol/localhostbecontroller.py | 149 +++++++++---------- .../bldcontrol/management/commands/runbuilds.py | 109 +++++++++----- .../migrations/0002_add_cancelling_state.py | 19 +++ .../toaster/bldcontrol/migrations/0003_merge.py | 15 ++ bitbake/lib/toaster/bldcontrol/models.py | 27 +++- .../orm/migrations/0006_add_cancelled_state.py | 19 +++ bitbake/lib/toaster/orm/migrations/0007_merge.py | 15 ++ bitbake/lib/toaster/orm/models.py | 12 +- bitbake/lib/toaster/toastergui/api.py | 110 ++++++++++++++ .../toaster/toastergui/static/js/customrecipe.js | 4 +- .../lib/toaster/toastergui/static/js/layerBtn.js | 3 +- .../lib/toaster/toastergui/static/js/libtoaster.js | 41 ++++-- .../lib/toaster/toastergui/static/js/mrbsection.js | 95 ++++++++++++ .../toaster/toastergui/static/js/projectpage.js | 4 +- .../toaster/toastergui/static/js/projecttopbar.js | 6 +- .../toaster/toastergui/static/js/recipedetails.js | 4 +- bitbake/lib/toaster/toastergui/tables.py | 48 +------ bitbake/lib/toaster/toastergui/templates/base.html | 1 + .../toaster/toastergui/templates/mrb_section.html | 148 +++++++------------ .../toaster/toastergui/templates/projectconf.html | 160 ++++++++++++++++++++- bitbake/lib/toaster/toastergui/urls.py | 5 + bitbake/lib/toaster/toastergui/views.py | 40 +++++- meta-poky/conf/toasterconf.json | 4 +- meta/conf/toasterconf.json | 4 +- 29 files changed, 848 insertions(+), 456 deletions(-) create mode 100644 bitbake/lib/toaster/bldcontrol/migrations/0002_add_cancelling_state.py create mode 100644 bitbake/lib/toaster/bldcontrol/migrations/0003_merge.py create mode 100644 bitbake/lib/toaster/orm/migrations/0006_add_cancelled_state.py create mode 100644 bitbake/lib/toaster/orm/migrations/0007_merge.py create mode 100644 bitbake/lib/toaster/toastergui/api.py create mode 100644 bitbake/lib/toaster/toastergui/static/js/mrbsection.js
--
Regards,
Ed
PATCH v6 1/41 toaster: don't start bitbake server
From now on toaster script will not run bitbake server. It will be started by runbuilds and stopped after the build.
--- bitbake/bin/toaster | 67 +++++------------------------------------------------ 1 file changed, 6 insertions(+), 61 deletions(-)
bitbake/bin/toaster +6 -61
@@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/. -# Usage: source toaster [start|stop|restart-bitbake] +# Usage: source toaster [start|stop] # [webport=<port>] [noui] [noweb] # Helper function to kill a background toaster development server
@@ -95,7 +95,6 @@ stop_system() kill `cat ${BUILDDIR}/.toasterui.pid` 2>/dev/null rm ${BUILDDIR}/.toasterui.pid fi - stop_bitbake webserverKillAll # unset exported variables unset DATABASE_URL
@@ -106,31 +105,6 @@ stop_system() INSTOPSYSTEM=0 } -start_bitbake() { - unset BBSERVER - bitbake --read conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:0 - if [ $? -ne 0 ]; then - echo "Bitbake server start failed" - return 1 - fi - export BBSERVER=0.0.0.0:-1 - export DATABASE_URL=`$MANAGE get-dburl` - # we start the TOASTERUI only if not inhibited - if [ $NOTOASTERUI -eq 0 ]; then - bitbake --observe-only -u toasterui --remote-server=$BBSERVER -t xmlrpc \ - >>${BUILDDIR}/toaster_ui.log 2>&1 \ - & echo $! >${BUILDDIR}/.toasterui.pid - fi - return 0 -} - -stop_bitbake() { - BBSERVER=0.0.0.0:-1 bitbake -m - unset BBSERVER - # force stop any misbehaving bitbake server - lsof -t bitbake.lock | awk '{print $2}' | grep "[0-9]\+" | xargs -n1 -r kill -} - verify_prereq() { # Verify Django version reqfile=$(python -c "import os; print os.path.realpath('$BBBASEDIR/toaster-requirements.txt')")
@@ -229,15 +203,6 @@ if [ `basename \"$0\"` = `basename \"${TOASTER}\"` ]; then return 1 fi -if [ "$1" = 'restart-bitbake' ] ; then - stop_bitbake - sleep 1 - start_bitbake - rc=$? - sleep 3 - return $rc -fi - verify_prereq || return 1 # We make sure we're running in the current shell and in a good environment
@@ -281,16 +246,6 @@ case $CMD in $MANAGE checksocket "0.0.0.0:$WEB_PORT" || return 1 fi - # Make sure it's safe to start by checking bitbake lock - if [ -e $BUILDDIR/bitbake.lock ]; then - python -c "import fcntl; fcntl.flock(open(\"$BUILDDIR/bitbake.lock\"), fcntl.LOCK_EX|fcntl.LOCK_NB)" 2>/dev/null - if [ $? -ne 0 ] ; then - echo "Error: bitbake lock state error. File locks show that the system is on." 1>&2 - echo "Please wait for the current build to finish, stop and then start the system again." 1>&2 - return 3 - fi - fi - # kill Toaster web server if it's alive if [ -e $BUILDDIR/.toastermain.pid ] && kill -0 `cat $BUILDDIR/.toastermain.pid`; then echo "Warning: bitbake appears to be dead, but the Toaster web server is running." 1>&2
@@ -308,22 +263,12 @@ case $CMD in echo "Failed ${CMD}." return 4 fi - start_bitbake - if [ $? -eq 0 ]; then - $MANAGE runbuilds & echo $! >${BUILDDIR}/.runbuilds.pid - # set fail safe stop system on terminal exit - trap stop_system SIGHUP - echo "Successful ${CMD}." - return 0 - else - # failed start, do stop - stop_system - echo "Failed ${CMD}." - return 1 - fi - # stop system on terminal exit - set -o monitor + export DATABASE_URL=`$MANAGE get-dburl` + $MANAGE runbuilds & echo $! >${BUILDDIR}/.runbuilds.pid + # set fail safe stop system on terminal exit trap stop_system SIGHUP + echo "Successful ${CMD}." + return 0 ;; stop ) stop_system
Signature · 1 line
2.1.4
PATCH v6 2/41 toaster: get rid of noui option
In reply to Ed Bartoshnoui command line option doesn't makes sense anymore as toaster doesn't run bitbake. It should be safe to to remove it.
The purpose of this option was to skip running bitbake observer process. This was never used before as it's not possible to run toaster build without running observer.
--- bitbake/bin/toaster | 4 ---- 1 file changed, 4 deletions(-)
bitbake/bin/toaster +0 -4
@@ -175,15 +175,11 @@ fi # make sure that the toaster.sqlite file doesn't default to `pwd` like it currently does. export TOASTER_DIR=`pwd` -NOTOASTERUI=0 WEBSERVER=1 WEB_PORT="8000" unset CMD for param in $*; do case $param in - noui ) - NOTOASTERUI=1 - ;; noweb ) WEBSERVER=0 ;;
Signature · 1 line
2.1.4
PATCH v6 3/41 toaster: set BITBAKE_UI environment variable
In reply to Ed BartoshSet BITBAKE_UI variable to 'toastergui' for command line builds to use toasterui as a default ui module for bitbake.
--- bitbake/bin/toaster | 2 ++ 1 file changed, 2 insertions(+)
bitbake/bin/toaster +2 -0
@@ -100,6 +100,7 @@ stop_system() unset DATABASE_URL unset TOASTER_CONF unset TOASTER_DIR + unset BITBAKE_UI trap - SIGHUP #trap - SIGCHLD INSTOPSYSTEM=0
@@ -259,6 +260,7 @@ case $CMD in echo "Failed ${CMD}." return 4 fi + export BITBAKE_UI='toasterui' export DATABASE_URL=`$MANAGE get-dburl` $MANAGE runbuilds & echo $! >${BUILDDIR}/.runbuilds.pid # set fail safe stop system on terminal exit
Signature · 1 line
2.1.4
PATCH v6 4/41 toasterui: add brbe parameter to buildinfohelper
In reply to Ed BartoshIn current toaster code BRBE(build request:build environment) value is passed from toaster to buildinfohelper through the 'SetBRBE' event.
Passing it through environment variable is easier as it doesn't involve rpc communication between toaster and bitbake server. It also eliminates the need in running bitbake observer process.
Added parameter 'brbe' to BuildInfoHelper.__init__ Used environment variable TOASTER_BRBE to set brbe for buildinfohelper object.
--- bitbake/lib/bb/ui/buildinfohelper.py | 4 ++-- bitbake/lib/bb/ui/toasterui.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-)
bitbake/lib/bb/ui/buildinfohelper.py +2 -2
@@ -837,7 +837,7 @@ class BuildInfoHelper(object): # pylint: disable=bad-continuation # we do not follow the python conventions for continuation indentation due to long lines here - def __init__(self, server, has_build_history = False): + def __init__(self, server, has_build_history = False, brbe = None): self.internal_state = {} self.internal_state['taskdata'] = {} self.internal_state['targets'] = []
@@ -853,7 +853,7 @@ class BuildInfoHelper(object): # this is set for Toaster-triggered builds by localhostbecontroller # via toasterui - self.brbe = None + self.brbe = brbe self.project = None
bitbake/lib/bb/ui/toasterui.py +2 -1
@@ -196,7 +196,8 @@ def main(server, eventHandler, params): taskfailures = [] first = True - buildinfohelper = BuildInfoHelper(server, build_history_enabled) + buildinfohelper = BuildInfoHelper(server, build_history_enabled, + os.getenv('TOASTER_BRBE')) # write our own log files into bitbake's log directory; # we're only interested in the path to the parent directory of
Signature · 1 line
2.1.4
PATCH v6 5/41 uievent: improve BBUIEventQueue code
In reply to Ed BartoshReturn value of self.BBServer.registerEventHandler differs between jethro and master. To be able to build jethro toaster should be able to communicate with jethro bitbake server i.e. it must work with both old and new registerEventHandler call.
--- bitbake/lib/bb/ui/uievent.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
bitbake/lib/bb/ui/uievent.py +8 -2
@@ -24,7 +24,7 @@ server and queue them for the UI to process. This process must be used to avoid client/server deadlocks. """ -import socket, threading, pickle +import socket, threading, pickle, collections from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler class BBUIEventQueue:
@@ -51,7 +51,13 @@ class BBUIEventQueue: # giving up for count_tries in range(5): - self.EventHandle, error = self.BBServer.registerEventHandler(self.host, self.port) + ret = self.BBServer.registerEventHandler(self.host, self.port) + + if isinstance(ret, collections.Iterable): + self.EventHandle, error = ret + else: + self.EventHandle = ret + error = "" if self.EventHandle != None: break
Signature · 1 line
2.1.4
PATCH v6 6/41 buildinfohelper: improve handling of providermap
In reply to Ed BartoshDepTreeGenerated event doesn't contain 'providermap' data in jethro. Modified buildinfohelper to handle events without this data. This should make it possible to handle jethro events coming from jethro bitbake server by the latest buildinfohelper.
--- bitbake/lib/bb/ui/buildinfohelper.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
bitbake/lib/bb/ui/buildinfohelper.py +1 -2
@@ -1231,7 +1231,6 @@ class BuildInfoHelper(object): assert 'layer-priorities' in event._depgraph assert 'pn' in event._depgraph assert 'tdepends' in event._depgraph - assert 'providermap' in event._depgraph errormsg = ""
@@ -1314,7 +1313,7 @@ class BuildInfoHelper(object): if dep in assume_provided: continue via = None - if dep in event._depgraph['providermap']: + if 'providermap' in event._depgraph and dep in event._depgraph['providermap']: deprecipe = event._depgraph['providermap'][dep][0] dependency = self.internal_state['recipes'][deprecipe] via = Provides.objects.get_or_create(name=dep,
Signature · 1 line
2.1.4
PATCH v6 7/41 toasterui: fix brbe reporting
In reply to Ed Bartoshbuildinfohelper.brbe is lost when buildinfohelper is closed. This causes incorrect report of brbe when build is done.
Saved brbe attribute before closing buildinfohelper and used it to report correct brbe.
Got rid of useless and confusing 'ToasterUI build done 1' log message.
--- bitbake/lib/bb/ui/toasterui.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
bitbake/lib/bb/ui/toasterui.py +3 -3
@@ -373,9 +373,9 @@ def main(server, eventHandler, params): # update the build info helper on BuildCompleted, not on CommandXXX buildinfohelper.update_build_information(event, errors, warnings, taskfailures) + + brbe = buildinfohelper.brbe buildinfohelper.close(errorcode) - # mark the log output; controllers may kill the toasterUI after seeing this log - logger.info("ToasterUI build done 1, brbe: %s", buildinfohelper.brbe ) # we start a new build info logger.debug("ToasterUI prepared for new build")
@@ -384,7 +384,7 @@ def main(server, eventHandler, params): taskfailures = [] buildinfohelper = BuildInfoHelper(server, build_history_enabled) - logger.info("ToasterUI build done 2") + logger.info("ToasterUI build done, brbe: %s", brbe) continue if isinstance(event, (bb.command.CommandCompleted,
Signature · 1 line
2.1.4
PATCH v6 8/41 toaster: remove startBBServer API
In reply to Ed BartoshWe still will have to run bitbake server, but it will be done different way and the code will be in triggerBuild function.
Removed startBBServer API from BuildEnvironmentController and LocalhostBEController classes.
--- bitbake/lib/toaster/bldcontrol/bbcontroller.py | 9 ------ .../toaster/bldcontrol/localhostbecontroller.py | 32 ---------------------- 2 files changed, 41 deletions(-)
bitbake/lib/toaster/bldcontrol/bbcontroller.py +0 -9
@@ -127,14 +127,6 @@ class BuildEnvironmentController(object): bblayerconffile.write("# line added by toaster build control\nBBLAYERS = \"" + " ".join(layerlist) + "\"") bblayerconffile.close() - def startBBServer(self): - """ Starts a BB server with Toaster toasterui set up to record the builds, an no controlling UI. - After this method executes, self.be bbaddress/bbport MUST point to a running and free server, - and the bbstate MUST be updated to "started". - """ - raise NotImplementedError("FIXME: Must override in order to actually start the BB server") - - def setLayers(self, bitbake, ls): """ Checks-out bitbake executor and layers from git repositories. Sets the layer variables in the config file, after validating local layer paths.
@@ -151,7 +143,6 @@ class BuildEnvironmentController(object): starts if needed; or reconnects to the server if we can """ if not self.connection: - self.startBBServer() self.be.lock = BuildEnvironment.LOCK_RUNNING self.be.save()
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +0 -32
@@ -70,38 +70,6 @@ class LocalhostBEController(BuildEnvironmentController): logger.debug("localhostbecontroller: shellcmd success") return out - def startBBServer(self): - assert self.pokydirname and os.path.exists(self.pokydirname) - assert self.islayerset - - # find our own toasterui listener/bitbake - from toaster.bldcontrol.management.commands.loadconf import _reduce_canon_path - - toaster = _reduce_canon_path(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../bin/toaster")) - assert os.path.exists(toaster) and os.path.isfile(toaster) - - # restart bitbake server and toastergui observer - self._shellcmd("bash -c 'source %s restart-bitbake'" % toaster, self.be.builddir) - logger.debug("localhostbecontroller: restarted bitbake server") - - # read port number from bitbake.lock - self.be.bbport = "" - bblock = os.path.join(self.be.builddir, 'bitbake.lock') - if os.path.exists(bblock): - with open(bblock) as fplock: - for line in fplock: - if ":" in line: - self.be.bbport = line.split(":")[-1].strip() - logger.debug("localhostbecontroller: bitbake port %s", self.be.bbport) - break - - if not self.be.bbport: - raise BuildSetupException("localhostbecontroller: can't read bitbake port from %s" % bblock) - - self.be.bbaddress = "localhost" - self.be.bbstate = BuildEnvironment.SERVER_STARTED - self.be.save() - def getGitCloneDirectory(self, url, branch): """Construct unique clone directory name out of url and branch.""" if branch != "HEAD":
Signature · 1 line
2.1.4
PATCH v6 9/41 toaster: remove release API
In reply to Ed BartoshThis API is quite dangerous as it removes build directory. It's not used anywhere and most probably will not be used in future as toaster is going to have one build directory per project.
--- bitbake/lib/toaster/bldcontrol/bbcontroller.py | 6 ------ bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | 6 ------ 2 files changed, 12 deletions(-)
bitbake/lib/toaster/bldcontrol/bbcontroller.py +0 -6
@@ -163,12 +163,6 @@ class BuildEnvironmentController(object): """ raise NotImplementedError("Must return the REST URL of the artifact") - def release(self): - """ This stops the server and releases any resources. After this point, all resources - are un-available for further reference - """ - raise NotImplementedError("Must override BE release") - def triggerBuild(self, bitbake, layers, variables, targets): raise NotImplementedError("Must override BE release")
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +0 -6
@@ -255,12 +255,6 @@ class LocalhostBEController(BuildEnvironmentController): def readServerLogFile(self): return open(os.path.join(self.be.builddir, "toaster_server.log"), "r").read() - def release(self): - assert self.be.sourcedir and os.path.exists(self.be.builddir) - import shutil - shutil.rmtree(os.path.join(self.be.sourcedir, "build")) - assert not os.path.exists(self.be.builddir) - def triggerBuild(self, bitbake, layers, variables, targets): # set up the build environment with the needed layers
Signature · 1 line
2.1.4
PATCH v6 10/41 toaster: add brbe parameter to triggerBuild
In reply to Ed BartoshCalled triggerBuild with brbe parameter instead of adding TOASTER_BRBE variable to the database and fetching it in triggerBuild.
--- bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | 2 +- bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-)
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +1 -1
@@ -256,7 +256,7 @@ class LocalhostBEController(BuildEnvironmentController): return open(os.path.join(self.be.builddir, "toaster_server.log"), "r").read() - def triggerBuild(self, bitbake, layers, variables, targets): + def triggerBuild(self, bitbake, layers, variables, targets, brbe): # set up the build environment with the needed layers self.setLayers(bitbake, layers, targets)
bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py +2 -4
@@ -49,15 +49,13 @@ class Command(NoArgsCommand): logger.debug("runbuilds: starting build %s, environment %s" % (str(br).decode('utf-8'), bec.be)) - # write the build identification variable - BRVariable.objects.create(req = br, name="TOASTER_BRBE", value="%d:%d" % (br.pk, bec.be.pk)) - # let the build request know where it is being executed br.environment = bec.be br.save() # this triggers an async build - bec.triggerBuild(br.brbitbake, br.brlayer_set.all(), br.brvariable_set.all(), br.brtarget_set.all()) + bec.triggerBuild(br.brbitbake, br.brlayer_set.all(), br.brvariable_set.all(), + br.brtarget_set.all(), "%d:%d" % (br.pk, bec.be.pk)) except Exception as e: logger.error("runbuilds: Error launching build %s" % e)
Signature · 1 line
2.1.4
PATCH v6 11/41 toaster: modified setLayers API
In reply to Ed BartoshRemoved updating of bblayers.conf. It will be done in runBuild method. Changed return value: return list of layers.
Removed _updateBBLayers method.
--- bitbake/lib/toaster/bldcontrol/bbcontroller.py | 18 ------------------ .../lib/toaster/bldcontrol/localhostbecontroller.py | 9 +-------- 2 files changed, 1 insertion(+), 26 deletions(-)
bitbake/lib/toaster/bldcontrol/bbcontroller.py +0 -18
@@ -109,24 +109,6 @@ class BuildEnvironmentController(object): self.be = be self.connection = None - @staticmethod - def _updateBBLayers(bblayerconf, layerlist): - conflines = open(bblayerconf, "r").readlines() - - bblayerconffile = open(bblayerconf, "w") - skip = 0 - for i in xrange(len(conflines)): - if skip > 0: - skip =- 1 - continue - if conflines[i].startswith("# line added by toaster"): - skip = 1 - else: - bblayerconffile.write(conflines[i]) - - bblayerconffile.write("# line added by toaster build control\nBBLAYERS = \"" + " ".join(layerlist) + "\"") - bblayerconffile.close() - def setLayers(self, bitbake, ls): """ Checks-out bitbake executor and layers from git repositories. Sets the layer variables in the config file, after validating local layer paths.
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +1 -8
@@ -180,11 +180,6 @@ class LocalhostBEController(BuildEnvironmentController): logger.debug("localhostbecontroller: current layer list %s " % pformat(layerlist)) - # 4. update the bblayers.conf - bblayerconf = os.path.join(self.be.builddir, "conf/bblayers.conf") - if not os.path.exists(bblayerconf): - raise BuildSetupException("BE is not consistent: bblayers.conf file missing at %s" % bblayerconf) - # 5. create custom layer and add custom recipes to it layerpath = os.path.join(self.be.builddir, CustomImageRecipe.LAYER_NAME)
@@ -247,10 +242,8 @@ class LocalhostBEController(BuildEnvironmentController): if os.path.isdir(layerpath): layerlist.append(layerpath) - BuildEnvironmentController._updateBBLayers(bblayerconf, layerlist) - self.islayerset = True - return True + return layerlist def readServerLogFile(self): return open(os.path.join(self.be.builddir, "toaster_server.log"), "r").read()
Signature · 1 line
2.1.4
PATCH v6 12/41 toaster: reimplement triggerBuild
In reply to Ed BartoshReimplemented triggerBuild method to support one build directory per project:
- start bitbake server from the cloned repository
- don't run observer
- run bitbake build directly instead of triggering it through xmlrpc
[YOCTO #7880]
[YOCTO #9058]
[YOCTO #8958]
--- .../toaster/bldcontrol/localhostbecontroller.py | 100 +++++++++++++-------- 1 file changed, 65 insertions(+), 35 deletions(-)
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +65 -35
@@ -250,44 +250,74 @@ class LocalhostBEController(BuildEnvironmentController): def triggerBuild(self, bitbake, layers, variables, targets, brbe): - # set up the build environment with the needed layers - self.setLayers(bitbake, layers, targets) + layers = self.setLayers(bitbake, layers, targets) + + # init build environment from the clone + builddir = '%s-toaster-%d' % (self.be.builddir, bitbake.req.project.id) + oe_init = os.path.join(self.pokydirname, 'oe-init-build-env') + # init build environment + self._shellcmd('source %s %s' % (oe_init, builddir), self.be.sourcedir) + + # update bblayers.conf + bblconfpath = os.path.join(builddir, "conf/bblayers.conf") + conflines = open(bblconfpath, "r").readlines() + skip = False + with open(bblconfpath, 'w') as bblayers: + for line in conflines: + if line.startswith("# line added by toaster"): + skip = True + continue + if skip: + skip = False + else: + bblayers.write(line) + + bblayers.write('# line added by toaster build control\n' + 'BBLAYERS = "%s"' % ' '.join(layers)) # write configuration file - filepath = os.path.join(self.be.builddir, "conf/toaster.conf") - with open(filepath, 'w') as conf: + confpath = os.path.join(builddir, 'conf/toaster.conf') + with open(confpath, 'w') as conf: for var in variables: conf.write('%s="%s"\n' % (var.name, var.value)) conf.write('INHERIT+="toaster buildhistory"') - # get the bb server running with the build req id and build env id - bbctrl = self.getBBController() - - # set variables; TOASTER_BRBE is not set on the server, as this - # causes events from command-line builds to be attached to the last - # Toaster-triggered build; instead, TOASTER_BRBE is fired as an event so - # that toasterui can set it on the buildinfohelper; - # see https://bugzilla.yoctoproject.org/show_bug.cgi?id=9021 - for var in variables: - if var.name == 'TOASTER_BRBE': - bbctrl.triggerEvent('bb.event.MetadataEvent("SetBRBE", "%s")' \ - % var.value) - else: - bbctrl.setVariable(var.name, var.value) - - # Add 'toaster' and 'buildhistory' to INHERIT variable - inherit = {item.strip() for item in bbctrl.getVariable('INHERIT').split()} - inherit = inherit.union(["toaster", "buildhistory"]) - bbctrl.setVariable('INHERIT', ' '.join(inherit)) - - # trigger the build command - task = reduce(lambda x, y: x if len(y)== 0 else y, map(lambda y: y.task, targets)) - if len(task) == 0: - task = None - - bbctrl.build(list(map(lambda x:x.target, targets)), task) - - logger.debug("localhostbecontroller: Build launched, exiting. Follow build logs at %s/toaster_ui.log" % self.be.builddir) - - # disconnect from the server - bbctrl.disconnect() + # run bitbake server from the clone + bitbake = os.path.join(self.pokydirname, 'bitbake', 'bin', 'bitbake') + self._shellcmd('source %s %s; BITBAKE_UI="" %s --read %s ' + '--server-only -t xmlrpc -B 0.0.0.0:0' % (oe_init, builddir, + bitbake, confpath), self.be.sourcedir) + + # read port number from bitbake.lock + self.be.bbport = "" + bblock = os.path.join(builddir, 'bitbake.lock') + with open(bblock) as fplock: + for line in fplock: + if ":" in line: + self.be.bbport = line.split(":")[-1].strip() + logger.debug("localhostbecontroller: bitbake port %s", self.be.bbport) + break + + if not self.be.bbport: + raise BuildSetupException("localhostbecontroller: can't read bitbake port from %s" % bblock) + + self.be.bbaddress = "localhost" + self.be.bbstate = BuildEnvironment.SERVER_STARTED + self.be.lock = BuildEnvironment.LOCK_RUNNING + self.be.save() + + bbtargets = '' + for target in targets: + task = target.task or 'do_build' + if not task.startswith('do_'): + task = 'do_' + task + bbtargets += '%s:%s ' % (target.target, task) + + # run build with local bitbake + log = os.path.join(builddir, 'toaster_ui.log') + self._shellcmd('TOASTER_BRBE="%s" BBSERVER="0.0.0.0:-1" ' + '../bitbake/bin/bitbake %s -u toasterui ' + '>>%s 2>&1 &' % (brbe, bbtargets, log), builddir) + + logger.debug('localhostbecontroller: Build launched, exiting. ' + 'Follow build logs at %s' % log)
Signature · 1 line
2.1.4
PATCH v6 13/41 toaster: add new parameter to _shellcmd
In reply to Ed BartoshAdded 'nowait' parameter to _shellcmd method to support running chain of commands in a subshell.
This is going to be used to stop bitbake server after the build.
--- bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +3 -1
@@ -51,12 +51,14 @@ class LocalhostBEController(BuildEnvironmentController): self.pokydirname = None self.islayerset = False - def _shellcmd(self, command, cwd = None): + def _shellcmd(self, command, cwd=None, nowait=False): if cwd is None: cwd = self.be.sourcedir logger.debug("lbc_shellcmmd: (%s) %s" % (cwd, command)) p = subprocess.Popen(command, cwd = cwd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if nowait: + return (out,err) = p.communicate() p.wait() if p.returncode:
Signature · 1 line
2.1.4
PATCH v6 14/41 toaster: stop bitbake server after the build
In reply to Ed BartoshBitbake server is used only during the build. There is no need in keeping server running after the build.
Running bitbake -m in the subshell after the build should stop the server.
--- bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +6 -4
@@ -315,11 +315,13 @@ class LocalhostBEController(BuildEnvironmentController): task = 'do_' + task bbtargets += '%s:%s ' % (target.target, task) - # run build with local bitbake + # run build with local bitbake. stop the server after the build. log = os.path.join(builddir, 'toaster_ui.log') - self._shellcmd('TOASTER_BRBE="%s" BBSERVER="0.0.0.0:-1" ' - '../bitbake/bin/bitbake %s -u toasterui ' - '>>%s 2>&1 &' % (brbe, bbtargets, log), builddir) + self._shellcmd(['(TOASTER_BRBE="%s" BBSERVER="0.0.0.0:-1" ' + '../bitbake/bin/bitbake %s -u toasterui >>%s 2>&1;' + 'BITBAKE_UI="" BBSERVER=0.0.0.0:-1 %s -m)&' \ + % (brbe, bbtargets, log, bitbake)], builddir, + nowait=True) logger.debug('localhostbecontroller: Build launched, exiting. ' 'Follow build logs at %s' % log)
Signature · 1 line
2.1.4
PATCH v6 15/41 toaster: update conf/local.conf
In reply to Ed BartoshAdded 'INHERIT+="toaster buildhistory"' line to the conf/local conf when Toaster starts. It should make commandline builds to provide all required information to Toaster backend.
--- bitbake/bin/toaster | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
bitbake/bin/toaster +3 -3
@@ -252,9 +252,9 @@ case $CMD in fi # Create configuration file - conf=${BUILDDIR}/conf/toaster.conf - echo "# Created by toaster start script" > $conf - echo "INHERIT+=\"toaster buildhistory\"" >> $conf + conf=${BUILDDIR}/conf/local.conf + line='INHERIT+="toaster buildhistory"' + grep -q "$line" $conf || echo $line >> $conf if [ $WEBSERVER -gt 0 ] && ! webserverStartAll; then echo "Failed ${CMD}."
Signature · 1 line
2.1.4
PATCH v6 16/41 toaster: fix jethro build
In reply to Ed BartoshThe keys 'started', 'ended', 'cpu_time_user', 'disk_io_read' and 'disk_io_write' were added to the event recently, so they don't exist in the events generated by bitbake server from older releases.
Checking if task_to_update structure has these keys before using them should fix build of older releases.
--- bitbake/lib/bb/ui/buildinfohelper.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
bitbake/lib/bb/ui/buildinfohelper.py +10 -8
@@ -238,14 +238,16 @@ class ORMWrapper(object): recipe__name = recipe_name ) - task_to_update.started = self._timestamp_to_datetime(task_stats['started']) - task_to_update.ended = self._timestamp_to_datetime(task_stats['ended']) - task_to_update.elapsed_time = (task_stats['ended'] - task_stats['started']) - task_to_update.cpu_time_user = task_stats['cpu_time_user'] - task_to_update.cpu_time_system = task_stats['cpu_time_system'] - task_to_update.disk_io_read = task_stats['disk_io_read'] - task_to_update.disk_io_write = task_stats['disk_io_write'] - task_to_update.disk_io = task_stats['disk_io_read'] + task_stats['disk_io_write'] + if 'started' in task_stats and 'ended' in task_stats: + task_to_update.started = self._timestamp_to_datetime(task_stats['started']) + task_to_update.ended = self._timestamp_to_datetime(task_stats['ended']) + task_to_update.elapsed_time = (task_stats['ended'] - task_stats['started']) + task_to_update.cpu_time_user = task_stats.get('cpu_time_user') + task_to_update.cpu_time_system = task_stats.get('cpu_time_system') + if 'disk_io_read' in task_stats and 'disk_io_write' in task_stats: + task_to_update.disk_io_read = task_stats['disk_io_read'] + task_to_update.disk_io_write = task_stats['disk_io_write'] + task_to_update.disk_io = task_stats['disk_io_read'] + task_stats['disk_io_write'] task_to_update.save()
Signature · 1 line
2.1.4
PATCH v6 17/41 toaster: use bash explicitly
In reply to Ed BartoshToaster can't run builds on Ubuntu as default /bin/sh points to dash there. The reason is that oe-init-build-env can't be sourced under dash for various reasons. It can be fixed or work arounded, but it wouldn't fix builds for older releases. Explicitly using bash to start builds should fix the issue.
--- bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +7 -6
@@ -258,7 +258,8 @@ class LocalhostBEController(BuildEnvironmentController): builddir = '%s-toaster-%d' % (self.be.builddir, bitbake.req.project.id) oe_init = os.path.join(self.pokydirname, 'oe-init-build-env') # init build environment - self._shellcmd('source %s %s' % (oe_init, builddir), self.be.sourcedir) + self._shellcmd("bash -c 'source %s %s'" % (oe_init, builddir), + self.be.sourcedir) # update bblayers.conf bblconfpath = os.path.join(builddir, "conf/bblayers.conf")
@@ -286,9 +287,9 @@ class LocalhostBEController(BuildEnvironmentController): # run bitbake server from the clone bitbake = os.path.join(self.pokydirname, 'bitbake', 'bin', 'bitbake') - self._shellcmd('source %s %s; BITBAKE_UI="" %s --read %s ' - '--server-only -t xmlrpc -B 0.0.0.0:0' % (oe_init, builddir, - bitbake, confpath), self.be.sourcedir) + self._shellcmd('bash -c \"source %s %s; BITBAKE_UI="" %s --read %s ' + '--server-only -t xmlrpc -B 0.0.0.0:0\"' % (oe_init, + builddir, bitbake, confpath), self.be.sourcedir) # read port number from bitbake.lock self.be.bbport = ""
@@ -317,9 +318,9 @@ class LocalhostBEController(BuildEnvironmentController): # run build with local bitbake. stop the server after the build. log = os.path.join(builddir, 'toaster_ui.log') - self._shellcmd(['(TOASTER_BRBE="%s" BBSERVER="0.0.0.0:-1" ' + self._shellcmd(['bash -c \"(TOASTER_BRBE="%s" BBSERVER="0.0.0.0:-1" ' '../bitbake/bin/bitbake %s -u toasterui >>%s 2>&1;' - 'BITBAKE_UI="" BBSERVER=0.0.0.0:-1 %s -m)&' \ + 'BITBAKE_UI="" BBSERVER=0.0.0.0:-1 %s -m)&\"' \ % (brbe, bbtargets, log, bitbake)], builddir, nowait=True)
Signature · 1 line
2.1.4
PATCH v6 18/41 toasterui: shutdown on BuildCompleted event
In reply to Ed Bartoshtoasterui exits event loop on one of the following events:
CommandCompleted, CommandFailed or CommandExit. Unfortunately none of them come from bitbake when build fails. This is normai if toasterui runs in observer mode. However, if it's in build mode this causes toasterui to stuck in the infinite loop waiting for new events.
The only event we can rely on is BuildCompleted as it always comes from bitbake unlike 3 above mentioned events.
Modified the code to always shutdown toasterui in build mode on BuildCompleted event.
--- bitbake/lib/bb/ui/toasterui.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
bitbake/lib/bb/ui/toasterui.py +8 -5
@@ -378,11 +378,14 @@ def main(server, eventHandler, params): buildinfohelper.close(errorcode) # we start a new build info - logger.debug("ToasterUI prepared for new build") - errors = 0 - warnings = 0 - taskfailures = [] - buildinfohelper = BuildInfoHelper(server, build_history_enabled) + if params.observe_only: + logger.debug("ToasterUI prepared for new build") + errors = 0 + warnings = 0 + taskfailures = [] + buildinfohelper = BuildInfoHelper(server, build_history_enabled) + else: + main.shutdown = 1 logger.info("ToasterUI build done, brbe: %s", brbe) continue
Signature · 1 line
2.1.4
PATCH v6 19/41 toaster: bldcontrol Add forceShutDown function to BitbakeController
In reply to Ed BartoshFrom: Sujith H <[email protected]>
Add forceShutDown function to BitbakeController class. This function provides a mechanism to cancel the build from toaster. An API which can be used safely to cancel build and hence shutdown running bitbake server.
[YOCTO #6787]
--- bitbake/lib/toaster/bldcontrol/bbcontroller.py | 3 +++ 1 file changed, 3 insertions(+)
bitbake/lib/toaster/bldcontrol/bbcontroller.py +3 -0
@@ -63,6 +63,9 @@ class BitbakeController(object): task = "build" return self._runCommand(["buildTargets", targets, task]) + def forceShutDown(self): + return self._runCommand(["stateForceShutdown"]) + def getBuildEnvironmentController(**kwargs):
Signature · 1 line
2.1.4
PATCH v6 20/41 toaster: Move xhr calls for starting and stopping builds
In reply to Ed BartoshFrom: Michael Wood <[email protected]>
Move the backend xhr implementation of the build request changes into it's own file and out of the ToasterTable definition.
It used to live in the views.py but in a hope of starting to collate logical groups of views move this to a new file called api.
--- bitbake/lib/toaster/toastergui/api.py | 74 ++++++++++++++++++++++++++++++++ bitbake/lib/toaster/toastergui/tables.py | 43 +------------------ bitbake/lib/toaster/toastergui/urls.py | 5 +++ 3 files changed, 80 insertions(+), 42 deletions(-) create mode 100644 bitbake/lib/toaster/toastergui/api.py
bitbake/lib/toaster/toastergui/api.py new file +74 -0
@@ -0,0 +1,74 @@ +# +# BitBake Toaster Implementation +# +# Copyright (C) 2016 Intel Corporation +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + +# Temporary home for the UI's misc API + +from orm.models import Project, ProjectTarget +from bldcontrol.models import BuildRequest +from bldcontrol import bbcontroller +from django.http import HttpResponse, JsonResponse +from django.views.generic import View + + +class XhrBuildRequest(View): + + def get(self, request, *args, **kwargs): + return HttpResponse() + + def post(self, request, *args, **kwargs): + """ Process HTTP POSTs which make build requests """ + + project = Project.objects.get(pk=kwargs['pid']) + + if 'buildCancel' in request.POST: + for i in request.POST['buildCancel'].strip().split(" "): + try: + br = BuildRequest.objects.select_for_update().get(project = project, pk = i, state__lte = BuildRequest.REQ_QUEUED) + br.state = BuildRequest.REQ_DELETED + br.save() + except BuildRequest.DoesNotExist: + pass + + if 'buildDelete' in request.POST: + for i in request.POST['buildDelete'].strip().split(" "): + try: + BuildRequest.objects.select_for_update().get(project = project, pk = i, state__lte = BuildRequest.REQ_DELETED).delete() + except BuildRequest.DoesNotExist: + pass + + if 'targets' in request.POST: + ProjectTarget.objects.filter(project = project).delete() + s = str(request.POST['targets']) + for t in s.translate(None, ";%|\"").split(" "): + if ":" in t: + target, task = t.split(":") + else: + target = t + task = "" + ProjectTarget.objects.create(project = project, + target = target, + task = task) + project.schedule_build() + + # redirect back to builds page so any new builds in progress etc. + # are visible + response = HttpResponse() + response.status_code = 302 + response['Location'] = request.build_absolute_uri() + return response
bitbake/lib/toaster/toastergui/tables.py +1 -42
55 lines not on this page · raw message
bitbake/lib/toaster/toastergui/urls.py +5 -0
@@ -22,6 +22,7 @@ from django.views.generic import RedirectView, TemplateView from django.http import HttpResponseBadRequest from toastergui import tables from toastergui import typeaheads +from toastergui import api urlpatterns = patterns('toastergui.views', # landing page
@@ -180,6 +181,10 @@ urlpatterns = patterns('toastergui.views', url(r'^xhr_customrecipe/', 'xhr_customrecipe', name='xhr_customrecipe'), + url(r'^xhr_buildrequest/project/(?P<pid>\d+)$', + api.XhrBuildRequest.as_view(), + name='xhr_buildrequest'), + # default redirection url(r'^$', RedirectView.as_view(url='landing', permanent=True)), )
Signature · 1 line
2.1.4
PATCH v6 21/41 toaster: xhr Update the implementation of the build cancellation request
In reply to Ed BartoshFrom: Michael Wood <[email protected]>
Update the implementation of the backend api for cancelling builds with the new cancelling BuildRequest state and cancelled Build state. Also added some docstring about general usage.
Co-Author: Sujith H <[email protected]>
--- bitbake/lib/toaster/toastergui/api.py | 54 +++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 9 deletions(-)
bitbake/lib/toaster/toastergui/api.py +45 -9
@@ -19,7 +19,7 @@ # Temporary home for the UI's misc API -from orm.models import Project, ProjectTarget +from orm.models import Project, ProjectTarget, Build from bldcontrol.models import BuildRequest from bldcontrol import bbcontroller from django.http import HttpResponse, JsonResponse
@@ -32,18 +32,54 @@ class XhrBuildRequest(View): return HttpResponse() def post(self, request, *args, **kwargs): - """ Process HTTP POSTs which make build requests """ + """ + Build control + + Entry point: /xhr_buildrequest/<project_id> + Method: POST + + Args: + id: id of build to change + buildCancel = build_request_id ... + buildDelete = id ... + targets = recipe_name ... + + Returns: + {"error": "ok"} + or + {"error": <error message>} + """ project = Project.objects.get(pk=kwargs['pid']) if 'buildCancel' in request.POST: for i in request.POST['buildCancel'].strip().split(" "): try: - br = BuildRequest.objects.select_for_update().get(project = project, pk = i, state__lte = BuildRequest.REQ_QUEUED) - br.state = BuildRequest.REQ_DELETED + br = BuildRequest.objects.get(project=project, pk=i) + + try: + bbctrl = bbcontroller.BitbakeController(br.environment) + bbctrl.forceShutDown() + except: + # We catch a bunch of exceptions here because + # this is where the server has not had time to start up + # and the build request or build is in transit between + # processes. + # We can safely just set the build as cancelled + # already as it never got started + build = br.build + build.outcome = Build.CANCELLED + build.save() + + # We now hand over to the buildinfohelper to update the + # build state once we've finished cancelling + br.state = BuildRequest.REQ_CANCELLING br.save() + except BuildRequest.DoesNotExist: - pass + return JsonResponse({'error':'No such build id %s' % i}) + + return JsonResponse({'error': 'ok'}) if 'buildDelete' in request.POST: for i in request.POST['buildDelete'].strip().split(" "):
@@ -51,6 +87,7 @@ class XhrBuildRequest(View): BuildRequest.objects.select_for_update().get(project = project, pk = i, state__lte = BuildRequest.REQ_DELETED).delete() except BuildRequest.DoesNotExist: pass + return JsonResponse({'error': 'ok' }) if 'targets' in request.POST: ProjectTarget.objects.filter(project = project).delete()
@@ -66,9 +103,8 @@ class XhrBuildRequest(View): task = task) project.schedule_build() - # redirect back to builds page so any new builds in progress etc. - # are visible + return JsonResponse({'error': 'ok' }) + response = HttpResponse() - response.status_code = 302 - response['Location'] = request.build_absolute_uri() + response.status_code = 500 return response
Signature · 1 line
2.1.4
PATCH v6 22/41 toaster: libtoaster Update implementation of startABuild and cancelABuild
In reply to Ed BartoshFrom: Michael Wood <[email protected]>
Update the implementation of startABuild and cancelAbuild to reflect changes to the backend api. We now have a dedicated endpoint to make calls into so add this url to libtoaster.ctx and allow passing null in as a url value to indicate that we want to use the current project
Also:
- Fix some documentation comments
- Add the convenience of passing in an array of targets to startABuild
--- .../toaster/toastergui/static/js/customrecipe.js | 4 +-- .../lib/toaster/toastergui/static/js/layerBtn.js | 3 +- .../lib/toaster/toastergui/static/js/libtoaster.js | 41 ++++++++++++++-------- .../toaster/toastergui/static/js/projectpage.js | 4 +-- .../toaster/toastergui/static/js/projecttopbar.js | 6 ++-- .../toaster/toastergui/static/js/recipedetails.js | 4 +-- bitbake/lib/toaster/toastergui/templates/base.html | 1 + 7 files changed, 34 insertions(+), 29 deletions(-)
bitbake/lib/toaster/toastergui/static/js/customrecipe.js +1 -3
@@ -207,9 +207,7 @@ function customRecipePageInit(ctx) { /* Trigger a build of your custom image */ $(".build-custom-image").click(function(){ - libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl, - libtoaster.ctx.projectId, - ctx.recipe.name, + libtoaster.startABuild(null, ctx.recipe.name, function(){ window.location.replace(libtoaster.ctx.projectBuildsUrl); });
bitbake/lib/toaster/toastergui/static/js/layerBtn.js +1 -2
@@ -60,8 +60,7 @@ function layerBtnsInit() { e.preventDefault(); var recipe = $(this).data('recipe-name'); - libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl, - libtoaster.ctx.projectId, recipe, + libtoaster.startABuild(null, recipe, function(){ /* Success */ window.location.replace(libtoaster.ctx.projectBuildsUrl);
bitbake/lib/toaster/toastergui/static/js/libtoaster.js +26 -15
75 lines not on this page · raw message
bitbake/lib/toaster/toastergui/static/js/projectpage.js +1 -3
@@ -232,9 +232,7 @@ function projectPageInit(ctx) { toBuild = toBuild.trim(); - libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl, - libtoaster.ctx.projectId, - toBuild, + libtoaster.startABuild(null, toBuild, function(){ /* Build request started */ window.location.replace(libtoaster.ctx.projectBuildsUrl);
bitbake/lib/toaster/toastergui/static/js/projecttopbar.js +3 -3
@@ -82,9 +82,9 @@ function projectTopBarInit(ctx) { selectedTarget = { name: newBuildTargetInput.val() }; /* Fire off the build */ - libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl, - null, selectedTarget.name, function(){ - window.location.replace(libtoaster.ctx.projectBuildsUrl); + libtoaster.startABuild(null, selectedTarget.name, + function(){ + window.location.replace(libtoaster.ctx.projectBuildsUrl); }, null); }); }
bitbake/lib/toaster/toastergui/static/js/recipedetails.js +1 -3
@@ -42,9 +42,7 @@ function recipeDetailsPageInit(ctx){ /* Trigger a build of your custom image */ $(".build-recipe-btn").click(function(){ - libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl, - libtoaster.ctx.projectId, - ctx.recipe.name, + libtoaster.startABuild(null, ctx.recipe.name, function(){ window.location.replace(libtoaster.ctx.projectBuildsUrl); });
bitbake/lib/toaster/toastergui/templates/base.html +1 -0
@@ -47,6 +47,7 @@ projectBuildsUrl: {% url 'projectbuilds' project.id as pburl %}{{pburl|json}}, xhrCustomRecipeUrl : "{% url 'xhr_customrecipe' %}", projectId : {{project.id}}, + xhrBuildRequestUrl: "{% url 'xhr_buildrequest' project.id %}", {% else %} projectId : undefined, projectPageUrl : undefined,
Signature · 1 line
2.1.4
PATCH v6 23/41 toaster: update BuildEnvironmentController and BitbakeController
In reply to Ed BartoshFrom: Sujith H <[email protected]>
Remove getBBController function from BuildEnvironmentController. The constructor of BitbakeController is updated appropriately so that call can be made to connect to running server.
The call to startBBServer is removed from bbcontroller and handledin localhostbecontroller.
[YOCTO #6787]
--- bitbake/lib/toaster/bldcontrol/bbcontroller.py | 26 ++++------------------ .../toaster/bldcontrol/localhostbecontroller.py | 2 +- 2 files changed, 5 insertions(+), 23 deletions(-)
bitbake/lib/toaster/bldcontrol/bbcontroller.py +4 -22
@@ -37,11 +37,12 @@ class BitbakeController(object): It is outside the scope of this class on how the server is started and aquired """ - def __init__(self, connection): - self.connection = connection + def __init__(self, be): + self.connection = bb.server.xmlrpc._create_server(be.bbaddress, + int(be.bbport))[0] def _runCommand(self, command): - result, error = self.connection.connection.runCommand(command) + result, error = self.connection.runCommand(command) if error: raise Exception(error) return result
@@ -122,25 +123,6 @@ class BuildEnvironmentController(object): """ raise NotImplementedError("FIXME: Must override setLayers") - - def getBBController(self): - """ returns a BitbakeController to an already started server; this is the point where the server - starts if needed; or reconnects to the server if we can - """ - if not self.connection: - self.be.lock = BuildEnvironment.LOCK_RUNNING - self.be.save() - - server = bb.server.xmlrpc.BitBakeXMLRPCClient() - server.initServer() - server.saveConnectionDetails("%s:%s" % (self.be.bbaddress, self.be.bbport)) - self.connection = server.establishConnection([]) - - self.be.bbtoken = self.connection.transport.connection_token - self.be.save() - - return BitbakeController(self.connection) - def getArtifact(self, path): """ This call returns an artifact identified by the 'path'. How 'path' is interpreted as up to the implementing BEC. The return MUST be a REST URL where a GET will actually return
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +1 -1
@@ -32,7 +32,7 @@ import subprocess from toastermain import settings -from bbcontroller import BuildEnvironmentController, ShellCmdException, BuildSetupException +from bbcontroller import BuildEnvironmentController, ShellCmdException, BuildSetupException, BitbakeController import logging logger = logging.getLogger("toaster")
Signature · 1 line
2.1.4
PATCH v6 24/41 toaster: models Add cancelled state to build outcome
In reply to Ed BartoshFrom: Sujith H <[email protected]>
A new state CANCELLED is introduced to, distinguish the state of build.
[YOCTO #6787]
--- .../orm/migrations/0006_add_cancelled_state.py | 19 +++++++++++++++++++ bitbake/lib/toaster/orm/models.py | 7 ++++++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 bitbake/lib/toaster/orm/migrations/0006_add_cancelled_state.py
bitbake/lib/toaster/orm/migrations/0006_add_cancelled_state.py new file +19 -0
@@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('orm', '0004_provides'), + ] + + operations = [ + migrations.AlterField( + model_name='build', + name='outcome', + field=models.IntegerField(default=2, choices=[(0, b'Succeeded'), (1, b'Failed'), (2, b'In Progress'), (3, b'Cancelled')]), + ), + ]
bitbake/lib/toaster/orm/models.py +6 -1
@@ -358,11 +358,13 @@ class Build(models.Model): SUCCEEDED = 0 FAILED = 1 IN_PROGRESS = 2 + CANCELLED = 3 BUILD_OUTCOME = ( (SUCCEEDED, 'Succeeded'), (FAILED, 'Failed'), (IN_PROGRESS, 'In Progress'), + (CANCELLED, 'Cancelled'), ) search_allowed_fields = ['machine', 'cooker_log_path', "target__target", "target__target_image_file__file_name"]
@@ -389,7 +391,10 @@ class Build(models.Model): if project: builds = builds.filter(project=project) - finished_criteria = Q(outcome=Build.SUCCEEDED) | Q(outcome=Build.FAILED) + finished_criteria = \ + Q(outcome=Build.SUCCEEDED) | \ + Q(outcome=Build.FAILED) | \ + Q(outcome=Build.CANCELLED) recent_builds = list(itertools.chain( builds.filter(outcome=Build.IN_PROGRESS).order_by("-started_on"),
Signature · 1 line
2.1.4
PATCH v6 25/41 toaster: bldcontrol models Add a cancelling state the BuildRequest
In reply to Ed BartoshFrom: Michael Wood <[email protected]>
To accurately reflect the state of a build request we also need a cancelling state. This is set when we've started a build and then for whatever reason cancel it, cancelling is not instantaneous so we have this state to indicate that a cancel is in progress.
Also add a state transition guard. As the state of a BuildRequest can currently be modified by three processes; Toastergui, Runbuilds/bldcontrol and the buildinofhelper we cannot say for sure which process will be running at the time of cancellation so in order to avoid one of these processes making an incorrect transition only allow transitions of state to increase.
e.g. CREATED -> QUEUED -> INPROGRESS
And to ignore such requested changes such as
INPROGRESS -> CREATED
--- .../migrations/0002_add_cancelling_state.py | 19 +++++++++++++++ bitbake/lib/toaster/bldcontrol/models.py | 27 +++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 bitbake/lib/toaster/bldcontrol/migrations/0002_add_cancelling_state.py
bitbake/lib/toaster/bldcontrol/migrations/0002_add_cancelling_state.py new file +19 -0
@@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('bldcontrol', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='buildrequest', + name='state', + field=models.IntegerField(default=0, choices=[(0, b'created'), (1, b'queued'), (2, b'in progress'), (3, b'completed'), (4, b'failed'), (5, b'deleted'), (6, b'cancelling'), (7, b'archive')]), + ), + ]
bitbake/lib/toaster/bldcontrol/models.py +26 -1
@@ -4,6 +4,8 @@ from django.core.validators import MaxValueValidator, MinValueValidator from django.utils.encoding import force_bytes from orm.models import Project, ProjectLayer, ProjectVariable, ProjectTarget, Build, Layer_Version +import logging +logger = logging.getLogger("toaster") # a BuildEnvironment is the equivalent of the "build/" directory on the localhost class BuildEnvironment(models.Model): SERVER_STOPPED = 0
@@ -64,7 +66,8 @@ class BuildRequest(models.Model): REQ_COMPLETED = 3 REQ_FAILED = 4 REQ_DELETED = 5 - REQ_ARCHIVE = 6 + REQ_CANCELLING = 6 + REQ_ARCHIVE = 7 REQUEST_STATE = ( (REQ_CREATED, "created"),
@@ -73,6 +76,7 @@ class BuildRequest(models.Model): (REQ_COMPLETED, "completed"), (REQ_FAILED, "failed"), (REQ_DELETED, "deleted"), + (REQ_CANCELLING, "cancelling"), (REQ_ARCHIVE, "archive"), )
@@ -85,6 +89,27 @@ class BuildRequest(models.Model): created = models.DateTimeField(auto_now_add = True) updated = models.DateTimeField(auto_now = True) + def __init__(self, *args, **kwargs): + super(BuildRequest, self).__init__(*args, **kwargs) + # Save the old state incase it's about to be modified + self.old_state = self.state + + def save(self, *args, **kwargs): + # Check that the state we're trying to set is not going backwards + # e.g. from REQ_FAILED to REQ_INPROGRESS + if self.old_state != self.state and self.old_state > self.state: + logger.warn("Invalid state change requested: " + "Cannot go from %s to %s - ignoring request" % + (BuildRequest.REQUEST_STATE[self.old_state][1], + BuildRequest.REQUEST_STATE[self.state][1]) + ) + # Set property back to the old value + self.state = self.old_state + return + + super(BuildRequest, self).save(*args, **kwargs) + + def get_duration(self): return (self.updated - self.created).total_seconds()
Signature · 1 line
2.1.4
PATCH v6 26/41 buildinfohelper: Add handler for cancelling a build
In reply to Ed BartoshFrom: Michael Wood <[email protected]>
When a build is cancelled the build (action) is complete if it has been caused the request being cancelled then update the build outcome accordingly.
--- bitbake/lib/bb/ui/buildinfohelper.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
bitbake/lib/bb/ui/buildinfohelper.py +18 -1
@@ -215,6 +215,15 @@ class ORMWrapper(object): assert isinstance(errors, int) assert isinstance(warnings, int) + if build.outcome == Build.CANCELLED: + return + try: + if build.buildrequest.state == BuildRequest.REQ_CANCELLING: + return + except AttributeError: + # We may not have a buildrequest if this is a command line build + pass + outcome = Build.SUCCEEDED if errors or taskfailures: outcome = Build.FAILED
@@ -1389,9 +1398,17 @@ class BuildInfoHelper(object): be.lock = BuildEnvironment.LOCK_LOCK be.save() br = BuildRequest.objects.get(pk = br_id) + + # if we're 'done' because we got cancelled update the build outcome + if br.state == BuildRequest.REQ_CANCELLING: + logger.info("Build cancelled") + br.build.outcome = Build.CANCELLED + br.build.save() + errorcode = 0 + if errorcode == 0: # request archival of the project artifacts - br.state = BuildRequest.REQ_ARCHIVE + br.state = BuildRequest.REQ_COMPLETED else: br.state = BuildRequest.REQ_FAILED br.save()
Signature · 1 line
2.1.4
PATCH v6 27/41 toaster: tables BuildsTable exclude cancelled builds
In reply to Ed BartoshFrom: Sujith H <[email protected]>
Exclude cancelled builds from showing in the builds table
[YOCTO #6787]
--- bitbake/lib/toaster/toastergui/tables.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
bitbake/lib/toaster/toastergui/tables.py +3 -2
@@ -1080,8 +1080,9 @@ class BuildsTable(ToasterTable): """ queryset = self.get_builds() - # don't include in progress builds - queryset = queryset.exclude(outcome=Build.IN_PROGRESS) + # Don't include in progress builds pr cancelled builds + queryset = queryset.exclude(Q(outcome=Build.IN_PROGRESS) | + Q(outcome=Build.CANCELLED)) # sort queryset = queryset.order_by(self.default_orderby)
Signature · 1 line
2.1.4
PATCH v6 28/41 toaster: mrb_section template Add build cancel button
In reply to Ed BartoshFrom: Michael Wood <[email protected]>
Add the cancel build button to the mrb section template and add the event handlers to cancelABuild.
Also clean up the calls to startABuild to use the updated libtoaster methods and to make the code consistent with it's cancelABuild counterpart.
Co-Author: Sujith H <[email protected]>
--- .../lib/toaster/toastergui/static/js/mrbsection.js | 95 +++++++++++++ .../toaster/toastergui/templates/mrb_section.html | 148 ++++++++------------- 2 files changed, 149 insertions(+), 94 deletions(-) create mode 100644 bitbake/lib/toaster/toastergui/static/js/mrbsection.js
bitbake/lib/toaster/toastergui/static/js/mrbsection.js new file +95 -0
@@ -0,0 +1,95 @@ + +function mrbSectionInit(ctx){ + + var projectBuilds; + + if (ctx.mrbType === 'project') + projectBuilds = true; + + $(".cancel-build-btn").click(function(e){ + e.preventDefault(); + + var url = $(this).data('request-url'); + var buildReqIds = $(this).data('buildrequest-id'); + var banner = $(this).parents(".alert"); + + banner.find(".progress-info").fadeOut().promise().done(function(){ + $("#cancelling-msg-" + buildReqIds).show(); + console.log("cancel build"); + libtoaster.cancelABuild(url, buildReqIds, function(){ + if (projectBuilds == false){ + /* the all builds page is not 'self updating' like thei + * project Builds + */ + window.location.reload(); + } + }, null); + }); + }); + + $(".run-again-btn").click(function(e){ + e.preventDefault(); + + var url = $(this).data('request-url'); + var target = $(this).data('target'); + + libtoaster.startABuild(url, target, function(){ + window.location.reload(); + }, null); + }); + + + var progressTimer; + + if (projectBuilds === true){ + progressTimer = window.setInterval(function() { + libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl, + function(prjInfo){ + /* These two are needed because a build can be 100% and still + * in progress due to the fact that the % done is updated at the + * start of a task so it can be doing the last task at 100% + */ + var inProgress = 0; + var allPercentDone = 0; + if (prjInfo.builds.length === 0) + return + + for (var i in prjInfo.builds){ + var build = prjInfo.builds[i]; + + if (build.outcome === "In Progress" || + $(".progress .bar").length > 0){ + /* Update the build progress */ + var percentDone; + + if (build.outcome !== "In Progress"){ + /* We have to ignore the value when it's Succeeded because it + * goes back to 0 + */ + percentDone = 100; + } else { + percentDone = build.percentDone; + inProgress++; + } + + $("#build-pc-done-" + build.id).text(percentDone); + $("#build-pc-done-title-" + build.id).attr("title", percentDone); + $("#build-pc-done-bar-" + build.id).css("width", + String(percentDone) + "%"); + + allPercentDone += percentDone; + } + } + + if (allPercentDone === (100 * prjInfo.builds.length) && !inProgress) + window.location.reload(); + + /* Our progress bar is not still showing so shutdown the polling. */ + if ($(".progress .bar").length === 0) + window.clearInterval(progressTimer); + + }); + }, 1500); + } +} +
bitbake/lib/toaster/toastergui/templates/mrb_section.html +54 -94
177 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v6 29/41 toaster: models Exclude the CANCELLED builds from get_number_of_builds
In reply to Ed BartoshFrom: Michael Wood <[email protected]>
Don't count CANCELLED builds when returning the number of builds.
--- bitbake/lib/toaster/orm/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
bitbake/lib/toaster/orm/models.py +4 -1
@@ -197,7 +197,10 @@ class Project(models.Model): def get_number_of_builds(self): """Return the number of builds which have ended""" - return self.build_set.filter(~Q(outcome=Build.IN_PROGRESS)).count() + return self.build_set.exclude( + Q(outcome=Build.IN_PROGRESS) | + Q(outcome=Build.CANCELLED) + ).count() def get_last_build_id(self): try:
Signature · 1 line
2.1.4
PATCH v6 30/41 toaster: runbuilds Make runbuilds aware of the build CANCELLED state
In reply to Ed BartoshFrom: Michael Wood <[email protected]>
Add handlers to make sure we remove the BuildEnvironment LOCK when we have cancelled a build.
--- .../bldcontrol/management/commands/runbuilds.py | 26 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py +22 -4
@@ -1,5 +1,7 @@ from django.core.management.base import NoArgsCommand, CommandError from django.db import transaction +from django.db.models import Q + from orm.models import Build, ToasterSetting, LogMessage, Target from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException, BuildSetupException from bldcontrol.models import BuildRequest, BuildEnvironment, BRError, BRVariable
@@ -86,13 +88,20 @@ class Command(NoArgsCommand): def cleanup(self): from django.utils import timezone from datetime import timedelta - # environments locked for more than 30 seconds - they should be unlocked - BuildEnvironment.objects.filter(buildrequest__state__in=[BuildRequest.REQ_FAILED, BuildRequest.REQ_COMPLETED]).filter(lock=BuildEnvironment.LOCK_LOCK).filter(updated__lt = timezone.now() - timedelta(seconds = 30)).update(lock = BuildEnvironment.LOCK_FREE) - - # update all Builds that failed to start for br in BuildRequest.objects.filter(state = BuildRequest.REQ_FAILED, build__outcome = Build.IN_PROGRESS): + # environments locked for more than 30 seconds + # they should be unlocked + BuildEnvironment.objects.filter( + Q(buildrequest__state__in=[BuildRequest.REQ_FAILED, + BuildRequest.REQ_COMPLETED, + BuildRequest.REQ_CANCELLING]) & + Q(lock=BuildEnvironment.LOCK_LOCK) & + Q(updated__lt=timezone.now() - timedelta(seconds = 30)) + ).update(lock=BuildEnvironment.LOCK_FREE) + + # transpose the launch errors in ToasterExceptions br.build.outcome = Build.FAILED for brerror in br.brerror_set.all():
@@ -125,6 +134,15 @@ class Command(NoArgsCommand): br.build.save() pass + # Make sure the LOCK is removed for builds which have been fully + # cancelled + for br in BuildRequest.objects.filter( + Q(build__outcome=Build.CANCELLED) & + Q(state=BuildRequest.REQ_CANCELLING) & + ~Q(environment=None)): + br.environment.lock = BuildEnvironment.LOCK_FREE + br.environment.save() + def handle_noargs(self, **options): while True:
Signature · 1 line
2.1.4
PATCH v6 31/41 toaster: runbuilds Clean up runbuilds
In reply to Ed BartoshFrom: Michael Wood <[email protected]>
- Organise the imports into logical groups
- Fix 80 col wrapping
- Remove catch all exceptions
- Log to the toaster log
- Use QuerySet functions such as .first() and Q()
--- .../bldcontrol/management/commands/runbuilds.py | 81 ++++++++++++++-------- 1 file changed, 52 insertions(+), 29 deletions(-)
bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py +52 -29
@@ -2,18 +2,25 @@ from django.core.management.base import NoArgsCommand, CommandError from django.db import transaction from django.db.models import Q +from bldcontrol.bbcontroller import getBuildEnvironmentController +from bldcontrol.bbcontroller import ShellCmdException, BuildSetupException +from bldcontrol.models import BuildRequest, BuildEnvironment +from bldcontrol.models import BRError, BRVariable + from orm.models import Build, ToasterSetting, LogMessage, Target -from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException, BuildSetupException -from bldcontrol.models import BuildRequest, BuildEnvironment, BRError, BRVariable + import os import logging import time +import sys +import traceback -logger = logging.getLogger("ToasterScheduler") +logger = logging.getLogger("toaster") class Command(NoArgsCommand): args = "" - help = "Schedules and executes build requests as possible. Does not return (interrupt with Ctrl-C)" + help = "Schedules and executes build requests as possible." + "Does not return (interrupt with Ctrl-C)" @transaction.atomic
@@ -25,21 +32,19 @@ class Command(NoArgsCommand): @transaction.atomic def _selectBuildRequest(self): - br = BuildRequest.objects.filter(state = BuildRequest.REQ_QUEUED).order_by('pk')[0] - br.state = BuildRequest.REQ_INPROGRESS - br.save() + br = BuildRequest.objects.filter(state=BuildRequest.REQ_QUEUED).first() return br def schedule(self): - import traceback try: - br = None - try: - # select the build environment and the request to build - br = self._selectBuildRequest() - except IndexError as e: - #logger.debug("runbuilds: No build request") + # select the build environment and the request to build + br = self._selectBuildRequest() + if br: + br.state = BuildRequest.REQ_INPROGRESS + br.save() + else: return + try: bec = self._selectBuildEnvironment() except IndexError as e:
@@ -49,15 +54,17 @@ class Command(NoArgsCommand): logger.debug("runbuilds: No build env") return - logger.debug("runbuilds: starting build %s, environment %s" % (str(br).decode('utf-8'), bec.be)) + logger.debug("runbuilds: starting build %s, environment %s" % \ + (str(br).decode('utf-8'), bec.be)) # let the build request know where it is being executed br.environment = bec.be br.save() # this triggers an async build - bec.triggerBuild(br.brbitbake, br.brlayer_set.all(), br.brvariable_set.all(), - br.brtarget_set.all(), "%d:%d" % (br.pk, bec.be.pk)) + bec.triggerBuild(br.brbitbake, br.brlayer_set.all(), + br.brvariable_set.all(), br.brtarget_set.all(), + "%d:%d" % (br.pk, bec.be.pk)) except Exception as e: logger.error("runbuilds: Error launching build %s" % e)
@@ -88,9 +95,6 @@ class Command(NoArgsCommand): def cleanup(self): from django.utils import timezone from datetime import timedelta - # update all Builds that failed to start - - for br in BuildRequest.objects.filter(state = BuildRequest.REQ_FAILED, build__outcome = Build.IN_PROGRESS): # environments locked for more than 30 seconds # they should be unlocked BuildEnvironment.objects.filter(
@@ -102,22 +106,30 @@ class Command(NoArgsCommand): ).update(lock=BuildEnvironment.LOCK_FREE) + # update all Builds that were in progress and failed to start + for br in BuildRequest.objects.filter( + state=BuildRequest.REQ_FAILED, + build__outcome=Build.IN_PROGRESS): # transpose the launch errors in ToasterExceptions br.build.outcome = Build.FAILED for brerror in br.brerror_set.all(): logger.debug("Saving error %s" % brerror) - LogMessage.objects.create(build = br.build, level = LogMessage.EXCEPTION, message = brerror.errmsg) + LogMessage.objects.create(build=br.build, + level=LogMessage.EXCEPTION, + message=brerror.errmsg) br.build.save() - # we don't have a true build object here; hence, toasterui didn't have a change to release the BE lock + # we don't have a true build object here; hence, toasterui + # didn't have a change to release the BE lock br.environment.lock = BuildEnvironment.LOCK_FREE br.environment.save() - # update all BuildRequests without a build created for br in BuildRequest.objects.filter(build = None): - br.build = Build.objects.create(project = br.project, completed_on = br.updated, started_on = br.created) + br.build = Build.objects.create(project=br.project, + completed_on=br.updated, + started_on=br.created) br.build.outcome = Build.FAILED try: br.build.machine = br.brvariable_set.get(name='MACHINE').value
@@ -126,13 +138,16 @@ class Command(NoArgsCommand): br.save() # transpose target information for brtarget in br.brtarget_set.all(): - Target.objects.create(build=br.build, target=brtarget.target, task=brtarget.task) + Target.objects.create(build=br.build, + target=brtarget.target, + task=brtarget.task) # transpose the launch errors in ToasterExceptions for brerror in br.brerror_set.all(): - LogMessage.objects.create(build = br.build, level = LogMessage.EXCEPTION, message = brerror.errmsg) + LogMessage.objects.create(build=br.build, + level=LogMessage.EXCEPTION, + message=brerror.errmsg) br.build.save() - pass # Make sure the LOCK is removed for builds which have been fully # cancelled
@@ -148,9 +163,17 @@ class Command(NoArgsCommand): while True: try: self.cleanup() + except Exception as e: + logger.warn("runbuilds: cleanup exception %s" % str(e)) + + try: self.archive() + except Exception as e: + logger.warn("runbuilds: archive exception %s" % str(e)) + + try: self.schedule() - except: - pass + except Exception as e: + logger.warn("runbuilds: schedule exception %s" % str(e)) time.sleep(1)
Signature · 1 line
2.1.4
PATCH v6 32/41 toaster: fix conflicting migrations
In reply to Ed BartoshFixed by running manage.py makemigrations --merge
--- bitbake/lib/toaster/bldcontrol/migrations/0003_merge.py | 15 +++++++++++++++ bitbake/lib/toaster/orm/migrations/0007_merge.py | 15 +++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 bitbake/lib/toaster/bldcontrol/migrations/0003_merge.py create mode 100644 bitbake/lib/toaster/orm/migrations/0007_merge.py
bitbake/lib/toaster/bldcontrol/migrations/0003_merge.py new file +15 -0
@@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('bldcontrol', '0002_add_cancelling_state'), + ('bldcontrol', '0002_auto_20160120_1250'), + ] + + operations = [ + ]
bitbake/lib/toaster/orm/migrations/0007_merge.py new file +15 -0
@@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('orm', '0006_add_cancelled_state'), + ('orm', '0006_remove_build_build_name'), + ] + + operations = [ + ]
Signature · 1 line
2.1.4
PATCH v6 33/41 toaster: use empty token
In reply to Ed BartoshIf client xmlrpc token is not provided in the command line, bitbake generates random token. Server token in --server-only mode is always empty. This prevents clients with non-empty tokens to communicate with the server. Specifying empty token should prevent generation of random token and makes it possible to communicate with the server.
--- bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +1 -1
@@ -319,7 +319,7 @@ class LocalhostBEController(BuildEnvironmentController): # run build with local bitbake. stop the server after the build. log = os.path.join(builddir, 'toaster_ui.log') self._shellcmd(['bash -c \"(TOASTER_BRBE="%s" BBSERVER="0.0.0.0:-1" ' - '../bitbake/bin/bitbake %s -u toasterui >>%s 2>&1;' + '../bitbake/bin/bitbake %s -u toasterui --token="" >>%s 2>&1;' 'BITBAKE_UI="" BBSERVER=0.0.0.0:-1 %s -m)&\"' \ % (brbe, bbtargets, log, bitbake)], builddir, nowait=True)
Signature · 1 line
2.1.4
PATCH v6 34/41 toaster: add DL_DIR and SSTATE_DIR to poky toasterconf
In reply to Ed BartoshFrom: Sujith H <[email protected]>
[YOCTO #8422]
--- meta-poky/conf/toasterconf.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
meta-poky/conf/toasterconf.json +3 -1
@@ -2,9 +2,11 @@ "config": { "MACHINE" : "qemux86", "DISTRO" : "poky", + "DL_DIR" : "${TOPDIR}/../downloads", "IMAGE_FSTYPES": "ext3 jffs2 tar.bz2", "IMAGE_INSTALL_append": "", - "PACKAGE_CLASSES": "package_rpm" + "PACKAGE_CLASSES": "package_rpm", + "SSTATE_DIR" : "${TOPDIR}/../sstate-cache" }, "layersources": [ {
Signature · 1 line
2.1.4
PATCH v6 35/41 toaster: add DL_DIR and SSTATE_DIR to oe toasterconf
In reply to Ed Bartosh--- meta/conf/toasterconf.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
meta/conf/toasterconf.json +3 -1
@@ -2,9 +2,11 @@ "config": { "MACHINE" : "qemux86", "DISTRO" : "poky", + "DL_DIR" : "${TOPDIR}/../downloads", "IMAGE_FSTYPES": "ext3 jffs2 tar.bz2", "IMAGE_INSTALL_append": "", - "PACKAGE_CLASSES": "package_rpm" + "PACKAGE_CLASSES": "package_rpm", + "SSTATE_DIR" : "${TOPDIR}/../sstate-cache" }, "layersources": [ {
Signature · 1 line
2.1.4
PATCH v6 36/41 toaster: update view to support DL_DIR and SSTATE_DIR
In reply to Ed BartoshFrom: Sujith H <[email protected]>
Update toaster's views.py to support DL_DIR and SSTATE_DIR for page projectconf.html. Removed DL_DIR and SSTATE_DIR from blacklist. Initial value of DL_DIR and SSTATE_DIR comes from BuildEnvironment.
[YOCTO #8422]
--- bitbake/lib/toaster/toastergui/views.py | 40 +++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)
bitbake/lib/toaster/toastergui/views.py +38 -2
@@ -45,6 +45,7 @@ from django.utils import formats from toastergui.templatetags.projecttags import json as jsonfilter from decimal import Decimal import json +import os from os.path import dirname from functools import wraps import itertools
@@ -1875,6 +1876,7 @@ def managedcontextprocessor(request): import toastermain.settings from orm.models import Project, ProjectLayer, ProjectTarget, ProjectVariable +from bldcontrol.models import BuildEnvironment # we have a set of functions if we're in managed mode, or # a default "page not available" simple functions for interactive mode
@@ -2177,6 +2179,10 @@ if True: except ProjectVariable.DoesNotExist: pass try: + return_data['dl_dir'] = ProjectVariable.objects.get(project = prj, name = "DL_DIR").value, + except ProjectVariable.DoesNotExist: + pass + try: return_data['fstypes'] = ProjectVariable.objects.get(project = prj, name = "IMAGE_FSTYPES").value, except ProjectVariable.DoesNotExist: pass
@@ -2188,6 +2194,10 @@ if True: return_data['package_classes'] = ProjectVariable.objects.get(project = prj, name = "PACKAGE_CLASSES").value, except ProjectVariable.DoesNotExist: pass + try: + return_data['sstate_dir'] = ProjectVariable.objects.get(project = prj, name = "SSTATE_DIR").value, + except ProjectVariable.DoesNotExist: + pass return HttpResponse(json.dumps( return_data ), content_type = "application/json")
@@ -2728,9 +2738,9 @@ if True: } vars_blacklist = { - 'DL_DR','PARALLEL_MAKE','BB_NUMBER_THREADS','SSTATE_DIR', + 'PARALLEL_MAKE','BB_NUMBER_THREADS', 'BB_DISKMON_DIRS','BB_NUMBER_THREADS','CVS_PROXY_HOST','CVS_PROXY_PORT', - 'DL_DIR','PARALLEL_MAKE','SSTATE_DIR','SSTATE_DIR','SSTATE_MIRRORS','TMPDIR', + 'PARALLEL_MAKE','SSTATE_MIRRORS','TMPDIR', 'all_proxy','ftp_proxy','http_proxy ','https_proxy' }
@@ -2768,6 +2778,19 @@ if True: except ProjectVariable.DoesNotExist: pass try: + if ProjectVariable.objects.get(project = prj, name = "DL_DIR").value == "${TOPDIR}/../downloads": + be = BuildEnvironment.objects.get(pk = str(1)) + dl_dir = os.path.join(dirname(be.builddir), "downloads") + context['dl_dir'] = dl_dir + pv, created = ProjectVariable.objects.get_or_create(project = prj, name = "DL_DIR") + pv.value = dl_dir + pv.save() + else: + context['dl_dir'] = ProjectVariable.objects.get(project = prj, name = "DL_DIR").value + context['dl_dir_defined'] = "1" + except ProjectVariable.DoesNotExist,BuildEnvironment.DoesNotExist: + pass + try: context['fstypes'] = ProjectVariable.objects.get(project = prj, name = "IMAGE_FSTYPES").value context['fstypes_defined'] = "1" except ProjectVariable.DoesNotExist:
@@ -2782,6 +2805,19 @@ if True: context['package_classes_defined'] = "1" except ProjectVariable.DoesNotExist: pass + try: + if ProjectVariable.objects.get(project = prj, name = "SSTATE_DIR").value == "${TOPDIR}/../sstate-cache": + be = BuildEnvironment.objects.get(pk = str(1)) + sstate_dir = os.path.join(dirname(be.builddir), "sstate-cache") + context['sstate_dir'] = sstate_dir + pv, created = ProjectVariable.objects.get_or_create(project = prj, name = "SSTATE_DIR") + pv.value = sstate_dir + pv.save() + else: + context['sstate_dir'] = ProjectVariable.objects.get(project = prj, name = "SSTATE_DIR").value + context['sstate_dir_defined'] = "1" + except ProjectVariable.DoesNotExist, BuildEnvironment.DoesNotExist: + pass return context
Signature · 1 line
2.1.4
PATCH v6 37/41 toaster: update projectconf.html for DL_DIR and SSTATE_DIR
In reply to Ed BartoshFrom: Sujith H <[email protected]>
Modified the projectconf.html to include DL_DIR and SSTATE_DIR. Updated the script section in the html to handle the changes made by the user on DL_DIR and SSTATE_DIR. Included validation check for the folder names.
[YOCTO #8422]
--- .../toaster/toastergui/templates/projectconf.html | 160 ++++++++++++++++++++- 1 file changed, 157 insertions(+), 3 deletions(-)
bitbake/lib/toaster/toastergui/templates/projectconf.html +157 -3
@@ -31,6 +31,28 @@ </dd> {% endif %} + {% if dl_dir_defined %} + <dt> + <span class="js-config-var-name js-config-var-managed-name">DL_DIR</span> + <i class="icon-question-sign get-help" title="Absolute path to the directory used to store downloads required for your builds. By default, Toaster projects share the same downloads directory.<br /><a href='http://www.yoctoproject.org/docs/2.1/ref-manual/ref-manual.html#var-DL_DIR' target='_blank'>Read more in the manual</a>"></i> + </dt> + <dd class="lead"> + <span id="dl_dir"{% if dl_dir %}{%else%} class="muted"{%endif%}>{% if dl_dir %}{{dl_dir}}{%else%}Not set{%endif%}</span> + <i class="icon-pencil" id="change-dl_dir-icon"></i> + <form id="change-dl_dir-form" style="display:none;"> + <div class="row-fluid"> + <span class="help-block span4">To set DL_DIR type the absolute path of the download folder.</span> + </div> + <div class="input-append" id="validate-dl_dir"> + <input type="text" class="input-xlarge" id="new-dl_dir" placeholder="Type absolute path of the DL_DIR folder"> + <button id="apply-change-dl_dir" class="btn" type="button">Save</button> + <button id="cancel-change-dl_dir" type="button" class="btn btn-link">Cancel</button> + </br><span class="help-block error" id="hintError-dl_dir">A valid directory cannot include spaces or any of these characters: . \ ? % * : | " " < ></span> + </div> + </form> + </dd> + {% endif %} + {% if fstypes_defined %} <dt> <span class="js-config-var-name js-config-var-managed-name">IMAGE_FSTYPES</span>
@@ -107,6 +129,29 @@ </form> </dd> {% endif %} + + {% if sstate_dir_defined %} + <dt> + <span class="js-config-var-name js-config-var-managed-name">SSTATE_DIR</span> + <i class="icon-question-sign get-help" title="Absolute path to the directory used to store shared state cache files. These files are reused across the builds, which makes the builds faster. By default, Toaster projects share the same cache directory.<br /><a href='http://www.yoctoproject.org/docs/2.1/ref-manual/ref-manual.html#var-SSTATE_DIR' target='_blank'>Read more in the manual</a>"></i> + </dt> + <dd class="lead"> + <span id="sstate_dir"{% if sstate_dir %}{%else%} class="muted"{%endif%}>{% if sstate_dir %}{{sstate_dir}}{%else%}Not set{%endif%}</span> + <i class="icon-pencil" id="change-sstate_dir-icon"></i> + <form id="change-sstate_dir-form" style="display:none;"> + <div class="row-fluid"> + <span class="help-block span4">To set SSTATE_DIR type the absolute path of the download folder.</span> + </div> + <div class="input-append" id="validate-sstate_dir"> + <input type="text" class="input-xlarge" id="new-sstate_dir" placeholder="Type absolute path of the SSTATE_DIR folder"> + <span class="error">A valid directory name required</span> + <button id="apply-change-sstate_dir" class="btn" type="button">Save</button> + <button id="cancel-change-sstate_dir" type="button" class="btn btn-link">Cancel</button> + </br><p class="help-block error" id="hintError-sstate_dir">A valid directory cannot include spaces or any of these characters: . \ ? % * : | " " < ></span> + </div> + </form> + </dd> + {% endif %} </dl> <!-- <ul class="unstyled configuration-list" id="configvar-list"> -->
@@ -156,9 +201,7 @@ <code><a href="http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-BB_NUMBER_THREADS" target="_blank">BB_NUMBER_THREADS</a></code> <code>CVS_PROXY_HOST</code> <code>CVS_PROXY_PORT</code> - <code><a href="http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-DL_DIR" target="_blank">DL_DIR</a></code> <code><a href="http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-PARALLEL_MAKE" target="_blank">PARALLEL_MAKE</a></code> - <code><a href="http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-SSTATE_DIR" target="_blank">SSTATE_DIR</a></code> <code><a href="http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-SSTATE_MIRRORS" target="_blank">SSTATE_MIRRORS</a></code> <code><a href="http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-TMPDIR" target="_blank">TMPDIR</a></code></p> <p>Plus the following standard shell environment variables:</p>
@@ -501,6 +544,61 @@ }); {% endif %} + {% if dl_dir_defined %} + + // change DL_DIR variable + $('#change-dl_dir-icon').click(function() { + $('#hintError-dl_dir').hide(); + // preset the edit value + var current_val = $("span#dl_dir").text().trim(); + if (current_val == "Not set") { + current_val=""; + $("#apply-change-dl_dir").attr("disabled","disabled"); + } + $("input#new-dl_dir").val(current_val); + + $('#change-dl_dir-icon, #dl_dir').hide(); + $("#change-dl_dir-form").slideDown(); + }); + + $('#cancel-change-dl_dir').click(function(){ + $("#change-dl_dir-form").slideUp(function() { + $('#dl_dir, #change-dl_dir-icon').show(); + }); + }); + + $("#new-dl_dir").on('input', function(){ + if ($(this).val().trim().length == 0) { + $("#apply-change-dl_dir").attr("disabled","disabled"); + } + else { + var input = $(this); + var re = /^\/([^ <>\\|":\.%\?\*]+)$/; + var invalidDir = re.test(input.val()); + console.log(invalidDir); + if ( invalidDir ) { + $('#validate-dl_dir').removeClass('control-group error'); + $("#apply-change-dl_dir").removeAttr("disabled"); + $('#hintError-dl_dir').hide(); + } else { + $('#validate-dl_dir').addClass('control-group error'); + $("#apply-change-dl_dir").attr("disabled","disabled"); + $('#hintError-dl_dir').show(); + } + } + }); + + $('#apply-change-dl_dir').click(function(){ + var value = $('#new-dl_dir').val().trim(); + postEditAjaxRequest({"configvarChange" : 'DL_DIR:'+value}); + $('#dl_dir').text(value); + $('#dl_dir').removeClass('muted'); + $("#change-dl_dir-form").slideUp(function () { + $('#dl_dir, #change-dl_dir-icon').show(); + }); + }); + + {% endif %} {% if fstypes_defined %} // change IMAGE_FSTYPES variable
@@ -748,6 +846,62 @@ }); {% endif %} + {% if sstate_dir_defined %} + + // change SSTATE_DIR variable + $('#change-sstate_dir-icon').click(function() { + $('#hintError-sstate_dir').hide(); + // preset the edit value + var current_val = $("span#sstate_dir").text().trim(); + if (current_val == "Not set") { + current_val=""; + $("#apply-change-sstate_dir").attr("disabled","disabled"); + } + $("input#new-sstate_dir").val(current_val); + + $('#change-sstate_dir-icon, #sstate_dir').hide(); + $("#change-sstate_dir-form").slideDown(); + }); + + $('#cancel-change-sstate_dir').click(function(){ + $("#change-sstate_dir-form").slideUp(function() { + $('#sstate_dir, #change-sstate_dir-icon').show(); + }); + }); + + $("#new-sstate_dir").on('input', function(){ + if ($(this).val().trim().length == 0) { + $("#apply-change-sstate_dir").attr("disabled","disabled"); + } + else { + var input = $(this); + var re = /^\/([^ <>\\|":\.%\?\*]+)$/; + var invalidDir = re.test(input.val()); + console.log(invalidDir); + if ( invalidDir ) { + $('#validate-sstate_dir').removeClass('control-group error'); + $("#apply-change-sstate_dir").removeAttr("disabled"); + $('#hintError-sstate_dir').hide(); + } else { + $('#validate-sstate_dir').addClass('control-group error'); + $("#apply-change-sstate_dir").attr("disabled","disabled"); + $('#hintError-sstate_dir').show(); + } + } + }); + + $('#apply-change-sstate_dir').click(function(){ + var value = $('#new-sstate_dir').val().trim(); + postEditAjaxRequest({"configvarChange" : 'SSTATE_DIR:'+value}); + $('#sstate_dir').text(value); + $('#sstate_dir').removeClass('muted'); + $("#change-sstate_dir-form").slideUp(function () { + $('#sstate_dir, #change-sstate_dir-icon').show(); + }); + }); + + {% endif %} + // add new variable $("button#add-configvar-button").click( function (evt) { var variable = $("input#variable").val();
@@ -762,7 +916,7 @@ $(".save").attr("disabled","disabled"); // Reload page if admin-removed core managed value is manually added back in - if (0 <= " DISTRO IMAGE_FSTYPES IMAGE_INSTALL_append PACKAGE_CLASSES ".indexOf( " "+variable+" " )) { + if (0 <= " DISTRO DL_DIR IMAGE_FSTYPES IMAGE_INSTALL_append PACKAGE_CLASSES SSTATE_DIR ".indexOf( " "+variable+" " )) { // delayed reload to avoid race condition with postEditAjaxRequest do_reload=true; }
Signature · 1 line
2.1.4
PATCH v6 38/41 toaster: use bitbake from sourcedir/bitbake/bin
In reply to Ed BartoshIt was incorrectly assumed in current code that bitbake is in ../bitbake/bin/ directory. It's not always the case. Using bitbake from poky sourcedir/bitbake/bin/ should be better.
--- bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +4 -3
@@ -318,11 +318,12 @@ class LocalhostBEController(BuildEnvironmentController): # run build with local bitbake. stop the server after the build. log = os.path.join(builddir, 'toaster_ui.log') + local_bitbake = os.path.join(self.be.sourcedir, 'bitbake', 'bin', 'bitbake') self._shellcmd(['bash -c \"(TOASTER_BRBE="%s" BBSERVER="0.0.0.0:-1" ' - '../bitbake/bin/bitbake %s -u toasterui --token="" >>%s 2>&1;' + '%s %s -u toasterui --token="" >>%s 2>&1;' 'BITBAKE_UI="" BBSERVER=0.0.0.0:-1 %s -m)&\"' \ - % (brbe, bbtargets, log, bitbake)], builddir, - nowait=True) + % (brbe, local_bitbake, bbtargets, log, bitbake)], + builddir, nowait=True) logger.debug('localhostbecontroller: Build launched, exiting. ' 'Follow build logs at %s' % log)
Signature · 1 line
2.1.4
PATCH v6 39/41 toasterui: detect build run start correctly on Jethro
In reply to Ed BartoshFrom: Elliot Smith <[email protected]>
We currently use the TargetsAcquired event fired by the XMLRPC server to mark the start of a build run from the command line. At this point, we create the Build object in buildinfohelper, then append targets etc. to it as the run continues.
However, on Jethro, this event isn't fired. This means that we can't support builds with the Jethro release correctly, as a Build object is never created.
Add a condition so that we can create a Build object when building with Jethro by falling back to the BuildStarted event. Jethro builds which fail early (bad target, bad MACHINE, bad DISTRO etc.) will not be captured (as we need the TargetsAcquired event for that), but other builds which succeed or fail later will be captured.
--- bitbake/lib/bb/ui/buildinfohelper.py | 9 +++------ bitbake/lib/bb/ui/toasterui.py | 26 +++++++++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-)
bitbake/lib/bb/ui/buildinfohelper.py +3 -6
@@ -979,18 +979,15 @@ class BuildInfoHelper(object): build_information = self._get_build_information(build_log_path) self.internal_state['build'] = self.orm_wrapper.create_build_object(build_information, self.brbe) - def store_targets(self, event): + def store_targets(self, targets): """ store targets for the current build, if that build was started from the command line; targets for non-cli builds are irrelevant, as we create them from the BuildRequest anyway - event: a TargetsAcquired event with a task property (e.g. "build") - and a targetsList property (e.g. ["zlib", "dropbear"]) + targets: a list of targets for the build, e.g. + ["zlib:build", "dropbear:build"] """ - targets = map(lambda target: target + ':' + event.task, - event.targetsList) - target_information = { 'targets': targets, 'build': self.internal_state['build']
bitbake/lib/bb/ui/toasterui.py +19 -7
@@ -232,18 +232,30 @@ def main(server, eventHandler, params): # pylint: disable=protected-access # the code will look into the protected variables of the event; no easy way around this - # start of build: this event is fired just before the buildTargets() - # command is invoked on the XMLRPC server - if isinstance(event, bb.event.TargetsAcquired): + # start of build: TargetsAcquired event is fired just before the + # buildTargets() command is invoked on the XMLRPC server; if + # we are on Jethro, we don't get TargetsAcquired, so treat + # BuildStarted as the start of the build instead + targets_acquired = isinstance(event, bb.event.TargetsAcquired) + build_started = isinstance(event, bb.event.BuildStarted) + + if targets_acquired or build_started: if not (build_log and build_log_file_path): build_log, build_log_file_path = _open_build_log(log_dir) - buildinfohelper.store_new_build(build_log_file_path) - buildinfohelper.store_targets(event) - continue + buildinfohelper.store_new_build(build_log_file_path) + + # BuildStarted signals the start of the build on Toaster 2.0, + # TargetsAcquired signals it on Toaster 2.1+ + if build_started: + targets = event._pkgs + else: + targets = map(lambda target: target + ':' + event.task, event.targetsList) + + buildinfohelper.store_targets(targets) # when the build proper starts, we extract information about # any layers and config data - if isinstance(event, bb.event.BuildStarted): + if build_started: buildinfohelper.update_build(event) continue
Signature · 1 line
2.1.4
PATCH v6 40/41 buildinfohelper: fix KeyError
In reply to Ed BartoshWhen bitbake doesn't need to build anything it still sends ImagePkgList event with empty 'pkgdata', 'imgdata' and 'filedata' fields. This causes crash in buildinfohelper code as it's assumed that above mentioned fields always have data keyed by build target:
ERROR: u'core-image-minimal'
Traceback (most recent call last):
File "toasterui.py", line 423, in main
buildinfohelper.store_target_package_data(event)
File "buildinfohelper.py", line 1218, in store_target_package_data
imgdata = BuildInfoHelper._get_data_from_event(event)['imgdata'][target.target]
KeyError: u'core-image-minimal'
Fixed this by using dict.get method with empty dictionary as default return value instead of trying to get value without checking if target key is in the data.
--- bitbake/lib/bb/ui/buildinfohelper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
bitbake/lib/bb/ui/buildinfohelper.py +2 -2
@@ -1215,8 +1215,8 @@ class BuildInfoHelper(object): for target in self.internal_state['targets']: if target.is_image: pkgdata = BuildInfoHelper._get_data_from_event(event)['pkgdata'] - imgdata = BuildInfoHelper._get_data_from_event(event)['imgdata'][target.target] - filedata = BuildInfoHelper._get_data_from_event(event)['filedata'][target.target] + imgdata = BuildInfoHelper._get_data_from_event(event)['imgdata'].get(target.target, {}) + filedata = BuildInfoHelper._get_data_from_event(event)['filedata'].get(target.target, {}) try: self.orm_wrapper.save_target_package_information(self.internal_state['build'], target, imgdata, pkgdata, self.internal_state['recipes'], built_package=True)
Signature · 1 line
2.1.4
PATCH v6 41/41 toasterui: fix warning 'Unknown event'
In reply to Ed BartoshFixed this warning:
WARNING: Unknown event: <bb.event.TargetsAcquired object at 0x7f95b8753d50> by ensuring that code continues the main event loop
after processing TargetsAcquired event.
--- bitbake/lib/bb/ui/toasterui.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
bitbake/lib/bb/ui/toasterui.py +4 -4
@@ -253,10 +253,10 @@ def main(server, eventHandler, params): buildinfohelper.store_targets(targets) - # when the build proper starts, we extract information about - # any layers and config data - if build_started: - buildinfohelper.update_build(event) + # when the build proper starts, we extract information about + # any layers and config data + if build_started: + buildinfohelper.update_build(event) continue if isinstance(event, (bb.build.TaskStarted, bb.build.TaskSucceeded, bb.build.TaskFailedSilent)):
Signature · 1 line
2.1.4