diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-08-30 17:14:55 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-08-31 19:38:31 +0100 |
commit | a8d5225c3c05b6f6c48e7db5cfb81786ae52b89b (patch) | |
tree | b0ba567c8dc7f2b9eca16c19c999cb4de3dd3951 /meta/classes/sanity.bbclass | |
parent | 0c78dbc6076c2114dc894e5cebdb2a01ad35d262 (diff) | |
download | poky-a8d5225c3c05b6f6c48e7db5cfb81786ae52b89b.tar.gz |
sanity.bbclass: Clean up various MACHINE checks
[YOCTO #1398]
Firstly we should start checking if MACHINE is set. It if isn't lets
make this a sanity warning since its very hard to successfully build
without setting one (and anyone wanting to do that can disable the
sanity checks easily enough anyway).
Some of the checks depend on a MACHINE being specified. This change
moves those checks to a separate function so they only run if MACHINE
has been set correctly.
Both these issues combine to ensure the user sees a sane message
and avoids the nasty tracebacks in the bug report referenced above.
(From OE-Core rev: 02aceca132f9e259cdc5283c4bfe84e6a55df54d)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/sanity.bbclass')
-rw-r--r-- | meta/classes/sanity.bbclass | 87 |
1 files changed, 50 insertions, 37 deletions
diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass index 7fc334388b..37b90289f5 100644 --- a/meta/classes/sanity.bbclass +++ b/meta/classes/sanity.bbclass | |||
@@ -154,6 +154,48 @@ def check_supported_distro(e): | |||
154 | else: | 154 | else: |
155 | bb.warn('Host distribution could not be determined; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.') | 155 | bb.warn('Host distribution could not be determined; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.') |
156 | 156 | ||
157 | # Checks we should only make if MACHINE is set correctly | ||
158 | def check_sanity_validmachine(e): | ||
159 | from bb import data | ||
160 | |||
161 | messages = "" | ||
162 | |||
163 | # Check TUNE_ARCH is set | ||
164 | if data.getVar('TUNE_ARCH', e.data, True) == 'INVALID': | ||
165 | messages = messages + 'TUNE_ARCH is unset. Please ensure your MACHINE configuration includes a valid tune configuration file which will set this correctly.\n' | ||
166 | |||
167 | # Check TARGET_ARCH is set correctly | ||
168 | if data.getVar('TARGE_ARCH', e.data, False) == '${TUNE_ARCH}': | ||
169 | messages = messages + 'TARGET_ARCH is being overwritten, likely by your MACHINE configuration files.\nPlease use a valid tune configuration file which should set this correctly automatically\nand avoid setting this in the machine configuration. See the OE-Core mailing list for more information.\n' | ||
170 | |||
171 | # Check TARGET_OS is set | ||
172 | if data.getVar('TARGET_OS', e.data, True) == 'INVALID': | ||
173 | messages = messages + 'Please set TARGET_OS directly, or choose a MACHINE or DISTRO that does so.\n' | ||
174 | |||
175 | # Check that we don't have duplicate entries in PACKAGE_ARCHS & that TUNE_PKGARCH is in PACKAGE_ARCHS | ||
176 | pkgarchs = data.getVar('PACKAGE_ARCHS', e.data, True) | ||
177 | tunepkg = data.getVar('TUNE_PKGARCH', e.data, True) | ||
178 | tunefound = False | ||
179 | seen = {} | ||
180 | dups = [] | ||
181 | |||
182 | for pa in pkgarchs.split(): | ||
183 | if seen.get(pa, 0) == 1: | ||
184 | dups.append(pa) | ||
185 | else: | ||
186 | seen[pa] = 1 | ||
187 | if pa == tunepkg: | ||
188 | tunefound = True | ||
189 | |||
190 | if len(dups): | ||
191 | messages = messages + "Error, the PACKAGE_ARCHS variable contains duplicates. The following archs are listed more than once: %s" % " ".join(dups) | ||
192 | |||
193 | if tunefound == False: | ||
194 | messages = messages + "Error, the PACKAGE_ARCHS variable does not contain TUNE_PKGARCH (%s)." % tunepkg | ||
195 | |||
196 | return messages | ||
197 | |||
198 | |||
157 | def check_sanity(e): | 199 | def check_sanity(e): |
158 | from bb import note, error, data, __version__ | 200 | from bb import note, error, data, __version__ |
159 | 201 | ||
@@ -185,17 +227,14 @@ def check_sanity(e): | |||
185 | if (LooseVersion(__version__) < LooseVersion(minversion)): | 227 | if (LooseVersion(__version__) < LooseVersion(minversion)): |
186 | messages = messages + 'Bitbake version %s is required and version %s was found\n' % (minversion, __version__) | 228 | messages = messages + 'Bitbake version %s is required and version %s was found\n' % (minversion, __version__) |
187 | 229 | ||
188 | # Check TUNE_ARCH is set | 230 | # Check that the MACHINE is valid, if it is set |
189 | if data.getVar('TUNE_ARCH', e.data, True) == 'INVALID': | 231 | if data.getVar('MACHINE', e.data, True): |
190 | messages = messages + 'TUNE_ARCH is unset. Please ensure your MACHINE configuration includes a valid tune configuration file which will set this correctly.\n' | 232 | if not check_conf_exists("conf/machine/${MACHINE}.conf", e.data): |
191 | 233 | messages = messages + 'Please set a valid MACHINE in your local.conf or environment\n' | |
192 | # Check TARGET_ARCH is set correctly | 234 | else: |
193 | if data.getVar('TARGE_ARCH', e.data, False) == '${TUNE_ARCH}': | 235 | messages = messages + check_sanity_validmachine(e) |
194 | messages = messages + 'TARGET_ARCH is being overwritten, likely by your MACHINE configuration files.\nPlease use a valid tune configuration file which should set this correctly automatically\nand avoid setting this in the machine configuration. See the OE-Core mailing list for more information.\n' | 236 | else: |
195 | 237 | messages = messages + 'Please set a MACHINE in your local.conf or environment\n' | |
196 | # Check TARGET_OS is set | ||
197 | if data.getVar('TARGET_OS', e.data, True) == 'INVALID': | ||
198 | messages = messages + 'Please set TARGET_OS directly, or choose a MACHINE or DISTRO that does so.\n' | ||
199 | 238 | ||
200 | # Check we are using a valid lacal.conf | 239 | # Check we are using a valid lacal.conf |
201 | current_conf = data.getVar('CONF_VERSION', e.data, True) | 240 | current_conf = data.getVar('CONF_VERSION', e.data, True) |
@@ -221,11 +260,6 @@ def check_sanity(e): | |||
221 | # Check user doesn't have ASSUME_PROVIDED = instead of += in local.conf | 260 | # Check user doesn't have ASSUME_PROVIDED = instead of += in local.conf |
222 | if "diffstat-native" not in assume_provided: | 261 | if "diffstat-native" not in assume_provided: |
223 | messages = messages + 'Please use ASSUME_PROVIDED +=, not ASSUME_PROVIDED = in your local.conf\n' | 262 | messages = messages + 'Please use ASSUME_PROVIDED +=, not ASSUME_PROVIDED = in your local.conf\n' |
224 | |||
225 | # Check that the MACHINE is valid, if it is set | ||
226 | if data.getVar('MACHINE', e.data, True): | ||
227 | if not check_conf_exists("conf/machine/${MACHINE}.conf", e.data): | ||
228 | messages = messages + 'Please set a valid MACHINE in your local.conf\n' | ||
229 | 263 | ||
230 | # Check that DL_DIR is set, exists and is writable. In theory, we should never even hit the check if DL_DIR isn't | 264 | # Check that DL_DIR is set, exists and is writable. In theory, we should never even hit the check if DL_DIR isn't |
231 | # set, since so much relies on it being set. | 265 | # set, since so much relies on it being set. |
@@ -415,27 +449,6 @@ def check_sanity(e): | |||
415 | elif oeroot.find (' ') != -1: | 449 | elif oeroot.find (' ') != -1: |
416 | messages = messages + "Error, you have a space in your COREBASE directory path. Please move the installation to a directory which doesn't include a space." | 450 | messages = messages + "Error, you have a space in your COREBASE directory path. Please move the installation to a directory which doesn't include a space." |
417 | 451 | ||
418 | # Check that we don't have duplicate entries in PACKAGE_ARCHS & that TUNE_PKGARCH is in PACKAGE_ARCHS | ||
419 | pkgarchs = data.getVar('PACKAGE_ARCHS', e.data, True) | ||
420 | tunepkg = data.getVar('TUNE_PKGARCH', e.data, True) | ||
421 | tunefound = False | ||
422 | seen = {} | ||
423 | dups = [] | ||
424 | |||
425 | for pa in pkgarchs.split(): | ||
426 | if seen.get(pa, 0) == 1: | ||
427 | dups.append(pa) | ||
428 | else: | ||
429 | seen[pa] = 1 | ||
430 | if pa == tunepkg: | ||
431 | tunefound = True | ||
432 | |||
433 | if len(dups): | ||
434 | messages = messages + "Error, the PACKAGE_ARCHS variable contains duplicates. The following archs are listed more than once: %s" % " ".join(dups) | ||
435 | |||
436 | if tunefound == False: | ||
437 | messages = messages + "Error, the PACKAGE_ARCHS variable does not contain TUNE_PKGARCH (%s)." % tunepkg | ||
438 | |||
439 | if messages != "": | 452 | if messages != "": |
440 | raise_sanity_error(messages) | 453 | raise_sanity_error(messages) |
441 | 454 | ||