2 # Sanity check the users setup for common misconfigurations
5 def raise_sanity_error(msg):
7 bb.fatal(""" Openembedded's config sanity checker detected a potential misconfiguration.
8 Either fix the cause of this error or at your own risk disable the checker (see sanity.conf).
9 Following is the list of potential problems / advisories:
13 def check_conf_exists(fn, data):
17 fn = bb.data.expand(fn, data)
18 vbbpath = bb.data.getVar("BBPATH", data)
20 bbpath += vbbpath.split(":")
22 currname = os.path.join(bb.data.expand(p, data), fn)
23 if os.access(currname, os.R_OK):
27 def check_app_exists(app, d):
28 from bb import which, data
30 app = data.expand(app, d)
31 path = data.getVar('PATH', d)
32 return len(which(path, app)) != 0
36 from bb import note, error, data, __version__
37 from bb.event import Handled, NotHandled, getName
39 from distutils.version import LooseVersion
41 def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1
44 # Check the bitbake version meets minimum requirements
45 minversion = data.getVar('BB_MIN_VERSION', e.data , True)
47 # Hack: BB_MIN_VERSION hasn't been parsed yet so return
48 # and wait for the next call
49 print "Foo %s" % minversion
52 if (LooseVersion(__version__) < LooseVersion(minversion)):
53 raise_sanity_error('Bitbake version %s is required and version %s was found' % (minversion, __version__))
55 # Check TARGET_ARCH is set
56 if data.getVar('TARGET_ARCH', e.data, True) == 'INVALID':
57 raise_sanity_error('Please set TARGET_ARCH directly, or choose a MACHINE or DISTRO that does so.')
59 # Check TARGET_OS is set
60 if data.getVar('TARGET_OS', e.data, True) == 'INVALID':
61 raise_sanity_error('Please set TARGET_OS directly, or choose a MACHINE or DISTRO that does so.')
63 # Check user doesn't have ASSUME_PROVIDED = instead of += in local.conf
64 if "diffstat-native" not in data.getVar('ASSUME_PROVIDED', e.data, True).split():
65 raise_sanity_error('Please use ASSUME_PROVIDED +=, not ASSUME_PROVIDED = in your local.conf')
67 # Check that the MACHINE is valid
68 if not check_conf_exists("conf/machine/${MACHINE}.conf", e.data):
69 raise_sanity_error('Please set a valid MACHINE in your local.conf')
71 # Check that the DISTRO is valid
72 # need to take into account DISTRO renaming DISTRO
73 if not ( check_conf_exists("conf/distro/${DISTRO}.conf", e.data) or check_conf_exists("conf/distro/include/${DISTRO}.inc", e.data) ):
74 raise_sanity_error("DISTRO '%s' not found. Please set a valid DISTRO in your local.conf" % data.getVar("DISTRO", e.data, True ))
76 if not check_app_exists("${MAKE}", e.data):
77 raise_sanity_error('GNU make missing. Please install GNU make')
79 if not check_app_exists('${BUILD_PREFIX}gcc', e.data):
80 raise_sanity_error('C Host-Compiler is missing, please install one' )
82 if not check_app_exists('${BUILD_PREFIX}g++', e.data):
83 raise_sanity_error('C++ Host-Compiler is missing, please install one' )
85 if not check_app_exists('patch', e.data):
86 raise_sanity_error('Please install the patch utility, preferable GNU patch.')
88 if not check_app_exists('diffstat', e.data):
89 raise_sanity_error('Please install the diffstat utility')
91 if not check_app_exists('texi2html', e.data):
92 raise_sanity_error('Please install the texi2html binary')
94 if not check_app_exists('cvs', e.data):
95 raise_sanity_error('Please install the cvs utility')
97 if not check_app_exists('svn', e.data):
98 raise_sanity_error('Please install the svn utility')
100 if not check_app_exists('bzip2', e.data):
101 raise_sanity_error('Please install the bzip2 utility')
103 oes_bb_conf = data.getVar( 'OES_BITBAKE_CONF', e.data, True )
105 raise_sanity_error('You do not include OpenEmbeddeds version of conf/bitbake.conf')
107 addhandler check_sanity_eventhandler
108 python check_sanity_eventhandler() {
109 from bb import note, error, data, __version__
110 from bb.event import getName
112 if getName(e) == "BuildStarted":