2006-03-20 15:06:33 +00:00
#
# Sanity check the users setup for common misconfigurations
#
def raise_sanity_error(msg):
import bb
2006-09-28 09:18:17 +00:00
bb.fatal(""" Poky's config sanity checker detected a potential misconfiguration.
2006-05-27 21:49:50 +00:00
Either fix the cause of this error or at your own risk disable the checker (see sanity.conf).
Following is the list of potential problems / advisories:
%s""" % msg)
2006-03-20 15:06:33 +00:00
def check_conf_exists(fn, data):
import bb, os
bbpath = []
fn = bb.data.expand(fn, data)
vbbpath = bb.data.getVar("BBPATH", data)
if vbbpath:
bbpath += vbbpath.split(":")
for p in bbpath:
currname = os.path.join(bb.data.expand(p, data), fn)
if os.access(currname, os.R_OK):
return True
return False
2006-05-09 16:10:46 +00:00
def check_sanity(e):
2006-03-20 15:06:33 +00:00
from bb import note, error, data, __version__
from bb.event import Handled, NotHandled, getName
2006-05-27 21:49:50 +00:00
try:
from distutils.version import LooseVersion
except ImportError:
def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1
2006-09-28 09:18:17 +00:00
import os, commands
2006-03-20 15:06:33 +00:00
# Check the bitbake version meets minimum requirements
2006-05-09 16:10:46 +00:00
minversion = data.getVar('BB_MIN_VERSION', e.data , True)
2006-03-20 15:06:33 +00:00
if not minversion:
# Hack: BB_MIN_VERSION hasn't been parsed yet so return
# and wait for the next call
2006-05-09 16:10:46 +00:00
print "Foo %s" % minversion
2006-03-20 15:06:33 +00:00
return
2007-07-04 07:53:48 +00:00
if 0 == os.getuid():
raise_sanity_error("Do not use Bitbake as root.")
2006-11-16 14:20:49 +00:00
messages = ""
2006-05-09 16:10:46 +00:00
if (LooseVersion(__version__) < LooseVersion(minversion)):
2006-11-16 14:20:49 +00:00
messages = messages + 'Bitbake version %s is required and version %s was found\n' % (minversion, __version__)
2006-03-20 15:06:33 +00:00
# Check TARGET_ARCH is set
2006-05-09 16:10:46 +00:00
if data.getVar('TARGET_ARCH', e.data, True) == 'INVALID':
2006-11-16 14:20:49 +00:00
messages = messages + 'Please set TARGET_ARCH directly, or choose a MACHINE or DISTRO that does so.\n'
2006-03-20 15:06:33 +00:00
# Check TARGET_OS is set
2006-05-09 16:10:46 +00:00
if data.getVar('TARGET_OS', e.data, True) == 'INVALID':
2006-11-16 14:20:49 +00:00
messages = messages + 'Please set TARGET_OS directly, or choose a MACHINE or DISTRO that does so.\n'
2006-03-20 15:06:33 +00:00
2007-08-09 10:57:33 +00:00
assume_provided = data.getVar('ASSUME_PROVIDED', e.data , True).split()
2006-03-20 15:06:33 +00:00
# Check user doesn't have ASSUME_PROVIDED = instead of += in local.conf
2007-08-09 10:57:33 +00:00
if "diffstat-native" not in assume_provided:
2006-11-16 14:20:49 +00:00
messages = messages + 'Please use ASSUME_PROVIDED +=, not ASSUME_PROVIDED = in your local.conf\n'
2006-03-20 15:06:33 +00:00
2008-05-07 09:49:38 +00:00
# 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'
2006-03-20 15:06:33 +00:00
2006-08-27 16:01:33 +00:00
# Check that the DISTRO is valid
# need to take into account DISTRO renaming DISTRO
if not ( check_conf_exists("conf/distro/${DISTRO}.conf", e.data) or check_conf_exists("conf/distro/include/${DISTRO}.inc", e.data) ):
2006-11-16 14:20:49 +00:00
messages = messages + "DISTRO '%s' not found. Please set a valid DISTRO in your local.conf\n" % data.getVar("DISTRO", e.data, True )
2006-03-20 15:06:33 +00:00
2006-09-28 09:18:17 +00:00
missing = ""
2006-05-09 16:10:46 +00:00
if not check_app_exists("${MAKE}", e.data):
2006-09-28 09:18:17 +00:00
missing = missing + "GNU make,"
2006-05-09 16:10:46 +00:00
if not check_app_exists('${BUILD_PREFIX}gcc', e.data):
2009-02-04 08:42:08 +00:00
missing = missing + "C Compiler (%sgcc)," % data.getVar("BUILD_PREFIX", e.data, True)
2006-05-09 16:10:46 +00:00
if not check_app_exists('${BUILD_PREFIX}g++', e.data):
2009-02-04 08:42:08 +00:00
missing = missing + "C++ Compiler (%sg++)," % data.getVar("BUILD_PREFIX", e.data, True)
2006-05-09 16:10:46 +00:00
2009-08-25 14:08:15 +00:00
required_utilities = "patch help2man diffstat texi2html makeinfo cvs svn bzip2 tar gzip gawk hg"
2006-09-28 09:18:17 +00:00
2007-08-09 10:52:43 +00:00
# qemu-native needs gcc 3.x
2008-02-05 17:27:12 +00:00
if "qemu-native" not in assume_provided and "gcc3-native" in assume_provided:
2007-08-09 10:57:33 +00:00
gcc_version = commands.getoutput("${BUILD_PREFIX}gcc --version | head -n 1 | cut -f 3 -d ' '")
2007-08-09 10:52:43 +00:00
2008-01-03 14:07:44 +00:00
if not check_gcc3(e.data) and gcc_version[0] != '3':
2008-02-05 17:27:12 +00:00
messages = messages + "gcc3-native was in ASSUME_PROVIDED but the gcc-3.x binary can't be found in PATH"
2007-08-09 10:57:33 +00:00
missing = missing + "gcc-3.x (needed for qemu-native),"
2008-02-05 17:27:12 +00:00
if "qemu-native" in assume_provided:
2008-02-07 10:24:40 +00:00
if not check_app_exists("qemu-arm", e.data):
2008-02-07 10:23:08 +00:00
messages = messages + "qemu-native was in ASSUME_PROVIDED but the QEMU binaries (qemu-arm) can't be found in PATH"
2007-08-09 11:02:13 +00:00
2008-05-07 09:49:38 +00:00
if data.getVar('TARGET_ARCH', e.data, True) == "arm":
if os.path.exists("/proc/sys/vm/mmap_min_addr"):
f = file("/proc/sys/vm/mmap_min_addr", "r")
if (f.read().strip() != "0"):
2008-08-26 10:23:59 +00:00
messages = messages + "/proc/sys/vm/mmap_min_addr is not 0. This will cause problems with qemu so please fix the value (as root).\n\nTo fix this in later reboots, set vm.mmap_min_addr = 0 in /etc/sysctl.conf.\n"
2008-05-07 09:49:38 +00:00
f.close()
2008-05-07 09:31:43 +00:00
2007-08-09 11:02:13 +00:00
for util in required_utilities.split():
if not check_app_exists( util, e.data ):
missing = missing + "%s," % util
2007-08-09 10:52:43 +00:00
2006-11-16 14:20:49 +00:00
if missing != "":
2006-09-28 09:18:17 +00:00
missing = missing.rstrip(',')
2006-11-16 14:20:49 +00:00
messages = messages + "Please install following missing utilities: %s\n" % missing
2008-04-21 22:53:20 +00:00
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"
2006-11-29 16:55:31 +00:00
omask = os.umask(022)
if omask & 0755:
messages = messages + "Please use a umask which allows a+rx and u+rwx\n"
os.umask(omask)
2006-05-09 16:10:46 +00:00
oes_bb_conf = data.getVar( 'OES_BITBAKE_CONF', e.data, True )
if not oes_bb_conf:
2008-01-31 15:18:54 +00:00
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")
2009-05-28 20:32:30 +00:00
saved_tmpdir = f.read().strip()
if (saved_tmpdir != tmpdir):
2009-05-23 09:56:21 +00:00
messages = messages + "Error, TMPDIR has changed location. You need to either move it back to %s or rebuild\n" % saved_tmpdir
2008-01-31 15:18:54 +00:00
else:
f = file(checkfile, "w")
f.write(tmpdir)
f.close()
2007-08-12 23:23:18 +00:00
2008-05-07 09:49:38 +00:00
#
# Check the 'ABI' of TMPDIR
#
2008-07-24 11:10:33 +00:00
current_abi = data.getVar('OELAYOUT_ABI', e.data, True)
2008-05-07 09:49:38 +00:00
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()
2007-08-12 23:23:18 +00:00
if messages != "":
raise_sanity_error(messages)
2006-05-09 16:10:46 +00:00
addhandler check_sanity_eventhandler
python check_sanity_eventhandler() {
from bb import note, error, data, __version__
from bb.event import getName
2008-05-07 09:49:38 +00:00
if getName(e) == "ConfigParsed":
2006-05-09 16:10:46 +00:00
check_sanity(e)
return NotHandled
}