diff options
Diffstat (limited to 'bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py')
-rw-r--r-- | bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py | 47 |
1 files changed, 35 insertions, 12 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 | ||