summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/sanity.bbclass77
1 files changed, 52 insertions, 25 deletions
diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index ecc0a434a5..ac2314fdcf 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -4,8 +4,34 @@
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() { 7def bblayers_conf_file(d):
8 bblayers_fn = os.path.join(d.getVar('TOPDIR', True), 'conf/bblayers.conf') 8 return os.path.join(d.getVar('TOPDIR', True), 'conf/bblayers.conf')
9
10def sanity_conf_read(fn):
11 with open(fn, 'r') as f:
12 lines = f.readlines()
13 return lines
14
15def sanity_conf_find_line(pattern, lines):
16 import re
17 return next(((index, line)
18 for index, line in enumerate(lines)
19 if re.search(pattern, line)), (None, None))
20
21def sanity_conf_update(fn, lines, version_var_name, new_version):
22 index, line = sanity_conf_find_line(version_var_name, lines)
23 lines[index] = '%s = "%d"\n' % (version_var_name, new_version)
24 with open(fn, "w") as f:
25 f.write(''.join(lines))
26
27EXPORT_FUNCTIONS bblayers_conf_file sanity_conf_read sanity_conf_find_line sanity_conf_update
28
29# Functions added to this variable MUST throw an exception (or sys.exit()) unless they
30# successfully changed LCONF_VERSION in bblayers.conf
31BBLAYERS_CONF_UPDATE_FUNCS += "oecore_update_bblayers"
32
33python oecore_update_bblayers() {
34 # bblayers.conf is out of date, so see if we can resolve that
9 35
10 current_lconf = int(d.getVar('LCONF_VERSION', True)) 36 current_lconf = int(d.getVar('LCONF_VERSION', True))
11 if not current_lconf: 37 if not current_lconf:
@@ -13,21 +39,15 @@ python check_bblayers_conf() {
13 lconf_version = int(d.getVar('LAYER_CONF_VERSION', True)) 39 lconf_version = int(d.getVar('LAYER_CONF_VERSION', True))
14 lines = [] 40 lines = []
15 41
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: 42 if current_lconf < 4:
23 sys.exit() 43 sys.exit()
24 44
25 with open(bblayers_fn, 'r') as f: 45 bblayers_fn = bblayers_conf_file(d)
26 lines = f.readlines() 46 lines = sanity_conf_read(bblayers_fn)
27 47
28 if current_lconf == 4: 48 if current_lconf == 4 and lconf_version > 4:
29 topdir_var = '$' + '{TOPDIR}' 49 topdir_var = '$' + '{TOPDIR}'
30 index, bbpath_line = find_line('BBPATH', lines) 50 index, bbpath_line = sanity_conf_find_line('BBPATH', lines)
31 if bbpath_line: 51 if bbpath_line:
32 start = bbpath_line.find('"') 52 start = bbpath_line.find('"')
33 if start != -1 and (len(bbpath_line) != (start + 1)): 53 if start != -1 and (len(bbpath_line) != (start + 1)):
@@ -41,17 +61,17 @@ python check_bblayers_conf() {
41 else: 61 else:
42 sys.exit() 62 sys.exit()
43 else: 63 else:
44 index, bbfiles_line = find_line('BBFILES', lines) 64 index, bbfiles_line = sanity_conf_find_line('BBFILES', lines)
45 if bbfiles_line: 65 if bbfiles_line:
46 lines.insert(index, 'BBPATH = "' + topdir_var + '"\n') 66 lines.insert(index, 'BBPATH = "' + topdir_var + '"\n')
47 else: 67 else:
48 sys.exit() 68 sys.exit()
49 69
50 index, line = find_line('LCONF_VERSION', lines)
51 current_lconf += 1 70 current_lconf += 1
52 lines[index] = 'LCONF_VERSION = "%d"\n' % current_lconf 71 sanity_conf_update(bblayers_fn, lines, 'LCONF_VERSION', current_lconf)
53 with open(bblayers_fn, "w") as f: 72 return
54 f.write(''.join(lines)) 73
74 sys.exit()
55} 75}
56 76
57def raise_sanity_error(msg, d, network_error=False): 77def raise_sanity_error(msg, d, network_error=False):
@@ -387,18 +407,25 @@ def check_sanity(sanity_data):
387 conf_version = sanity_data.getVar('LOCALCONF_VERSION', True) 407 conf_version = sanity_data.getVar('LOCALCONF_VERSION', True)
388 408
389 if current_conf != conf_version: 409 if current_conf != conf_version:
390 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" 410 messages = messages + "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"
391 411
392 # Check bblayers.conf is valid 412 # Check bblayers.conf is valid
393 current_lconf = sanity_data.getVar('LCONF_VERSION', True) 413 current_lconf = sanity_data.getVar('LCONF_VERSION', True)
394 lconf_version = sanity_data.getVar('LAYER_CONF_VERSION', True) 414 lconf_version = sanity_data.getVar('LAYER_CONF_VERSION', True)
395 if current_lconf != lconf_version: 415 if current_lconf != lconf_version:
396 try: 416 funcs = sanity_data.getVar('BBLAYERS_CONF_UPDATE_FUNCS', True).split()
397 bb.build.exec_func("check_bblayers_conf", sanity_data) 417 for func in funcs:
398 bb.note("Your conf/bblayers.conf has been automatically updated.") 418 success = True
399 reparse = True 419 try:
400 except Exception: 420 bb.build.exec_func(func, sanity_data)
401 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" 421 except Exception:
422 success = False
423 if success:
424 bb.note("Your conf/bblayers.conf has been automatically updated.")
425 reparse = True
426 break
427 if not reparse:
428 messages = messages + "Your version of bblayers.conf was generated from an older/newer 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"
402 429
403 # If we have a site.conf, check it's valid 430 # If we have a site.conf, check it's valid
404 if check_conf_exists("conf/site.conf", sanity_data): 431 if check_conf_exists("conf/site.conf", sanity_data):
@@ -454,7 +481,7 @@ def check_sanity(sanity_data):
454 messages = messages + "Parsed PATH is " + str(paths) + "\n" 481 messages = messages + "Parsed PATH is " + str(paths) + "\n"
455 482
456 bbpaths = sanity_data.getVar('BBPATH', True).split(":") 483 bbpaths = sanity_data.getVar('BBPATH', True).split(":")
457 if "." in bbpaths or "" in bbpaths: 484 if ("." in bbpaths or "" in bbpaths) and not reparse:
458 # TODO: change the following message to fatal when all BBPATH issues 485 # TODO: change the following message to fatal when all BBPATH issues
459 # are fixed 486 # are fixed
460 bb.warn("BBPATH references the current directory, either through " \ 487 bb.warn("BBPATH references the current directory, either through " \