diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2015-02-05 12:07:44 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-02-10 23:07:48 +0000 |
commit | 0c89846dafa229b5af9653d6e141011c35451825 (patch) | |
tree | 12c42dccf16a5f94202507b747899c2ed122c268 /bitbake | |
parent | 202d808f890b03958cd6873486e6a37f3f437098 (diff) | |
download | poky-0c89846dafa229b5af9653d6e141011c35451825.tar.gz |
bitbake: toaster: enhancements for the startup sequence
This patch brings fixes and enhancements in the startup sequence.
- the dependency version checking is now correctly enforced when
starting in both modes
- fixed errors in looking up environment variables
- added message with 'daemon' program start location
- presenting menu for selecting config file
[YOCTO #7283]
[YOCTO #7291]
[YOCTO #7273]
(Bitbake rev: c5ddd9d88910857a1b745b1c237df0390dd56835)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rwxr-xr-x | bitbake/bin/toaster | 37 | ||||
-rw-r--r-- | bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py | 76 |
2 files changed, 84 insertions, 29 deletions
diff --git a/bitbake/bin/toaster b/bitbake/bin/toaster index 6f7c6f09ea..c3b8633c25 100755 --- a/bitbake/bin/toaster +++ b/bitbake/bin/toaster | |||
@@ -126,17 +126,20 @@ function notify_chldexit() { | |||
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | # Verify prerequisites | 129 | function verify_prereq() { |
130 | # Verify prerequisites | ||
130 | 131 | ||
131 | if ! echo "import django; print (1,) == django.VERSION[0:1] and django.VERSION[1:2][0] in (5,6)" | python 2>/dev/null | grep True >/dev/null; then | 132 | if ! echo "import django; print (1,) == django.VERSION[0:1] and django.VERSION[1:2][0] in (5,6)" | python 2>/dev/null | grep True >/dev/null; then |
132 | echo -e "This program needs Django 1.5 or 1.6. Please install with\n\npip install django==1.6" | 133 | echo -e "This program needs Django 1.5 or 1.6. Please install with\n\npip install django==1.6\n" |
133 | return 2 | 134 | return 2 |
134 | fi | 135 | fi |
135 | 136 | ||
136 | if ! echo "import south; print [0,8,4] == map(int,south.__version__.split(\".\"))" | python 2>/dev/null | grep True >/dev/null; then | 137 | if ! echo "import south; print reduce(lambda x, y: 2 if x==2 else 0 if x == 0 else y, map(lambda x: 1+cmp(x[1]-x[0],0), zip([0,8,4], map(int,south.__version__.split(\".\"))))) > 0" | python 2>/dev/null | grep True >/dev/null; then |
137 | echo -e "This program needs South 0.8.4. Please install with\n\npip install south==0.8.4" | 138 | echo -e "This program needs South 0.8.4. Please install with\n\npip install south==0.8.4\n" |
138 | return 2 | 139 | return 2 |
139 | fi | 140 | fi |
141 | return 0 | ||
142 | } | ||
140 | 143 | ||
141 | 144 | ||
142 | # read command line parameters | 145 | # read command line parameters |
@@ -170,13 +173,18 @@ if [ -z "$ZSH_NAME" ] && [ `basename \"$0\"` = `basename \"$BASH_SOURCE\"` ]; th | |||
170 | # We are called as standalone. We refuse to run in a build environment - we need the interactive mode for that. | 173 | # We are called as standalone. We refuse to run in a build environment - we need the interactive mode for that. |
171 | # Start just the web server, point the web browser to the interface, and start any Django services. | 174 | # Start just the web server, point the web browser to the interface, and start any Django services. |
172 | 175 | ||
176 | if ! verify_prereq; then | ||
177 | echo -e "Error: Could not verify that the needed dependencies are installed. Please use virtualenv and pip to install dependencies listed in toaster-requirements.txt" 1>&2; | ||
178 | exit 1; | ||
179 | fi | ||
180 | |||
173 | if [ -n "$BUILDDIR" ]; then | 181 | if [ -n "$BUILDDIR" ]; then |
174 | echo -e "Error: It looks like you sourced oe-init-build-env. Toaster cannot start in build mode from an oe-core build environment. You can work around this problem by starting Toaster from a new terminal window." 1>&2; | 182 | echo -e "Error: It looks like you sourced oe-init-build-env. Toaster cannot start in build mode from an oe-core build environment.\n You should be starting Toaster from a new terminal window." 1>&2; |
175 | exit 1; | 183 | exit 1; |
176 | fi | 184 | fi |
177 | 185 | ||
178 | if [ "x`which daemon`" == "x" ]; then | 186 | if [ "x`which daemon`" == "x" ]; then |
179 | echo -e "Failed dependency; toaster needs the 'daemon' program in order to be able to start builds'. Please install the 'daemon' program." 1>&2; | 187 | echo -e "Failed dependency; toaster needs the 'daemon' program in order to be able to start builds'. Please install the 'daemon' program from your distribution repositories or http://www.libslack.org/daemon/" 1>&2; |
180 | exit 1; | 188 | exit 1; |
181 | fi | 189 | fi |
182 | 190 | ||
@@ -208,6 +216,13 @@ if [ -z "$ZSH_NAME" ] && [ `basename \"$0\"` = `basename \"$BASH_SOURCE\"` ]; th | |||
208 | exit 0 | 216 | exit 0 |
209 | fi | 217 | fi |
210 | 218 | ||
219 | |||
220 | if ! verify_prereq; then | ||
221 | echo -e "Error: Could not verify that the needed dependencies are installed. Please use virtualenv and pip to install dependencies listed in toaster-requirements.txt" 1>&2; | ||
222 | return 1; | ||
223 | fi | ||
224 | |||
225 | |||
211 | # We make sure we're running in the current shell and in a good environment | 226 | # We make sure we're running in the current shell and in a good environment |
212 | if [ -z "$BUILDDIR" ] || [ -z `which bitbake` ]; then | 227 | if [ -z "$BUILDDIR" ] || [ -z `which bitbake` ]; then |
213 | echo "Error: Build environment is not setup or bitbake is not in path." 1>&2; | 228 | echo "Error: Build environment is not setup or bitbake is not in path." 1>&2; |
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py index cf3c3d7ecf..5d80bc7155 100644 --- a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py +++ b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py | |||
@@ -78,44 +78,68 @@ class Command(NoArgsCommand): | |||
78 | 78 | ||
79 | # we make sure we have builddir and sourcedir for all defined build envionments | 79 | # we make sure we have builddir and sourcedir for all defined build envionments |
80 | for be in BuildEnvironment.objects.all(): | 80 | for be in BuildEnvironment.objects.all(): |
81 | be.needs_import = False | ||
81 | def _verify_be(): | 82 | def _verify_be(): |
82 | is_changed = False | 83 | is_changed = False |
83 | print("Verifying the Build Environment. If the Build Environment is completly configured, you will be asked to configure it.") | 84 | print("Verifying the Build Environment. If the local Build Environment is not properly configured, you will be asked to configure it.") |
84 | if len(be.sourcedir) == 0: | 85 | |
86 | def _update_sourcedir(): | ||
85 | suggesteddir = self._get_suggested_sourcedir(be) | 87 | suggesteddir = self._get_suggested_sourcedir(be) |
86 | if len(suggesteddir) > 0: | 88 | if len(suggesteddir) > 0: |
87 | be.sourcedir = raw_input("\nToaster needs to know in which directory it should check out the layers that will be needed for your builds.\n Toaster suggests \"%s\". If you select this directory, a layer like \"meta-yocto\" will end up in \"%s/meta-yocto\".\n Press Enter to select \"%s\" or type the full path to a different directory: " % (suggesteddir, suggesteddir, suggesteddir)) | 89 | be.sourcedir = raw_input("Toaster needs to know in which directory it should check out the layers that will be needed for your builds.\n Toaster suggests \"%s\". If you select this directory, a layer like \"meta-intel\" will end up in \"%s/meta-intel\".\n Press Enter to select \"%s\" or type the full path to a different directory (must be a parent of current checkout directory): " % (suggesteddir, suggesteddir, suggesteddir)) |
88 | else: | 90 | else: |
89 | be.sourcedir = raw_input("\nToaster needs to know in which directory it should check out the layers that will be needed for your builds. Type the full path to the directory (for example: \"%s\": " % os.environment['HOME']) | 91 | be.sourcedir = raw_input("Toaster needs to know in which directory it should check out the layers that will be needed for your builds. Type the full path to the directory (for example: \"%s\": " % os.environ.get('HOME', '/tmp/')) |
90 | if len(be.sourcedir) == 0 and len(suggesteddir) > 0: | 92 | if len(be.sourcedir) == 0 and len(suggesteddir) > 0: |
91 | be.sourcedir = suggesteddir | 93 | be.sourcedir = suggesteddir |
92 | is_changed = True | 94 | return True |
95 | |||
96 | if len(be.sourcedir) == 0: | ||
97 | print "\n -- Validation: The checkout directory must be set." | ||
98 | is_changed = _update_sourcedir() | ||
93 | 99 | ||
94 | if not be.sourcedir.startswith("/"): | 100 | if not be.sourcedir.startswith("/"): |
95 | be.sourcedir = raw_input(" Layer sources checkout directory must be an absolute path:") | 101 | print "\n -- Validation: The checkout directory must be set to an absolute path." |
96 | is_changed = True | 102 | is_changed = _update_sourcedir() |
97 | 103 | ||
98 | if len(be.builddir) == 0: | 104 | if not be.sourcedir in DN(__file__): |
105 | print "\n -- Validation: The checkout directory must be a parent of the current checkout." | ||
106 | is_changed = _update_sourcedir() | ||
107 | |||
108 | if is_changed: | ||
109 | if be.betype == BuildEnvironment.TYPE_LOCAL: | ||
110 | be.needs_import = True | ||
111 | return True | ||
112 | |||
113 | def _update_builddir(): | ||
99 | suggesteddir = self._get_suggested_builddir(be) | 114 | suggesteddir = self._get_suggested_builddir(be) |
100 | if len(suggesteddir) > 0: | 115 | if len(suggesteddir) > 0: |
101 | be.builddir = raw_input("\nToaster needs to know where is your build directory.\n The build directory is where all the artifacts created by your builds will be stored. Toaster suggests \"%s\".\n Press Enter to select \"%s\" or type the full path to a different directory: " % (suggesteddir, suggesteddir)) | 116 | be.builddir = raw_input("Toaster needs to know where it your build directory is located.\n The build directory is where all the artifacts created by your builds will be stored. Toaster suggests \"%s\".\n Press Enter to select \"%s\" or type the full path to a different directory: " % (suggesteddir, suggesteddir)) |
102 | else: | 117 | else: |
103 | be.builddir = raw_input("\nToaster needs to know where is your build directory.\n The build directory is where all the artifacts created by your builds will be stored. Type the full path to the directory (for example: \" %s/build\")" % os.environment['HOME']) | 118 | be.builddir = raw_input("Toaster needs to know where is your build directory.\n The build directory is where all the artifacts created by your builds will be stored. Type the full path to the directory (for example: \" %s/build\")" % os.environ.get('HOME','/tmp/')) |
104 | if len(be.builddir) == 0 and len(suggesteddir) > 0: | 119 | if len(be.builddir) == 0 and len(suggesteddir) > 0: |
105 | be.builddir = suggesteddir | 120 | be.builddir = suggesteddir |
106 | is_changed = True | 121 | return True |
122 | |||
123 | if len(be.builddir) == 0: | ||
124 | print "\n -- Validation: The build directory must be set." | ||
125 | is_changed = _update_builddir() | ||
107 | 126 | ||
108 | if not be.builddir.startswith("/"): | 127 | if not be.builddir.startswith("/"): |
109 | be.builddir = raw_input(" Build directory must be an absolute path:") | 128 | print "\n -- Validation: The build directory must to be set to an absolute path." |
110 | is_changed = True | 129 | is_changed = _update_builddir() |
111 | 130 | ||
112 | 131 | ||
113 | if is_changed: | 132 | if is_changed: |
114 | print "Build configuration saved" | 133 | print "Build configuration saved" |
115 | be.save() | 134 | be.save() |
135 | return True | ||
136 | |||
137 | |||
138 | if be.needs_import: | ||
139 | print "\nToaster can use a SINGLE predefined configuration file to set up default project settings and layer information sources.\n" | ||
116 | 140 | ||
117 | if is_changed and be.betype == BuildEnvironment.TYPE_LOCAL: | 141 | # find configuration files |
118 | print "\nToaster can use a SINGLE predefined configuration file to set up default project settings and layer information sources.\n Toaster will list now the configuration files that it found. Select Yes to use the desired configuration file." | 142 | config_files = [] |
119 | for dirname in self._recursive_list_directories(be.sourcedir,2): | 143 | for dirname in self._recursive_list_directories(be.sourcedir,2): |
120 | if os.path.exists(os.path.join(dirname, ".templateconf")): | 144 | if os.path.exists(os.path.join(dirname, ".templateconf")): |
121 | import subprocess | 145 | import subprocess |
@@ -123,11 +147,20 @@ class Command(NoArgsCommand): | |||
123 | conffilepath = os.path.join(conffilepath.strip(), "toasterconf.json") | 147 | conffilepath = os.path.join(conffilepath.strip(), "toasterconf.json") |
124 | candidatefilepath = os.path.join(dirname, conffilepath) | 148 | candidatefilepath = os.path.join(dirname, conffilepath) |
125 | if os.path.exists(candidatefilepath): | 149 | if os.path.exists(candidatefilepath): |
126 | i = raw_input("\n Found an preset configuration file \"%s\".\n Do you want to use it? (y/N):" % candidatefilepath) | 150 | config_files.append(candidatefilepath) |
127 | if len(i) and i.upper()[0] == 'Y': | 151 | |
152 | if len(config_files) > 0: | ||
153 | print " Toaster will list now the configuration files that it found. Select the number to use the desired configuration file." | ||
154 | for cf in config_files: | ||
155 | print " [%d] - %s" % (config_files.index(cf) + 1, cf) | ||
156 | print "\n [0] - Exit without importing any file" | ||
157 | try: | ||
158 | i = raw_input("\n Enter your option: ") | ||
159 | if len(i) and (int(i) - 1 >= 0 and int(i) - 1 < len(config_files)): | ||
160 | print "Importing file: %s" % config_files[int(i)-1] | ||
128 | from loadconf import Command as LoadConfigCommand | 161 | from loadconf import Command as LoadConfigCommand |
129 | 162 | ||
130 | LoadConfigCommand()._import_layer_config(candidatefilepath) | 163 | LoadConfigCommand()._import_layer_config(config_files[int(i)-1]) |
131 | # we run lsupdates after config update | 164 | # we run lsupdates after config update |
132 | print "Layer configuration imported. Updating information from the layer sources, please wait.\n You can re-update any time later by running bitbake/lib/toaster/manage.py lsupdates" | 165 | print "Layer configuration imported. Updating information from the layer sources, please wait.\n You can re-update any time later by running bitbake/lib/toaster/manage.py lsupdates" |
133 | from django.core.management import call_command | 166 | from django.core.management import call_command |
@@ -135,6 +168,13 @@ class Command(NoArgsCommand): | |||
135 | 168 | ||
136 | # we don't look for any other config files | 169 | # we don't look for any other config files |
137 | return is_changed | 170 | return is_changed |
171 | except Exception as e: | ||
172 | print "Failure while trying to import the toaster config file: %s" % e | ||
173 | else: | ||
174 | print "\n Toaster could not find a configuration file. You need to configure Toaster manually using the web interface, or create a configuration file and use\n bitbake/lib/toaster/managepy.py loadconf [filename]\n command to load it. You can use https://wiki.yoctoproject.org/wiki/File:Toasterconf.json.txt.patch as a starting point." | ||
175 | |||
176 | |||
177 | |||
138 | 178 | ||
139 | return is_changed | 179 | return is_changed |
140 | 180 | ||