summaryrefslogtreecommitdiff
path: root/yocto-poky/meta/classes/sanity.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'yocto-poky/meta/classes/sanity.bbclass')
-rw-r--r--yocto-poky/meta/classes/sanity.bbclass199
1 files changed, 133 insertions, 66 deletions
diff --git a/yocto-poky/meta/classes/sanity.bbclass b/yocto-poky/meta/classes/sanity.bbclass
index ae86d261e..77813e41b 100644
--- a/yocto-poky/meta/classes/sanity.bbclass
+++ b/yocto-poky/meta/classes/sanity.bbclass
@@ -20,26 +20,83 @@ def sanity_conf_find_line(pattern, lines):
if re.search(pattern, line)), (None, None))
def sanity_conf_update(fn, lines, version_var_name, new_version):
- index, line = sanity_conf_find_line(version_var_name, lines)
+ index, line = sanity_conf_find_line(r"^%s" % version_var_name, lines)
lines[index] = '%s = "%d"\n' % (version_var_name, new_version)
with open(fn, "w") as f:
f.write(''.join(lines))
-# Functions added to this variable MUST throw an exception (or sys.exit()) unless they
-# successfully changed LCONF_VERSION in bblayers.conf
-BBLAYERS_CONF_UPDATE_FUNCS += "oecore_update_bblayers"
+# 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 \
+"
+SANITY_DIFF_TOOL ?= "meld"
+
+SANITY_LOCALCONF_SAMPLE ?= "${COREBASE}/meta*/conf/local.conf.sample"
+python oecore_update_localconf() {
+ # Check we are using a valid local.conf
+ current_conf = d.getVar('CONF_VERSION', True)
+ conf_version = d.getVar('LOCALCONF_VERSION', True)
+
+ failmsg = """Your version of local.conf was generated from an older/newer 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.
+
+Matching the version numbers will remove this message.
+
+\"${SANITY_DIFF_TOOL} conf/local.conf ${SANITY_LOCALCONF_SAMPLE}\"
+
+is a good way to visualise the changes."""
+ failmsg = d.expand(failmsg)
+
+ raise NotImplementedError(failmsg)
+}
+
+SANITY_SITECONF_SAMPLE ?= "${COREBASE}/meta*/conf/site.conf.sample"
+python oecore_update_siteconf() {
+ # If we have a site.conf, check it's valid
+ current_sconf = d.getVar('SCONF_VERSION', True)
+ sconf_version = d.getVar('SITE_CONF_VERSION', True)
+
+ failmsg = """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.
+
+Matching the version numbers will remove this message.
+
+\"${SANITY_DIFF_TOOL} conf/site.conf ${SANITY_SITECONF_SAMPLE}\"
+
+is a good way to visualise the changes."""
+ failmsg = d.expand(failmsg)
+
+ raise NotImplementedError(failmsg)
+}
+
+SANITY_BBLAYERCONF_SAMPLE ?= "${COREBASE}/meta*/conf/bblayers.conf.sample"
python oecore_update_bblayers() {
# bblayers.conf is out of date, so see if we can resolve that
current_lconf = int(d.getVar('LCONF_VERSION', True))
- if not current_lconf:
- sys.exit()
lconf_version = int(d.getVar('LAYER_CONF_VERSION', True))
+
+ failmsg = """Your version of bblayers.conf has the wrong LCONF_VERSION (has ${LCONF_VERSION}, expecting ${LAYER_CONF_VERSION}).
+Please compare your file against bblayers.conf.sample and merge any changes before continuing.
+"${SANITY_DIFF_TOOL} conf/bblayers.conf ${SANITY_BBLAYERCONF_SAMPLE}"
+
+is a good way to visualise the changes."""
+ failmsg = d.expand(failmsg)
+
+ if not current_lconf:
+ raise NotImplementedError(failmsg)
+
lines = []
if current_lconf < 4:
- sys.exit()
+ raise NotImplementedError(failmsg)
bblayers_fn = bblayers_conf_file(d)
lines = sanity_conf_read(bblayers_fn)
@@ -58,25 +115,61 @@ python oecore_update_bblayers() {
lines[index] = (bbpath_line[:start + 1] +
topdir_var + ':' + bbpath_line[start + 1:])
else:
- sys.exit()
+ raise NotImplementedError(failmsg)
else:
index, bbfiles_line = sanity_conf_find_line('BBFILES', lines)
if bbfiles_line:
lines.insert(index, 'BBPATH = "' + topdir_var + '"\n')
else:
- sys.exit()
+ raise NotImplementedError(failmsg)
current_lconf += 1
sanity_conf_update(bblayers_fn, lines, 'LCONF_VERSION', current_lconf)
+ bb.note("Your conf/bblayers.conf has been automatically updated.")
return
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)
+ bb.note("Your conf/bblayers.conf has been automatically updated.")
+ return
+
+ if not status.reparse:
+ status.addresult()
+
+ 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.
+ layers = d.getVar('BBLAYERS', True).split()
+ layers = [ os.path.basename(path) for path in layers ]
+ if 'meta-yocto' in layers:
+ 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:
+ 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))
+ bb.note("Your conf/bblayers.conf has been automatically updated.")
+ return
+ current_lconf += 1
+ sanity_conf_update(bblayers_fn, lines, 'LCONF_VERSION', current_lconf)
+ bb.note("Your conf/bblayers.conf has been automatically updated.")
return
- sys.exit()
+ raise NotImplementedError(failmsg)
}
def raise_sanity_error(msg, d, network_error=False):
@@ -241,7 +334,7 @@ def check_create_long_filename(filepath, pathname):
def check_path_length(filepath, pathname, limit):
if len(filepath) > limit:
- return "The length of %s is longer than 410, this would cause unexpected errors, please use a shorter path.\n" % pathname
+ return "The length of %s is longer than %s, this would cause unexpected errors, please use a shorter path.\n" % (pathname, limit)
return ""
def get_filesystem_id(path):
@@ -329,6 +422,7 @@ def check_sanity_validmachine(sanity_data):
# Check that we don't have duplicate entries in PACKAGE_ARCHS & that TUNE_PKGARCH is in PACKAGE_ARCHS
pkgarchs = sanity_data.getVar('PACKAGE_ARCHS', True)
tunepkg = sanity_data.getVar('TUNE_PKGARCH', True)
+ defaulttune = sanity_data.getVar('DEFAULTTUNE', True)
tunefound = False
seen = {}
dups = []
@@ -345,7 +439,7 @@ def check_sanity_validmachine(sanity_data):
messages = messages + "Error, the PACKAGE_ARCHS variable contains duplicates. The following archs are listed more than once: %s" % " ".join(dups)
if tunefound == False:
- messages = messages + "Error, the PACKAGE_ARCHS variable does not contain TUNE_PKGARCH (%s)." % tunepkg
+ messages = messages + "Error, the PACKAGE_ARCHS variable (%s) for DEFAULTTUNE (%s) does not contain TUNE_PKGARCH (%s)." % (pkgarchs, defaulttune, tunepkg)
return messages
@@ -437,60 +531,46 @@ def check_tar_version(sanity_data):
return None
# We use git parameters and functionality only found in 1.7.8 or later
+# 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
def check_git_version(sanity_data):
from distutils.version import LooseVersion
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]
- if LooseVersion(version) < LooseVersion("1.7.8"):
- return "Your version of git is older than 1.7.8 and has bugs which will break builds. Please install a newer version of git.\n"
+ 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"
return None
# 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" )
+ errresult = ''
for m in modules:
- status, result = oe.utils.getstatusoutput("perl -e 'use %s' 2> /dev/null" % m)
+ status, result = oe.utils.getstatusoutput("perl -e 'use %s'" % m)
if status != 0:
+ errresult += result
ret += "%s " % m
if ret:
- return "Required perl module(s) not found: %s\n" % ret
+ return "Required perl module(s) not found: %s\n\n%s\n" % (ret, errresult)
return None
def sanity_check_conffiles(status, d):
- # Check we are using a valid local.conf
- current_conf = d.getVar('CONF_VERSION', True)
- conf_version = d.getVar('LOCALCONF_VERSION', True)
-
- if current_conf != conf_version:
- status.addresult("Your version of local.conf was generated from an older/newer 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")
-
- # Check bblayers.conf is valid
- current_lconf = d.getVar('LCONF_VERSION', True)
- lconf_version = d.getVar('LAYER_CONF_VERSION', True)
- if current_lconf != lconf_version:
- funcs = d.getVar('BBLAYERS_CONF_UPDATE_FUNCS', True).split()
- for func in funcs:
+ funcs = d.getVar('BBLAYERS_CONF_UPDATE_FUNCS', True).split()
+ for func in funcs:
+ conffile, current_version, required_version, func = func.split(":")
+ if check_conf_exists(conffile, d) and d.getVar(current_version, True) is not None and \
+ d.getVar(current_version, True) != d.getVar(required_version, True):
success = True
try:
- bb.build.exec_func(func, d)
- except Exception:
+ bb.build.exec_func(func, d, pythonexception=True)
+ except NotImplementedError as e:
success = False
+ status.addresult(str(e))
if success:
- bb.note("Your conf/bblayers.conf has been automatically updated.")
status.reparse = True
- if not status.reparse:
- status.addresult("Your version of bblayers.conf has the wrong LCONF_VERSION (has %s, expecting %s).\nPlease compare the your file against bblayers.conf.sample and merge any changes before continuing.\n\"meld conf/bblayers.conf ${COREBASE}/meta*/conf/bblayers.conf.sample\" is a good way to visualise the changes.\n" % (current_lconf, lconf_version))
-
- # If we have a site.conf, check it's valid
- if check_conf_exists("conf/site.conf", d):
- current_sconf = d.getVar('SCONF_VERSION', True)
- sconf_version = d.getVar('SITE_CONF_VERSION', True)
- if current_sconf != sconf_version:
- status.addresult("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")
-
def sanity_handle_abichanges(status, d):
#
@@ -571,9 +651,9 @@ def check_sanity_sstate_dir_change(sstate_dir, data):
return testmsg
def check_sanity_version_change(status, d):
- # Sanity checks to be done when SANITY_VERSION changes
+ # Sanity checks to be done when SANITY_VERSION or NATIVELSBSTRING changes
# In other words, these tests run once in a given build directory and then
- # never again until the sanity version changes.
+ # never again until the sanity version or host distrubution id/version changes.
# Check the python install is complete. glib-2.0-natives requries
# xml.parsers.expat
@@ -749,14 +829,6 @@ def check_sanity_everybuild(status, d):
check_supported_distro(d)
- # Check if DISPLAY is set if TEST_IMAGE is set
- if d.getVar('TEST_IMAGE', True) == '1' or d.getVar('DEFAULT_TEST_SUITES', True):
- testtarget = d.getVar('TEST_TARGET', True)
- if testtarget == 'qemu' or testtarget == 'QemuTarget':
- display = d.getVar("BB_ORIGENV", False).getVar("DISPLAY", True)
- if not display:
- status.addresult('testimage needs an X desktop to start qemu, please set DISPLAY correctly (e.g. DISPLAY=:1.0)\n')
-
omask = os.umask(022)
if omask & 0755:
status.addresult("Please use a umask which allows a+rx and u+rwx\n")
@@ -788,7 +860,7 @@ def check_sanity_everybuild(status, d):
mirror_vars = ['MIRRORS', 'PREMIRRORS', 'SSTATE_MIRRORS']
protocols = ['http', 'ftp', 'file', 'https', \
'git', 'gitsm', 'hg', 'osc', 'p4', 'svn', \
- 'bzr', 'cvs']
+ 'bzr', 'cvs', 'npm', 'sftp', 'ssh']
for mirror_var in mirror_vars:
mirrors = (d.getVar(mirror_var, True) or '').replace('\\n', '\n').split('\n')
for mirror_entry in mirrors:
@@ -848,18 +920,6 @@ def check_sanity_everybuild(status, d):
with open(checkfile, "w") as f:
f.write(tmpdir)
- # Check vmdk and live can't be built together.
- if 'vmdk' in d.getVar('IMAGE_FSTYPES', True) and 'live' in d.getVar('IMAGE_FSTYPES', True):
- status.addresult("Error, IMAGE_FSTYPES vmdk and live can't be built together\n")
-
- # Check vdi and live can't be built together.
- if 'vdi' in d.getVar('IMAGE_FSTYPES', True) and 'live' in d.getVar('IMAGE_FSTYPES', True):
- status.addresult("Error, IMAGE_FSTYPES vdi and live can't be built together\n")
-
- # Check qcow2 and live can't be built together.
- if 'qcow2' in d.getVar('IMAGE_FSTYPES', True) and 'live' in d.getVar('IMAGE_FSTYPES', True):
- status.addresult("Error, IMAGE_FSTYPES qcow2 and live can't be built together\n")
-
# Check /bin/sh links to dash or bash
real_sh = os.path.realpath('/bin/sh')
if not real_sh.endswith('/dash') and not real_sh.endswith('/bash'):
@@ -887,6 +947,7 @@ def check_sanity(sanity_data):
last_sanity_version = 0
last_tmpdir = ""
last_sstate_dir = ""
+ last_nativelsbstr = ""
sanityverfile = sanity_data.expand("${TOPDIR}/conf/sanity_info")
if os.path.exists(sanityverfile):
with open(sanityverfile, 'r') as f:
@@ -897,12 +958,17 @@ def check_sanity(sanity_data):
last_tmpdir = line.split()[1]
if line.startswith('SSTATE_DIR'):
last_sstate_dir = line.split()[1]
+ if line.startswith('NATIVELSBSTRING'):
+ last_nativelsbstr = line.split()[1]
check_sanity_everybuild(status, sanity_data)
sanity_version = int(sanity_data.getVar('SANITY_VERSION', True) or 1)
network_error = False
- if last_sanity_version < sanity_version:
+ # 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:
check_sanity_version_change(status, sanity_data)
status.addresult(check_sanity_sstate_dir_change(sstate_dir, sanity_data))
else:
@@ -914,6 +980,7 @@ def check_sanity(sanity_data):
f.write("SANITY_VERSION %s\n" % sanity_version)
f.write("TMPDIR %s\n" % tmpdir)
f.write("SSTATE_DIR %s\n" % sstate_dir)
+ f.write("NATIVELSBSTRING %s\n" % nativelsbstr)
sanity_handle_abichanges(status, sanity_data)