diff options
Diffstat (limited to 'classes/sanity.bbclass')
| -rw-r--r-- | classes/sanity.bbclass | 113 |
1 files changed, 83 insertions, 30 deletions
diff --git a/classes/sanity.bbclass b/classes/sanity.bbclass index 479abce7fa..b6c6ed939a 100644 --- a/classes/sanity.bbclass +++ b/classes/sanity.bbclass @@ -2,6 +2,8 @@ # Sanity check the users setup for common misconfigurations # +inherit qemu + def raise_sanity_error(msg): import bb bb.fatal(""" Openembedded's config sanity checker detected a potential misconfiguration. @@ -11,8 +13,6 @@ def raise_sanity_error(msg): %s""" % msg) def check_conf_exists(fn, data): - import bb, os - bbpath = [] fn = bb.data.expand(fn, data) vbbpath = bb.data.getVar("BBPATH", data) @@ -24,22 +24,14 @@ def check_conf_exists(fn, data): return True return False -def check_app_exists(app, d): - from bb import which, data - - app = data.expand(app, d) - path = data.getVar('PATH', d) - return len(which(path, app)) != 0 - - def check_sanity(e): from bb import note, error, data, __version__ - from bb.event import Handled, NotHandled, getName + try: from distutils.version import LooseVersion except ImportError: def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1 - import os + import commands # Check the bitbake version meets minimum requirements minversion = data.getVar('BB_MIN_VERSION', e.data , True) @@ -70,9 +62,10 @@ def check_sanity(e): if "diffstat-native" not in assume_provided: messages = messages + 'Please use ASSUME_PROVIDED +=, not ASSUME_PROVIDED = in your local.conf\n' - # Check that the MACHINE is valid - if not check_conf_exists("conf/machine/${MACHINE}.conf", e.data): - messages = messages + 'Please set a valid MACHINE in your local.conf\n' + # Check that the MACHINE is valid, if it is set + if data.getVar('MACHINE', e.data, True): + if not check_conf_exists("conf/machine/${MACHINE}.conf", e.data): + messages = messages + 'Please set a valid MACHINE in your local.conf\n' # Check that the DISTRO is valid # need to take into account DISTRO renaming DISTRO @@ -92,6 +85,11 @@ def check_sanity(e): required_utilities = "patch help2man diffstat texi2html makeinfo cvs svn bzip2 tar gzip gawk md5sum" + # If we'll be running qemu, perform some sanity checks + if data.getVar('ENABLE_BINARY_LOCALE_GENERATION', e.data, True): + if "qemu-native" in assume_provided: + required_utilities += " %s" % (qemu_target_binary(e.data)) + for util in required_utilities.split(): if not check_app_exists( util, e.data ): missing = missing + "%s," % util @@ -100,6 +98,12 @@ def check_sanity(e): missing = missing.rstrip(',') messages = messages + "Please install following missing utilities: %s\n" % missing + try: + if os.path.basename(os.readlink('/bin/sh')) == 'dash': + messages = messages + "Using dash as /bin/sh causes various subtle build problems, please use bash instead.\n" + except: + pass + omask = os.umask(022) if omask & 0755: messages = messages + "Please use a umask which allows a+rx and u+rwx\n" @@ -107,27 +111,76 @@ def check_sanity(e): oes_bb_conf = data.getVar( 'OES_BITBAKE_CONF', e.data, True ) if not oes_bb_conf: - messages = messages + 'You do not include OpenEmbeddeds version of conf/bitbake.conf\n' + messages = messages + 'You do not include OpenEmbeddeds version of conf/bitbake.conf. This means your environment is misconfigured, in particular check BBPATH.\n' + + # + # Check that TMPDIR hasn't changed location since the last time we were run + # + tmpdir = data.getVar('TMPDIR', e.data, True) + checkfile = os.path.join(tmpdir, "saved_tmpdir") + if os.path.exists(checkfile): + f = file(checkfile, "r") + if (f.read().strip() != tmpdir): + messages = messages + "Error, TMPDIR has changed location. You need to either move it back to %s or rebuild\n" % tmpdir + else: + import bb + bb.mkdirhier(tmpdir) + f = file(checkfile, "w") + f.write(tmpdir) + f.close() + + # + # Check the 'ABI' of TMPDIR + # + current_abi = data.getVar('OELAYOUT_ABI', e.data, True) + abifile = data.getVar('SANITY_ABIFILE', e.data, True) + if os.path.exists(abifile): + f = file(abifile, "r") + abi = f.read().strip() + if not abi.isdigit(): + f = file(abifile, "w") + f.write(current_abi) + elif (abi != current_abi): + # Code to convert from one ABI to another could go here if possible. + messages = messages + "Error, TMPDIR has changed ABI (%s to %s) and you need to either rebuild, revert or adjust it at your own risk.\n" % (abi, current_abi) + else: + f = file(abifile, "w") + f.write(current_abi) + f.close() + + # + # Check the Distro PR value didn't change + # + distro_pr = data.getVar('DISTRO_PR', e.data, True) + prfile = data.getVar('SANITY_PRFILE', e.data, True) + if os.path.exists(prfile): + f = file(prfile, "r") + pr = f.read().strip() + if (pr != distro_pr): + # Code to convert from one ABI to another could go here if possible. + messages = messages + "Error, DISTRO_PR has changed (%s to %s) which means all packages need to rebuild. Please remove your TMPDIR so this can happen. For autobuilder setups you can avoid this by using a TMPDIR that include DISTRO_PR in the path.\n" % (pr, distro_pr) + else: + f = file(prfile, "w") + f.write(distro_pr) + f.close() + + + # + # Check there aren't duplicates in PACKAGE_ARCHS + # + archs = data.getVar('PACKAGE_ARCHS', e.data, True).split() + for arch in archs: + if archs.count(arch) != 1: + messages = messages + "Error, Your PACKAGE_ARCHS field contains duplicates. Perhaps you set PACKAGE_EXTRA_ARCHS twice accidently through some tune file?\n" + break if messages != "": raise_sanity_error(messages) addhandler check_sanity_eventhandler python check_sanity_eventhandler() { - from bb import note, error, data, __version__ - from bb.event import getName - - try: - from distutils.version import LooseVersion - except ImportError: - def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1 - - if (LooseVersion(bb.__version__) > LooseVersion("1.8.6")): - if getName(e) == "ConfigParsed": - check_sanity(e) - return NotHandled - - if getName(e) == "BuildStarted": + from bb.event import Handled, NotHandled + if bb.event.getName(e) == "ConfigParsed": check_sanity(e) return NotHandled |
