summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorConstantin Musca <constantinx.musca@intel.com>2012-09-27 15:39:55 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-09-28 11:07:40 +0100
commit6d3d4baeebc850492d523419683348cffa2d63b0 (patch)
tree3fae397509fd1bf631f71d17a76cc5bbbe497ca8 /meta/classes
parentf786991c3ab3e60aa534b28c93e6860fa9362556 (diff)
downloadpoky-6d3d4baeebc850492d523419683348cffa2d63b0.tar.gz
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] (From OE-Core rev: 03ad4edace5db9c6e15ca776d06d20b7d4e42afc) Signed-off-by: Constantin Musca <constantinx.musca@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-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 @@
4 4
5SANITY_REQUIRED_UTILITIES ?= "patch diffstat makeinfo git bzip2 tar gzip gawk chrpath wget cpio" 5SANITY_REQUIRED_UTILITIES ?= "patch diffstat makeinfo git bzip2 tar gzip gawk chrpath wget cpio"
6 6
7python check_bblayers_conf() {
8 bblayers_fn = os.path.join(d.getVar('TOPDIR', True), 'conf/bblayers.conf')
9
10 current_lconf = int(d.getVar('LCONF_VERSION', True))
11 if not current_lconf:
12 sys.exit()
13 lconf_version = int(d.getVar('LAYER_CONF_VERSION', True))
14 lines = []
15
16 import re
17 def find_line(pattern, lines):
18 return next(((index, line)
19 for index, line in enumerate(lines)
20 if re.search(pattern, line)), (None, None))
21
22 if current_lconf < 4:
23 sys.exit()
24
25 with open(bblayers_fn, 'r') as f:
26 lines = f.readlines()
27
28 if current_lconf == 4:
29 topdir_var = '$' + '{TOPDIR}'
30 index, bbpath_line = find_line('BBPATH', lines)
31 if bbpath_line:
32 start = bbpath_line.find('"')
33 if start != -1 and (len(bbpath_line) != (start + 1)):
34 if bbpath_line[start + 1] == '"':
35 lines[index] = (bbpath_line[:start + 1] +
36 topdir_var + bbpath_line[start + 1:])
37 else:
38 if not topdir_var in bbpath_line:
39 lines[index] = (bbpath_line[:start + 1] +
40 topdir_var + ':' + bbpath_line[start + 1:])
41 else:
42 sys.exit()
43 else:
44 index, bbfiles_line = find_line('BBFILES', lines)
45 if bbfiles_line:
46 lines.insert(index, 'BBPATH = "' + topdir_var + '"\n')
47 else:
48 sys.exit()
49
50 index, line = find_line('LCONF_VERSION', lines)
51 current_lconf += 1
52 lines[index] = 'LCONF_VERSION = "%d"\n' % current_lconf
53 with open(bblayers_fn, "w") as f:
54 f.write(''.join(lines))
55}
56
7def raise_sanity_error(msg, d): 57def raise_sanity_error(msg, d):
8 if d.getVar("SANITY_USE_EVENTS", True) == "1": 58 if d.getVar("SANITY_USE_EVENTS", True) == "1":
9 bb.event.fire(bb.event.SanityCheckFailed(msg), d) 59 bb.event.fire(bb.event.SanityCheckFailed(msg), d)
@@ -337,7 +387,16 @@ def check_sanity(sanity_data):
337 current_lconf = sanity_data.getVar('LCONF_VERSION', True) 387 current_lconf = sanity_data.getVar('LCONF_VERSION', True)
338 lconf_version = sanity_data.getVar('LAYER_CONF_VERSION', True) 388 lconf_version = sanity_data.getVar('LAYER_CONF_VERSION', True)
339 if current_lconf != lconf_version: 389 if current_lconf != lconf_version:
340 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" 390 try:
391 bb.build.exec_func("check_bblayers_conf", sanity_data)
392 if sanity_data.getVar("SANITY_USE_EVENTS", True) == "1":
393 bb.event.fire(bb.event.SanityCheckFailed("Your conf/bblayers.conf has been automatically updated. Please close and re-run."), sanity_data)
394 return
395 else:
396 bb.note("Your conf/bblayers.conf has been automatically updated. Please re-run %s." % os.path.basename(sys.argv[0]))
397 sys.exit(0)
398 except Exception:
399 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"
341 400
342 # If we have a site.conf, check it's valid 401 # If we have a site.conf, check it's valid
343 if check_conf_exists("conf/site.conf", sanity_data): 402 if check_conf_exists("conf/site.conf", sanity_data):