[gnome-continuous-yocto/gnomeostree-3.28-rocko: 1799/8267] bitbake: toaster: checksettings call django's loaddata instead of custom command



commit 33a4006529ca0e463f1e1fc95daef973a6facd3f
Author: Michael Wood <michael g wood intel com>
Date:   Mon Aug 1 19:32:53 2016 +0100

    bitbake: toaster: checksettings call django's loaddata instead of custom command
    
    Call django's inbuilt loaddata command to load the appropriate fixtures.
    We also attempt to load a fixture called "custom" and fail silently if
    we don't have one. This is where initial customisations can be done to
    load particular settings or data into Toaster (for example layers or
    default values for variables)
    
    Make sure the value for TEMPLATECONF is available to checksettings so
    that we can have a go a working out which default data to load.
    
    (Bitbake rev: 7d14ca8cbabbb893e507a66e4cc6e3e77c1e8c84)
    
    Signed-off-by: Michael Wood <michael g wood intel com>
    Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>

 bitbake/bin/toaster                                |    3 +-
 .../management/commands/checksettings.py           |   55 ++++++++++++++++----
 2 files changed, 46 insertions(+), 12 deletions(-)
---
diff --git a/bitbake/bin/toaster b/bitbake/bin/toaster
index 79ab301..80d07ab 100755
--- a/bitbake/bin/toaster
+++ b/bitbake/bin/toaster
@@ -59,7 +59,8 @@ webserverStartAll()
         echo "Failed migrations, aborting system start" 1>&2
         return $retval
     fi
-
+    # Make sure that checksettings can pick up any value for TEMPLATECONF
+    export TEMPLATECONF
     $MANAGE checksettings --traceback || retval=1
 
     if [ $retval -eq 1 ]; then
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py 
b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
index 8cdc813..fcee8b0 100644
--- a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
+++ b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
@@ -1,10 +1,15 @@
 from django.core.management.base import NoArgsCommand, CommandError
 from django.db import transaction
+
+from django.core.management import call_command
 from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException
 from bldcontrol.models import BuildRequest, BuildEnvironment, BRError
-from orm.models import ToasterSetting, Build
+from orm.models import ToasterSetting, Build, Layer
+
 import os
 import traceback
+import warnings
+
 
 def DN(path):
     if path is None:
@@ -94,30 +99,58 @@ class Command(NoArgsCommand):
                     print("\n -- Validation: The build directory must to be set to an absolute path.")
                     is_changed = _update_builddir()
 
-
                 if is_changed:
                     print("\nBuild configuration saved")
                     be.save()
                     return True
 
-
                 if be.needs_import:
                     try:
-                        config_file = os.environ.get('TOASTER_CONF')
-                        print("\nImporting file: %s" % config_file)
-                        from .loadconf import Command as LoadConfigCommand
+                        print("Loading default settings")
+                        call_command("loaddata", "settings")
+                        template_conf = os.environ.get("TEMPLATECONF", "")
+
+                        if "poky" in template_conf:
+                            print("Loading poky configuration")
+                            call_command("loaddata", "poky")
+                        else:
+                            print("Loading OE-Core configuration")
+                            call_command("loaddata", "oe-core")
+                            if template_conf:
+                                oe_core_path = os.realpath(template_conf +
+                                                           "/../")
+                            else:
+                                print("TEMPLATECONF not found. You may have to"
+                                      " manually configure layer paths")
+                                oe_core_path = input("Please enter the path of"
+                                                     " your openembedded-core "
+                                                     "layer: ")
+                            # Update the layer instances of openemebedded-core
+                            for layer in Layer.objects.filter(
+                                    name="openembedded-core"):
+                                layer.local_source_dir = oe_core_path
+                                layer.save()
+
+                        # Import the custom fixture if it's present
+                        with warnings.catch_warnings():
+                            warnings.filterwarnings(
+                                action="ignore",
+                                message="^.*No fixture named.*$")
+                            print("Importing custom settings if present")
+                            call_command("loaddata", "custom")
 
-                        LoadConfigCommand()._import_layer_config(config_file)
                         # we run lsupdates after config update
-                        print("\nLayer configuration imported. Updating information from the layer sources, 
please wait.\nYou can re-update any time later by running bitbake/lib/toaster/manage.py lsupdates")
-                        from django.core.management import call_command
+                        print("\nFetching information from the layer index, "
+                              "please wait.\nYou can re-update any time later "
+                              "by running bitbake/lib/toaster/manage.py "
+                              "lsupdates\n")
                         call_command("lsupdates")
 
                         # we don't look for any other config files
                         return is_changed
                     except Exception as e:
-                        print("Failure while trying to import the toaster config file %s: %s" %\
-                            (config_file, e))
+                        print("Failure while trying to setup toaster: %s"
+                              % e)
                         traceback.print_exc()
 
                 return is_changed


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]