summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConstantin Musca <constantinx.musca@intel.com>2012-09-27 15:39:55 +0300
committerSaul Wold <sgw@linux.intel.com>2012-09-28 01:14:01 -0700
commit03ad4edace5db9c6e15ca776d06d20b7d4e42afc (patch)
treef3986fa378273324d7d817d276e844372cdca21a
parent1f7f590369eaa76dc970c9cffd1f0db53ce08c00 (diff)
downloadopenembedded-core-03ad4edace5db9c6e15ca776d06d20b7d4e42afc.tar.gz
openembedded-core-03ad4edace5db9c6e15ca776d06d20b7d4e42afc.tar.bz2
openembedded-core-03ad4edace5db9c6e15ca776d06d20b7d4e42afc.zip
sanity.bbclass: bblayers.conf should be updated automatically
- add check_bblayers_conf bitbake function which does the bblayers.conf v4 -> v5 update if necessary (every layer should make its specific bblayers.conf upgrades appending to the check_bblayers_conf function) - we ask the user to re-run bitbake because we can't trigger reparsing without being invasive [YOCTO #3082] Signed-off-by: Constantin Musca <constantinx.musca@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
-rw-r--r--meta/classes/sanity.bbclass61
1 files changed, 60 insertions, 1 deletions
diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index 385d7339d3..9c3ab1ff2e 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -4,6 +4,56 @@
SANITY_REQUIRED_UTILITIES ?= "patch diffstat makeinfo git bzip2 tar gzip gawk chrpath wget cpio"
+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))
+}
+
def raise_sanity_error(msg, d):
if d.getVar("SANITY_USE_EVENTS", True) == "1":
bb.event.fire(bb.event.SanityCheckFailed(msg), d)
@@ -337,7 +387,16 @@ def check_sanity(sanity_data):
current_lconf = sanity_data.getVar('LCONF_VERSION', True)
lconf_version = sanity_data.getVar('LAYER_CONF_VERSION', True)
if current_lconf != lconf_version:
- 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"
+ try:
+ bb.build.exec_func("check_bblayers_conf", sanity_data)
+ if sanity_data.getVar("SANITY_USE_EVENTS", True) == "1":
+ bb.event.fire(bb.event.SanityCheckFailed("Your conf/bblayers.conf has been automatically updated. Please close and re-run."), sanity_data)
+ return
+ else:
+ bb.note("Your conf/bblayers.conf has been automatically updated. Please re-run %s." % os.path.basename(sys.argv[0]))
+ sys.exit(0)
+ 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"
# If we have a site.conf, check it's valid
if check_conf_exists("conf/site.conf", sanity_data):