Skip to contentSkip to conversation

toaster: Merge analysis and managed modes

PATCH In review brian avery 4 participants 36 messages Dec 2, 2015 – Dec 7, 2015

lore
Share & tools
lore
#0 lore raw

cover toaster: Merge analysis and managed modes

This large patchset merges the analysis (cli) and managed (toaster ui) modes so that toaster can be started in one way (sourced just like oe-init-build-env) and can then handle builds of both types.
-brian

The following changes since commit f09bf40d0d1a6fbaf2251f903d41d970c8a66e3a:

toaster: toastergui tests Add generic test for ToasterTables widget (2015-12-02 10:41:34 +0000)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib bavery/submit/ed/2015-12-2_runOneWay-8279
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=bavery/submit/ed/2015-12-2_runOneWay-8279

Ed Bartosh (29):
toaster: don't allow to run toaster as a script
toaster: implement get-dburl command
toaster: set DATABASE_URL in toaster script
toaster: run bitbake the same way
toaster: remove unused variable
toaster: check for toaster configuration later
toaster: use parent of the build dir
toaster: make runbuilds to loop
toaster: start 'manage.py runbuilds' in the script
toaster: update brbe and project attributes
toaster: implement stop_bitbake function
toaster: implement start_bitbake function
toaster: implement 'toaster restart-bitbake'
toaster: remove _setupBE function
toaster: reimplemented startBBServer method
toaster: remove stopBBServer API
toaster: do not terminate bb server
toaster: remove usage of BUILD_MODE variable
toaster: do not create duplicate HelpText objects
toaster: implement BitbakeController.getVariable
toaster: set varibales on bitbake server
toaster: remove writeConfFile API
toaster: stop using toaster-pre.conf
toaster: remove SDKMACHINE from project variables
toaster: get rid of complicated heuristics
toaster: unset environment variables
command: add CommandStarted event
bb/ui: ignore CommandStarted event
toasterui: process CommandStarted event

Michael Wood (1):
toaster: buildinfohelper Broaden the toaster created recipe data case

 bin/toaster                                        | 166 +++++++++------------
 lib/bb/command.py                                  |   6 +
 lib/bb/ui/buildinfohelper.py                       |  68 +++------
 lib/bb/ui/crumbs/runningbuild.py                   |   3 +-
 lib/bb/ui/knotty.py                                |   3 +-
 lib/bb/ui/toasterui.py                             |  21 +--
 lib/toaster/bldcontrol/bbcontroller.py             |  15 +-
 lib/toaster/bldcontrol/localhostbecontroller.py    | 140 ++++-------------
 .../bldcontrol/management/commands/runbuilds.py    |  13 +-
 lib/toaster/bldcontrol/sshbecontroller.py          |  10 --
 lib/toaster/bldcontrol/tests.py                    |   4 -
 lib/toaster/toastergui/templates/base.html         |   9 +-
 lib/toaster/toastergui/templates/landing.html      |  10 --
 lib/toaster/toastergui/templates/projectconf.html  |  70 +--------
 lib/toaster/toastergui/tests.py                    |   4 -
 lib/toaster/toastergui/views.py                    |  29 ----
 .../toastermain/management/commands/get-dburl.py   |   9 ++
 lib/toaster/toastermain/settings.py                |   3 -
 lib/toaster/toastermain/urls.py                    |   9 +-
 19 files changed, 167 insertions(+), 425 deletions(-)
 create mode 100644 bitbake/lib/toaster/toastermain/management/commands/get-dburl.py

--
1.9.1

#1 lore raw

PATCH 1/30 toaster: don't allow to run toaster as a script

From: Ed Bartosh <[email protected]>

Removed support of starting toaster as a script.

Sourcing a toaster script becomes the only way to start it. It's consistent with the way oe build system is started by sourcing oe-init-build-env. It also returns user back to shell, so user can continue running builds without having to open new terminal window.

[YOCTO #8279]

---
 bin/toaster | 80 ++++---------------------------------------------------------
 1 file changed, 5 insertions(+), 75 deletions(-)
bin/toaster +5 -75
index 432756c..7b510fc 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/echo ERROR: This script needs to be sourced. Please run as .
 # (c) 2013 Intel Corp.
 
 # This program is free software; you can redistribute it and/or modify
@@ -81,9 +81,7 @@ webserverStartAll()
         return $retval
     fi
 
-    if [ "$TOASTER_MANAGED" = '1' ]; then
-        python $BBBASEDIR/lib/toaster/manage.py checksettings --traceback || retval=1
-    fi
+    python $BBBASEDIR/lib/toaster/manage.py checksettings --traceback || retval=1
 
     if [ $retval -eq 1 ]; then
         printf "\nError while checking settings; aborting\n"
@@ -176,8 +174,6 @@ else
     TOASTER=$0
 fi
 
-[ `basename \"$0\"` = `basename \"${TOASTER}\"` ] && TOASTER_MANAGED=1
-
 BBBASEDIR=`dirname $TOASTER`/..
 OEROOT=`dirname $TOASTER`/../..
 
@@ -250,88 +246,22 @@ for param in $*; do
     esac
 done
 
-if [ "$TOASTER_MANAGED" = '1' ]; then
-    # We are called as standalone. We refuse to run in a build environment - we need the interactive mode for that.
-    # Start just the web server, point the web browser to the interface, and start any Django services.
-
-    if ! verify_prereq; then
-        echo "Error: Could not verify that the needed dependencies are installed. Please use virtualenv and pip to install dependencies listed in toaster-requirements.txt" 1>&2
-        exit 1
-    fi
-
-    if [ -n "$BUILDDIR" ]; then
-        printf "Error: It looks like you sourced oe-init-build-env. Toaster cannot start in build mode from an oe-core build environment.\n You should be starting Toaster from a new terminal window.\n" 1>&2
-        exit 1
-    fi
-
-    # Define a fake builddir where only the pid files are actually created. No real builds will take place here.
-    BUILDDIR=/tmp/toaster_$$
-    if [ -d "$BUILDDIR" ]; then
-        echo "Previous toaster run directory $BUILDDIR found, cowardly refusing to start. Please remove the directory when that toaster instance is over" 2>&1
-        exit 1
-    fi
-
-    mkdir -p "$BUILDDIR"
-
-    RUNNING=1
-    trap_ctrlc() {
-        echo "** Stopping system"
-        webserverKillAll
-        RUNNING=0
-    }
-
-    do_cleanup() {
-        find "$BUILDDIR" -type f | xargs rm
-        rmdir "$BUILDDIR"
-    }
-    cleanup() {
-        if grep -ir error "$BUILDDIR" >/dev/null; then
-            if grep -irn "That port is already in use" "$BUILDDIR"; then
-                echo "You can use the \"webport=PORTNUMBER\" parameter to start Toaster on a different port (port $WEB_PORT is already in use)"
-                do_cleanup
-            else
-                printf "\nErrors found in the Toaster log files present in '$BUILDDIR'. Directory will not be cleaned.\n Please review the errors and notify [email protected] or submit a bug https://bugzilla.yoctoproject.org/enter_bug.cgi?product=Toaster"
-            fi
-        else
-            echo "No errors found, removing the run directory '$BUILDDIR'"
-            do_cleanup
-        fi
-    }
-    export TOASTER_MANAGED=1
-    if [ $WEBSERVER -gt 0 ] && ! webserverStartAll; then
-        echo "Failed to start the web server, stopping" 1>&2
-        cleanup
-        exit 1
-    fi
-    if [ $WEBSERVER -gt 0 ] && [ $NOBROWSER -eq 0 ]  ; then
-        echo "Starting browser..."
-        xdg-open http://127.0.0.1:$WEB_PORT/ >/dev/null 2>&1 &
-    fi
-    trap trap_ctrlc 2
-    echo "Toaster is now running. You can stop it with Ctrl-C"
-    while [ $RUNNING -gt 0 ]; do
-        python $BBBASEDIR/lib/toaster/manage.py runbuilds 2>&1 | tee -a "$BUILDDIR/toaster.log"
-        sleep 1
-    done
-    cleanup
-    echo "**** Exit"
-    exit 0
+if [ `basename \"$0\"` = `basename \"${TOASTER}\"` ]; then
+    echo "Error: This script needs to be sourced. Please run as . $TOASTER"
+    exit 1
 fi
 
-
 if ! verify_prereq; then
     echo "Error: Could not verify that the needed dependencies are installed. Please use virtualenv and pip to install dependencies listed in toaster-requirements.txt" 1>&2
     return 1
 fi
 
-
 # We make sure we're running in the current shell and in a good environment
 if [ -z "$BUILDDIR" ] ||  ! which bitbake >/dev/null 2>&1 ; then
     echo "Error: Build environment is not setup or bitbake is not in path." 1>&2
     return 2
 fi
 
-
 # Determine the action. If specified by arguments, fine, if not, toggle it
 if [ "$1" = 'start' ] || [ "$1" = 'stop' ]; then
     CMD="$1"
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/30 toaster: implement get-dburl command

From: Ed Bartosh <[email protected]>

Implemented management command to call getDATABASE_URL API. It will be used to get database url from toaster shell script by running 'manage.py get-dburl'

---
 lib/toaster/toastermain/management/commands/get-dburl.py | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 bitbake/lib/toaster/toastermain/management/commands/get-dburl.py
lib/toaster/toastermain/management/commands/get-dburl.py new file +9 -0
new file mode 100644
index 0000000..22b3eb7
@@ -0,0 +1,9 @@
+from toastermain.settings import getDATABASE_URL
+from django.core.management.base import NoArgsCommand
+
+class Command(NoArgsCommand):
+    args    = ""
+    help    = "get database url"
+
+    def handle_noargs(self,**options):
+        print getDATABASE_URL()
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/30 toaster: set DATABASE_URL in toaster script

In reply to brian avery

From: Ed Bartosh <[email protected]>

Set environment variable DATABASE_URL in bitbake/bit/toaster Variable value is obtained by running 'manage.py get-dburl'

---
 bin/toaster | 1 +
 1 file changed, 1 insertion(+)
bin/toaster +1 -0
index 7b510fc..118c305 100755
@@ -316,6 +316,7 @@ case $CMD in
             echo "Bitbake server start failed"
         else
             export BBSERVER=0.0.0.0:-1
+            export DATABASE_URL=`$BBBASEDIR/lib/toaster/manage.py get-dburl`
             if [ $NOTOASTERUI -eq 0 ]; then        # we start the TOASTERUI only if not inhibited
                 bitbake --observe-only -u toasterui >>${BUILDDIR}/toaster_ui.log 2>&1 & echo $! >${BUILDDIR}/.toasterui.pid
             fi
Signature · 1 line
1.9.1
#4 lore raw

PATCH 4/30 toaster: run bitbake the same way

In reply to brian avery

From: Ed Bartosh <[email protected]>

Run bitbake in toaster script the same way as it's run by localbuildcontroller.

---
 bin/toaster | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
bin/toaster +4 -6
index 118c305..abc8737 100755
@@ -301,16 +301,13 @@ case $CMD in
     start )
         start_success=1
         addtoConfiguration toaster.conf "INHERIT+=\"toaster buildhistory\"" $TOASTER_BRBE
+        echo > ${BUILDDIR}/conf/toaster-pre.conf
         if [ $WEBSERVER -gt 0 ] && ! webserverStartAll; then
             echo "Failed ${CMD}."
             return 4
         fi
         unset BBSERVER
-        PREREAD=""
-        if [ -e ${BUILDDIR}/conf/toaster-pre.conf ]; then
-            rm ${BUILDDIR}/conf/toaster-pre.conf
-        fi
-        bitbake $PREREAD --postread conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:0
+        bitbake --read conf/toaster-pre.conf --postread conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:0
         if [ $? -ne 0 ]; then
             start_success=0
             echo "Bitbake server start failed"
@@ -318,7 +315,8 @@ case $CMD in
             export BBSERVER=0.0.0.0:-1
             export DATABASE_URL=`$BBBASEDIR/lib/toaster/manage.py get-dburl`
             if [ $NOTOASTERUI -eq 0 ]; then        # we start the TOASTERUI only if not inhibited
-                bitbake --observe-only -u toasterui >>${BUILDDIR}/toaster_ui.log 2>&1 & echo $! >${BUILDDIR}/.toasterui.pid
+                bitbake --observe-only -u toasterui --remote-server=$BBSERVER -t xmlrpc >>${BUILDDIR}/toaster_ui.log 2>&1 \
+                    & echo $! >${BUILDDIR}/.toasterui.pid
             fi
         fi
         if [ $start_success -eq 1 ]; then
Signature · 1 line
1.9.1
#5 lore raw

PATCH 5/30 toaster: remove unused variable

In reply to brian avery

From: Ed Bartosh <[email protected]>

Removed variable RUNNING as it's not used anymore
in the toaster script.

---
 bin/toaster | 2 --
 1 file changed, 2 deletions(-)
bin/toaster +0 -2
index abc8737..1ce4af7 100755
@@ -176,9 +176,7 @@ fi
 
 BBBASEDIR=`dirname $TOASTER`/..
 OEROOT=`dirname $TOASTER`/../..
-
 RUNNING=0
-
 NOTOASTERUI=0
 WEBSERVER=1
 TOASTER_BRBE=""
Signature · 1 line
1.9.1
#8 lore raw

PATCH 6/30 toaster: check for toaster configuration later

In reply to brian avery

From: Ed Bartosh <[email protected]>

Moved check for toasterconf.json after check of build environment. We'll need some variables from build environment to find toasterconf.json better way.

---
 bin/toaster | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
bin/toaster +24 -1
index 1ce4af7..359b23d 100755
@@ -222,7 +222,6 @@ fi
 # make sure that the toaster.sqlite file doesn't default to `pwd` like it currently does.
 export TOASTER_DIR=`pwd`
 
-
 NOBROWSER=0
 
 for param in $*; do
@@ -260,6 +259,30 @@ if [ -z "$BUILDDIR" ] ||  ! which bitbake >/dev/null 2>&1 ; then
     return 2
 fi
 
+# this is the configuraton file we are using for toaster
+# note default is assuming yocto. Override this if you are
+# running in a pure OE environment and use the toasterconf.json
+# in meta/conf/toasterconf.json
+# note: for future there are a number of relative path assumptions
+# in the local layers that currently prevent using an arbitrary
+# toasterconf.json
+if [ "$TOASTER_CONF" = "" ]; then
+    TOASTER_CONF="$(dirname $TOASTER)/../../meta-yocto/conf/toasterconf.json"
+    export TOASTER_CONF=$(python -c "import os; print os.path.realpath('$TOASTER_CONF')")
+fi
+if [ ! -f $TOASTER_CONF ]; then
+    echo "$TOASTER_CONF configuration file not found. set TOASTER_CONF to specify a path"
+    return 1
+fi
+# this defines the dir toaster will use for
+# 1) clones of layers (in _toaster_clones )
+# 2) the build dir (in build)
+# 3) the sqlite db if that is being used.
+# 4) pid's we need to clean up on exit/shutdown
+# note: for future. in order to make this an arbitrary directory, we need to
+# make sure that the toaster.sqlite file doesn't default to `pwd` like it currently does.
+export TOASTER_DIR=`pwd`
+
 # Determine the action. If specified by arguments, fine, if not, toggle it
 if [ "$1" = 'start' ] || [ "$1" = 'stop' ]; then
     CMD="$1"
Signature · 1 line
1.9.1
#9 lore raw

PATCH 7/30 toaster: use parent of the build dir

In reply to brian avery

From: Ed Bartosh <[email protected]>

Assigned TOASTER_DIR to the parent of the build directory. This should fix local controller crash as it assumes that TOASTER_DIR is a root of local poky and tries to clone it.

---
 bin/toaster | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bin/toaster +1 -1
index 359b23d..de03099 100755
@@ -281,7 +281,7 @@ fi
 # 4) pid's we need to clean up on exit/shutdown
 # note: for future. in order to make this an arbitrary directory, we need to
 # make sure that the toaster.sqlite file doesn't default to `pwd` like it currently does.
-export TOASTER_DIR=`pwd`
+export TOASTER_DIR=`dirname $BUILDDIR`
 
 # Determine the action. If specified by arguments, fine, if not, toggle it
 if [ "$1" = 'start' ] || [ "$1" = 'stop' ]; then
Signature · 1 line
1.9.1
#10 lore raw

PATCH 8/30 toaster: make runbuilds to loop

In reply to brian avery

From: Ed Bartosh <[email protected]>

Made runbuilds to loop to avoid having a loop in shell code and initialize heavy Django init machinery every second.

Ignored exceptions to prevent exiting a loop.

---
 lib/toaster/bldcontrol/management/commands/runbuilds.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
lib/toaster/bldcontrol/management/commands/runbuilds.py +10 -3
index 5243a50..48dc618 100644
@@ -5,6 +5,7 @@ from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdExcep
 from bldcontrol.models import BuildRequest, BuildEnvironment, BRError, BRVariable
 import os
 import logging
+import time
 
 logger = logging.getLogger("ToasterScheduler")
 
@@ -128,6 +129,12 @@ class Command(NoArgsCommand):
 
 
     def handle_noargs(self, **options):
-        self.cleanup()
-        self.archive()
-        self.schedule()
+        while True:
+            try:
+                self.cleanup()
+                self.archive()
+                self.schedule()
+            except:
+                pass
+
+            time.sleep(1)
Signature · 1 line
1.9.1
#11 lore raw

PATCH 9/30 toaster: start 'manage.py runbuilds' in the script

In reply to brian avery

From: Ed Bartosh <[email protected]>

Running runbuilds machinery in background allows Toaster to start builds initiated by toaster UI.

Added runbuilds pid file to the list in webserverKillAll to kill runbuilds the same way as runserver process.

---
 bin/toaster | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
bin/toaster +2 -1
index de03099..eb83e9a 100755
@@ -31,7 +31,7 @@
 webserverKillAll()
 {
     local pidfile
-    for pidfile in ${BUILDDIR}/.toastermain.pid; do
+    for pidfile in ${BUILDDIR}/.toastermain.pid ${BUILDDIR}/.runbuilds.pid; do
         if [ -f ${pidfile} ]; then
             pid=`cat ${pidfile}`
             while kill -0 $pid 2>/dev/null; do
@@ -339,6 +339,7 @@ case $CMD in
                 bitbake --observe-only -u toasterui --remote-server=$BBSERVER -t xmlrpc >>${BUILDDIR}/toaster_ui.log 2>&1 \
                     & echo $! >${BUILDDIR}/.toasterui.pid
             fi
+            python $BBBASEDIR/lib/toaster/manage.py runbuilds & echo $! >${BUILDDIR}/.runbuilds.pid
         fi
         if [ $start_success -eq 1 ]; then
             # set fail safe stop system on terminal exit
Signature · 1 line
1.9.1
#12 lore raw

PATCH 10/30 toaster: update brbe and project attributes

In reply to brian avery

From: Ed Bartosh <[email protected]>

Updated attributes of buildinfohelper object as they can be changed for every build. For example brbe is set by runbuilds for every build triggered by Toaster UI.

---
 lib/bb/ui/buildinfohelper.py | 6 ++++++
 1 file changed, 6 insertions(+)
lib/bb/ui/buildinfohelper.py +6 -0
index 78f1e92..43c243e 100644
@@ -796,6 +796,8 @@ class BuildInfoHelper(object):
         build_info['cooker_log_path'] = build_log_path
         build_info['build_name'] = self.server.runCommand(["getVariable", "BUILDNAME"])[0]
         build_info['bitbake_version'] = self.server.runCommand(["getVariable", "BB_VERSION"])[0]
+        build_info['brbe'] = self.server.runCommand(["getVariable", "TOASTER_BRBE"])[0]
+        build_info['project'] = self.project = self.server.runCommand(["getVariable", "TOASTER_PROJECT"])[0]
 
         return build_info
 
@@ -938,6 +940,10 @@ class BuildInfoHelper(object):
         assert '_pkgs' in vars(event)
         build_information = self._get_build_information(build_log_path)
 
+        # Update brbe and project as they can be changed for every build
+        self.brbe = build_information['brbe']
+        self.project = build_information['project']
+
         build_obj = self.orm_wrapper.create_build_object(build_information, self.brbe, self.project)
 
         self.internal_state['build'] = build_obj
Signature · 1 line
1.9.1
#13 lore raw

PATCH 11/30 toaster: implement stop_bitbake function

In reply to brian avery

From: Ed Bartosh <[email protected]>

Separated functionality of stopping bitbake server and observer processes.

This functionality will be used by build controllers to restart bitbake processes.

---
 bin/toaster | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
bin/toaster +8 -4
index eb83e9a..e82df9b 100755
@@ -126,16 +126,20 @@ stop_system()
         kill `cat ${BUILDDIR}/.toasterui.pid` 2>/dev/null
         rm ${BUILDDIR}/.toasterui.pid
     fi
-    BBSERVER=0.0.0.0:-1 bitbake -m
-    unset BBSERVER
+    stop_bitbake
     webserverKillAll
-    # force stop any misbehaving bitbake server
-    lsof bitbake.lock | awk '{print $2}' | grep "[0-9]\+" | xargs -n1 -r kill
     trap - SIGHUP
     #trap - SIGCHLD
     INSTOPSYSTEM=0
 }
 
+stop_bitbake() {
+    BBSERVER=0.0.0.0:-1 bitbake -m
+    unset BBSERVER
+    # force stop any misbehaving bitbake server
+    lsof bitbake.lock | awk '{print $2}' | grep "[0-9]\+" | xargs -n1 -r kill
+}
+
 check_pidbyfile() {
     [ -e $1 ] && kill -0 `cat $1` 2>/dev/null
 }
Signature · 1 line
1.9.1
#14 lore raw

PATCH 12/30 toaster: implement start_bitbake function

In reply to brian avery

From: Ed Bartosh <[email protected]>

Separated functionality of starting bitbake server and observer processes.

This functionality will be used by build controllers to restart bitbake processes.

---
 bin/toaster | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)
bin/toaster +18 -15
index e82df9b..34a4e8f 100755
@@ -133,6 +133,22 @@ stop_system()
     INSTOPSYSTEM=0
 }
 
+start_bitbake() {
+    unset BBSERVER
+    bitbake --read conf/toaster-pre.conf --postread 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=`$BBBASEDIR/lib/toaster/manage.py get-dburl`
+    if [ $NOTOASTERUI -eq 0 ]; then        # we start the TOASTERUI only if not inhibited
+        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
@@ -324,28 +340,15 @@ fi
 
 case $CMD in
     start )
-        start_success=1
         addtoConfiguration toaster.conf "INHERIT+=\"toaster buildhistory\"" $TOASTER_BRBE
         echo > ${BUILDDIR}/conf/toaster-pre.conf
         if [ $WEBSERVER -gt 0 ] && ! webserverStartAll; then
             echo "Failed ${CMD}."
             return 4
         fi
-        unset BBSERVER
-        bitbake --read conf/toaster-pre.conf --postread conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:0
-        if [ $? -ne 0 ]; then
-            start_success=0
-            echo "Bitbake server start failed"
-        else
-            export BBSERVER=0.0.0.0:-1
-            export DATABASE_URL=`$BBBASEDIR/lib/toaster/manage.py get-dburl`
-            if [ $NOTOASTERUI -eq 0 ]; then        # we start the TOASTERUI only if not inhibited
-                bitbake --observe-only -u toasterui --remote-server=$BBSERVER -t xmlrpc >>${BUILDDIR}/toaster_ui.log 2>&1 \
-                    & echo $! >${BUILDDIR}/.toasterui.pid
-            fi
+        start_bitbake
+        if [ $? -eq 0 ]; then
             python $BBBASEDIR/lib/toaster/manage.py runbuilds & echo $! >${BUILDDIR}/.runbuilds.pid
-        fi
-        if [ $start_success -eq 1 ]; then
             # set fail safe stop system on terminal exit
             trap stop_system SIGHUP
             echo "Successful ${CMD}."
Signature · 1 line
1.9.1
#15 lore raw

PATCH 13/30 toaster: implement 'toaster restart-bitbake'

In reply to brian avery

From: Ed Bartosh <[email protected]>

This implementation allows to have functionality of restarting bitbake in toaster script. It can be used by toaster script and build controllers.

[YOCTO #8279]

---
 bin/toaster | 9 +++++++++
 1 file changed, 9 insertions(+)
bin/toaster +9 -0
index 34a4e8f..c89e015 100755
@@ -268,6 +268,15 @@ if [ `basename \"$0\"` = `basename \"${TOASTER}\"` ]; then
     exit 1
 fi
 
+if [ "$1" = 'restart-bitbake' ] ; then
+    stop_bitbake
+    sleep 1
+    start_bitbake
+    rc=$?
+    sleep 1
+    return $rc
+fi
+
 if ! verify_prereq; then
     echo "Error: Could not verify that the needed dependencies are installed. Please use virtualenv and pip to install dependencies listed in toaster-requirements.txt" 1>&2
     return 1
Signature · 1 line
1.9.1
#16 lore raw

PATCH 14/30 toaster: remove _setupBE function

In reply to brian avery

From: Ed Bartosh <[email protected]>

This function is not needed as build environment is always created because of the new way to run Toaster. It can be only sourced after oe-init-build-env is sourced.

---
 lib/toaster/bldcontrol/localhostbecontroller.py | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)
lib/toaster/bldcontrol/localhostbecontroller.py +2 -17
index 854a6bb..15c0ff9 100644
@@ -70,17 +70,6 @@ class LocalhostBEController(BuildEnvironmentController):
             logger.debug("localhostbecontroller: shellcmd success")
             return out
 
-    def _setupBE(self):
-        assert self.pokydirname and os.path.exists(self.pokydirname)
-        path = self.be.builddir
-        if not path:
-            raise Exception("Invalid path creation specified.")
-        if not os.path.exists(path):
-            os.makedirs(path, 0755)
-        self._shellcmd("bash -c \"source %s/oe-init-build-env %s\"" % (self.pokydirname, path))
-        # delete the templateconf.cfg; it may come from an unsupported layer configuration
-        os.remove(os.path.join(path, "conf/templateconf.cfg"))
-
 
     def writeConfFile(self, file_name, variable_list = None, raw = None):
         filepath = os.path.join(self.be.builddir, file_name)
@@ -297,16 +286,12 @@ class LocalhostBEController(BuildEnvironmentController):
 
         logger.debug("localhostbecontroller: current layer list %s " % pformat(layerlist))
 
-        # 4. configure the build environment, so we have a conf/bblayers.conf
-        assert self.pokydirname is not None
-        self._setupBE()
-
-        # 5. update the bblayers.conf
+        # 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)
 
-        # 6. create custom layer and add custom recipes to it
+        # 5. create custom layer and add custom recipes to it
         layerpath = os.path.join(self.be.sourcedir, "_meta-toaster-custom")
         if os.path.isdir(layerpath):
             shutil.rmtree(layerpath) # remove leftovers from previous builds
Signature · 1 line
1.9.1
#17 lore raw

PATCH 15/30 toaster: reimplemented startBBServer method

In reply to brian avery

From: Ed Bartosh <[email protected]>

Rewritten LocalhostBEController.startBBServer to use 'toaster restart-bitbake' and read bitbake port number from bitbake.lock.

Removed complicated logic of running oe-init-memres and looking for bitbake port number in the logs.

---
 lib/toaster/bldcontrol/localhostbecontroller.py | 90 +++++--------------------
 1 file changed, 18 insertions(+), 72 deletions(-)
lib/toaster/bldcontrol/localhostbecontroller.py +18 -72
index 15c0ff9..44a9136 100644
@@ -88,82 +88,28 @@ class LocalhostBEController(BuildEnvironmentController):
         # find our own toasterui listener/bitbake
         from toaster.bldcontrol.management.commands.loadconf import _reduce_canon_path
 
-        own_bitbake = _reduce_canon_path(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../bin/bitbake"))
-
-        assert os.path.exists(own_bitbake) and os.path.isfile(own_bitbake)
-
-        logger.debug("localhostbecontroller: running the listener at %s" % own_bitbake)
-
-        toaster_ui_log_filepath = os.path.join(self.be.builddir, "toaster_ui.log")
-        # get the file length; we need to detect the _last_ start of the toaster UI, not the first
-        toaster_ui_log_filelength = 0
-        if os.path.exists(toaster_ui_log_filepath):
-            with open(toaster_ui_log_filepath, "w") as f:
-                f.seek(0, 2)    # jump to the end
-                toaster_ui_log_filelength = f.tell()
-
-        cmd = "bash -c \"source %s/oe-init-build-env %s 2>&1 >toaster_server.log && bitbake --read %s/conf/toaster-pre.conf --postread %s/conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:0 2>&1 >>toaster_server.log \"" % (self.pokydirname, self.be.builddir, self.be.builddir, self.be.builddir)
-
-        port = "-1"
-        logger.debug("localhostbecontroller: starting builder \n%s\n" % cmd)
-
-        cmdoutput = self._shellcmd(cmd)
-        with open(self.be.builddir + "/toaster_server.log", "r") as f:
-            for i in f.readlines():
-                if i.startswith("Bitbake server address"):
-                    port = i.split(" ")[-1]
-                    logger.debug("localhostbecontroller: Found bitbake server port %s" % port)
-
-        cmd = "bash -c \"source %s/oe-init-build-env-memres -1 %s && %s --observe-only -u toasterui --remote-server=0.0.0.0:-1 -t xmlrpc\"" % \
-                (self.pokydirname, self.be.builddir, own_bitbake)
-
-        # Use a copy of the current environment and add the DATABASE_URL
-        # for the bitbake observer process.
-        env = os.environ.copy()
-        env['DATABASE_URL'] = settings.getDATABASE_URL()
-
-        with open(toaster_ui_log_filepath, "a+") as f:
-            p = subprocess.Popen(cmd, cwd = self.be.builddir, shell=True,
-                                 stdout=f, stderr=f, env=env)
-
-        def _toaster_ui_started(filepath, filepos = 0):
-            if not os.path.exists(filepath):
-                return False
-            with open(filepath, "r") as f:
-                f.seek(filepos)
-                for line in f:
-                    if line.startswith("NOTE: ToasterUI waiting for events"):
-                        return True
-            return False
-
-        retries = 0
-        started = False
-        while not started and retries < 50:
-            started = _toaster_ui_started(toaster_ui_log_filepath, toaster_ui_log_filelength)
-            import time
-            logger.debug("localhostbecontroller: Waiting bitbake server to start")
-            time.sleep(0.5)
-            retries += 1
-
-        if not started:
-            toaster_ui_log = open(os.path.join(self.be.builddir, "toaster_ui.log"), "r").read()
-            toaster_server_log = open(os.path.join(self.be.builddir, "toaster_server.log"), "r").read()
-            raise BuildSetupException("localhostbecontroller: Bitbake server did not start in 25 seconds, aborting (Error: '%s' '%s')" % (toaster_ui_log, toaster_server_log))
-
-        logger.debug("localhostbecontroller: Started bitbake server")
-
-        while port == "-1":
-            # the port specification is "autodetect"; read the bitbake.lock file
-            with open("%s/bitbake.lock" % self.be.builddir, "r") as f:
-                for line in f.readlines():
+        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:
-                        port = line.split(":")[1].strip()
-                        logger.debug("localhostbecontroller: Autodetected bitbake port %s", port)
+                        self.be.bbport = line.split(":")[-1].strip()
+                        logger.debug("localhostbecontroller: bitbake port %s", self.be.bbport)
                         break
 
-        assert self.be.sourcedir and os.path.exists(self.be.builddir)
+        if not self.be.bbport:
+            raise BuildSetupException("localhostbecontroller: can't read bitbake port from %s" % bblock)
+
         self.be.bbaddress = "localhost"
-        self.be.bbport = port
         self.be.bbstate = BuildEnvironment.SERVER_STARTED
         self.be.save()
 
Signature · 1 line
1.9.1
#18 lore raw

PATCH 16/30 toaster: remove stopBBServer API

In reply to brian avery

From: Ed Bartosh <[email protected]>

Removed stopBBServer API from build controller as toaster doesn't stop bitbake server anymore. It's reused for both types of builds: triggered by UI and started manually.

---
 lib/toaster/bldcontrol/bbcontroller.py          |  6 ------
 lib/toaster/bldcontrol/localhostbecontroller.py |  9 ---------
 lib/toaster/bldcontrol/sshbecontroller.py       | 10 ----------
 lib/toaster/bldcontrol/tests.py                 |  4 ----
 4 files changed, 29 deletions(-)
lib/toaster/bldcontrol/bbcontroller.py +0 -6
index ad70ac8..3d98ad7 100644
@@ -140,12 +140,6 @@ class BuildEnvironmentController(object):
         """
         raise Exception("FIXME: Must override in order to actually start the BB server")
 
-    def stopBBServer(self):
-        """ Stops the currently running BB server.
-            The bbstate MUST be updated to "stopped".
-            self.connection must be none.
-        """
-        raise Exception("FIXME: Must override stoBBServer")
 
     def setLayers(self, bbs, ls):
         """ Checks-out bitbake executor and layers from git repositories.
lib/toaster/bldcontrol/localhostbecontroller.py +0 -9
index 44a9136..19afb1a 100644
@@ -113,15 +113,6 @@ class LocalhostBEController(BuildEnvironmentController):
         self.be.bbstate = BuildEnvironment.SERVER_STARTED
         self.be.save()
 
-    def stopBBServer(self):
-        assert self.pokydirname and os.path.exists(self.pokydirname)
-        assert self.islayerset
-        self._shellcmd("bash -c \"source %s/oe-init-build-env %s && %s source toaster stop\"" %
-            (self.pokydirname, self.be.builddir, (lambda: "" if self.be.bbtoken is None else "BBTOKEN=%s" % self.be.bbtoken)()))
-        self.be.bbstate = BuildEnvironment.SERVER_STOPPED
-        self.be.save()
-        logger.debug("localhostbecontroller: Stopped bitbake server")
-
     def getGitCloneDirectory(self, url, branch):
         """Construct unique clone directory name out of url and branch."""
         if branch != "HEAD":
lib/toaster/bldcontrol/sshbecontroller.py +0 -10
index 8ef434b..17dd66c 100644
@@ -98,16 +98,6 @@ class SSHBEController(BuildEnvironmentController):
         self.be.bbstate = BuildEnvironment.SERVER_STARTED
         self.be.save()
 
-    def stopBBServer(self):
-        assert self.pokydirname and self._pathexists(self.pokydirname)
-        assert self.islayerset
-        print self._shellcmd("bash -c \"source %s/oe-init-build-env %s && %s source toaster stop\"" %
-            (self.pokydirname, self.be.builddir, (lambda: "" if self.be.bbtoken is None else "BBTOKEN=%s" % self.be.bbtoken)()))
-        self.be.bbstate = BuildEnvironment.SERVER_STOPPED
-        self.be.save()
-        print "Stopped server"
-
-
     def _copyFile(self, filepath1, filepath2):
         p = subprocess.Popen("scp '%s' '%s'" % (filepath1, filepath2), stdout=subprocess.PIPE, stderr = subprocess.PIPE, shell=True)
         (out, err) = p.communicate()
lib/toaster/bldcontrol/tests.py +0 -4
index 5dbc77f..f54cf7f 100644
@@ -71,9 +71,6 @@ class BEControllerTests(object):
 
         self.assertFalse(socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex((hostname, int(bc.be.bbport))), "Server not answering")
 
-        bc.stopBBServer()
-        self.assertTrue(socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex((hostname, int(bc.be.bbport))), "Server not stopped")
-
         self._serverForceStop(bc)
 
     def test_getBBController(self):
@@ -96,7 +93,6 @@ class BEControllerTests(object):
 
         bbc = bc.getBBController()
         self.assertTrue(isinstance(bbc, BitbakeController))
-        bc.stopBBServer()
 
         self._serverForceStop(bc)
 
Signature · 1 line
1.9.1
#19 lore raw

PATCH 17/30 toaster: do not terminate bb server

In reply to brian avery

From: Ed Bartosh <[email protected]>

Toaster needs bb server to be running all the time due to merged analysis and managed modes. Server gets restarted before every build triggered by UI, but it shouldn't be terminated as it will influence command line builds.

[YOCTO #8279]

---
 lib/bb/ui/toasterui.py | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
lib/bb/ui/toasterui.py +5 -9
index cdfe7ae..435cc2b 100644
@@ -330,15 +330,11 @@ def main(server, eventHandler, params):
                 logger.info("ToasterUI build done 1, brbe: %s", buildinfohelper.brbe )
 
                 # we start a new build info
-                if buildinfohelper.brbe is not None:
-                    logger.debug("ToasterUI under BuildEnvironment management - exiting after the build")
-                    server.terminateServer()
-                else:
-                    logger.debug("ToasterUI prepared for new build")
-                    errors = 0
-                    warnings = 0
-                    taskfailures = []
-                    buildinfohelper = BuildInfoHelper(server, build_history_enabled)
+                logger.debug("ToasterUI prepared for new build")
+                errors = 0
+                warnings = 0
+                taskfailures = []
+                buildinfohelper = BuildInfoHelper(server, build_history_enabled)
 
                 logger.info("ToasterUI build done 2")
                 continue
Signature · 1 line
1.9.1
#20 lore raw

PATCH 18/30 toaster: remove usage of BUILD_MODE variable

In reply to brian avery

From: Ed Bartosh <[email protected]>

As both modes can be used at the same time we can't have any difference in UI between modes.

Removed all conditional statements that used BUILD_MODE.

---
 lib/toaster/toastergui/templates/base.html    |  9 +--------
 lib/toaster/toastergui/templates/landing.html | 10 ----------
 lib/toaster/toastergui/tests.py               |  4 ----
 lib/toaster/toastergui/views.py               | 20 --------------------
 lib/toaster/toastermain/settings.py           |  3 ---
 lib/toaster/toastermain/urls.py               |  9 ++++-----
 6 files changed, 5 insertions(+), 50 deletions(-)
lib/toaster/toastergui/templates/base.html +1 -8
index e0b15ce..8081f06 100644
@@ -79,7 +79,7 @@
             <i class="icon-info-sign" title="<strong>Toaster version information</strong>" data-content="<dl><dt>Branch</dt><dd>{{TOASTER_BRANCH}}</dd><dt>Revision</dt><dd>{{TOASTER_REVISION}}</dd></dl>"></i>
             {% endif %}
           </span>
-          {% if BUILD_MODE and request.resolver_match.url_name != 'landing' and request.resolver_match.url_name != 'newproject' %}
+          {% if request.resolver_match.url_name != 'landing' and request.resolver_match.url_name != 'newproject' %}
           <ul class="nav">
             <li {% if request.resolver_match.url_name == 'all-builds' %}
                 class="active"
@@ -108,13 +108,6 @@
             </li>
           </ul>
           <span class="pull-right divider-vertical"></span>
-
-          <!-- new project button; only show in build mode -->
-          {% if BUILD_MODE %}
-          <div class="btn-group pull-right">
-            <a class="btn" id="new-project-button" href="{% url 'newproject' %}">New project</a>
-          </div>
-          {% endif %}
         </div>
       </div>
     </div>
lib/toaster/toastergui/templates/landing.html +0 -10
index cafaa1a..a1b5cdc 100644
@@ -6,9 +6,6 @@
 
 {% block title %} Welcome to Toaster {% endblock %}
 {% block pagecontent %}
-
-  {% if BUILD_MODE %}
-    <!-- build mode -->
     <div class="container-fluid">
       <div class="row-fluid">
         <div class="hero-unit span12 well-transparent">
@@ -62,11 +59,4 @@
         </div>
       </div>
     </div>
-  {% else %}
-    <!-- analysis mode -->
-    <div class="alert alert-info lead top-air">
-      Toaster has not recorded any builds yet. Run a build from the command line to see it here.
-    </div>
-  {% endif %}
-
 {% endblock %}
lib/toaster/toastergui/tests.py +0 -4
index a631203..c927fe1 100644
@@ -45,10 +45,6 @@ import string
 PROJECT_NAME = "test project"
 CLI_BUILDS_PROJECT_NAME = 'Command line builds'
 
-# by default, tests are run in build mode; to run in analysis mode,
-# set this to False in individual test cases
-toastermain.settings.BUILD_MODE = True
-
 class ViewTests(TestCase):
     """Tests to verify view APIs."""
 
lib/toaster/toastergui/views.py +0 -20
index 0e255f1..69f5af0 100755
@@ -76,10 +76,6 @@ def landing(request):
     default_project = Project.objects.get_default_project()
     default_project_builds = Build.objects.filter(project = default_project)
 
-    if (not toastermain.settings.BUILD_MODE) and default_project_builds.count() > 0:
-        args = (default_project.id,)
-        return redirect(reverse('projectbuilds', args = args), permanent = False)
-
     # we only redirect to projects page if there is a user-generated project
     num_builds = Build.objects.all().count()
     user_projects = Project.objects.filter(is_default = False)
@@ -102,9 +98,6 @@ def _get_latest_builds(prj=None):
     if prj is not None:
         queryset = queryset.filter(project = prj)
 
-    if not toastermain.settings.BUILD_MODE:
-        queryset = queryset.exclude(project__is_default=False)
-
     return list(itertools.chain(
         queryset.filter(outcome=Build.IN_PROGRESS).order_by("-started_on"),
         queryset.filter(outcome__lt=Build.IN_PROGRESS).order_by("-started_on")[:3] ))
@@ -1893,10 +1886,6 @@ def managedcontextprocessor(request):
         "projects": projects,
         "non_cli_projects": projects.exclude(is_default=True),
         "DEBUG" : toastermain.settings.DEBUG,
-
-        # True if Toaster is in build mode, False otherwise
-        "BUILD_MODE": toastermain.settings.BUILD_MODE,
-
         "CUSTOM_IMAGE" : toastermain.settings.CUSTOM_IMAGE,
         "TOASTER_BRANCH": toastermain.settings.TOASTER_BRANCH,
         "TOASTER_REVISION" : toastermain.settings.TOASTER_REVISION,
@@ -1939,11 +1928,6 @@ if True:
 
         queryset = Build.objects.all()
 
-        # if in analysis mode, exclude builds for all projects except
-        # command line builds
-        if not toastermain.settings.BUILD_MODE:
-            queryset = queryset.exclude(project__is_default=False)
-
         redirect_page = resolve(request.path_info).url_name
 
         context, pagesize, orderby = _build_list_helper(request,
@@ -3048,10 +3032,6 @@ if True:
         queryset_all = queryset_all.filter(Q(is_default=False) |
                                            q_default_with_builds)
 
-        # if in BUILD_MODE, exclude everything but the command line builds project
-        if not toastermain.settings.BUILD_MODE:
-            queryset_all = queryset_all.exclude(is_default=False)
-
         # boilerplate code that takes a request for an object type and returns a queryset
         # for that object type. copypasta for all needed table searches
         (filter_string, search_term, ordering_string) = _search_tuple(request, Project)
lib/toaster/toastermain/settings.py +0 -3
index b28ddb2..de686b2 100644
@@ -92,9 +92,6 @@ if 'DATABASE_URL' in os.environ:
     else:
         raise Exception("FIXME: Please implement missing database url schema for url: %s" % dburl)
 
-BUILD_MODE = False
-if 'TOASTER_MANAGED' in os.environ and os.environ['TOASTER_MANAGED'] == "1":
-    BUILD_MODE = True
 
 # Allows current database settings to be exported as a DATABASE_URL environment variable value
 
lib/toaster/toastermain/urls.py +4 -5
index 6c4a953..5ce5a92 100644
@@ -59,12 +59,11 @@ if toastermain.settings.DEBUG_PANEL_ENABLED:
     urlpatterns.insert(1, url(r'', include(debug_toolbar.urls)))
     #logger.info("Enabled django_toolbar extension")
 
+urlpatterns = [
+    # Uncomment the next line to enable the admin:
+    url(r'^admin/', include(admin.site.urls)),
+] + urlpatterns
 
-if toastermain.settings.BUILD_MODE:
-    urlpatterns = [
-        # Uncomment the next line to enable the admin:
-        url(r'^admin/', include(admin.site.urls)),
-    ] + urlpatterns
 # Automatically discover urls.py in various apps, beside our own
 # and map module directories to the patterns
 
Signature · 1 line
1.9.1
#21 lore raw

PATCH 19/30 toaster: do not create duplicate HelpText objects

In reply to brian avery

From: Ed Bartosh <[email protected]>

buildinfohelper code expects only one HelpText object per build/variable/description.
Current code creates more than one such an object, which causes toastergui to crash with this exception:
MultipleObjectsReturned: get() returned more than one HelpText -- it returned 2!

Used git_or_create API to ensure that only one HelpText object is created.

---
 lib/bb/ui/buildinfohelper.py | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
lib/bb/ui/buildinfohelper.py +3 -7
index 43c243e..2b9302d 100644
@@ -700,7 +700,6 @@ class ORMWrapper(object):
     def save_build_variables(self, build_obj, vardump):
         assert isinstance(build_obj, Build)
 
-        helptext_objects = []
         for k in vardump:
             desc = vardump[k]['doc']
             if desc is None:
@@ -711,10 +710,9 @@ class ORMWrapper(object):
             if desc is None:
                 desc = ''
             if len(desc):
-                helptext_objects.append(HelpText(build=build_obj,
-                    area=HelpText.VARIABLE,
-                    key=k,
-                    text=desc))
+                HelpText.objects.get_or_create(build=build_obj,
+                                               area=HelpText.VARIABLE,
+                                               key=k, text=desc)
             if not bool(vardump[k]['func']):
                 value = vardump[k]['v']
                 if value is None:
@@ -734,8 +732,6 @@ class ORMWrapper(object):
                 if len(varhist_objects):
                     VariableHistory.objects.bulk_create(varhist_objects)
 
-        HelpText.objects.bulk_create(helptext_objects)
-
 
 class MockEvent(object):
     """ This object is used to create event, for which normal event-processing methods can
Signature · 1 line
1.9.1
#22 lore raw

PATCH 20/30 toaster: buildinfohelper Broaden the toaster created recipe data case

In reply to brian avery

From: Michael Wood <[email protected]>

When build information is the 'original' source of the information we need to return the recipe that was created rather than the copy of the recipe that is taken for keeping build history. We do this already for command line triggered builds, but we also have this case for custom images. We can simply check if the built_recipe exists instead of special casing this.

---
 lib/bb/ui/buildinfohelper.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
lib/bb/ui/buildinfohelper.py +3 -4
index 2b9302d..5ea9284 100644
@@ -304,12 +304,11 @@ class ORMWrapper(object):
                 break
 
 
-        # If we're in analysis mode then we are wholly responsible for the data
+        # If we're in analysis mode or if this is a custom recipe
+        # then we are wholly responsible for the data
         # and therefore we return the 'real' recipe rather than the build
         # history copy of the recipe.
-        if  recipe_information['layer_version'].build is not None and \
-            recipe_information['layer_version'].build.project == \
-                Project.objects.get_default_project():
+        if built_recipe is None:
             return recipe
 
         return built_recipe
Signature · 1 line
1.9.1
#23 lore raw

PATCH 21/30 toaster: implement BitbakeController.getVariable

In reply to brian avery

From: Ed Bartosh <[email protected]>

Added new API to get value of bitbake variable from bitbake server. The API will be used to update INHERIT variable instead of writing it to the toaster configuration files.

---
 lib/toaster/bldcontrol/bbcontroller.py | 3 +++
 1 file changed, 3 insertions(+)
lib/toaster/bldcontrol/bbcontroller.py +3 -0
index 3d98ad7..ba00931 100644
@@ -52,6 +52,9 @@ class BitbakeController(object):
     def setVariable(self, name, value):
         return self._runCommand(["setVariable", name, value])
 
+    def getVariable(self, name):
+        return self._runCommand(["getVariable", name])
+
     def build(self, targets, task = None):
         if task is None:
             task = "build"
Signature · 1 line
1.9.1
#24 lore raw

PATCH 22/30 toaster: set varibales on bitbake server

In reply to brian avery

From: Ed Bartosh <[email protected]>

Set project variables using connection to bitbake server instead of writing them to toaster configuration files.

This is a way to avoid rewriting configuration files before and after every build, triggered by toaster UI.

---
 lib/toaster/bldcontrol/localhostbecontroller.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
lib/toaster/bldcontrol/localhostbecontroller.py +9 -2
index 19afb1a..efba73e 100644
@@ -291,12 +291,19 @@ class LocalhostBEController(BuildEnvironmentController):
     def triggerBuild(self, bitbake, layers, variables, targets):
         # set up the buid environment with the needed layers
         self.setLayers(bitbake, layers, targets)
-        self.writeConfFile("conf/toaster-pre.conf", variables)
-        self.writeConfFile("conf/toaster.conf", raw = "INHERIT+=\"toaster buildhistory\"")
 
         # get the bb server running with the build req id and build env id
         bbctrl = self.getBBController()
 
+        # set variables
+        for var in variables:
+            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:
Signature · 1 line
1.9.1
#25 lore raw

PATCH 23/30 toaster: remove writeConfFile API

In reply to brian avery

From: Ed Bartosh <[email protected]>

This API is not used anymore as toaster doesn't write variables to configuration files anymore. It sets variables through its connection to bitbake server.

---
 lib/toaster/bldcontrol/bbcontroller.py          |  6 ------
 lib/toaster/bldcontrol/localhostbecontroller.py | 11 -----------
 2 files changed, 17 deletions(-)
lib/toaster/bldcontrol/bbcontroller.py +0 -6
index ba00931..8b99318 100644
@@ -130,12 +130,6 @@ class BuildEnvironmentController(object):
         bblayerconffile.write("# line added by toaster build control\nBBLAYERS = \"" + " ".join(layerlist) + "\"")
         bblayerconffile.close()
 
-
-    def writeConfFile(self, variable_list = None, raw = None):
-        """ Writes a configuration file in the build directory. Override with buildenv-specific implementation. """
-        raise Exception("FIXME: Must override to actually write a configuration file")
-
-
     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,
lib/toaster/bldcontrol/localhostbecontroller.py +0 -11
index efba73e..92d9ac5 100644
@@ -70,17 +70,6 @@ class LocalhostBEController(BuildEnvironmentController):
             logger.debug("localhostbecontroller: shellcmd success")
             return out
 
-
-    def writeConfFile(self, file_name, variable_list = None, raw = None):
-        filepath = os.path.join(self.be.builddir, file_name)
-        with open(filepath, "w") as conffile:
-            if variable_list is not None:
-                for i in variable_list:
-                    conffile.write("%s=\"%s\"\n" % (i.name, i.value))
-            if raw is not None:
-                conffile.write(raw)
-
-
     def startBBServer(self):
         assert self.pokydirname and os.path.exists(self.pokydirname)
         assert self.islayerset
Signature · 1 line
1.9.1
#26 lore raw

PATCH 24/30 toaster: stop using toaster-pre.conf

In reply to brian avery

From: Ed Bartosh <[email protected]>

This file is not needed anymore as toaster UI doesn't write variables to it. It sets them directly on bitbake server.

---
 bin/toaster | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
bin/toaster +1 -2
index c89e015..3b5b7f8 100755
@@ -135,7 +135,7 @@ stop_system()
 
 start_bitbake() {
     unset BBSERVER
-    bitbake --read conf/toaster-pre.conf --postread conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:0
+    bitbake --postread conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:0
     if [ $? -ne 0 ]; then
         echo "Bitbake server start failed"
         return 1
@@ -350,7 +350,6 @@ fi
 case $CMD in
     start )
         addtoConfiguration toaster.conf "INHERIT+=\"toaster buildhistory\"" $TOASTER_BRBE
-        echo > ${BUILDDIR}/conf/toaster-pre.conf
         if [ $WEBSERVER -gt 0 ] && ! webserverStartAll; then
             echo "Failed ${CMD}."
             return 4
Signature · 1 line
1.9.1
#27 lore raw

PATCH 25/30 toaster: remove SDKMACHINE from project variables

In reply to brian avery

From: Ed Bartosh <[email protected]>

Removed SDKMACHINE from predefined set of variables
for the project as it causes bitbake build error:
SDKMACHINE is set, but SDK_ARCH has not been changed as a result

This variable does not need to be predefined as it's not used by toaster.

It's still possible to specify it in project configuration if needed. SDK_ARCH variable should be set too to avoid above mentioned build failure.

---
 lib/toaster/toastergui/templates/projectconf.html | 70 +----------------------
 lib/toaster/toastergui/views.py                   |  9 ---
 2 files changed, 1 insertion(+), 78 deletions(-)
lib/toaster/toastergui/templates/projectconf.html +1 -69
index 30fd03e..08223da 100644
@@ -107,32 +107,6 @@
                 </form>
             </dd>
             {% endif %}
-
-            {% if sdk_machine_defined %}
-            <dt>
-                <span class="js-config-var-name js-config-var-managed-name">SDKMACHINE</span>
-                <i class="icon-question-sign get-help" title="Specifies the architecture (i.e. i686 or x86_64) for which to build SDK and ADT items <br /><a href='http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-SDKMACHINE' target='_blank'>Read more in the manual</a>"></i>
-            </dt>
-            <dd class="lead">
-                <span id="sdkmachine">{{sdk_machine}}</span>
-                <i id="change-sdkmachine-icon" class="icon-pencil"></i>
-                <form id="change-sdkmachine-form" style="display:none;">
-                    <label class="radio">
-                        <input type="radio" name="sdkmachine" value="i686">
-                        i686
-                    </label>
-                    <label class="radio">
-                        <input type="radio" name="sdkmachine" value="x86_64">
-                        x86_64
-                    </label>
-                    <div style="padding-top:10px;">
-                        <button id="apply-change-sdkmachine" type="button" class="btn">Save</button>
-                        <button id="cancel-change-sdkmachine" type="button" class="btn btn-link">Cancel</button>
-                    </div>
-                </form>
-            </dd>
-            {% endif %}
-
         </dl>
 
         <!-- <ul class="unstyled configuration-list" id="configvar-list"> -->
@@ -774,48 +748,6 @@
             });
             {% endif %}
 
-
-            {% if sdk_machine_defined %}
-            // change SDKMACHINE variable
-            $('#change-sdkmachine-icon').click(function() {
-                var current_value = document.getElementById("sdkmachine").innerHTML;
-                var radios = document.getElementsByName('sdkmachine');
-                for (var i = 0, length = radios.length; i < length; i++) {
-                    radios[i].checked = false;
-                    if (radios[i].value == current_value) {
-                        radios[i].checked = true;
-                    }
-                }
-                $('#change-sdkmachine-icon, #sdkmachine').hide();
-                $("#change-sdkmachine-form").slideDown();
-            });
-
-            $('#cancel-change-sdkmachine').click(function(){
-                $("#change-sdkmachine-form").slideUp(function() {
-                    $('#sdkmachine, #change-sdkmachine-icon').show();
-                });
-            });
-
-            $('#apply-change-sdkmachine').click(function(){
-                var value="";
-                var radios = document.getElementsByName('sdkmachine');
-                for (var i = 0, length = radios.length; i < length; i++) {
-                    if (radios[i].checked) {
-                        // do whatever you want with the checked radio
-                        value=radios[i].value;
-                        break;
-                    }
-                }
-                postEditAjaxRequest({"configvarChange" : 'SDKMACHINE:'+value});
-                $('#sdkmachine').text(value);
-                $("#change-sdkmachine-form").slideUp(function() {
-                    $('#sdkmachine, #change-sdkmachine-icon').show();
-                });
-
-            });
-            {% endif %}
-
-
             // add new variable
             $("button#add-configvar-button").click( function (evt) {
                 var variable = $("input#variable").val();
@@ -830,7 +762,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 SDKMACHINE ".indexOf( " "+variable+" " )) {
+                if (0 <= " DISTRO IMAGE_FSTYPES IMAGE_INSTALL_append PACKAGE_CLASSES ".indexOf( " "+variable+" " )) {
                     // delayed reload to avoid race condition with postEditAjaxRequest
                     do_reload=true;
                 }
lib/toaster/toastergui/views.py +0 -9
index 69f5af0..243bb09 100755
@@ -2456,10 +2456,6 @@ if True:
                 return_data['package_classes'] = ProjectVariable.objects.get(project = prj, name = "PACKAGE_CLASSES").value,
             except ProjectVariable.DoesNotExist:
                 pass
-            try:
-                return_data['sdk_machine'] = ProjectVariable.objects.get(project = prj, name = "SDKMACHINE").value,
-            except ProjectVariable.DoesNotExist:
-                pass
 
             return HttpResponse(json.dumps( return_data ), content_type = "application/json")
 
@@ -2868,11 +2864,6 @@ if True:
             context['package_classes_defined'] = "1"
         except ProjectVariable.DoesNotExist:
             pass
-        try:
-            context['sdk_machine'] =  ProjectVariable.objects.get(project = prj, name = "SDKMACHINE").value
-            context['sdk_machine_defined'] = "1"
-        except ProjectVariable.DoesNotExist:
-            pass
 
         return context
 
Signature · 1 line
1.9.1
#28 lore raw

PATCH 26/30 toaster: get rid of complicated heuristics

In reply to brian avery

From: Ed Bartosh <[email protected]>

Removed buildinfohelper code which was trying to guess layer version of the recipe using build request information. The code caused creation of duplicated recipes as it resulted in layer version from layer index instead of returning build layer version. As a result of this Toaster UI was not showing any information about recipes.

Default approach used to find layer version seems to work much better as it finds proper layer version. Now toaster will use it as the only way to find layer version.

---
 lib/bb/ui/buildinfohelper.py | 47 +++++++++-----------------------------------
 1 file changed, 9 insertions(+), 38 deletions(-)
lib/bb/ui/buildinfohelper.py +9 -38
index 5ea9284..1d41bba 100644
@@ -815,44 +815,15 @@ class BuildInfoHelper(object):
         assert path.startswith("/")
         assert 'build' in self.internal_state
 
-        if self.brbe is None:
-            def _slkey_interactive(layer_version):
-                assert isinstance(layer_version, Layer_Version)
-                return len(layer_version.local_path)
-
-            # Heuristics: we always match recipe to the deepest layer path in the discovered layers
-            for lvo in sorted(self.orm_wrapper.layer_version_objects, reverse=True, key=_slkey_interactive):
-                # we can match to the recipe file path
-                if path.startswith(lvo.local_path):
-                    return lvo
-
-        else:
-            br_id, be_id = self.brbe.split(":")
-            from bldcontrol.bbcontroller import getBuildEnvironmentController
-            bc = getBuildEnvironmentController(pk = be_id)
-
-            def _slkey_managed(layer_version):
-                return len(bc.getGitCloneDirectory(layer_version.giturl, layer_version.commit) + layer_version.dirpath)
-
-            # Heuristics: we match the path to where the layers have been checked out
-            for brl in sorted(BuildRequest.objects.get(pk = br_id).brlayer_set.all(), reverse = True, key = _slkey_managed):
-                localdirname = os.path.join(bc.getGitCloneDirectory(brl.giturl, brl.commit), brl.dirpath)
-                # we get a relative path, unless running in HEAD mode where the path is absolute
-                if not localdirname.startswith("/"):
-                    localdirname = os.path.join(bc.be.sourcedir, localdirname)
-                if path.startswith(localdirname):
-                    # If the build request came from toaster this field
-                    # should contain the information from the layer_version
-                    # That created this build request.
-                    if brl.layer_version:
-                        return brl.layer_version
-
-                    #logger.warn("-- managed: matched path %s with layer %s " % (path, localdirname))
-                    # we matched the BRLayer, but we need the layer_version that generated this br
-
-                    for lvo in self.orm_wrapper.layer_version_objects:
-                        if brl.name == lvo.layer.name:
-                            return lvo
+        def _slkey_interactive(layer_version):
+            assert isinstance(layer_version, Layer_Version)
+            return len(layer_version.local_path)
+
+        # Heuristics: we always match recipe to the deepest layer path in the discovered layers
+        for lvo in sorted(self.orm_wrapper.layer_version_objects, reverse=True, key=_slkey_interactive):
+            # we can match to the recipe file path
+            if path.startswith(lvo.local_path):
+                return lvo
 
         #if we get here, we didn't read layers correctly; dump whatever information we have on the error log
         logger.warn("Could not match layer version for recipe path %s : %s", path, self.orm_wrapper.layer_version_objects)
Signature · 1 line
1.9.1
#29 lore raw

PATCH 27/30 toaster: unset environment variables

In reply to brian avery

From: Ed Bartosh <[email protected]>

Toaster script sets environment variables when it starts. It makes sense to unset them when toaster stops as they can cause other programs to behave incorrectly.

---
 bin/toaster | 4 ++++
 1 file changed, 4 insertions(+)
bin/toaster +4 -0
index 3b5b7f8..6d1ec05 100755
@@ -128,6 +128,10 @@ stop_system()
     fi
     stop_bitbake
     webserverKillAll
+    # unset exported variables
+    unset DATABASE_URL
+    unset TOASTER_CONF
+    unset TOASTER_DIR
     trap - SIGHUP
     #trap - SIGCHLD
     INSTOPSYSTEM=0
Signature · 1 line
1.9.1
#30 lore raw

PATCH 28/30 command: add CommandStarted event

In reply to brian avery

From: Ed Bartosh <[email protected]>

This event will be used by toasterui to set BRBE build parameter as soon as it's provided to bitbake server by Toaster.

---
 lib/bb/command.py | 6 ++++++
 1 file changed, 6 insertions(+)
lib/bb/command.py +6 -0
index 74106d1..78ce03a 100644
@@ -31,6 +31,11 @@ Commands are queued in a CommandQueue
 import bb.event
 import bb.cooker
 
+class CommandStarted(bb.event.Event):
+    def  __init__(self, commandline):
+        bb.event.Event.__init__(self)
+        self.commandline = commandline
+
 class CommandCompleted(bb.event.Event):
     pass
 
@@ -60,6 +65,7 @@ class Command:
         self.currentAsyncCommand = None
 
     def runCommand(self, commandline, ro_only = False):
+        bb.event.fire(CommandStarted(commandline), self.cooker.expanded_data)
         command = commandline.pop(0)
         if hasattr(CommandsSync, command):
             # Can run synchronous commands straight away
Signature · 1 line
1.9.1
#34 lore raw

PATCH 29/30 bb/ui: ignore CommandStarted event

In reply to brian avery

From: Ed Bartosh <[email protected]>

Fixed 'Unknown event' warnings in knotty and runningbuild for new event. The reason for them to appear despite of setting filter mask in ui modules is that this event is fired earlier than mask is set.

---
 lib/bb/ui/crumbs/runningbuild.py | 3 ++-
 lib/bb/ui/knotty.py              | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
lib/bb/ui/crumbs/runningbuild.py +2 -1
index 16a955d..ba8a05c 100644
@@ -433,7 +433,8 @@ class RunningBuild (gobject.GObject):
                                       bb.runqueue.runQueueExitWait,
                                       bb.event.OperationStarted,
                                       bb.event.OperationCompleted,
-                                      bb.event.OperationProgress)):
+                                      bb.event.OperationProgress,
+                                      bb.command.CommandStarted)):
                 self.emit("log", "error", "Unknown event: %s" % (event.error if hasattr(event, 'error') else 'error'))
 
         return
lib/bb/ui/knotty.py +2 -1
index 90c3183..9dfba35 100644
@@ -499,7 +499,8 @@ def main(server, eventHandler, params, tf = TerminalFilter):
                                   bb.event.OperationStarted,
                                   bb.event.OperationCompleted,
                                   bb.event.OperationProgress,
-                                  bb.event.DiskFull)):
+                                  bb.event.DiskFull,
+                                  bb.command.CommandStarted)):
                 continue
 
             logger.error("Unknown event: %s", event)
Signature · 1 line
1.9.1
#35 lore raw

PATCH 30/30 toasterui: process CommandStarted event

In reply to brian avery

From: Ed Bartosh <[email protected]>

Currently BRBE is known to toasterui only when build is started. It't passed to it with BuildStarted event. This is too late as if build fails earilier than build starts toasterui can not inform Toaster about the failure.

Set BRBE as soon as it's provided by Toaster. This should make toasterui to be able to inform Toaster about early build failures, i.e. failures during parsing.

---
 lib/bb/ui/toasterui.py | 7 +++++++
 1 file changed, 7 insertions(+)
lib/bb/ui/toasterui.py +7 -0
index 435cc2b..1fc5f1f 100644
@@ -185,6 +185,13 @@ 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
 
+            # Set brbe as soon as it's provided by toaster
+            if isinstance(event, bb.command.CommandStarted):
+                if event.commandline[0] == 'setVariable' and \
+                   event.commandline[1] == 'TOASTER_BRBE':
+                    buildinfohelper.brbe = event.commandline[2]
+                continue
+
             # we treat ParseStarted as the first event of toaster-triggered
             # builds; that way we get the Build Configuration included in the log
             # and any errors that occur before BuildStarted is fired
Signature · 1 line
1.9.1
#6 lore raw

Re: [PATCH 05/30] toaster: remove unused variable

In reply to brian avery
Quoted 23 lines

-----Original Message-----
From: [email protected] [mailto:bitbake- [email protected]] On Behalf Of brian avery
Sent: den 2 december 2015 19:03
To: [email protected]
Subject: [bitbake-devel] [PATCH 05/30] toaster: remove unused variable

From: Ed Bartosh <[email protected]>

Removed variable RUNNING as it's not used anymore
in the toaster script.

---
 bin/toaster | 2 --
 1 file changed, 2 deletions(-)
bin/toaster +0 -0
index abc8737..1ce4af7 100755

bin/toaster fi · line 179

Quoted 5 lines
bin/toaster +0 -1
@@ -176,9 +176,7 @@ fi
 
 BBBASEDIR=`dirname $TOASTER`/..
 OEROOT=`dirname $TOASTER`/../..
-
 RUNNING=0

The commit message says that it removes the RUNNING variable, but the commit only seems to remove some whitespace and not the actual variable...

Quoted 8 lines
bin/toaster +0 -2
-
 NOTOASTERUI=0
 WEBSERVER=1
 TOASTER_BRBE=""
--

1.9.1

--

//Peter

#7 lore raw

Re: [PATCH 05/30] toaster: remove unused variable

true :/

It was removed from the places in the script where it was used but not the initialization .

Good catch,
-b

Quoted 44 lines · Peter Kjellerstedt
Quoted 23 lines

-----Original Message-----
From: [email protected] [mailto:bitbake- [email protected]] On Behalf Of brian avery
Sent: den 2 december 2015 19:03
To: [email protected]
Subject: [bitbake-devel] [PATCH 05/30] toaster: remove unused variable

From: Ed Bartosh <[email protected]>

Removed variable RUNNING as it's not used anymore
in the toaster script.

---
 bin/toaster | 2 --
 1 file changed, 2 deletions(-)
bin/toaster +0 -0
index abc8737..1ce4af7 100755

bin/toaster fi · line 179

Quoted 5 lines
bin/toaster +0 -1
@@ -176,9 +176,7 @@ fi
 
 BBBASEDIR=`dirname $TOASTER`/..
 OEROOT=`dirname $TOASTER`/../..
-
 RUNNING=0

The commit message says that it removes the RUNNING variable, but the commit only seems to remove some whitespace and not the actual variable...

Quoted 8 lines
bin/toaster +0 -2
-
 NOTOASTERUI=0
 WEBSERVER=1
 TOASTER_BRBE=""
--

1.9.1

--

//Peter

#31 lore raw

Re: [PATCH 28/30] command: add CommandStarted event

In reply to brian avery

Hi Ed,

Quoted 28 lines · brian avery

From: Ed Bartosh <[email protected]>

This event will be used by toasterui to set BRBE build parameter as soon as it's provided to bitbake server by Toaster.

---
 lib/bb/command.py | 6 ++++++
 1 file changed, 6 insertions(+)
lib/bb/command.py +5 -0
index 74106d1..78ce03a 100644
@@ -31,6 +31,11 @@ Commands are queued in a CommandQueue
 import bb.event
 import bb.cooker
 
+class CommandStarted(bb.event.Event):
+    def  __init__(self, commandline):
+        bb.event.Event.__init__(self)
+        self.commandline = commandline
+
 class CommandCompleted(bb.event.Event):
     pass
 

lib/bb/command.py class Command: · line 71

Quoted 7 lines
lib/bb/command.py +1 -0
@@ -60,6 +65,7 @@ class Command:
         self.currentAsyncCommand = None
 
     def runCommand(self, commandline, ro_only = False):
+        bb.event.fire(CommandStarted(commandline), self.cooker.expanded_data)
         command = commandline.pop(0)
         if hasattr(CommandsSync, command):
             # Can run synchronous commands straight away

I'm not sure I like the idea of this, particularly after I've seen what you're using it to do. Just from a performance standpoint, adding in an event per command execution adds in round trips and will increase the time something simple like "bitbake -p" takes to do nothing when the cache is hot.

I note in a later patch you use this to check for a command coming from elsewhere to modify the data store and I worry that we'll end up with unstructured code if we encourage people to do that too.

I did briefly talk to Brian and he mentioned you needed a way to differentiate between events from different builds. I'd suggest you can could do this if you markup the events as they come through your event receiver, since events for a specific build should come through a specific socket. Worst case I'd prefer doing this internally to bitbake rather than the command interception above but adding data to every event being sent over IPC is something I'd prefer to avoid if we can too.

Would you be able to see if there is a different way we could handle this?

Cheers,

Richard

#32 lore raw

Re: [PATCH 28/30] command: add CommandStarted event

Quoted 45 lines · Richard Purdie

Hi Ed,

Quoted 28 lines · brian avery

From: Ed Bartosh <[email protected]>

This event will be used by toasterui to set BRBE build parameter as soon as it's provided to bitbake server by Toaster.

---
 lib/bb/command.py | 6 ++++++
 1 file changed, 6 insertions(+)
lib/bb/command.py +5 -0
index 74106d1..78ce03a 100644
@@ -31,6 +31,11 @@ Commands are queued in a CommandQueue
 import bb.event
 import bb.cooker
 
+class CommandStarted(bb.event.Event):
+    def  __init__(self, commandline):
+        bb.event.Event.__init__(self)
+        self.commandline = commandline
+
 class CommandCompleted(bb.event.Event):
     pass
 

lib/bb/command.py class Command: · line 71

Quoted 7 lines
lib/bb/command.py +1 -0
@@ -60,6 +65,7 @@ class Command:
         self.currentAsyncCommand = None
 
     def runCommand(self, commandline, ro_only = False):
+        bb.event.fire(CommandStarted(commandline), self.cooker.expanded_data)
         command = commandline.pop(0)
         if hasattr(CommandsSync, command):
             # Can run synchronous commands straight away

I'm not sure I like the idea of this, particularly after I've seen what you're using it to do. Just from a performance standpoint, adding in an event per command execution adds in round trips and will increase the time something simple like "bitbake -p" takes to do nothing when the cache is hot.

Quoted 4 lines

I note in a later patch you use this to check for a command coming from elsewhere to modify the data store and I worry that we'll end up with unstructured code if we encourage people to do that too.

The reason of adding this event is that I wanted to introduce generic event that can be used by other people. Less generic ones would be 'VariableSet' or 'BRBESet'. I'm not sure those are better choice than CommandStarted.

Quoted 9 lines

I did briefly talk to Brian and he mentioned you needed a way to differentiate between events from different builds. I'd suggest you can could do this if you markup the events as they come through your event receiver, since events for a specific build should come through a specific socket. Worst case I'd prefer doing this internally to bitbake rather than the command interception above but adding data to every event being sent over IPC is something I'd prefer to avoid if we can too.

There were no suitable events for this purpose I'm afraid. All events I looked at were fired late than BRBE variable is set. I wanted to know when it's changed as soon as possible.

Quoted 2 lines

Would you be able to see if there is a different way we could handle this?

I'll try to look again.

--
Regards,
Ed

#33 lore raw

Re: [PATCH 28/30] command: add CommandStarted event

Quoted 25 lines · Ed Bartosh
Quoted 11 lines · Richard Purdie

On Wed, 2015-12-02 at 10:03 -0800, brian avery wrote:
I'm not sure I like the idea of this, particularly after I've seen what you're using it to do. Just from a performance standpoint, adding in an event per command execution adds in round trips and will increase the time something simple like "bitbake -p" takes to do nothing when the cache is hot.

I note in a later patch you use this to check for a command coming from elsewhere to modify the data store and I worry that we'll end up with unstructured code if we encourage people to do that too.

The reason of adding this event is that I wanted to introduce generic event that can be used by other people. Less generic ones would be 'VariableSet' or 'BRBESet'. I'm not sure those are better choice than CommandStarted.

Quoted 9 lines

I did briefly talk to Brian and he mentioned you needed a way to differentiate between events from different builds. I'd suggest you can could do this if you markup the events as they come through your event receiver, since events for a specific build should come through a specific socket. Worst case I'd prefer doing this internally to bitbake rather than the command interception above but adding data to every event being sent over IPC is something I'd prefer to avoid if we can too.

Quoted 7 lines

There were no suitable events for this purpose I'm afraid. All events I looked at were fired late than BRBE variable is set. I wanted to know when it's changed as soon as possible.

Quoted 2 lines

Would you be able to see if there is a different way we could handle this?

I'll try to look again.

We did support custom event injection for toaster if I remember correctly. Could the code that is setting this variable generate an event that suited your needs?

Cheers,

Richard