summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/bldcontrol
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-08-01 19:32:53 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-08-11 00:09:25 +0100
commit33a4006529ca0e463f1e1fc95daef973a6facd3f (patch)
tree0e4a099067afa1a3a13ad95a4eb6e0137a11e97a /bitbake/lib/toaster/bldcontrol
parent72fa18fb35af5d7cb1c7f92e72781bc2c56167be (diff)
downloadpoky-33a4006529ca0e463f1e1fc95daef973a6facd3f.tar.gz
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>
Diffstat (limited to 'bitbake/lib/toaster/bldcontrol')
-rw-r--r--bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py55
1 files changed, 44 insertions, 11 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
index 8cdc81311f..fcee8b09ef 100644
--- a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
+++ b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
@@ -1,10 +1,15 @@
1from django.core.management.base import NoArgsCommand, CommandError 1from django.core.management.base import NoArgsCommand, CommandError
2from django.db import transaction 2from django.db import transaction
3
4from django.core.management import call_command
3from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException 5from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException
4from bldcontrol.models import BuildRequest, BuildEnvironment, BRError 6from bldcontrol.models import BuildRequest, BuildEnvironment, BRError
5from orm.models import ToasterSetting, Build 7from orm.models import ToasterSetting, Build, Layer
8
6import os 9import os
7import traceback 10import traceback
11import warnings
12
8 13
9def DN(path): 14def DN(path):
10 if path is None: 15 if path is None:
@@ -94,30 +99,58 @@ class Command(NoArgsCommand):
94 print("\n -- Validation: The build directory must to be set to an absolute path.") 99 print("\n -- Validation: The build directory must to be set to an absolute path.")
95 is_changed = _update_builddir() 100 is_changed = _update_builddir()
96 101
97
98 if is_changed: 102 if is_changed:
99 print("\nBuild configuration saved") 103 print("\nBuild configuration saved")
100 be.save() 104 be.save()
101 return True 105 return True
102 106
103
104 if be.needs_import: 107 if be.needs_import:
105 try: 108 try:
106 config_file = os.environ.get('TOASTER_CONF') 109 print("Loading default settings")
107 print("\nImporting file: %s" % config_file) 110 call_command("loaddata", "settings")
108 from .loadconf import Command as LoadConfigCommand 111 template_conf = os.environ.get("TEMPLATECONF", "")
112
113 if "poky" in template_conf:
114 print("Loading poky configuration")
115 call_command("loaddata", "poky")
116 else:
117 print("Loading OE-Core configuration")
118 call_command("loaddata", "oe-core")
119 if template_conf:
120 oe_core_path = os.realpath(template_conf +
121 "/../")
122 else:
123 print("TEMPLATECONF not found. You may have to"
124 " manually configure layer paths")
125 oe_core_path = input("Please enter the path of"
126 " your openembedded-core "
127 "layer: ")
128 # Update the layer instances of openemebedded-core
129 for layer in Layer.objects.filter(
130 name="openembedded-core"):
131 layer.local_source_dir = oe_core_path
132 layer.save()
133
134 # Import the custom fixture if it's present
135 with warnings.catch_warnings():
136 warnings.filterwarnings(
137 action="ignore",
138 message="^.*No fixture named.*$")
139 print("Importing custom settings if present")
140 call_command("loaddata", "custom")
109 141
110 LoadConfigCommand()._import_layer_config(config_file)
111 # we run lsupdates after config update 142 # we run lsupdates after config update
112 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") 143 print("\nFetching information from the layer index, "
113 from django.core.management import call_command 144 "please wait.\nYou can re-update any time later "
145 "by running bitbake/lib/toaster/manage.py "
146 "lsupdates\n")
114 call_command("lsupdates") 147 call_command("lsupdates")
115 148
116 # we don't look for any other config files 149 # we don't look for any other config files
117 return is_changed 150 return is_changed
118 except Exception as e: 151 except Exception as e:
119 print("Failure while trying to import the toaster config file %s: %s" %\ 152 print("Failure while trying to setup toaster: %s"
120 (config_file, e)) 153 % e)
121 traceback.print_exc() 154 traceback.print_exc()
122 155
123 return is_changed 156 return is_changed