Skip to contentSkip to conversation

toaster: add 'nobuild' option to Toaster

PATCH New David Reyna 1 participant 1 message Nov 17, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toaster: add 'nobuild' option to Toaster

From: David Reyna <[email protected]>

Add a 'nobuild' option for starting Toaster without the project and hosted builds support. This allows a Toaster host to provide local build statistics without opening the host to external users building projects.

[YOCTO #12315]

---
 bitbake/bin/toaster                                | 14 ++++--
 bitbake/lib/toaster/toastergui/templates/base.html |  4 ++
 .../lib/toaster/toastergui/templates/landing.html  |  2 +
 bitbake/lib/toaster/toastergui/views.py            | 57 +++++++++++++---------
 bitbake/lib/toaster/toastergui/widgets.py          |  4 ++
 5 files changed, 55 insertions(+), 26 deletions(-)
bitbake/bin/toaster +11 -3
index 762451d..0391f61b 100755
@@ -183,6 +183,7 @@ unset OE_ROOT
 
 
 WEBSERVER=1
+export TOASTER_BUILDSERVER=1
 ADDR_PORT="localhost:8000"
 unset CMD
 for param in $*; do
@@ -190,6 +191,9 @@ for param in $*; do
     noweb )
             WEBSERVER=0
     ;;
+    nobuild )
+            TOASTER_BUILDSERVER=0
+    ;;
     start )
             CMD=$param
     ;;
@@ -286,9 +290,13 @@ case $CMD in
             return 4
         fi
         export BITBAKE_UI='toasterui'
-        $MANAGE runbuilds \
-           </dev/null >>${BUILDDIR}/toaster_runbuilds.log 2>&1 \
-           & echo $! >${BUILDDIR}/.runbuilds.pid
+        if [ $TOASTER_BUILDSERVER -eq 1 ] ; then
+            $MANAGE runbuilds \
+               </dev/null >>${BUILDDIR}/toaster_runbuilds.log 2>&1 \
+               & echo $! >${BUILDDIR}/.runbuilds.pid
+        else
+            echo "Toaster build server not started."
+        fi
 
         # set fail safe stop system on terminal exit
         trap stop_system SIGHUP
bitbake/lib/toaster/toastergui/templates/base.html +4 -0
index edbd110..4f72064 100644
@@ -110,6 +110,7 @@
                 All builds
               </a>
               </li>
+              {% if project_enable %}
               <li id="navbar-all-projects"
               {% if request.resolver_match.url_name == 'all-projects'  %}
               class="active"
@@ -119,6 +120,7 @@
                 All projects
               </a>
               </li>
+              {% endif %}
             {% endif %}
               <li id="navbar-docs">
               <a target="_blank" href="http://www.yoctoproject.org/docs/latest/toaster-manual/toaster-manual.html">
@@ -127,7 +129,9 @@
               </a>
               </li>
             </ul>
+            {% if project_enable %}
             <a class="btn btn-default navbar-btn navbar-right" id="new-project-button" href="{% url 'newproject' %}">New project</a>
+            {% endif %}
           </div>
       </div>
     </nav>
bitbake/lib/toaster/toastergui/templates/landing.html +2 -0
index cf7516d..70c7359 100644
@@ -21,11 +21,13 @@
 		          </p>
 
 		          {% if lvs_nos %}
+                    {% if project_enable %}
 		            <p class="top-air">
 		              <a class="btn btn-primary btn-lg" href="{% url 'newproject' %}">
 			              Create your first Toaster project to run manage builds
 		              </a>
 		            </p>
+                    {% endif %}
 		          {% else %}
                 <div class="alert alert-info lead top-air">
                   Toaster has no layer information. Without layer information, you cannot run builds. To generate layer information you can:
bitbake/lib/toaster/toastergui/views.py +34 -23

206 lines not on this page · raw message

bitbake/lib/toaster/toastergui/widgets.py +4 -0
index 67c1ff9..a1792d9 100644
@@ -41,6 +41,7 @@ import types
 import json
 import collections
 import re
+import os
 
 from toastergui.tablefilter import TableFilterMap
 
@@ -86,6 +87,9 @@ class ToasterTable(TemplateView):
         context['table_name'] = type(self).__name__.lower()
         context['empty_state'] = self.empty_state
 
+        # global variables
+        context['project_enable'] = ('1' == os.environ.get('TOASTER_BUILDSERVER'))
+
         return context
 
     def get(self, request, *args, **kwargs):
Signature · 1 line
1.9.1