diff options
Diffstat (limited to 'bitbake/lib/toaster/bldcontrol/management/commands')
-rw-r--r-- | bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py | 47 | ||||
-rw-r--r-- | bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py | 29 |
2 files changed, 54 insertions, 22 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py index 56e4e1bf0c..cd604eba7e 100644 --- a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py +++ b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py | |||
@@ -34,6 +34,22 @@ class Command(NoArgsCommand): | |||
34 | return ret | 34 | return ret |
35 | return None | 35 | return None |
36 | 36 | ||
37 | def _recursive_list_directories(self, startdirectory, level = 0): | ||
38 | if level < 0: | ||
39 | return [] | ||
40 | dirs = [] | ||
41 | try: | ||
42 | for i in os.listdir(startdirectory): | ||
43 | j = os.path.join(startdirectory, i) | ||
44 | if os.path.isdir(j): | ||
45 | dirs.append(j) | ||
46 | except OSError: | ||
47 | pass | ||
48 | for j in dirs: | ||
49 | dirs = dirs + self._recursive_list_directories(j, level - 1) | ||
50 | return dirs | ||
51 | |||
52 | |||
37 | def _get_suggested_sourcedir(self, be): | 53 | def _get_suggested_sourcedir(self, be): |
38 | if be.betype != BuildEnvironment.TYPE_LOCAL: | 54 | if be.betype != BuildEnvironment.TYPE_LOCAL: |
39 | return "" | 55 | return "" |
@@ -67,7 +83,6 @@ class Command(NoArgsCommand): | |||
67 | print("Verifying the Build Environment type %s id %d." % (be.get_betype_display(), be.pk)) | 83 | print("Verifying the Build Environment type %s id %d." % (be.get_betype_display(), be.pk)) |
68 | if len(be.sourcedir) == 0: | 84 | if len(be.sourcedir) == 0: |
69 | suggesteddir = self._get_suggested_sourcedir(be) | 85 | suggesteddir = self._get_suggested_sourcedir(be) |
70 | homesourcedir = suggesteddir | ||
71 | be.sourcedir = raw_input(" -- Layer sources checkout directory may not be empty [guessed \"%s\"]:" % suggesteddir) | 86 | be.sourcedir = raw_input(" -- Layer sources checkout directory may not be empty [guessed \"%s\"]:" % suggesteddir) |
72 | if len(be.sourcedir) == 0 and len(suggesteddir) > 0: | 87 | if len(be.sourcedir) == 0 and len(suggesteddir) > 0: |
73 | be.sourcedir = suggesteddir | 88 | be.sourcedir = suggesteddir |
@@ -94,17 +109,25 @@ class Command(NoArgsCommand): | |||
94 | be.save() | 109 | be.save() |
95 | 110 | ||
96 | if is_changed and be.betype == BuildEnvironment.TYPE_LOCAL: | 111 | if is_changed and be.betype == BuildEnvironment.TYPE_LOCAL: |
97 | baselayerdir = DN(DN(self._find_first_path_for_file(homesourcedir, "toasterconf.json", 3))) | 112 | for dirname in self._recursive_list_directories(be.sourcedir,2): |
98 | if baselayerdir: | 113 | if os.path.exists(os.path.join(dirname, ".templateconf")): |
99 | i = raw_input(" -- Do you want to import basic layer configuration from \"%s\" ? (y/N):" % baselayerdir) | 114 | import subprocess |
100 | if len(i) and i.upper()[0] == 'Y': | 115 | conffilepath, error = subprocess.Popen('bash -c ". '+os.path.join(dirname, ".templateconf")+'; echo \"\$TEMPLATECONF\""', shell=True, stdout=subprocess.PIPE).communicate() |
101 | from loadconf import Command as LoadConfigCommand | 116 | conffilepath = os.path.join(conffilepath.strip(), "toasterconf.json") |
102 | LoadConfigCommand()._import_layer_config(os.path.join(baselayerdir, "meta/conf/toasterconf.json")) | 117 | candidatefilepath = os.path.join(dirname, conffilepath) |
103 | # we run lsupdates after config update | 118 | if os.path.exists(candidatefilepath): |
104 | print "Updating information from the layer source, please wait." | 119 | i = raw_input(" -- Do you want to import basic layer configuration from \"%s\" ? (y/N):" % candidatefilepath) |
105 | from django.core.management import call_command | 120 | if len(i) and i.upper()[0] == 'Y': |
106 | call_command("lsupdates") | 121 | from loadconf import Command as LoadConfigCommand |
107 | pass | 122 | |
123 | LoadConfigCommand()._import_layer_config(candidatefilepath) | ||
124 | # we run lsupdates after config update | ||
125 | print "Layer configuration imported. Updating information from the layer source, please wait." | ||
126 | from django.core.management import call_command | ||
127 | call_command("lsupdates") | ||
128 | |||
129 | # we don't look for any other config files | ||
130 | return is_changed | ||
108 | 131 | ||
109 | return is_changed | 132 | return is_changed |
110 | 133 | ||
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py b/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py index c9af487d9d..6e1f97a9f9 100644 --- a/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py +++ b/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py | |||
@@ -1,6 +1,6 @@ | |||
1 | from django.core.management.base import BaseCommand, CommandError | 1 | from django.core.management.base import BaseCommand, CommandError |
2 | from orm.models import LayerSource, ToasterSetting, Branch, Layer, Layer_Version | 2 | from orm.models import LayerSource, ToasterSetting, Branch, Layer, Layer_Version |
3 | from orm.models import BitbakeVersion, Release, ReleaseDefaultLayer | 3 | from orm.models import BitbakeVersion, Release, ReleaseDefaultLayer, ReleaseLayerSourcePriority |
4 | import os | 4 | import os |
5 | 5 | ||
6 | from checksettings import DN | 6 | from checksettings import DN |
@@ -71,17 +71,23 @@ class Command(BaseCommand): | |||
71 | assert 'name' in lsi | 71 | assert 'name' in lsi |
72 | assert 'branches' in lsi | 72 | assert 'branches' in lsi |
73 | 73 | ||
74 | if lsi['sourcetype'] == LayerSource.TYPE_LAYERINDEX or lsi['apiurl'].startswith("/"): | 74 | def _get_id_for_sourcetype(s): |
75 | for i in LayerSource.SOURCE_TYPE: | ||
76 | if s == i[1]: | ||
77 | return i[0] | ||
78 | raise Exception("Could not find definition for sourcetype " + s) | ||
79 | |||
80 | if _get_id_for_sourcetype(lsi['sourcetype']) == LayerSource.TYPE_LAYERINDEX or lsi['apiurl'].startswith("/"): | ||
75 | apiurl = lsi['apiurl'] | 81 | apiurl = lsi['apiurl'] |
76 | else: | 82 | else: |
77 | apiurl = self._reduce_canon_path(os.path.join(DN(filepath), lsi['apiurl'])) | 83 | apiurl = self._reduce_canon_path(os.path.join(DN(filepath), lsi['apiurl'])) |
78 | 84 | ||
79 | try: | 85 | try: |
80 | ls = LayerSource.objects.get(sourcetype = lsi['sourcetype'], apiurl = apiurl) | 86 | ls = LayerSource.objects.get(sourcetype = _get_id_for_sourcetype(lsi['sourcetype']), apiurl = apiurl) |
81 | except LayerSource.DoesNotExist: | 87 | except LayerSource.DoesNotExist: |
82 | ls = LayerSource.objects.create( | 88 | ls = LayerSource.objects.create( |
83 | name = lsi['name'], | 89 | name = lsi['name'], |
84 | sourcetype = lsi['sourcetype'], | 90 | sourcetype = _get_id_for_sourcetype(lsi['sourcetype']), |
85 | apiurl = apiurl | 91 | apiurl = apiurl |
86 | ) | 92 | ) |
87 | 93 | ||
@@ -121,17 +127,20 @@ class Command(BaseCommand): | |||
121 | bvo = BitbakeVersion.objects.get(name = ri['bitbake']) | 127 | bvo = BitbakeVersion.objects.get(name = ri['bitbake']) |
122 | assert bvo is not None | 128 | assert bvo is not None |
123 | 129 | ||
124 | ro, created = Release.objects.get_or_create(name = ri['name'], bitbake_version = bvo, branch = Branch.objects.get( layer_source__name = ri['layersource'], name=ri['branch'])) | 130 | ro, created = Release.objects.get_or_create(name = ri['name'], bitbake_version = bvo, branch_name = ri['branch']) |
125 | ro.description = ri['description'] | 131 | ro.description = ri['description'] |
126 | ro.helptext = ri['helptext'] | 132 | ro.helptext = ri['helptext'] |
127 | ro.save() | 133 | ro.save() |
128 | 134 | ||
135 | # save layer source priority for release | ||
136 | for ls_name in ri['layersourcepriority'].keys(): | ||
137 | rlspo, created = ReleaseLayerSourcePriority.objects.get_or_create(release = ro, layer_source = LayerSource.objects.get(name=ls_name)) | ||
138 | rlspo.priority = ri['layersourcepriority'][ls_name] | ||
139 | rlspo.save() | ||
140 | |||
129 | for dli in ri['defaultlayers']: | 141 | for dli in ri['defaultlayers']: |
130 | layer, created = Layer.objects.get_or_create( | 142 | # find layers with the same name |
131 | layer_source = LayerSource.objects.get(name = ri['layersource']), | 143 | ReleaseDefaultLayer.objects.get_or_create( release = ro, layer_name = dli) |
132 | name = dli | ||
133 | ) | ||
134 | ReleaseDefaultLayer.objects.get_or_create( release = ro, layer = layer) | ||
135 | 144 | ||
136 | # set default release | 145 | # set default release |
137 | if ToasterSetting.objects.filter(name = "DEFAULT_RELEASE").count() > 0: | 146 | if ToasterSetting.objects.filter(name = "DEFAULT_RELEASE").count() > 0: |