replace custom loadconf with loaddata
cover replace custom loadconf with loaddata
Replace the custom loadconf command with django's own inbuilt loaddata command.
Django's command is much better tested, supports multiple formats and makes for much easier customisation of Toaster.
We check the TEMPLATECONF value to determine if Toaster is running within poky or OpenEmbedded-core. And fallback if no value is found. Based on this we can load default data for the correct environment the first time you run Toaster.
- settings.xml This contains Toaster wide settings, such as the default values for certain bitbake variables.
- poky.xml This is the release metadata for supported poky based setup
- oe-core.xml This is the release metadata for supported oe-core based setups
As we also want to allow customisation of Toaster at start up added is a mechanism to load a "custom" fixture if present in the fixtures directory (see README).
After this is merged we can. Remove toasterconf.json in the OpenEmbedded-core layer and the copy in the meta-poky layer.
While testing this I added one unrelated patch which is to add a spinner for parsing/http fetch on the layerindex fetcher - When on a slow connection/machine it's not clear if downloading and parsing the data from the Layerindex is still underway so add some visual feedback.
Michael Wood (5):
toaster: Add poky and openembedded configuration fixtures
toaster: checksettings call django's loaddata instead of custom
command
toaster: lsupdates Add spinner for parsing/http fetch
toaster: Remove old toaster config loading mechanism
toaster: fixtures Add README
bitbake/bin/toaster | 18 +-- .../management/commands/checksettings.py | 88 +++++----- .../bldcontrol/management/commands/loadconf.py | 179 --------------------- bitbake/lib/toaster/orm/fixtures/README | 30 ++++ bitbake/lib/toaster/orm/fixtures/oe-core.xml | 57 +++++++ bitbake/lib/toaster/orm/fixtures/poky.xml | 105 ++++++++++++ bitbake/lib/toaster/orm/fixtures/settings.xml | 36 +++++ .../toaster/orm/management/commands/lsupdates.py | 35 +++- 8 files changed, 307 insertions(+), 241 deletions(-) delete mode 100644 bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py create mode 100644 bitbake/lib/toaster/orm/fixtures/README create mode 100644 bitbake/lib/toaster/orm/fixtures/oe-core.xml create mode 100644 bitbake/lib/toaster/orm/fixtures/poky.xml create mode 100644 bitbake/lib/toaster/orm/fixtures/settings.xml
Signature · 1 line
2.7.4
PATCH 1/5 toaster: Add poky and openembedded configuration fixtures
These fixtures provide a recommended default configuration of toaster for either using bitbake and oe-core or as part of poky.
They can be used as the sample configuration for writing custom configurations.
--- bitbake/lib/toaster/orm/fixtures/oe-core.xml | 57 ++++++++++++++ bitbake/lib/toaster/orm/fixtures/poky.xml | 105 ++++++++++++++++++++++++++ bitbake/lib/toaster/orm/fixtures/settings.xml | 36 +++++++++ 3 files changed, 198 insertions(+) create mode 100644 bitbake/lib/toaster/orm/fixtures/oe-core.xml create mode 100644 bitbake/lib/toaster/orm/fixtures/poky.xml create mode 100644 bitbake/lib/toaster/orm/fixtures/settings.xml
bitbake/lib/toaster/orm/fixtures/oe-core.xml new file +57 -0
@@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="utf-8"?> +<django-objects version="1.0"> + <!-- Bitbake versions which correspond to the metadata release --> + <object model="orm.bitbakeversion" pk="1"> + <field type="CharField" name="name">master</field> + <field type="CharField" name="giturl">git://git.openembedded.org/bitbake</field> + <field type="CharField" name="branch">master</field> + <field type="CharField" name="dirpath">bitbake</field> + </object> + <object model="orm.bitbakeversion" pk="2"> + <field type="CharField" name="name">HEAD</field> + <field type="CharField" name="giturl">git://git.openembedded.org/bitbake</field> + <field type="CharField" name="branch">HEAD</field> + <field type="CharField" name="dirpath">bitbake</field> + </object> + + <!-- Releases available --> + <object model="orm.release" pk="1"> + <field type="CharField" name="name">master</field> + <field type="CharField" name="description">Openembedded master</field> + <field rel="ManyToOneRel" to="orm.bitbakeversion" name="bitbake_version">1</field> + <field type="CharField" name="branch_name">master</field> + <field type="TextField" name="helptext">Toaster will run your builds using the tip of the <a href=\"http://cgit.openembedded.org/openembedded-core/log/\">OpenEmbedded master</a> branch, where active development takes place. This is not a stable branch, so your builds might not work as expected.</field> + </object> + <object model="orm.release" pk="2"> + <field type="CharField" name="name">local</field> + <field type="CharField" name="description">Local Openembedded</field> + <field rel="ManyToOneRel" to="orm.bitbakeversion" name="bitbake_version">2</field> + <field type="CharField" name="branch_name">HEAD</field> + <field type="TextField" name="helptext">Toaster will run your builds with the version of OpenEmbedded that you have cloned or downloaded to your computer.</field> + </object> + + <!-- Default layers for each release --> + <object model="orm.releasedefaultlayer" pk="1"> + <field rel="ManyToOneRel" to="orm.release" name="release">1</field> + <field type="CharField" name="layer_name">openembedded-core</field> + </object> + <object model="orm.releasedefaultlayer" pk="4"> + <field rel="ManyToOneRel" to="orm.release" name="release">2</field> + <field type="CharField" name="layer_name">openembedded-core</field> + </object> + + <!-- TYPE_LOCAL = 0 Layers for the Local release --> + <object model="orm.layer" pk="1"> + <field type="CharField" name="name">openembedded-core</field> + <field type="CharField" name="layer_index_url"></field> + <field type="CharField" name="vcs_url">git://git.openembedded.org/openembedded-core</field> + </object> + <object model="orm.layer_version" pk="1"> + <field rel="ManyToOneRel" to="orm.layer" name="layer">1</field> + <field type="IntegerField" name="layer_source">0</field> + <field rel="ManyToOneRel" to="orm.release" name="release">2</field> + <field type="CharField" name="branch">HEAD</field> + <field type="CharField" name="commit">HEAD</field> + </object> + +</django-objects>
bitbake/lib/toaster/orm/fixtures/poky.xml new file +105 -0
105 lines not on this page · raw message
bitbake/lib/toaster/orm/fixtures/settings.xml new file +36 -0
@@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<django-objects version="1.0"> + <!-- Default project settings --> + <object model="orm.toastersetting" pk="1"> + <field type="CharField" name="name">DEFAULT_RELEASE</field> + <field type="CharField" name="value">master</field> + </object> + <object model="orm.toastersetting" pk="2"> + <field type="CharField" name="name">DEFCONF_PACKAGE_CLASSES</field> + <field type="CharField" name="value">package_rpm</field> + </object> + <object model="orm.toastersetting" pk="3"> + <field type="CharField" name="name">DEFCONF_MACHINE</field> + <field type="CharField" name="value">qemux86</field> + </object> + <object model="orm.toastersetting" pk="4"> + <field type="CharField" name="name">DEFCONF_SSTATE_DIR</field> + <field type="CharField" name="value">${TOPDIR}/../sstate-cache</field> + </object> + <object model="orm.toastersetting" pk="5"> + <field type="CharField" name="name">DEFCONF_IMAGE_INSTALL_append</field> + <field type="CharField" name="value"></field> + </object> + <object model="orm.toastersetting" pk="6"> + <field type="CharField" name="name">DEFCONF_IMAGE_FSTYPES</field> + <field type="CharField" name="value">ext3 jffs2 tar.bz2</field> + </object> + <object model="orm.toastersetting" pk="7"> + <field type="CharField" name="name">DEFCONF_DISTRO</field> + <field type="CharField" name="value">poky</field> + </object> + <object model="orm.toastersetting" pk="8"> + <field type="CharField" name="name">DEFCONF_DL_DIR</field> + <field type="CharField" name="value">${TOPDIR}/../downloads</field> + </object> +</django-objects>
Signature · 1 line
2.7.4
PATCH 2/5 toaster: checksettings call django's loaddata instead of custom command
In reply to Michael WoodCall 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/bin/toaster | 3 +- .../management/commands/checksettings.py | 55 +++++++++++++++++----- 2 files changed, 46 insertions(+), 12 deletions(-)
bitbake/bin/toaster +2 -1
@@ -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
bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py +44 -11
84 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 3/5 toaster: lsupdates Add spinner for parsing/http fetch
In reply to Michael WoodAdds a spinner so that you know that the parse and http fetch from the layerindex is in progress.
--- .../toaster/orm/management/commands/lsupdates.py | 35 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)
bitbake/lib/toaster/orm/management/commands/lsupdates.py +33 -2
@@ -29,11 +29,33 @@ import sys import json import logging +import threading +import time logger = logging.getLogger("toaster") DEFAULT_LAYERINDEX_SERVER = "http://layers.openembedded.org/layerindex/api/" +class Spinner(threading.Thread): + """ A simple progress spinner to indicate download/parsing is happening""" + def __init__(self, *args, **kwargs): + super(Spinner, self).__init__(*args, **kwargs) + self.setDaemon(True) + self.signal = True + + def run(self): + os.system('setterm -cursor off') + while self.signal: + for char in ["/", "-", "\\", "|"]: + sys.stdout.write("\r" + char) + sys.stdout.flush() + time.sleep(0.25) + os.system('setterm -cursor on') + + def stop(self): + self.signal = False + + class Command(NoArgsCommand): args = "" help = "Updates locally cached information from a layerindex server"
@@ -55,6 +77,7 @@ class Command(NoArgsCommand): Fetches layer, recipe and machine information from a layerindex server """ + os.system('setterm -cursor off') self.apiurl = DEFAULT_LAYERINDEX_SERVER
@@ -70,6 +93,9 @@ class Command(NoArgsCommand): oe_core_layer = 'openembedded-core' def _get_json_response(apiurl=DEFAULT_LAYERINDEX_SERVER): + http_progress = Spinner() + http_progress.start() + _parsedurl = urlparse(apiurl) path = _parsedurl.path
@@ -79,7 +105,10 @@ class Command(NoArgsCommand): except URLError as e: raise Exception("Failed to read %s: %s" % (path, e.reason)) - return json.loads(res.read().decode('utf-8')) + parsed = json.loads(res.read().decode('utf-8')) + + http_progress.stop() + return parsed # verify we can get the basic api try:
@@ -293,5 +322,7 @@ class Command(NoArgsCommand): self.mini_progress("recipes", i, total) + os.system('setterm -cursor on') + def handle_noargs(self, **options): - self.update() + self.update()
Signature · 1 line
2.7.4
PATCH 4/5 toaster: Remove old toaster config loading mechanism
In reply to Michael WoodThis has been replaced using django's inbuilt loaddata. Django command documented at:
https://docs.djangoproject.com/en/1.8/ref/django-admin/#django-admin-loaddata
--- bitbake/bin/toaster | 15 -- .../management/commands/checksettings.py | 33 ---- .../bldcontrol/management/commands/loadconf.py | 179 --------------------- 3 files changed, 227 deletions(-) delete mode 100644 bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py
bitbake/bin/toaster +0 -15
@@ -101,7 +101,6 @@ stop_system() fi webserverKillAll # unset exported variables - unset TOASTER_CONF unset TOASTER_DIR unset BITBAKE_UI unset BBBASEDIR
@@ -154,23 +153,9 @@ if [ -n "$TEMPLATECONF" ]; then if [ -d "$OEROOT/$TEMPLATECONF" ]; then TEMPLATECONF="$OEROOT/$TEMPLATECONF" fi - if [ ! -d "$TEMPLATECONF" ]; then - echo >&2 "Error: '$TEMPLATECONF' must be a directory containing toasterconf.json" - return 1 - fi fi fi -if [ "$TOASTER_CONF" = "" ]; then - TOASTER_CONF="$TEMPLATECONF/toasterconf.json" - export TOASTER_CONF=$(python3 -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 file or fix .templateconf" - return 1 -fi - # this defines the dir toaster will use for # 1) clones of layers (in _toaster_clones ) # 2) the build dir (in build)
bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py +0 -33
@@ -26,39 +26,6 @@ class Command(NoArgsCommand): super(Command, self).__init__(*args, **kwargs) self.guesspath = DN(DN(DN(DN(DN(DN(DN(__file__))))))) - def _find_first_path_for_file(self, startdirectory, filename, level=0): - if level < 0: - return None - dirs = [] - for i in os.listdir(startdirectory): - j = os.path.join(startdirectory, i) - if os.path.isfile(j): - if i == filename: - return startdirectory - elif os.path.isdir(j): - dirs.append(j) - for j in dirs: - ret = self._find_first_path_for_file(j, filename, level - 1) - if ret is not None: - return ret - return None - - def _recursive_list_directories(self, startdirectory, level=0): - if level < 0: - return [] - dirs = [] - try: - for i in os.listdir(startdirectory): - j = os.path.join(startdirectory, i) - if os.path.isdir(j): - dirs.append(j) - except OSError: - pass - for j in dirs: - dirs = dirs + self._recursive_list_directories(j, level - 1) - return dirs - - def _verify_build_environment(self): # provide a local build env. This will be extended later to include non local if BuildEnvironment.objects.count() == 0:
bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py deleted +0 -179
179 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 5/5 toaster: fixtures Add README
In reply to Michael WoodAdd README to explain fixtures directory
--- bitbake/lib/toaster/orm/fixtures/README | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 bitbake/lib/toaster/orm/fixtures/README
bitbake/lib/toaster/orm/fixtures/README new file +30 -0
@@ -0,0 +1,30 @@ +# Fixtures directory + +Fixtures are data dumps that can be loaded into Toaster's database to provide +configuration and data. + +In this directory we have the fixtures which are loaded the first time you start Toaster. +This is to provide useful default values and metadata to Toaster. + + - settings.xml This Contains Toaster wide settings, such as the default values for + certain bitbake variables. + + - poky.xml This is the default release data for supported poky based setup + + - oe-core.xml This is the default release data for supported oe-core based setups + +# Custom data/configuration + + - custom.xml + +To add custom initial data/configuration to Toaster place a file called +"custom.xml" in this directory. If present it will be loaded into the database. +We suggest that this is used to overlay any configuration already done. +All objects loaded with the same primary keys overwrite the existing data. +Data can be provided in XML, JSON and if installed YAML formats. + +# To load data at any point in time + +Use the django management command manage.py loaddata <your fixture file> +For further information see the Django command documentation at: +https://docs.djangoproject.com/en/1.8/ref/django-admin/#django-admin-loaddata
Signature · 1 line
2.7.4
Quoted 36 lines · Michael Wood
Replace the custom loadconf command with django's own inbuilt loaddata command.
Django's command is much better tested, supports multiple formats and makes for much easier customisation of Toaster.We check the TEMPLATECONF value to determine if Toaster is running within poky or OpenEmbedded-core. And fallback if no value is found. Based on this we can load default data for the correct environment the first time you run Toaster.
- settings.xml This contains Toaster wide settings, such as the default values for certain bitbake variables.
- poky.xml This is the release metadata for supported poky based setup
- oe-core.xml This is the release metadata for supported oe-core based setups
As we also want to allow customisation of Toaster at start up added is a mechanism to load a "custom" fixture if present in the fixtures directory (see README).
After this is merged we can. Remove toasterconf.json in the OpenEmbedded-core layer and the copy in the meta-poky layer.
While testing this I added one unrelated patch which is to add a spinner for parsing/http fetch on the layerindex fetcher - When on a slow connection/machine it's not clear if downloading and parsing the data from the Layerindex is still underway so add some visual feedback.
Michael Wood (5):
toaster: Add poky and openembedded configuration fixtures
toaster: checksettings call django's loaddata instead of custom
command
toaster: lsupdates Add spinner for parsing/http fetch
toaster: Remove old toaster config loading mechanism
toaster: fixtures Add READMEbitbake/bin/toaster | 18 +-- .../management/commands/checksettings.py | 88 +++++----- .../bldcontrol/management/commands/loadconf.py | 179 --------------------- bitbake/lib/toaster/orm/fixtures/README | 30 ++++ bitbake/lib/toaster/orm/fixtures/oe-core.xml | 57 +++++++ bitbake/lib/toaster/orm/fixtures/poky.xml | 105 ++++++++++++ bitbake/lib/toaster/orm/fixtures/settings.xml | 36 +++++ .../toaster/orm/management/commands/lsupdates.py | 35 +++- 8 files changed, 307 insertions(+), 241 deletions(-)
Quoted 6 lines
delete mode 100644
bitbake/lib/toaster/bldcontrol/management/commands/loadconf.pycreate mode 100644 bitbake/lib/toaster/orm/fixtures/README
create mode 100644bitbake/lib/toaster/orm/fixtures/oe-core.xmlcreate mode 100644bitbake/lib/toaster/orm/fixtures/poky.xml
create mode 100644bitbake/lib/toaster/orm/fixtures/settings.xml
Forgot to mention the branch is available at poky-contrib michaelw/toaster_replace_loadconf
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.