2006-03-20 15:06:33 +00:00
#
# Sanity check the users setup for common misconfigurations
#
2012-08-20 08:47:56 +00:00
SANITY_REQUIRED_UTILITIES ?= "patch diffstat makeinfo git bzip2 tar gzip gawk chrpath wget cpio"
2011-06-02 20:16:47 +00:00
2012-09-27 12:39:55 +00:00
python check_bblayers_conf() {
bblayers_fn = os.path.join(d.getVar('TOPDIR', True), 'conf/bblayers.conf')
current_lconf = int(d.getVar('LCONF_VERSION', True))
if not current_lconf:
sys.exit()
lconf_version = int(d.getVar('LAYER_CONF_VERSION', True))
lines = []
import re
def find_line(pattern, lines):
return next(((index, line)
for index, line in enumerate(lines)
if re.search(pattern, line)), (None, None))
if current_lconf < 4:
sys.exit()
with open(bblayers_fn, 'r') as f:
lines = f.readlines()
if current_lconf == 4:
topdir_var = '$' + '{TOPDIR}'
index, bbpath_line = find_line('BBPATH', lines)
if bbpath_line:
start = bbpath_line.find('"')
if start != -1 and (len(bbpath_line) != (start + 1)):
if bbpath_line[start + 1] == '"':
lines[index] = (bbpath_line[:start + 1] +
topdir_var + bbpath_line[start + 1:])
else:
if not topdir_var in bbpath_line:
lines[index] = (bbpath_line[:start + 1] +
topdir_var + ':' + bbpath_line[start + 1:])
else:
sys.exit()
else:
index, bbfiles_line = find_line('BBFILES', lines)
if bbfiles_line:
lines.insert(index, 'BBPATH = "' + topdir_var + '"\n')
else:
sys.exit()
index, line = find_line('LCONF_VERSION', lines)
current_lconf += 1
lines[index] = 'LCONF_VERSION = "%d"\n' % current_lconf
with open(bblayers_fn, "w") as f:
f.write(''.join(lines))
}
2012-09-26 14:00:10 +00:00
def raise_sanity_error(msg, d, network_error=False):
2012-05-28 17:10:50 +00:00
if d.getVar("SANITY_USE_EVENTS", True) == "1":
2012-09-26 14:00:10 +00:00
try:
bb.event.fire(bb.event.SanityCheckFailed(msg, network_error), d)
except TypeError:
bb.event.fire(bb.event.SanityCheckFailed(msg), d)
2012-09-11 09:40:15 +00:00
return
2012-05-28 17:10:50 +00:00
2012-01-30 12:44:47 +00:00
bb.fatal(""" OE-core's config sanity checker detected a potential misconfiguration.
2010-12-16 11:10:09 +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
2012-05-01 16:20:22 +00:00
# Check a single tune for validity.
def check_toolchain_tune(data, tune, multilib):
tune_errors = []
if not tune:
return "No tuning found for %s multilib." % multilib
bb.debug(2, "Sanity-checking tuning '%s' (%s) features:" % (tune, multilib))
features = (data.getVar("TUNE_FEATURES_tune-%s" % tune, True) or "").split()
if not features:
return "Tuning '%s' has no defined features, and cannot be used." % tune
valid_tunes = data.getVarFlags('TUNEVALID') or {}
conflicts = data.getVarFlags('TUNECONFLICTS') or {}
# [doc] is the documentation for the variable, not a real feature
if 'doc' in valid_tunes:
del valid_tunes['doc']
if 'doc' in conflicts:
del conflicts['doc']
for feature in features:
if feature in conflicts:
for conflict in conflicts[feature].split():
if conflict in features:
tune_errors.append("Feature '%s' conflicts with '%s'." %
(feature, conflict))
if feature in valid_tunes:
bb.debug(2, " %s: %s" % (feature, valid_tunes[feature]))
else:
tune_errors.append("Feature '%s' is not defined." % feature)
whitelist = data.getVar("TUNEABI_WHITELIST", True) or ''
override = data.getVar("TUNEABI_OVERRIDE", True) or ''
if whitelist:
tuneabi = data.getVar("TUNEABI_tune-%s" % tune, True) or ''
if not tuneabi:
tuneabi = tune
if True not in [x in whitelist.split() for x in tuneabi.split()]:
tune_errors.append("Tuning '%s' (%s) cannot be used with any supported tuning/ABI." %
(tune, tuneabi))
if tune_errors:
return "Tuning '%s' has the following errors:\n" + '\n'.join(tune_errors)
def check_toolchain(data):
tune_error_set = []
deftune = data.getVar("DEFAULTTUNE", True)
tune_errors = check_toolchain_tune(data, deftune, 'default')
if tune_errors:
tune_error_set.append(tune_errors)
multilibs = (data.getVar("MULTILIB_VARIANTS", True) or "").split()
2012-12-24 11:28:38 +00:00
global_multilibs = (data.getVar("MULTILIB_GLOBAL_VARIANTS", True) or "").split()
2012-05-01 16:20:22 +00:00
if multilibs:
seen_libs = []
seen_tunes = []
for lib in multilibs:
if lib in seen_libs:
tune_error_set.append("The multilib '%s' appears more than once." % lib)
else:
seen_libs.append(lib)
2012-12-24 11:28:38 +00:00
if not lib in global_multilibs:
tune_error_set.append("Multilib %s is not present in MULTILIB_GLOBAL_VARIANTS" % lib)
2012-05-01 16:20:22 +00:00
tune = data.getVar("DEFAULTTUNE_virtclass-multilib-%s" % lib, True)
if tune in seen_tunes:
tune_error_set.append("The tuning '%s' appears in more than one multilib." % tune)
else:
seen_libs.append(tune)
if tune == deftune:
tune_error_set.append("Multilib '%s' (%s) is also the default tuning." % (lib, deftune))
else:
tune_errors = check_toolchain_tune(data, tune, lib)
if tune_errors:
tune_error_set.append(tune_errors)
if tune_error_set:
return "Toolchain tunings invalid:\n" + '\n'.join(tune_error_set)
return ""
2006-03-20 15:06:33 +00:00
def check_conf_exists(fn, data):
2010-12-16 11:10:09 +00:00
bbpath = []
2012-03-03 11:21:22 +00:00
fn = data.expand(fn)
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
vbbpath = data.getVar("BBPATH")
2010-12-16 11:10:09 +00:00
if vbbpath:
bbpath += vbbpath.split(":")
for p in bbpath:
2012-03-03 11:21:22 +00:00
currname = os.path.join(data.expand(p), fn)
2010-12-16 11:10:09 +00:00
if os.access(currname, os.R_OK):
return True
return False
2006-03-20 15:06:33 +00:00
2011-04-28 22:31:19 +00:00
def check_sanity_sstate_dir_change(sstate_dir, data):
2010-12-16 16:25:13 +00:00
# Sanity checks to be done when the value of SSTATE_DIR changes
2012-05-23 20:50:38 +00:00
# Check that SSTATE_DIR isn't on a filesystem with limited filename length (eg. eCryptFS)
2010-12-16 17:35:31 +00:00
testmsg = ""
if sstate_dir != "":
2012-05-23 20:50:38 +00:00
testmsg = check_create_long_filename(sstate_dir, "SSTATE_DIR")
2012-05-23 23:22:12 +00:00
# If we don't have permissions to SSTATE_DIR, suggest the user set it as an SSTATE_MIRRORS
try:
err = testmsg.split(': ')[1].strip()
if err == "Permission denied.":
testmsg = testmsg + "You could try using %s in SSTATE_MIRRORS rather than as an SSTATE_CACHE.\n" % (sstate_dir)
except IndexError:
pass
2010-12-16 17:35:31 +00:00
return testmsg
2011-04-28 22:31:19 +00:00
def check_sanity_tmpdir_change(tmpdir, data):
2010-12-16 16:25:13 +00:00
# Sanity checks to be done when the value of TMPDIR changes
2010-12-16 17:35:31 +00:00
# Check that TMPDIR isn't on a filesystem with limited filename length (eg. eCryptFS)
testmsg = check_create_long_filename(tmpdir, "TMPDIR")
2011-06-29 21:55:03 +00:00
# Check that we can fetch from various network transports
2012-09-26 14:00:10 +00:00
errmsg = check_connectivity(data)
2011-06-29 21:55:03 +00:00
testmsg = testmsg + check_connectivity(data)
2012-10-02 09:52:00 +00:00
return testmsg, errmsg != ""
2010-12-16 16:25:13 +00:00
2011-04-28 22:31:19 +00:00
def check_sanity_version_change(data):
2010-12-16 16:25:13 +00:00
# Sanity checks to be done when SANITY_VERSION changes
return ""
2011-03-16 16:51:40 +00:00
def check_pseudo_wrapper():
2011-06-19 11:50:46 +00:00
import sys
if not sys.argv[0].endswith('/bitbake'):
return ""
2011-03-16 16:51:40 +00:00
import subprocess as sub
# Check if bitbake wrapper is being used
pseudo_build = os.environ.get( 'PSEUDO_BUILD' )
if not pseudo_build:
2011-04-20 14:59:04 +00:00
bb.warn("Bitbake has not been run using the bitbake wrapper (scripts/bitbake); this is likely because your PATH has been altered from that normally set up by the oe-init-build-env script. Not using the wrapper may result in failures during package installation, so it is highly recommended that you set your PATH back so that the wrapper script is being executed.")
2011-03-16 16:51:40 +00:00
if (not pseudo_build) or pseudo_build == '2':
# pseudo ought to be working, let's see if it is...
p = sub.Popen(['sh', '-c', 'PSEUDO_DISABLED=0 id -u'],stdout=sub.PIPE,stderr=sub.PIPE)
out, err = p.communicate()
if out.rstrip() != '0':
msg = "Pseudo is not functioning correctly, which will cause failures during package installation. Please check your configuration."
if pseudo_build == '2':
return msg
else:
bb.warn(msg)
return ""
2010-12-16 17:35:31 +00:00
def check_create_long_filename(filepath, pathname):
testfile = os.path.join(filepath, ''.join([`num`[-1] for num in xrange(1,200)]))
try:
if not os.path.exists(filepath):
bb.utils.mkdirhier(filepath)
f = file(testfile, "w")
f.close()
os.remove(testfile)
except IOError as (errno, strerror):
if errno == 36: # ENAMETOOLONG
return "Failed to create a file with a long name in %s. Please use a filesystem that does not unreasonably limit filename length.\n" % pathname
else:
2012-05-23 23:19:23 +00:00
return "Failed to create a file in %s: %s.\n" % (pathname, strerror)
2012-05-23 23:28:59 +00:00
except OSError as (errno, strerror):
return "Failed to create %s directory in which to run long name sanity check: %s.\n" % (pathname, strerror)
2010-12-16 17:35:31 +00:00
return ""
sanity.bbclass: the tmpdir can't be longer than 410
There will be errors when the length of the tmpdir is longer than 410:
1) Longer than 420:
Can't exec "/bin/sh": Argument list too long at /usr/lib/perl/5.10/IO/File.pm line 66.
This error happens on both Ubuntu 10.04 and 10.10 when the pkg needs run
"autoreconf", this is because it passes many files with absolute path to
aclocal, aclocal passes them to perl, this is a limitation of the perl
on Ubuntu 10.04 and 10.10, and the perl-native is not ready at this very
early stage.
2) Longer than 490:
bitbake/lib/bb/persist_data.py", line 197, in connect(database=...)
> return sqlite3.connect(database, timeout=5, isolation_level=None)
OperationalError: unable to open database file
This error happens on Ubuntu 10.04, 10.10 and Fedora 17. This is because
the length of the database in sqlite3 module (host's) can't be longer
than 490 (or little smaller). The python-native is not ready at this
very early stage.
The 2 errors are host related, I think that limit the length of the
TMPDIR to 410 is OK for most of the build, rarely build sets TMPDIR's
longer than 410.
[YOCTO #2434]
(From OE-Core rev: ebcf949853ff667478a1ea1d3f1f8f41d643e708)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-07-05 08:57:33 +00:00
def check_path_length(filepath, pathname, limit):
if len(filepath) > limit:
2013-02-18 23:20:11 +00:00
return "The length of %s is longer than 410, this would cause unexpected errors, please use a shorter path.\n" % pathname
sanity.bbclass: the tmpdir can't be longer than 410
There will be errors when the length of the tmpdir is longer than 410:
1) Longer than 420:
Can't exec "/bin/sh": Argument list too long at /usr/lib/perl/5.10/IO/File.pm line 66.
This error happens on both Ubuntu 10.04 and 10.10 when the pkg needs run
"autoreconf", this is because it passes many files with absolute path to
aclocal, aclocal passes them to perl, this is a limitation of the perl
on Ubuntu 10.04 and 10.10, and the perl-native is not ready at this very
early stage.
2) Longer than 490:
bitbake/lib/bb/persist_data.py", line 197, in connect(database=...)
> return sqlite3.connect(database, timeout=5, isolation_level=None)
OperationalError: unable to open database file
This error happens on Ubuntu 10.04, 10.10 and Fedora 17. This is because
the length of the database in sqlite3 module (host's) can't be longer
than 490 (or little smaller). The python-native is not ready at this
very early stage.
The 2 errors are host related, I think that limit the length of the
TMPDIR to 410 is OK for most of the build, rarely build sets TMPDIR's
longer than 410.
[YOCTO #2434]
(From OE-Core rev: ebcf949853ff667478a1ea1d3f1f8f41d643e708)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-07-05 08:57:33 +00:00
return ""
2011-06-29 21:55:03 +00:00
def check_connectivity(d):
# URI's to check can be set in the CONNECTIVITY_CHECK_URIS variable
# using the same syntax as for SRC_URI. If the variable is not set
# the check is skipped
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
test_uris = (d.getVar('CONNECTIVITY_CHECK_URIS', True) or "").split()
2011-06-29 21:55:03 +00:00
retval = ""
# Only check connectivity if network enabled and the
# CONNECTIVITY_CHECK_URIS are set
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
network_enabled = not d.getVar('BB_NO_NETWORK', True)
2011-06-29 21:55:03 +00:00
check_enabled = len(test_uris)
2011-09-14 22:09:28 +00:00
# Take a copy of the data store and unset MIRRORS and PREMIRROS
data = bb.data.createCopy(d)
data.delVar('PREMIRRORS')
data.delVar('MIRRORS')
2011-06-29 21:55:03 +00:00
if check_enabled and network_enabled:
try:
2011-09-14 22:09:28 +00:00
fetcher = bb.fetch2.Fetch(test_uris, data)
2011-08-25 15:29:30 +00:00
fetcher.checkstatus()
2011-06-29 21:55:03 +00:00
except Exception:
# Allow the message to be configured so that users can be
# pointed to a support mechanism.
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
msg = data.getVar('CONNECTIVITY_CHECK_MSG', True) or ""
2011-06-29 21:55:03 +00:00
if len(msg) == 0:
msg = "Failed to fetch test data from the network. Please ensure your network is configured correctly.\n"
retval = msg
return retval
2012-05-23 22:16:19 +00:00
def check_supported_distro(sanity_data):
tested_distros = sanity_data.getVar('SANITY_TESTED_DISTROS', True)
2011-08-17 17:48:15 +00:00
if not tested_distros:
return
2013-03-01 17:42:22 +00:00
try:
distro = oe.lsb.distro_identifier()
except Exception:
distro = None
2011-08-17 17:48:15 +00:00
if distro:
2011-09-01 11:36:12 +00:00
if distro not in [x.strip() for x in tested_distros.split('\\n')]:
2011-08-17 17:48:15 +00:00
bb.warn('Host distribution "%s" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.' % distro)
else:
bb.warn('Host distribution could not be determined; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.')
2011-08-30 16:14:55 +00:00
# Checks we should only make if MACHINE is set correctly
2012-05-23 22:16:19 +00:00
def check_sanity_validmachine(sanity_data):
2011-08-30 16:14:55 +00:00
messages = ""
# Check TUNE_ARCH is set
2012-05-23 22:42:24 +00:00
if sanity_data.getVar('TUNE_ARCH', True) == 'INVALID':
2011-08-30 16:14:55 +00:00
messages = messages + 'TUNE_ARCH is unset. Please ensure your MACHINE configuration includes a valid tune configuration file which will set this correctly.\n'
# Check TARGET_OS is set
2012-05-23 22:42:24 +00:00
if sanity_data.getVar('TARGET_OS', True) == 'INVALID':
2011-08-30 16:14:55 +00:00
messages = messages + 'Please set TARGET_OS directly, or choose a MACHINE or DISTRO that does so.\n'
# Check that we don't have duplicate entries in PACKAGE_ARCHS & that TUNE_PKGARCH is in PACKAGE_ARCHS
2012-05-23 22:42:24 +00:00
pkgarchs = sanity_data.getVar('PACKAGE_ARCHS', True)
tunepkg = sanity_data.getVar('TUNE_PKGARCH', True)
2011-08-30 16:14:55 +00:00
tunefound = False
seen = {}
dups = []
for pa in pkgarchs.split():
if seen.get(pa, 0) == 1:
dups.append(pa)
else:
seen[pa] = 1
if pa == tunepkg:
tunefound = True
if len(dups):
2012-08-20 16:52:21 +00:00
messages = messages + "Error, the PACKAGE_ARCHS variable contains duplicates. The following archs are listed more than once: %s" % " ".join(dups)
2011-08-30 16:14:55 +00:00
if tunefound == False:
2012-08-20 16:52:21 +00:00
messages = messages + "Error, the PACKAGE_ARCHS variable does not contain TUNE_PKGARCH (%s)." % tunepkg
2011-08-30 16:14:55 +00:00
return messages
sanity.bbclass:check if necessary to add march to BUILD_CFLAGS
1, There are a set of GCC built-in functions for atomic memory access. The
definition given in the Intel documentation allows only for the use of the
types int, long, long long as well as their unsigned counterparts. GCC will
allow any integral scalar or pointer type that is 1, 2, 4, 8 or 16 bytes in
length, suffix `_n' where n is the size of the data type.Such as:
__sync_fetch_and_add_n
__sync_fetch_and_sub_n
__sync_fetch_and_or_n
__sync_fetch_and_and_n
__sync_fetch_and_xor_n
__sync_fetch_and_nand_n
The above builtins are intended to be compatible with those described in the
Intel Itanium Processor-specific Application Binary Interface, section 7.4.
2, The glib-2.0-native and qemu-native invoke the above builtin function with
suffix `_4', and glib-2.0-native uses __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 to
test the existance.
3, Not all above builtin functions are supported by all target processors.Such
as i386 does not support the functions with suffix `_4', but i486 or later
support.
4, Prior to GCC 4.5, on the Intel's processor, the default arch is i386 unless
GCC is built with the --with-arch switch. Since GCC 4.5 the default arch is
implied by the target.
5, If your host GCC is older than 4.5 and it is built without the --with-arch
switch, when you use the GCC to compile target, you should specify -march to
tell GCC what the target's arch is, otherwise i386 is used as default.
Above all, when use older GCC to compile glib-2.0-native or glib-2.0-native,
and the GCC incorrectly uses i386 as default, the above builtin function
with suffix `_4' is not referenced. We should have a check in sanity.bbclass
to tell the user if necessary to add march to BUILD_CFLAGS in this situation.
http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/_005f_005fsync-Builtins.html#_005f_005fsync-Builtins
http://gcc.gnu.org/ml/gcc-help/2009-06/msg00037.html
http://gcc.gnu.org/gcc-4.5/changes.html
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47460
http://llvm.org/bugs/show_bug.cgi?id=11174
http://download.intel.com/design/itanium/downloads/245370.pdf
[YOCTO #3563]
(From OE-Core rev: 38042ed8586b3abe427af33debc2402caeca52cb)
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-03-05 02:50:15 +00:00
# Checks if necessary to add option march to host gcc
def check_gcc_march(sanity_data):
result = False
# Check if -march not in BUILD_CFLAGS
if sanity_data.getVar("BUILD_CFLAGS",True).find("-march") < 0:
# Construct a test file
f = file("gcc_test.c", "w")
f.write("int main (){ __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4; return 0;}\n")
f.close()
import commands
# Check if GCC could work without march
status,result = commands.getstatusoutput("${BUILD_PREFIX}gcc gcc_test.c -o gcc_test")
if status != 0:
# Check if GCC could work with march
status,result = commands.getstatusoutput("${BUILD_PREFIX}gcc -march=native gcc_test.c -o gcc_test")
2013-03-20 07:52:12 +00:00
if status == 0:
result = True
else:
result = False
sanity.bbclass:check if necessary to add march to BUILD_CFLAGS
1, There are a set of GCC built-in functions for atomic memory access. The
definition given in the Intel documentation allows only for the use of the
types int, long, long long as well as their unsigned counterparts. GCC will
allow any integral scalar or pointer type that is 1, 2, 4, 8 or 16 bytes in
length, suffix `_n' where n is the size of the data type.Such as:
__sync_fetch_and_add_n
__sync_fetch_and_sub_n
__sync_fetch_and_or_n
__sync_fetch_and_and_n
__sync_fetch_and_xor_n
__sync_fetch_and_nand_n
The above builtins are intended to be compatible with those described in the
Intel Itanium Processor-specific Application Binary Interface, section 7.4.
2, The glib-2.0-native and qemu-native invoke the above builtin function with
suffix `_4', and glib-2.0-native uses __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 to
test the existance.
3, Not all above builtin functions are supported by all target processors.Such
as i386 does not support the functions with suffix `_4', but i486 or later
support.
4, Prior to GCC 4.5, on the Intel's processor, the default arch is i386 unless
GCC is built with the --with-arch switch. Since GCC 4.5 the default arch is
implied by the target.
5, If your host GCC is older than 4.5 and it is built without the --with-arch
switch, when you use the GCC to compile target, you should specify -march to
tell GCC what the target's arch is, otherwise i386 is used as default.
Above all, when use older GCC to compile glib-2.0-native or glib-2.0-native,
and the GCC incorrectly uses i386 as default, the above builtin function
with suffix `_4' is not referenced. We should have a check in sanity.bbclass
to tell the user if necessary to add march to BUILD_CFLAGS in this situation.
http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/_005f_005fsync-Builtins.html#_005f_005fsync-Builtins
http://gcc.gnu.org/ml/gcc-help/2009-06/msg00037.html
http://gcc.gnu.org/gcc-4.5/changes.html
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47460
http://llvm.org/bugs/show_bug.cgi?id=11174
http://download.intel.com/design/itanium/downloads/245370.pdf
[YOCTO #3563]
(From OE-Core rev: 38042ed8586b3abe427af33debc2402caeca52cb)
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-03-05 02:50:15 +00:00
os.remove("gcc_test.c")
2013-03-20 07:52:12 +00:00
if os.path.exists("gcc_test"):
os.remove("gcc_test")
sanity.bbclass:check if necessary to add march to BUILD_CFLAGS
1, There are a set of GCC built-in functions for atomic memory access. The
definition given in the Intel documentation allows only for the use of the
types int, long, long long as well as their unsigned counterparts. GCC will
allow any integral scalar or pointer type that is 1, 2, 4, 8 or 16 bytes in
length, suffix `_n' where n is the size of the data type.Such as:
__sync_fetch_and_add_n
__sync_fetch_and_sub_n
__sync_fetch_and_or_n
__sync_fetch_and_and_n
__sync_fetch_and_xor_n
__sync_fetch_and_nand_n
The above builtins are intended to be compatible with those described in the
Intel Itanium Processor-specific Application Binary Interface, section 7.4.
2, The glib-2.0-native and qemu-native invoke the above builtin function with
suffix `_4', and glib-2.0-native uses __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 to
test the existance.
3, Not all above builtin functions are supported by all target processors.Such
as i386 does not support the functions with suffix `_4', but i486 or later
support.
4, Prior to GCC 4.5, on the Intel's processor, the default arch is i386 unless
GCC is built with the --with-arch switch. Since GCC 4.5 the default arch is
implied by the target.
5, If your host GCC is older than 4.5 and it is built without the --with-arch
switch, when you use the GCC to compile target, you should specify -march to
tell GCC what the target's arch is, otherwise i386 is used as default.
Above all, when use older GCC to compile glib-2.0-native or glib-2.0-native,
and the GCC incorrectly uses i386 as default, the above builtin function
with suffix `_4' is not referenced. We should have a check in sanity.bbclass
to tell the user if necessary to add march to BUILD_CFLAGS in this situation.
http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/_005f_005fsync-Builtins.html#_005f_005fsync-Builtins
http://gcc.gnu.org/ml/gcc-help/2009-06/msg00037.html
http://gcc.gnu.org/gcc-4.5/changes.html
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47460
http://llvm.org/bugs/show_bug.cgi?id=11174
http://download.intel.com/design/itanium/downloads/245370.pdf
[YOCTO #3563]
(From OE-Core rev: 38042ed8586b3abe427af33debc2402caeca52cb)
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-03-05 02:50:15 +00:00
return result
2011-08-30 16:14:55 +00:00
2012-05-23 22:16:19 +00:00
def check_sanity(sanity_data):
2012-05-29 14:53:06 +00:00
import subprocess
2010-12-16 11:10:09 +00:00
2013-02-12 13:27:32 +00:00
reparse = False
2010-12-16 11:10:09 +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
import commands
# Check the bitbake version meets minimum requirements
2012-05-23 22:42:24 +00:00
minversion = sanity_data.getVar('BB_MIN_VERSION', True)
2010-12-16 11:10:09 +00:00
if not minversion:
# Hack: BB_MIN_VERSION hasn't been parsed yet so return
# and wait for the next call
print "Foo %s" % minversion
return
if 0 == os.getuid():
2012-05-28 17:10:50 +00:00
raise_sanity_error("Do not use Bitbake as root.", sanity_data)
2010-12-16 11:10:09 +00:00
messages = ""
# Check the Python version, we now use Python 2.6 features in
# various classes
import sys
if sys.hexversion < 0x020600F0:
2011-04-21 11:52:41 +00:00
messages = messages + 'The system requires at least Python 2.6 to run. Please update your Python interpreter.\n'
2010-12-16 11:10:09 +00:00
2012-07-18 13:08:48 +00:00
if (LooseVersion(bb.__version__) < LooseVersion(minversion)):
messages = messages + 'Bitbake version %s is required and version %s was found\n' % (minversion, bb.__version__)
2010-12-16 11:10:09 +00:00
2011-08-30 16:14:55 +00:00
# Check that the MACHINE is valid, if it is set
2012-09-11 09:40:14 +00:00
machinevalid = True
2012-05-23 22:42:24 +00:00
if sanity_data.getVar('MACHINE', True):
2012-05-23 22:16:19 +00:00
if not check_conf_exists("conf/machine/${MACHINE}.conf", sanity_data):
2011-08-30 16:14:55 +00:00
messages = messages + 'Please set a valid MACHINE in your local.conf or environment\n'
2012-09-11 09:40:14 +00:00
machinevalid = False
2011-08-30 16:14:55 +00:00
else:
2012-05-23 22:16:19 +00:00
messages = messages + check_sanity_validmachine(sanity_data)
2011-08-30 16:14:55 +00:00
else:
messages = messages + 'Please set a MACHINE in your local.conf or environment\n'
2012-09-11 09:40:14 +00:00
machinevalid = False
2006-03-20 15:06:33 +00:00
2013-02-12 13:27:32 +00:00
# Check we are using a valid local.conf
2012-05-23 22:42:24 +00:00
current_conf = sanity_data.getVar('CONF_VERSION', True)
conf_version = sanity_data.getVar('LOCALCONF_VERSION', True)
2011-08-30 13:52:41 +00:00
if current_conf != conf_version:
2012-09-05 14:25:51 +00:00
messages = messages + "Your version of local.conf was generated from an older version of local.conf.sample and there have been updates made to this file. Please compare the two files and merge any changes before continuing.\nMatching the version numbers will remove this message.\n\"meld conf/local.conf ${COREBASE}/meta*/conf/local.conf.sample\" is a good way to visualise the changes.\n"
2011-08-30 13:52:41 +00:00
# Check bblayers.conf is valid
2012-05-23 22:42:24 +00:00
current_lconf = sanity_data.getVar('LCONF_VERSION', True)
lconf_version = sanity_data.getVar('LAYER_CONF_VERSION', True)
2011-08-30 13:52:41 +00:00
if current_lconf != lconf_version:
2012-09-27 12:39:55 +00:00
try:
bb.build.exec_func("check_bblayers_conf", sanity_data)
2013-02-12 13:27:32 +00:00
bb.note("Your conf/bblayers.conf has been automatically updated.")
reparse = True
2012-09-27 12:39:55 +00:00
except Exception:
messages = messages + "Your version of bblayers.conf was generated from an older version of bblayers.conf.sample and there have been updates made to this file. Please compare the two files and merge any changes before continuing.\nMatching the version numbers will remove this message.\n\"meld conf/bblayers.conf ${COREBASE}/meta*/conf/bblayers.conf.sample\" is a good way to visualise the changes.\n"
2011-08-30 13:52:41 +00:00
# If we have a site.conf, check it's valid
2012-05-23 22:16:19 +00:00
if check_conf_exists("conf/site.conf", sanity_data):
2012-05-23 22:42:24 +00:00
current_sconf = sanity_data.getVar('SCONF_VERSION', True)
sconf_version = sanity_data.getVar('SITE_CONF_VERSION', True)
2011-08-30 13:52:41 +00:00
if current_sconf != sconf_version:
2012-09-05 14:25:51 +00:00
messages = messages + "Your version of site.conf was generated from an older version of site.conf.sample and there have been updates made to this file. Please compare the two files and merge any changes before continuing.\nMatching the version numbers will remove this message.\n\"meld conf/site.conf ${COREBASE}/meta*/conf/site.conf.sample\" is a good way to visualise the changes.\n"
2010-12-16 11:10:09 +00:00
2012-05-23 22:42:24 +00:00
assume_provided = sanity_data.getVar('ASSUME_PROVIDED', True).split()
2010-12-16 11:10:09 +00:00
# Check user doesn't have ASSUME_PROVIDED = instead of += in local.conf
if "diffstat-native" not in assume_provided:
messages = messages + 'Please use ASSUME_PROVIDED +=, not ASSUME_PROVIDED = in your local.conf\n'
2011-01-05 01:22:45 +00:00
# Check that DL_DIR is set, exists and is writable. In theory, we should never even hit the check if DL_DIR isn't
# set, since so much relies on it being set.
2012-05-23 22:42:24 +00:00
dldir = sanity_data.getVar('DL_DIR', True)
2011-01-05 01:22:45 +00:00
if not dldir:
messages = messages + "DL_DIR is not set. Your environment is misconfigured, check that DL_DIR is set, and if the directory exists, that it is writable. \n"
if os.path.exists(dldir) and not os.access(dldir, os.W_OK):
messages = messages + "DL_DIR: %s exists but you do not appear to have write access to it. \n" % dldir
2010-12-16 11:10:09 +00:00
2011-09-07 16:05:40 +00:00
# Check that the DISTRO is valid, if set
2010-12-16 11:10:09 +00:00
# need to take into account DISTRO renaming DISTRO
2012-05-23 22:42:24 +00:00
distro = sanity_data.getVar('DISTRO', True)
2011-09-07 16:05:40 +00:00
if distro:
2012-05-23 22:16:19 +00:00
if not ( check_conf_exists("conf/distro/${DISTRO}.conf", sanity_data) or check_conf_exists("conf/distro/include/${DISTRO}.inc", sanity_data) ):
2012-05-23 22:42:24 +00:00
messages = messages + "DISTRO '%s' not found. Please set a valid DISTRO in your local.conf\n" % sanity_data.getVar("DISTRO", True )
2010-12-16 11:10:09 +00:00
missing = ""
2012-05-23 22:16:19 +00:00
if not check_app_exists("${MAKE}", sanity_data):
2010-12-16 11:10:09 +00:00
missing = missing + "GNU make,"
2012-05-23 22:16:19 +00:00
if not check_app_exists('${BUILD_PREFIX}gcc', sanity_data):
2012-05-23 22:42:24 +00:00
missing = missing + "C Compiler (%sgcc)," % sanity_data.getVar("BUILD_PREFIX", True)
2010-12-16 11:10:09 +00:00
2012-05-23 22:16:19 +00:00
if not check_app_exists('${BUILD_PREFIX}g++', sanity_data):
2012-05-23 22:42:24 +00:00
missing = missing + "C++ Compiler (%sg++)," % sanity_data.getVar("BUILD_PREFIX", True)
2010-12-16 11:10:09 +00:00
2012-05-23 22:16:19 +00:00
required_utilities = sanity_data.getVar('SANITY_REQUIRED_UTILITIES', True)
2010-12-16 11:10:09 +00:00
if "qemu-native" in assume_provided:
2012-05-23 22:16:19 +00:00
if not check_app_exists("qemu-arm", sanity_data):
2010-12-16 11:10:09 +00:00
messages = messages + "qemu-native was in ASSUME_PROVIDED but the QEMU binaries (qemu-arm) can't be found in PATH"
sanity.bbclass:check if necessary to add march to BUILD_CFLAGS
1, There are a set of GCC built-in functions for atomic memory access. The
definition given in the Intel documentation allows only for the use of the
types int, long, long long as well as their unsigned counterparts. GCC will
allow any integral scalar or pointer type that is 1, 2, 4, 8 or 16 bytes in
length, suffix `_n' where n is the size of the data type.Such as:
__sync_fetch_and_add_n
__sync_fetch_and_sub_n
__sync_fetch_and_or_n
__sync_fetch_and_and_n
__sync_fetch_and_xor_n
__sync_fetch_and_nand_n
The above builtins are intended to be compatible with those described in the
Intel Itanium Processor-specific Application Binary Interface, section 7.4.
2, The glib-2.0-native and qemu-native invoke the above builtin function with
suffix `_4', and glib-2.0-native uses __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 to
test the existance.
3, Not all above builtin functions are supported by all target processors.Such
as i386 does not support the functions with suffix `_4', but i486 or later
support.
4, Prior to GCC 4.5, on the Intel's processor, the default arch is i386 unless
GCC is built with the --with-arch switch. Since GCC 4.5 the default arch is
implied by the target.
5, If your host GCC is older than 4.5 and it is built without the --with-arch
switch, when you use the GCC to compile target, you should specify -march to
tell GCC what the target's arch is, otherwise i386 is used as default.
Above all, when use older GCC to compile glib-2.0-native or glib-2.0-native,
and the GCC incorrectly uses i386 as default, the above builtin function
with suffix `_4' is not referenced. We should have a check in sanity.bbclass
to tell the user if necessary to add march to BUILD_CFLAGS in this situation.
http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/_005f_005fsync-Builtins.html#_005f_005fsync-Builtins
http://gcc.gnu.org/ml/gcc-help/2009-06/msg00037.html
http://gcc.gnu.org/gcc-4.5/changes.html
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47460
http://llvm.org/bugs/show_bug.cgi?id=11174
http://download.intel.com/design/itanium/downloads/245370.pdf
[YOCTO #3563]
(From OE-Core rev: 38042ed8586b3abe427af33debc2402caeca52cb)
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-03-05 02:50:15 +00:00
if check_gcc_march(sanity_data):
messages = messages + "Your gcc version is older than 4.5, please add the following param to local.conf\n \
BUILD_CFLAGS_append = \" -march=native\"\n"
2012-05-23 22:42:24 +00:00
paths = sanity_data.getVar('PATH', True).split(":")
2012-05-09 20:14:41 +00:00
if "." in paths or "" in paths:
2012-07-18 13:42:30 +00:00
messages = messages + "PATH contains '.' or '' (empty element), which will break the build, please remove this.\n"
messages = messages + "Parsed PATH is " + str(paths) + "\n"
2010-12-21 14:06:41 +00:00
2012-06-13 04:01:43 +00:00
bbpaths = sanity_data.getVar('BBPATH', True).split(":")
if "." in bbpaths or "" in bbpaths:
# TODO: change the following message to fatal when all BBPATH issues
# are fixed
bb.warn("BBPATH references the current directory, either through " \
"an empty entry, or a '.'.\n\t This is unsafe and means your "\
"layer configuration is adding empty elements to BBPATH.\n\t "\
"Please check your layer.conf files and other BBPATH " \
"settings to remove the current working directory " \
"references.");
2012-07-19 16:15:34 +00:00
bb.warn("Parsed BBPATH is" + str(bbpaths));
2012-06-13 04:01:43 +00:00
2012-05-23 22:42:24 +00:00
if sanity_data.getVar('TARGET_ARCH', True) == "arm":
2010-12-16 11:10:09 +00:00
# This path is no longer user-readable in modern (very recent) Linux
try:
if os.path.exists("/proc/sys/vm/mmap_min_addr"):
2011-03-08 06:46:08 +00:00
f = open("/proc/sys/vm/mmap_min_addr", "r")
try:
2011-03-12 11:25:34 +00:00
if (int(f.read().strip()) > 65536):
messages = messages + "/proc/sys/vm/mmap_min_addr is not <= 65536. 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 = 65536 in /etc/sysctl.conf.\n"
2011-03-08 06:46:08 +00:00
finally:
f.close()
2010-12-16 11:10:09 +00:00
except:
pass
for util in required_utilities.split():
2012-05-23 22:16:19 +00:00
if not check_app_exists( util, sanity_data ):
2010-12-16 11:10:09 +00:00
missing = missing + "%s," % util
if missing != "":
missing = missing.rstrip(',')
2012-05-28 17:10:51 +00:00
messages = messages + "Please install the following missing utilities: %s\n" % missing
2010-12-16 11:10:09 +00:00
2011-03-16 16:51:40 +00:00
pseudo_msg = check_pseudo_wrapper()
if pseudo_msg != "":
messages = messages + pseudo_msg + '\n'
2012-05-23 22:16:19 +00:00
check_supported_distro(sanity_data)
2012-09-11 09:40:14 +00:00
if machinevalid:
toolchain_msg = check_toolchain(sanity_data)
if toolchain_msg != "":
messages = messages + toolchain_msg + '\n'
2011-08-17 17:48:15 +00:00
2010-12-16 11:10:09 +00:00
# Check if DISPLAY is set if IMAGETEST is set
2013-02-07 09:16:18 +00:00
if sanity_data.getVar( 'IMAGETEST', True ) == 'qemu':
display = sanity_data.getVar("BB_ORIGENV", False).getVar("DISPLAY", True)
if not display:
messages = messages + 'qemuimagetest needs a X desktop to start qemu, please set DISPLAY correctly (e.g. DISPLAY=:1.0)\n'
2010-12-16 11:10:09 +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)
2012-05-23 22:42:24 +00:00
oes_bb_conf = sanity_data.getVar( 'OES_BITBAKE_CONF', True)
2010-12-16 11:10:09 +00:00
if not oes_bb_conf:
2012-05-28 17:10:51 +00:00
messages = messages + 'You do not include the OpenEmbedded version of conf/bitbake.conf. This means your environment is misconfigured, in particular check BBPATH.\n'
2010-12-16 11:10:09 +00:00
2012-05-23 22:42:24 +00:00
nolibs = sanity_data.getVar('NO32LIBS', True)
2010-12-16 11:10:09 +00:00
if not nolibs:
lib32path = '/lib'
2011-03-03 09:39:16 +00:00
if os.path.exists('/lib64') and ( os.path.islink('/lib64') or os.path.islink('/lib') ):
2010-12-16 11:10:09 +00:00
lib32path = '/lib32'
if os.path.exists('%s/libc.so.6' % lib32path) and not os.path.exists('/usr/include/gnu/stubs-32.h'):
messages = messages + "You have a 32-bit libc, but no 32-bit headers. You must install the 32-bit libc headers.\n"
2012-05-23 22:42:24 +00:00
tmpdir = sanity_data.getVar('TMPDIR', True)
sstate_dir = sanity_data.getVar('SSTATE_DIR', True)
2010-12-16 16:25:13 +00:00
sanity.bbclass: the tmpdir can't be longer than 410
There will be errors when the length of the tmpdir is longer than 410:
1) Longer than 420:
Can't exec "/bin/sh": Argument list too long at /usr/lib/perl/5.10/IO/File.pm line 66.
This error happens on both Ubuntu 10.04 and 10.10 when the pkg needs run
"autoreconf", this is because it passes many files with absolute path to
aclocal, aclocal passes them to perl, this is a limitation of the perl
on Ubuntu 10.04 and 10.10, and the perl-native is not ready at this very
early stage.
2) Longer than 490:
bitbake/lib/bb/persist_data.py", line 197, in connect(database=...)
> return sqlite3.connect(database, timeout=5, isolation_level=None)
OperationalError: unable to open database file
This error happens on Ubuntu 10.04, 10.10 and Fedora 17. This is because
the length of the database in sqlite3 module (host's) can't be longer
than 490 (or little smaller). The python-native is not ready at this
very early stage.
The 2 errors are host related, I think that limit the length of the
TMPDIR to 410 is OK for most of the build, rarely build sets TMPDIR's
longer than 410.
[YOCTO #2434]
(From OE-Core rev: ebcf949853ff667478a1ea1d3f1f8f41d643e708)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-07-05 08:57:33 +00:00
# The length of tmpdir can't be longer than 410
messages = messages + check_path_length(tmpdir, "TMPDIR", 410)
2010-12-16 16:25:13 +00:00
# Check saved sanity info
last_sanity_version = 0
last_tmpdir = ""
last_sstate_dir = ""
sanityverfile = 'conf/sanity_info'
if os.path.exists(sanityverfile):
f = file(sanityverfile, 'r')
for line in f:
if line.startswith('SANITY_VERSION'):
last_sanity_version = int(line.split()[1])
if line.startswith('TMPDIR'):
last_tmpdir = line.split()[1]
if line.startswith('SSTATE_DIR'):
last_sstate_dir = line.split()[1]
2012-05-23 22:42:24 +00:00
sanity_version = int(sanity_data.getVar('SANITY_VERSION', True) or 1)
2012-09-26 14:00:10 +00:00
network_error = False
2010-12-16 16:25:13 +00:00
if last_sanity_version < sanity_version:
2012-05-23 22:16:19 +00:00
messages = messages + check_sanity_version_change(sanity_data)
2012-09-26 14:00:10 +00:00
err, network_error = check_sanity_tmpdir_change(tmpdir, sanity_data)
messages = messages + err
2012-05-23 22:16:19 +00:00
messages = messages + check_sanity_sstate_dir_change(sstate_dir, sanity_data)
2010-12-16 16:25:13 +00:00
else:
if last_tmpdir != tmpdir:
2012-09-26 14:00:10 +00:00
err, network_error = check_sanity_tmpdir_change(tmpdir, sanity_data)
messages = messages + err
2010-12-16 16:25:13 +00:00
if last_sstate_dir != sstate_dir:
2012-05-23 22:16:19 +00:00
messages = messages + check_sanity_sstate_dir_change(sstate_dir, sanity_data)
2012-04-17 11:16:18 +00:00
if os.path.exists("conf") and not messages:
2010-12-16 16:25:13 +00:00
f = file(sanityverfile, 'w')
f.write("SANITY_VERSION %s\n" % sanity_version)
f.write("TMPDIR %s\n" % tmpdir)
f.write("SSTATE_DIR %s\n" % sstate_dir)
2010-12-16 11:10:09 +00:00
#
# Check that TMPDIR hasn't changed location since the last time we were run
#
checkfile = os.path.join(tmpdir, "saved_tmpdir")
if os.path.exists(checkfile):
f = file(checkfile, "r")
saved_tmpdir = f.read().strip()
if (saved_tmpdir != tmpdir):
messages = messages + "Error, TMPDIR has changed location. You need to either move it back to %s or rebuild\n" % saved_tmpdir
else:
2013-01-21 22:49:08 +00:00
bb.utils.mkdirhier(tmpdir)
2010-12-16 11:10:09 +00:00
f = file(checkfile, "w")
f.write(tmpdir)
f.close()
#
# Check the 'ABI' of TMPDIR
#
2012-05-23 22:42:24 +00:00
current_abi = sanity_data.getVar('OELAYOUT_ABI', True)
abifile = sanity_data.getVar('SANITY_ABIFILE', True)
2010-12-16 11:10:09 +00:00
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 == "2" and current_abi == "3":
bb.note("Converting staging from layout version 2 to layout version 3")
2012-05-29 14:53:06 +00:00
subprocess.call(sanity_data.expand("mv ${TMPDIR}/staging ${TMPDIR}/sysroots"), shell=True)
subprocess.call(sanity_data.expand("ln -s sysroots ${TMPDIR}/staging"), shell=True)
subprocess.call(sanity_data.expand("cd ${TMPDIR}/stamps; for i in */*do_populate_staging; do new=`echo $i | sed -e 's/do_populate_staging/do_populate_sysroot/'`; mv $i $new; done"), shell=True)
2010-12-16 11:10:09 +00:00
f = file(abifile, "w")
f.write(current_abi)
elif abi == "3" and current_abi == "4":
bb.note("Converting staging layout from version 3 to layout version 4")
2012-05-23 22:16:19 +00:00
if os.path.exists(sanity_data.expand("${STAGING_DIR_NATIVE}${bindir_native}/${MULTIMACH_HOST_SYS}")):
2012-05-29 14:53:06 +00:00
subprocess.call(sanity_data.expand("mv ${STAGING_DIR_NATIVE}${bindir_native}/${MULTIMACH_HOST_SYS} ${STAGING_BINDIR_CROSS}"), shell=True)
subprocess.call(sanity_data.expand("ln -s ${STAGING_BINDIR_CROSS} ${STAGING_DIR_NATIVE}${bindir_native}/${MULTIMACH_HOST_SYS}"), shell=True)
2010-12-16 11:10:09 +00:00
f = file(abifile, "w")
f.write(current_abi)
elif abi == "4":
messages = messages + "Staging layout has changed. The cross directory has been deprecated and cross packages are now built under the native sysroot.\nThis requires a rebuild.\n"
elif abi == "5" and current_abi == "6":
bb.note("Converting staging layout from version 5 to layout version 6")
2012-05-29 14:53:06 +00:00
subprocess.call(sanity_data.expand("mv ${TMPDIR}/pstagelogs ${SSTATE_MANIFESTS}"), shell=True)
2010-12-16 11:10:09 +00:00
f = file(abifile, "w")
f.write(current_abi)
2012-02-22 22:01:52 +00:00
elif abi == "7" and current_abi == "8":
messages = messages + "Your configuration is using stamp files including the sstate hash but your build directory was built with stamp files that do not include this.\nTo continue, either rebuild or switch back to the OEBasic signature handler with BB_SIGNATURE_HANDLER = 'OEBasic'.\n"
2012-11-16 15:35:53 +00:00
elif (abi != current_abi and current_abi == "9"):
messages = messages + "The layout of the TMPDIR STAMPS directory has changed. Please clean out TMPDIR and rebuild (sstate will be still be valid and reused)\n"
2010-12-16 11:10:09 +00:00
elif (abi != current_abi):
# Code to convert from one ABI to another could go here if possible.
2011-01-25 12:22:21 +00:00
messages = messages + "Error, TMPDIR has changed its layout version number (%s to %s) and you need to either rebuild, revert or adjust it at your own risk.\n" % (abi, current_abi)
2010-12-16 11:10:09 +00:00
else:
f = file(abifile, "w")
f.write(current_abi)
f.close()
2012-05-23 22:42:24 +00:00
oeroot = sanity_data.getVar('COREBASE')
2010-12-16 11:10:09 +00:00
if oeroot.find ('+') != -1:
2011-04-21 11:52:41 +00:00
messages = messages + "Error, you have an invalid character (+) in your COREBASE directory path. Please move the installation to a directory which doesn't include a +."
2010-12-16 11:10:09 +00:00
elif oeroot.find (' ') != -1:
2011-04-21 11:52:41 +00:00
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."
2010-12-16 11:10:09 +00:00
if messages != "":
2012-09-26 14:00:10 +00:00
raise_sanity_error(sanity_data.expand(messages), sanity_data, network_error)
2013-02-12 13:27:32 +00:00
return reparse
2006-05-09 16:10:46 +00:00
2012-05-23 22:16:19 +00:00
# Create a copy of the datastore and finalise it to ensure appends and
# overrides are set - the datastore has yet to be finalised at ConfigParsed
def copy_data(e):
sanity_data = bb.data.createCopy(e.data)
sanity_data.finalize()
return sanity_data
2006-05-09 16:10:46 +00:00
addhandler check_sanity_eventhandler
python check_sanity_eventhandler() {
2012-09-05 14:25:51 +00:00
if bb.event.getName(e) == "ConfigParsed" and e.data.getVar("BB_WORKERCONTEXT", True) != "1" and e.data.getVar("DISABLE_SANITY_CHECKS", True) != "1":
2012-05-23 22:16:19 +00:00
sanity_data = copy_data(e)
2013-02-12 13:27:32 +00:00
reparse = check_sanity(sanity_data)
e.data.setVar("BB_INVALIDCONF", reparse)
2012-04-24 08:18:15 +00:00
elif bb.event.getName(e) == "SanityCheck":
2012-05-23 22:16:19 +00:00
sanity_data = copy_data(e)
2012-05-28 17:10:50 +00:00
sanity_data.setVar("SANITY_USE_EVENTS", "1")
2013-02-12 13:27:32 +00:00
reparse = check_sanity(sanity_data)
e.data.setVar("BB_INVALIDCONF", reparse)
2012-04-24 08:18:15 +00:00
bb.event.fire(bb.event.SanityCheckPassed(), e.data)
2012-10-11 11:44:46 +00:00
elif bb.event.getName(e) == "NetworkTest":
sanity_data = copy_data(e)
bb.event.fire(bb.event.NetworkTestFailed() if check_connectivity(sanity_data) else bb.event.NetworkTestPassed(), e.data)
2006-05-09 16:10:46 +00:00
2010-12-30 18:40:32 +00:00
return
2006-05-09 16:10:46 +00:00
}