2006-03-20 15:06:33 +00:00
#
# Sanity check the users setup for common misconfigurations
#
2014-01-22 10:45:42 +00:00
SANITY_REQUIRED_UTILITIES ?= "patch diffstat makeinfo git bzip2 tar \
2017-02-08 20:27:06 +00:00
gzip gawk chrpath wget cpio perl file which"
2011-06-02 20:16:47 +00:00
2013-04-12 20:16:51 +00:00
def bblayers_conf_file(d):
2016-12-14 21:13:04 +00:00
return os.path.join(d.getVar('TOPDIR'), 'conf/bblayers.conf')
2013-04-12 20:16:51 +00:00
def sanity_conf_read(fn):
with open(fn, 'r') as f:
lines = f.readlines()
return lines
def sanity_conf_find_line(pattern, lines):
import re
return next(((index, line)
for index, line in enumerate(lines)
if re.search(pattern, line)), (None, None))
def sanity_conf_update(fn, lines, version_var_name, new_version):
2016-03-21 20:24:33 +00:00
index, line = sanity_conf_find_line(r"^%s" % version_var_name, lines)
2013-04-12 20:16:51 +00:00
lines[index] = '%s = "%d"\n' % (version_var_name, new_version)
with open(fn, "w") as f:
f.write(''.join(lines))
2016-02-16 21:51:12 +00:00
# Functions added to this variable MUST throw a NotImplementedError exception unless
# they successfully changed the config version in the config file. Exceptions
# are used since exec_func doesn't handle return values.
BBLAYERS_CONF_UPDATE_FUNCS += " \
conf/bblayers.conf:LCONF_VERSION:LAYER_CONF_VERSION:oecore_update_bblayers \
conf/local.conf:CONF_VERSION:LOCALCONF_VERSION:oecore_update_localconf \
conf/site.conf:SCONF_VERSION:SITE_CONF_VERSION:oecore_update_siteconf \
"
2016-03-17 16:00:57 +00:00
SANITY_DIFF_TOOL ?= "meld"
SANITY_LOCALCONF_SAMPLE ?= "${COREBASE}/meta*/conf/local.conf.sample"
2016-02-16 21:51:12 +00:00
python oecore_update_localconf() {
# Check we are using a valid local.conf
2016-12-14 21:13:04 +00:00
current_conf = d.getVar('CONF_VERSION')
conf_version = d.getVar('LOCALCONF_VERSION')
2016-02-16 21:51:12 +00:00
2016-03-24 09:40:08 +00:00
failmsg = """Your version of local.conf was generated from an older/newer version of
2016-02-16 21:51:12 +00:00
local.conf.sample and there have been updates made to this file. Please compare the two
files and merge any changes before continuing.
Matching the version numbers will remove this message.
2016-03-17 16:00:57 +00:00
\"${SANITY_DIFF_TOOL} conf/local.conf ${SANITY_LOCALCONF_SAMPLE}\"
2016-02-16 21:51:12 +00:00
2016-03-24 09:40:08 +00:00
is a good way to visualise the changes."""
2016-03-17 16:00:55 +00:00
failmsg = d.expand(failmsg)
2016-02-16 21:51:12 +00:00
raise NotImplementedError(failmsg)
}
2016-03-17 16:00:57 +00:00
SANITY_SITECONF_SAMPLE ?= "${COREBASE}/meta*/conf/site.conf.sample"
2016-02-16 21:51:12 +00:00
python oecore_update_siteconf() {
# If we have a site.conf, check it's valid
2016-12-14 21:13:04 +00:00
current_sconf = d.getVar('SCONF_VERSION')
sconf_version = d.getVar('SITE_CONF_VERSION')
2016-02-16 21:51:12 +00:00
2016-03-24 09:40:08 +00:00
failmsg = """Your version of site.conf was generated from an older version of
2016-02-16 21:51:12 +00:00
site.conf.sample and there have been updates made to this file. Please compare the two
files and merge any changes before continuing.
Matching the version numbers will remove this message.
2016-03-17 16:00:57 +00:00
\"${SANITY_DIFF_TOOL} conf/site.conf ${SANITY_SITECONF_SAMPLE}\"
2016-02-16 21:51:12 +00:00
2016-03-24 09:40:08 +00:00
is a good way to visualise the changes."""
2016-03-17 16:00:55 +00:00
failmsg = d.expand(failmsg)
2016-02-16 21:51:12 +00:00
raise NotImplementedError(failmsg)
}
2013-04-12 20:16:51 +00:00
2016-03-17 16:00:57 +00:00
SANITY_BBLAYERCONF_SAMPLE ?= "${COREBASE}/meta*/conf/bblayers.conf.sample"
2013-04-12 20:16:51 +00:00
python oecore_update_bblayers() {
# bblayers.conf is out of date, so see if we can resolve that
2012-09-27 12:39:55 +00:00
2016-12-14 21:13:04 +00:00
current_lconf = int(d.getVar('LCONF_VERSION'))
lconf_version = int(d.getVar('LAYER_CONF_VERSION'))
2016-02-16 21:51:12 +00:00
2016-03-17 16:00:55 +00:00
failmsg = """Your version of bblayers.conf has the wrong LCONF_VERSION (has ${LCONF_VERSION}, expecting ${LAYER_CONF_VERSION}).
2016-02-29 16:28:56 +00:00
Please compare your file against bblayers.conf.sample and merge any changes before continuing.
2016-03-17 16:00:57 +00:00
"${SANITY_DIFF_TOOL} conf/bblayers.conf ${SANITY_BBLAYERCONF_SAMPLE}"
2016-02-16 21:51:12 +00:00
2016-03-17 16:00:55 +00:00
is a good way to visualise the changes."""
failmsg = d.expand(failmsg)
2016-02-16 21:51:12 +00:00
if not current_lconf:
raise NotImplementedError(failmsg)
2012-09-27 12:39:55 +00:00
lines = []
if current_lconf < 4:
2016-02-16 21:51:12 +00:00
raise NotImplementedError(failmsg)
2012-09-27 12:39:55 +00:00
2013-04-12 20:16:51 +00:00
bblayers_fn = bblayers_conf_file(d)
lines = sanity_conf_read(bblayers_fn)
2012-09-27 12:39:55 +00:00
2013-04-12 20:16:51 +00:00
if current_lconf == 4 and lconf_version > 4:
2012-09-27 12:39:55 +00:00
topdir_var = '$' + '{TOPDIR}'
2013-04-12 20:16:51 +00:00
index, bbpath_line = sanity_conf_find_line('BBPATH', lines)
2012-09-27 12:39:55 +00:00
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:
2016-02-16 21:51:12 +00:00
raise NotImplementedError(failmsg)
2012-09-27 12:39:55 +00:00
else:
2013-04-12 20:16:51 +00:00
index, bbfiles_line = sanity_conf_find_line('BBFILES', lines)
2012-09-27 12:39:55 +00:00
if bbfiles_line:
lines.insert(index, 'BBPATH = "' + topdir_var + '"\n')
else:
2016-02-16 21:51:12 +00:00
raise NotImplementedError(failmsg)
2012-09-27 12:39:55 +00:00
current_lconf += 1
2013-04-12 20:16:51 +00:00
sanity_conf_update(bblayers_fn, lines, 'LCONF_VERSION', current_lconf)
2016-03-21 20:24:33 +00:00
bb.note("Your conf/bblayers.conf has been automatically updated.")
2013-04-12 20:16:51 +00:00
return
2015-02-05 12:05:40 +00:00
elif current_lconf == 5 and lconf_version > 5:
# Null update, to avoid issues with people switching between poky and other distros
current_lconf = 6
sanity_conf_update(bblayers_fn, lines, 'LCONF_VERSION', current_lconf)
2016-03-21 20:24:33 +00:00
bb.note("Your conf/bblayers.conf has been automatically updated.")
2015-02-05 12:05:40 +00:00
return
2016-09-15 11:21:26 +00:00
status.addresult()
2016-02-16 21:51:12 +00:00
elif current_lconf == 6 and lconf_version > 6:
# Handle rename of meta-yocto -> meta-poky
# This marks the start of separate version numbers but code is needed in OE-Core
# for the migration, one last time.
2016-12-14 21:13:04 +00:00
layers = d.getVar('BBLAYERS').split()
2016-03-21 20:24:33 +00:00
layers = [ os.path.basename(path) for path in layers ]
2016-02-16 21:51:12 +00:00
if 'meta-yocto' in layers:
2016-02-29 16:28:56 +00:00
found = False
while True:
index, meta_yocto_line = sanity_conf_find_line(r'.*meta-yocto[\'"\s\n]', lines)
if meta_yocto_line:
lines[index] = meta_yocto_line.replace('meta-yocto', 'meta-poky')
found = True
else:
break
if not found:
2016-02-16 21:51:12 +00:00
raise NotImplementedError(failmsg)
index, meta_yocto_line = sanity_conf_find_line('LCONF_VERSION.*\n', lines)
if meta_yocto_line:
lines[index] = 'POKY_BBLAYERS_CONF_VERSION = "1"\n'
else:
raise NotImplementedError(failmsg)
with open(bblayers_fn, "w") as f:
f.write(''.join(lines))
2016-03-21 20:24:33 +00:00
bb.note("Your conf/bblayers.conf has been automatically updated.")
2016-02-16 21:51:12 +00:00
return
2016-02-28 22:53:03 +00:00
current_lconf += 1
sanity_conf_update(bblayers_fn, lines, 'LCONF_VERSION', current_lconf)
2016-03-21 20:24:33 +00:00
bb.note("Your conf/bblayers.conf has been automatically updated.")
2016-02-16 21:51:12 +00:00
return
raise NotImplementedError(failmsg)
2012-09-27 12:39:55 +00:00
}
2012-09-26 14:00:10 +00:00
def raise_sanity_error(msg, d, network_error=False):
2016-12-14 21:13:04 +00:00
if d.getVar("SANITY_USE_EVENTS") == "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
2014-07-31 01:16:27 +00:00
# Check flags associated with a tuning.
def check_toolchain_tune_args(data, tune, multilib, errs):
found_errors = False
if check_toolchain_args_present(data, tune, multilib, errs, 'CCARGS'):
found_errors = True
if check_toolchain_args_present(data, tune, multilib, errs, 'ASARGS'):
found_errors = True
if check_toolchain_args_present(data, tune, multilib, errs, 'LDARGS'):
found_errors = True
return found_errors
def check_toolchain_args_present(data, tune, multilib, tune_errors, which):
2016-12-14 21:13:04 +00:00
args_set = (data.getVar("TUNE_%s" % which) or "").split()
2017-01-05 21:15:08 +00:00
args_wanted = (data.getVar("TUNEABI_REQUIRED_%s_tune-%s" % (which, tune)) or "").split()
2014-07-31 01:16:27 +00:00
args_missing = []
# If no args are listed/required, we are done.
if not args_wanted:
return
for arg in args_wanted:
if arg not in args_set:
args_missing.append(arg)
found_errors = False
if args_missing:
found_errors = True
tune_errors.append("TUNEABI for %s requires '%s' in TUNE_%s (%s)." %
(tune, ' '.join(args_missing), which, ' '.join(args_set)))
return found_errors
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
2014-07-31 01:16:27 +00:00
localdata = bb.data.createCopy(data)
if multilib != "default":
# Apply the overrides so we can look at the details.
overrides = localdata.getVar("OVERRIDES", False) + ":virtclass-multilib-" + multilib
localdata.setVar("OVERRIDES", overrides)
2012-05-01 16:20:22 +00:00
bb.debug(2, "Sanity-checking tuning '%s' (%s) features:" % (tune, multilib))
2016-12-14 21:13:04 +00:00
features = (localdata.getVar("TUNE_FEATURES_tune-%s" % tune) or "").split()
2012-05-01 16:20:22 +00:00
if not features:
return "Tuning '%s' has no defined features, and cannot be used." % tune
2014-07-31 01:16:27 +00:00
valid_tunes = localdata.getVarFlags('TUNEVALID') or {}
conflicts = localdata.getVarFlags('TUNECONFLICTS') or {}
2012-05-01 16:20:22 +00:00
# [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)
2016-12-14 21:13:04 +00:00
whitelist = localdata.getVar("TUNEABI_WHITELIST")
2012-05-01 16:20:22 +00:00
if whitelist:
2016-12-14 21:13:04 +00:00
tuneabi = localdata.getVar("TUNEABI_tune-%s" % tune)
2012-05-01 16:20:22 +00:00
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))
2014-07-31 01:16:27 +00:00
else:
if not check_toolchain_tune_args(localdata, tuneabi, multilib, tune_errors):
bb.debug(2, "Sanity check: Compiler args OK for %s." % tune)
2012-05-01 16:20:22 +00:00
if tune_errors:
2012-05-17 23:45:58 +00:00
return "Tuning '%s' has the following errors:\n" % tune + '\n'.join(tune_errors)
2012-05-01 16:20:22 +00:00
def check_toolchain(data):
tune_error_set = []
2016-12-14 21:13:04 +00:00
deftune = data.getVar("DEFAULTTUNE")
2012-05-01 16:20:22 +00:00
tune_errors = check_toolchain_tune(data, deftune, 'default')
if tune_errors:
tune_error_set.append(tune_errors)
2016-12-14 21:13:04 +00:00
multilibs = (data.getVar("MULTILIB_VARIANTS") or "").split()
global_multilibs = (data.getVar("MULTILIB_GLOBAL_VARIANTS") or "").split()
2012-12-24 11:28:38 +00:00
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)
2016-12-14 21:13:04 +00:00
tune = data.getVar("DEFAULTTUNE_virtclass-multilib-%s" % lib)
2012-05-01 16:20:22 +00:00
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:
2013-06-21 16:45:33 +00:00
return "Toolchain tunings invalid:\n" + '\n'.join(tune_error_set) + "\n"
2012-05-01 16:20:22 +00:00
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)
2015-06-18 14:14:16 +00:00
vbbpath = data.getVar("BBPATH", False)
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
2010-12-16 17:35:31 +00:00
def check_create_long_filename(filepath, pathname):
2013-11-25 15:20:14 +00:00
import string, random
testfile = os.path.join(filepath, ''.join(random.choice(string.ascii_letters) for x in range(200)))
2010-12-16 17:35:31 +00:00
try:
if not os.path.exists(filepath):
bb.utils.mkdirhier(filepath)
2013-05-07 12:56:01 +00:00
f = open(testfile, "w")
2010-12-16 17:35:31 +00:00
f.close()
os.remove(testfile)
2013-05-07 12:55:55 +00:00
except IOError as e:
2013-11-25 15:20:15 +00:00
import errno
err, strerror = e.args
if err == errno.ENAMETOOLONG:
2010-12-16 17:35:31 +00:00
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)
2013-05-07 12:55:55 +00:00
except OSError as e:
errno, strerror = e.args
2012-05-23 23:28:59 +00:00
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:
2016-04-06 09:30:01 +00:00
return "The length of %s is longer than %s, this would cause unexpected errors, please use a shorter path.\n" % (pathname, limit)
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 ""
2014-01-22 10:50:20 +00:00
def get_filesystem_id(path):
status, result = oe.utils.getstatusoutput("stat -f -c '%s' %s" % ("%t", path))
if status == 0:
return result
else:
bb.warn("Can't get the filesystem id of: %s" % path)
return None
# Check that the path isn't located on nfs.
def check_not_nfs(path, name):
# The nfs' filesystem id is 6969
if get_filesystem_id(path) == "6969":
return "The %s: %s can't be located on nfs.\n" % (name, path)
return ""
2015-08-10 14:00:23 +00:00
# Check that path isn't a broken symlink
def check_symlink(lnk, data):
if os.path.islink(lnk) and not os.path.exists(lnk):
raise_sanity_error("%s is a broken symlink." % lnk, data)
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
2016-12-14 21:13:04 +00:00
test_uris = (d.getVar('CONNECTIVITY_CHECK_URIS') or "").split()
2011-06-29 21:55:03 +00:00
retval = ""
2016-12-14 21:13:04 +00:00
bbn = d.getVar('BB_NO_NETWORK')
2016-11-14 14:34:06 +00:00
if bbn not in (None, '0', '1'):
return 'BB_NO_NETWORK should be "0" or "1", but it is "%s"' % bbn
2011-06-29 21:55:03 +00:00
# Only check connectivity if network enabled and the
# CONNECTIVITY_CHECK_URIS are set
2016-11-14 14:34:06 +00:00
network_enabled = not (bbn == '1')
2011-06-29 21:55:03 +00:00
check_enabled = len(test_uris)
if check_enabled and network_enabled:
2016-11-14 14:34:06 +00:00
# Take a copy of the data store and unset MIRRORS and PREMIRRORS
data = bb.data.createCopy(d)
data.delVar('PREMIRRORS')
data.delVar('MIRRORS')
2011-06-29 21:55:03 +00:00
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()
2015-04-28 11:27:25 +00:00
except Exception as err:
2011-06-29 21:55:03 +00:00
# Allow the message to be configured so that users can be
# pointed to a support mechanism.
2016-12-14 21:13:04 +00:00
msg = data.getVar('CONNECTIVITY_CHECK_MSG') or ""
2011-06-29 21:55:03 +00:00
if len(msg) == 0:
2016-11-14 14:34:05 +00:00
msg = "%s.\n" % err
msg += " Please ensure your host's network is configured correctly,\n"
msg += " or set BB_NO_NETWORK = \"1\" to disable network access if\n"
msg += " all required sources are on local disk.\n"
2011-06-29 21:55:03 +00:00
retval = msg
return retval
2012-05-23 22:16:19 +00:00
def check_supported_distro(sanity_data):
2014-03-03 14:37:36 +00:00
from fnmatch import fnmatch
2016-12-14 21:13:04 +00:00
tested_distros = sanity_data.getVar('SANITY_TESTED_DISTROS')
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
2014-03-03 14:37:36 +00:00
if not distro:
2011-08-17 17:48:15 +00:00
bb.warn('Host distribution could not be determined; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.')
2014-03-03 14:37:36 +00:00
for supported in [x.strip() for x in tested_distros.split('\\n')]:
if fnmatch(distro, supported):
return
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)
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
2016-12-14 21:13:04 +00:00
if sanity_data.getVar('TUNE_ARCH') == '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
2016-12-14 21:13:04 +00:00
if sanity_data.getVar('TARGET_OS') == '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
2016-12-14 21:13:04 +00:00
pkgarchs = sanity_data.getVar('PACKAGE_ARCHS')
tunepkg = sanity_data.getVar('TUNE_PKGARCH')
defaulttune = sanity_data.getVar('DEFAULTTUNE')
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:
2015-12-18 13:14:24 +00:00
messages = messages + "Error, the PACKAGE_ARCHS variable (%s) for DEFAULTTUNE (%s) does not contain TUNE_PKGARCH (%s)." % (pkgarchs, defaulttune, 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):
2013-07-15 20:10:26 +00:00
result = True
message = ""
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
# Check if -march not in BUILD_CFLAGS
2017-01-05 21:15:08 +00:00
if sanity_data.getVar("BUILD_CFLAGS").find("-march") < 0:
2013-07-15 20:10:26 +00:00
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
# Construct a test file
2013-05-07 12:56:01 +00:00
f = open("gcc_test.c", "w")
2013-07-15 20:10:26 +00:00
f.write("int main (){ volatile int atomic = 2; __sync_bool_compare_and_swap (&atomic, 2, 3); return 0; }\n")
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
f.close()
# Check if GCC could work without march
2013-07-15 20:10:26 +00:00
if not result:
2016-09-07 09:08:46 +00:00
status,res = oe.utils.getstatusoutput(sanity_data.expand("${BUILD_CC} gcc_test.c -o gcc_test"))
2013-07-15 20:10:26 +00:00
if status == 0:
result = True;
if not result:
2016-09-07 09:08:46 +00:00
status,res = oe.utils.getstatusoutput(sanity_data.expand("${BUILD_CC} -march=native gcc_test.c -o gcc_test"))
2013-07-15 20:10:26 +00:00
if status == 0:
message = "BUILD_CFLAGS_append = \" -march=native\""
result = True;
if not result:
2016-12-14 21:13:04 +00:00
build_arch = sanity_data.getVar('BUILD_ARCH')
2016-09-07 09:08:46 +00:00
status,res = oe.utils.getstatusoutput(sanity_data.expand("${BUILD_CC} -march=%s gcc_test.c -o gcc_test" % build_arch))
2013-07-15 20:10:26 +00:00
if status == 0:
message = "BUILD_CFLAGS_append = \" -march=%s\"" % build_arch
result = True;
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
2013-07-15 20:10:26 +00:00
return (result, message)
2011-08-30 16:14:55 +00:00
2013-06-27 14:08:33 +00:00
# Unpatched versions of make 3.82 are known to be broken. See GNU Savannah Bug 30612.
# Use a modified reproducer from http://savannah.gnu.org/bugs/?30612 to validate.
def check_make_version(sanity_data):
from distutils.version import LooseVersion
status, result = oe.utils.getstatusoutput("make --version")
if status != 0:
return "Unable to execute make --version, exit code %s\n" % status
version = result.split()[2]
if LooseVersion(version) == LooseVersion("3.82"):
# Construct a test file
f = open("makefile_test", "w")
f.write("makefile_test.a: makefile_test_a.c makefile_test_b.c makefile_test.a( makefile_test_a.c makefile_test_b.c)\n")
f.write("\n")
f.write("makefile_test_a.c:\n")
f.write(" touch $@\n")
f.write("\n")
f.write("makefile_test_b.c:\n")
f.write(" touch $@\n")
f.close()
# Check if make 3.82 has been patched
status,result = oe.utils.getstatusoutput("make -f makefile_test")
os.remove("makefile_test")
if os.path.exists("makefile_test_a.c"):
os.remove("makefile_test_a.c")
if os.path.exists("makefile_test_b.c"):
os.remove("makefile_test_b.c")
if os.path.exists("makefile_test.a"):
os.remove("makefile_test.a")
if status != 0:
return "Your version of make 3.82 is broken. Please revert to 3.81 or install a patched version.\n"
return None
2013-06-07 17:16:03 +00:00
# Tar version 1.24 and onwards handle overwriting symlinks correctly
# but earlier versions do not; this needs to work properly for sstate
2013-06-21 16:45:33 +00:00
def check_tar_version(sanity_data):
from distutils.version import LooseVersion
2013-06-07 17:16:03 +00:00
status, result = oe.utils.getstatusoutput("tar --version")
if status != 0:
return "Unable to execute tar --version, exit code %s\n" % status
version = result.split()[3]
2013-06-21 16:45:33 +00:00
if LooseVersion(version) < LooseVersion("1.24"):
2013-06-07 17:16:03 +00:00
return "Your version of tar is older than 1.24 and has bugs which will break builds. Please install a newer version of tar.\n"
return None
2014-07-04 10:49:50 +00:00
# We use git parameters and functionality only found in 1.7.8 or later
2016-04-05 14:46:21 +00:00
# The kernel tools assume git >= 1.8.3.1 (verified needed > 1.7.9.5) see #6162
# The git fetcher also had workarounds for git < 1.7.9.2 which we've dropped
2013-06-21 16:45:33 +00:00
def check_git_version(sanity_data):
from distutils.version import LooseVersion
2013-06-07 17:16:03 +00:00
status, result = oe.utils.getstatusoutput("git --version 2> /dev/null")
if status != 0:
return "Unable to execute git --version, exit code %s\n" % status
version = result.split()[2]
2016-04-05 14:46:21 +00:00
if LooseVersion(version) < LooseVersion("1.8.3.1"):
return "Your version of git is older than 1.8.3.1 and has bugs which will break builds. Please install a newer version of git.\n"
2013-06-07 17:16:03 +00:00
return None
2014-01-22 10:45:42 +00:00
# Check the required perl modules which may not be installed by default
def check_perl_modules(sanity_data):
ret = ""
modules = ( "Text::ParseWords", "Thread::Queue", "Data::Dumper" )
2016-02-10 23:19:53 +00:00
errresult = ''
2014-01-22 10:45:42 +00:00
for m in modules:
2016-02-10 23:19:53 +00:00
status, result = oe.utils.getstatusoutput("perl -e 'use %s'" % m)
2014-01-22 10:45:42 +00:00
if status != 0:
2016-02-10 23:19:53 +00:00
errresult += result
2014-01-22 10:45:42 +00:00
ret += "%s " % m
if ret:
2016-02-10 23:19:53 +00:00
return "Required perl module(s) not found: %s\n\n%s\n" % (ret, errresult)
2014-01-22 10:45:42 +00:00
return None
2013-06-07 17:16:03 +00:00
2016-09-15 11:21:26 +00:00
def sanity_check_conffiles(d):
2016-12-14 21:13:04 +00:00
funcs = d.getVar('BBLAYERS_CONF_UPDATE_FUNCS').split()
2016-02-16 21:51:12 +00:00
for func in funcs:
conffile, current_version, required_version, func = func.split(":")
2016-12-14 21:13:04 +00:00
if check_conf_exists(conffile, d) and d.getVar(current_version) is not None and \
d.getVar(current_version) != d.getVar(required_version):
2013-04-12 20:16:51 +00:00
try:
2016-03-30 19:55:42 +00:00
bb.build.exec_func(func, d, pythonexception=True)
2016-02-16 21:51:12 +00:00
except NotImplementedError as e:
2016-11-10 14:57:29 +00:00
bb.fatal(str(e))
2016-09-15 11:21:26 +00:00
d.setVar("BB_INVALIDCONF", True)
2011-01-05 01:22:45 +00:00
2013-06-21 16:45:33 +00:00
def sanity_handle_abichanges(status, d):
#
# Check the 'ABI' of TMPDIR
#
2015-05-20 19:11:06 +00:00
import subprocess
2016-12-14 21:13:04 +00:00
current_abi = d.getVar('OELAYOUT_ABI')
abifile = d.getVar('SANITY_ABIFILE')
2013-06-21 16:45:33 +00:00
if os.path.exists(abifile):
with open(abifile, "r") as f:
abi = f.read().strip()
if not abi.isdigit():
with open(abifile, "w") as f:
f.write(current_abi)
2017-03-30 09:26:56 +00:00
elif int(abi) <= 11 and current_abi == "12":
2017-04-04 16:14:06 +00:00
status.addresult("The layout of TMPDIR changed for Recipe Specific Sysroots.\nConversion doesn't make sense and this change will rebuild everything so please delete TMPDIR (%s).\n" % d.getVar("TMPDIR"))
2013-06-21 16:45:33 +00:00
elif (abi != current_abi):
# Code to convert from one ABI to another could go here if possible.
status.addresult("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))
else:
with open(abifile, "w") as f:
f.write(current_abi)
def check_sanity_sstate_dir_change(sstate_dir, data):
# Sanity checks to be done when the value of SSTATE_DIR changes
# Check that SSTATE_DIR isn't on a filesystem with limited filename length (eg. eCryptFS)
testmsg = ""
if sstate_dir != "":
testmsg = check_create_long_filename(sstate_dir, "SSTATE_DIR")
# 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
return testmsg
def check_sanity_version_change(status, d):
2016-03-22 17:23:18 +00:00
# Sanity checks to be done when SANITY_VERSION or NATIVELSBSTRING changes
2013-06-21 16:45:33 +00:00
# In other words, these tests run once in a given build directory and then
2016-03-22 17:23:18 +00:00
# never again until the sanity version or host distrubution id/version changes.
2013-06-21 16:45:33 +00:00
# Check the python install is complete. glib-2.0-natives requries
# xml.parsers.expat
try:
import xml.parsers.expat
except ImportError:
status.addresult('Your python is not a full install. Please install the module xml.parsers.expat (python-xml on openSUSE and SUSE Linux).\n')
2014-07-23 16:05:44 +00:00
import stat
2013-06-21 16:45:33 +00:00
2013-06-27 14:08:33 +00:00
status.addresult(check_make_version(d))
2013-06-21 16:45:33 +00:00
status.addresult(check_tar_version(d))
status.addresult(check_git_version(d))
2014-01-22 10:45:42 +00:00
status.addresult(check_perl_modules(d))
2010-12-16 11:10:09 +00:00
missing = ""
2013-06-21 16:45:33 +00:00
if not check_app_exists("${MAKE}", d):
2010-12-16 11:10:09 +00:00
missing = missing + "GNU make,"
2016-09-07 09:08:46 +00:00
if not check_app_exists('${BUILD_CC}', d):
2016-12-14 21:13:04 +00:00
missing = missing + "C Compiler (%s)," % d.getVar("BUILD_CC")
2013-06-21 16:45:33 +00:00
2016-09-07 09:08:46 +00:00
if not check_app_exists('${BUILD_CXX}', d):
2016-12-14 21:13:04 +00:00
missing = missing + "C++ Compiler (%s)," % d.getVar("BUILD_CXX")
2013-06-21 16:45:33 +00:00
2016-12-14 21:13:04 +00:00
required_utilities = d.getVar('SANITY_REQUIRED_UTILITIES')
2013-06-21 16:45:33 +00:00
for util in required_utilities.split():
if not check_app_exists(util, d):
missing = missing + "%s," % util
2010-12-16 11:10:09 +00:00
2013-06-21 16:45:33 +00:00
if missing:
missing = missing.rstrip(',')
status.addresult("Please install the following missing utilities: %s\n" % missing)
2010-12-16 11:10:09 +00:00
2016-12-14 21:13:04 +00:00
assume_provided = d.getVar('ASSUME_PROVIDED').split()
2013-06-21 16:45:33 +00:00
# Check user doesn't have ASSUME_PROVIDED = instead of += in local.conf
if "diffstat-native" not in assume_provided:
status.addresult('Please use ASSUME_PROVIDED +=, not ASSUME_PROVIDED = in your local.conf\n')
2010-12-16 11:10:09 +00:00
if "qemu-native" in assume_provided:
2013-06-21 16:45:33 +00:00
if not check_app_exists("qemu-arm", d):
status.addresult("qemu-native was in ASSUME_PROVIDED but the QEMU binaries (qemu-arm) can't be found in PATH")
2010-12-16 11:10:09 +00:00
2014-06-02 20:08:34 +00:00
if "libsdl-native" in assume_provided:
if not check_app_exists("sdl-config", d):
status.addresult("libsdl-native is set to be ASSUME_PROVIDED but sdl-config can't be found in PATH. Please either install it, or configure qemu not to require sdl.")
2013-07-15 20:10:26 +00:00
(result, message) = check_gcc_march(d)
if result and message:
2013-06-21 16:45:33 +00:00
status.addresult("Your gcc version is older than 4.5, please add the following param to local.conf\n \
2013-07-15 20:10:26 +00:00
%s\n" % message)
if not result:
2013-08-01 17:17:17 +00:00
status.addresult("Your gcc version is older than 4.5 or is not working properly. Please verify you can build")
2013-07-15 20:10:26 +00:00
status.addresult(" and link something that uses atomic operations, such as: \n")
status.addresult(" __sync_bool_compare_and_swap (&atomic, 2, 3);\n")
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
2013-06-21 16:45:33 +00:00
# Check that TMPDIR isn't on a filesystem with limited filename length (eg. eCryptFS)
2016-12-14 21:13:04 +00:00
tmpdir = d.getVar('TMPDIR')
2013-06-21 16:45:33 +00:00
status.addresult(check_create_long_filename(tmpdir, "TMPDIR"))
2014-07-23 16:05:44 +00:00
tmpdirmode = os.stat(tmpdir).st_mode
if (tmpdirmode & stat.S_ISGID):
status.addresult("TMPDIR is setgid, please don't build in a setgid directory")
if (tmpdirmode & stat.S_ISUID):
status.addresult("TMPDIR is setuid, please don't build in a setuid directory")
2013-06-21 16:45:33 +00:00
2013-08-01 17:17:16 +00:00
# Some third-party software apparently relies on chmod etc. being suid root (!!)
import stat
suid_check_bins = "chown chmod mknod".split()
for bin_cmd in suid_check_bins:
bin_path = bb.utils.which(os.environ["PATH"], bin_cmd)
if bin_path:
bin_stat = os.stat(bin_path)
if bin_stat.st_uid == 0 and bin_stat.st_mode & stat.S_ISUID:
status.addresult('%s has the setuid bit set. This interferes with pseudo and may cause other issues that break the build process.\n' % bin_path)
2013-06-21 16:45:33 +00:00
# Check that we can fetch from various network transports
netcheck = check_connectivity(d)
status.addresult(netcheck)
if netcheck:
status.network_error = True
2016-12-14 21:13:04 +00:00
nolibs = d.getVar('NO32LIBS')
2013-06-21 16:45:33 +00:00
if not nolibs:
lib32path = '/lib'
if os.path.exists('/lib64') and ( os.path.islink('/lib64') or os.path.islink('/lib') ):
lib32path = '/lib32'
if os.path.exists('%s/libc.so.6' % lib32path) and not os.path.exists('/usr/include/gnu/stubs-32.h'):
status.addresult("You have a 32-bit libc, but no 32-bit headers. You must install the 32-bit libc headers.\n")
2016-12-14 21:13:04 +00:00
bbpaths = d.getVar('BBPATH').split(":")
2016-09-15 11:21:26 +00:00
if ("." in bbpaths or "./" in bbpaths or "" in bbpaths):
2013-06-21 16:45:33 +00:00
status.addresult("BBPATH references the current directory, either through " \
2015-01-07 07:00:31 +00:00
"an empty entry, a './' or a '.'.\n\t This is unsafe and means your "\
2012-06-13 04:01:43 +00:00
"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 " \
2013-06-21 16:45:33 +00:00
"references.\n" \
"Parsed BBPATH is" + str(bbpaths));
2012-06-13 04:01:43 +00:00
2016-12-14 21:13:04 +00:00
oes_bb_conf = d.getVar( 'OES_BITBAKE_CONF')
2013-06-21 16:45:33 +00:00
if not oes_bb_conf:
2013-08-01 17:17:17 +00:00
status.addresult('You are not using the OpenEmbedded version of conf/bitbake.conf. This means your environment is misconfigured, in particular check BBPATH.\n')
2013-06-21 16:45:33 +00:00
2014-01-22 10:50:20 +00:00
# The length of TMPDIR can't be longer than 410
2013-06-21 16:45:33 +00:00
status.addresult(check_path_length(tmpdir, "TMPDIR", 410))
2014-01-22 10:50:20 +00:00
# Check that TMPDIR isn't located on nfs
status.addresult(check_not_nfs(tmpdir, "TMPDIR"))
2016-05-24 16:37:45 +00:00
def sanity_check_locale(d):
"""
Currently bitbake switches locale to en_US.UTF-8 so check that this locale actually exists.
"""
import locale
try:
locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
except locale.Error:
raise_sanity_error("You system needs to support the en_US.UTF-8 locale.", d)
2013-06-21 16:45:33 +00:00
def check_sanity_everybuild(status, d):
2015-08-28 22:34:04 +00:00
import os, stat
2013-06-21 16:45:33 +00:00
# Sanity tests which test the users environment so need to run at each build (or are so cheap
# it makes sense to always run them.
if 0 == os.getuid():
raise_sanity_error("Do not use Bitbake as root.", d)
# Check the Python version, we now have a minimum of Python 2.7.3
import sys
if sys.hexversion < 0x020703F0:
status.addresult('The system requires at least Python 2.7.3 to run. Please update your Python interpreter.\n')
# Check the bitbake version meets minimum requirements
from distutils.version import LooseVersion
2016-12-14 21:13:04 +00:00
minversion = d.getVar('BB_MIN_VERSION')
2013-06-21 16:45:33 +00:00
if (LooseVersion(bb.__version__) < LooseVersion(minversion)):
status.addresult('Bitbake version %s is required and version %s was found\n' % (minversion, bb.__version__))
2016-05-24 16:37:45 +00:00
sanity_check_locale(d)
2016-12-14 21:13:04 +00:00
paths = d.getVar('PATH').split(":")
2015-01-07 07:00:31 +00:00
if "." in paths or "./" in paths or "" in paths:
status.addresult("PATH contains '.', './' or '' (empty element), which will break the build, please remove this.\nParsed PATH is " + str(paths) + "\n")
2013-06-21 16:45:33 +00:00
# Check that the DISTRO is valid, if set
# need to take into account DISTRO renaming DISTRO
2016-12-14 21:13:04 +00:00
distro = d.getVar('DISTRO')
2013-11-07 22:35:07 +00:00
if distro and distro != "nodistro":
2013-06-21 16:45:33 +00:00
if not ( check_conf_exists("conf/distro/${DISTRO}.conf", d) or check_conf_exists("conf/distro/include/${DISTRO}.inc", d) ):
2016-12-14 21:13:04 +00:00
status.addresult("DISTRO '%s' not found. Please set a valid DISTRO in your local.conf\n" % d.getVar("DISTRO"))
2013-06-21 16:45:33 +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.
2016-12-14 21:13:04 +00:00
dldir = d.getVar('DL_DIR')
2013-06-21 16:45:33 +00:00
if not dldir:
status.addresult("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):
status.addresult("DL_DIR: %s exists but you do not appear to have write access to it. \n" % dldir)
2015-08-10 14:00:23 +00:00
check_symlink(dldir, d)
2013-06-21 16:45:33 +00:00
# Check that the MACHINE is valid, if it is set
machinevalid = True
2016-12-14 21:13:04 +00:00
if d.getVar('MACHINE'):
2013-06-21 16:45:33 +00:00
if not check_conf_exists("conf/machine/${MACHINE}.conf", d):
2017-01-12 22:07:58 +00:00
status.addresult('MACHINE=%s is invalid. Please set a valid MACHINE in your local.conf, environment or other configuration file.\n' % (d.getVar('MACHINE')))
2013-06-21 16:45:33 +00:00
machinevalid = False
else:
status.addresult(check_sanity_validmachine(d))
else:
status.addresult('Please set a MACHINE in your local.conf or environment\n')
machinevalid = False
if machinevalid:
status.addresult(check_toolchain(d))
2013-11-13 14:32:40 +00:00
# Check that the SDKMACHINE is valid, if it is set
2016-12-14 21:13:04 +00:00
if d.getVar('SDKMACHINE'):
2013-11-13 14:32:40 +00:00
if not check_conf_exists("conf/machine-sdk/${SDKMACHINE}.conf", d):
status.addresult('Specified SDKMACHINE value is not valid\n')
2014-03-31 10:29:36 +00:00
elif d.getVar('SDK_ARCH', False) == "${BUILD_ARCH}":
status.addresult('SDKMACHINE is set, but SDK_ARCH has not been changed as a result - SDKMACHINE may have been set too late (e.g. in the distro configuration)\n')
2013-11-13 14:32:40 +00:00
2013-06-21 16:45:33 +00:00
check_supported_distro(d)
2013-05-07 10:23:40 +00:00
omask = os.umask(0o022)
if omask & 0o755:
2013-06-21 16:45:33 +00:00
status.addresult("Please use a umask which allows a+rx and u+rwx\n")
os.umask(omask)
2016-12-14 21:13:04 +00:00
if d.getVar('TARGET_ARCH') == "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):
2013-06-21 16:45:33 +00:00
status.addresult("/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
2016-12-14 21:13:04 +00:00
oeroot = d.getVar('COREBASE')
2013-06-25 17:08:01 +00:00
if oeroot.find('+') != -1:
status.addresult("Error, you have an invalid character (+) in your COREBASE directory path. Please move the installation to a directory which doesn't include any + characters.")
if oeroot.find('@') != -1:
status.addresult("Error, you have an invalid character (@) in your COREBASE directory path. Please move the installation to a directory which doesn't include any @ characters.")
if oeroot.find(' ') != -1:
status.addresult("Error, you have a space in your COREBASE directory path. Please move the installation to a directory which doesn't include a space since autotools doesn't support this.")
2011-08-17 17:48:15 +00:00
2014-08-22 08:31:27 +00:00
# Check the format of MIRRORS, PREMIRRORS and SSTATE_MIRRORS
2014-08-25 22:57:43 +00:00
import re
2014-08-25 22:57:44 +00:00
mirror_vars = ['MIRRORS', 'PREMIRRORS', 'SSTATE_MIRRORS']
protocols = ['http', 'ftp', 'file', 'https', \
2015-05-04 21:49:53 +00:00
'git', 'gitsm', 'hg', 'osc', 'p4', 'svn', \
2017-03-06 22:34:06 +00:00
'bzr', 'cvs', 'npm', 'sftp', 'ssh', 's3' ]
2014-08-25 22:57:44 +00:00
for mirror_var in mirror_vars:
2017-03-03 00:12:49 +00:00
mirrors = (d.getVar(mirror_var) or '').replace('\\n', ' ').split()
2014-08-25 22:57:44 +00:00
2017-03-03 00:12:49 +00:00
# Split into pairs
if len(mirrors) % 2 != 0:
bb.warn('Invalid mirror variable value for %s: %s, should contain paired members.' % (mirror_var, mirrors.strip()))
continue
mirrors = list(zip(*[iter(mirrors)]*2))
for mirror_entry in mirrors:
pattern, mirror = mirror_entry
2014-08-25 22:57:44 +00:00
decoded = bb.fetch2.decodeurl(pattern)
try:
pattern_scheme = re.compile(decoded[0])
except re.error as exc:
bb.warn('Invalid scheme regex (%s) in %s; %s' % (pattern, mirror_var, mirror_entry))
continue
if not any(pattern_scheme.match(protocol) for protocol in protocols):
bb.warn('Invalid protocol (%s) in %s: %s' % (decoded[0], mirror_var, mirror_entry))
continue
if not any(mirror.startswith(protocol + '://') for protocol in protocols):
bb.warn('Invalid protocol in %s: %s' % (mirror_var, mirror_entry))
continue
2015-08-10 14:00:23 +00:00
if mirror.startswith('file://'):
2016-05-12 22:41:50 +00:00
import urllib
check_symlink(urllib.parse.urlparse(mirror).path, d)
2015-08-10 14:00:23 +00:00
# SSTATE_MIRROR ends with a /PATH string
if mirror.endswith('/PATH'):
# remove /PATH$ from SSTATE_MIRROR to get a working
# base directory path
2016-05-12 22:41:50 +00:00
mirror_base = urllib.parse.urlparse(mirror[:-1*len('/PATH')]).path
2015-08-10 14:00:23 +00:00
check_symlink(mirror_base, d)
2014-08-22 08:31:27 +00:00
2013-06-21 16:45:33 +00:00
# Check that TMPDIR hasn't changed location since the last time we were run
2016-12-14 21:13:04 +00:00
tmpdir = d.getVar('TMPDIR')
2013-06-21 16:45:33 +00:00
checkfile = os.path.join(tmpdir, "saved_tmpdir")
if os.path.exists(checkfile):
with open(checkfile, "r") as f:
saved_tmpdir = f.read().strip()
if (saved_tmpdir != tmpdir):
status.addresult("Error, TMPDIR has changed location. You need to either move it back to %s or rebuild\n" % saved_tmpdir)
else:
bb.utils.mkdirhier(tmpdir)
2015-08-28 22:34:04 +00:00
# Remove setuid, setgid and sticky bits from TMPDIR
2015-09-23 16:13:56 +00:00
try:
os.chmod(tmpdir, os.stat(tmpdir).st_mode & ~ stat.S_ISUID)
os.chmod(tmpdir, os.stat(tmpdir).st_mode & ~ stat.S_ISGID)
os.chmod(tmpdir, os.stat(tmpdir).st_mode & ~ stat.S_ISVTX)
2015-10-16 22:51:12 +00:00
except OSError as exc:
bb.warn("Unable to chmod TMPDIR: %s" % exc)
2013-06-21 16:45:33 +00:00
with open(checkfile, "w") as f:
f.write(tmpdir)
2010-12-16 11:10:09 +00:00
2016-08-10 07:38:48 +00:00
# If /bin/sh is a symlink, check that it points to dash or bash
if os.path.islink('/bin/sh'):
real_sh = os.path.realpath('/bin/sh')
2017-03-15 16:37:39 +00:00
# Due to update-alternatives, the shell name may take various
# forms, such as /bin/dash, bin/bash, /bin/bash.bash ...
if '/dash' not in real_sh and '/bash' not in real_sh:
2016-08-10 07:38:48 +00:00
status.addresult("Error, /bin/sh links to %s, must be dash or bash\n" % real_sh)
2015-06-03 18:07:26 +00:00
2013-06-21 16:45:33 +00:00
def check_sanity(sanity_data):
class SanityStatus(object):
def __init__(self):
self.messages = ""
self.network_error = False
2010-12-16 11:10:09 +00:00
2013-06-21 16:45:33 +00:00
def addresult(self, message):
if message:
self.messages = self.messages + message
2010-12-16 11:10:09 +00:00
2013-06-21 16:45:33 +00:00
status = SanityStatus()
2010-12-16 11:10:09 +00:00
2016-12-14 21:13:04 +00:00
tmpdir = sanity_data.getVar('TMPDIR')
sstate_dir = sanity_data.getVar('SSTATE_DIR')
2010-12-16 16:25:13 +00:00
2015-08-10 14:00:23 +00:00
check_symlink(sstate_dir, sanity_data)
2010-12-16 16:25:13 +00:00
# Check saved sanity info
last_sanity_version = 0
last_tmpdir = ""
last_sstate_dir = ""
2016-03-22 17:23:18 +00:00
last_nativelsbstr = ""
2013-09-01 15:19:32 +00:00
sanityverfile = sanity_data.expand("${TOPDIR}/conf/sanity_info")
2010-12-16 16:25:13 +00:00
if os.path.exists(sanityverfile):
2013-05-09 16:05:58 +00:00
with open(sanityverfile, 'r') as f:
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]
2016-03-22 17:23:18 +00:00
if line.startswith('NATIVELSBSTRING'):
last_nativelsbstr = line.split()[1]
2013-06-21 16:45:33 +00:00
check_sanity_everybuild(status, sanity_data)
2010-12-16 16:25:13 +00:00
2016-12-14 21:13:04 +00:00
sanity_version = int(sanity_data.getVar('SANITY_VERSION') or 1)
2012-09-26 14:00:10 +00:00
network_error = False
2016-03-22 17:23:18 +00:00
# NATIVELSBSTRING var may have been overridden with "universal", so
# get actual host distribution id and version
nativelsbstr = lsb_distro_identifier(sanity_data)
if last_sanity_version < sanity_version or last_nativelsbstr != nativelsbstr:
2013-06-21 16:45:33 +00:00
check_sanity_version_change(status, sanity_data)
status.addresult(check_sanity_sstate_dir_change(sstate_dir, sanity_data))
2010-12-16 16:25:13 +00:00
else:
if last_sstate_dir != sstate_dir:
2013-06-21 16:45:33 +00:00
status.addresult(check_sanity_sstate_dir_change(sstate_dir, sanity_data))
2013-09-01 15:19:32 +00:00
if os.path.exists(os.path.dirname(sanityverfile)) and not status.messages:
2013-05-09 16:05:58 +00:00
with open(sanityverfile, 'w') as f:
f.write("SANITY_VERSION %s\n" % sanity_version)
f.write("TMPDIR %s\n" % tmpdir)
f.write("SSTATE_DIR %s\n" % sstate_dir)
2016-03-22 17:23:18 +00:00
f.write("NATIVELSBSTRING %s\n" % nativelsbstr)
2010-12-16 16:25:13 +00:00
2013-06-21 16:45:33 +00:00
sanity_handle_abichanges(status, sanity_data)
2010-12-16 11:10:09 +00:00
2013-06-21 16:45:33 +00:00
if status.messages != "":
raise_sanity_error(sanity_data.expand(status.messages), sanity_data, status.network_error)
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
2016-09-15 11:21:26 +00:00
addhandler config_reparse_eventhandler
config_reparse_eventhandler[eventmask] = "bb.event.ConfigParsed"
python config_reparse_eventhandler() {
sanity_check_conffiles(e.data)
}
2006-05-09 16:10:46 +00:00
addhandler check_sanity_eventhandler
2014-03-26 15:09:06 +00:00
check_sanity_eventhandler[eventmask] = "bb.event.SanityCheck bb.event.NetworkTest"
2006-05-09 16:10:46 +00:00
python check_sanity_eventhandler() {
2014-03-26 15:09:06 +00:00
if bb.event.getName(e) == "SanityCheck":
2012-05-23 22:16:19 +00:00
sanity_data = copy_data(e)
2016-09-15 11:21:26 +00:00
check_sanity(sanity_data)
2014-03-26 15:09:06 +00:00
if e.generateevents:
sanity_data.setVar("SANITY_USE_EVENTS", "1")
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)
2014-03-26 15:09:06 +00:00
if e.generateevents:
sanity_data.setVar("SANITY_USE_EVENTS", "1")
2012-10-11 11:44:46 +00:00
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
}