blob: 81cd2eb6a65df0caa4a77c00357dbdfeeaec3718 [file] [log] [blame]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001# Provide some extensions to sanity.bbclass to handle poky-specific conf file upgrades
2
3python poky_update_bblayersconf() {
4 current_version = int(d.getVar('POKY_BBLAYERS_CONF_VERSION', True) or -1)
5 latest_version = int(d.getVar('REQUIRED_POKY_BBLAYERS_CONF_VERSION', True) or -1)
6 if current_version == -1 or latest_version == -1:
7 # one or the other missing => malformed configuration
8 raise NotImplementedError("You need to update bblayers.conf manually for this version transition")
9
10 success = True
11
12 # check for out of date templateconf.cfg file
13 lines = []
14 fn = os.path.join(d.getVar('TOPDIR', True), 'conf/templateconf.cfg')
15
16 lines = sanity_conf_read(fn)
17 index, meta_yocto_line = sanity_conf_find_line(r'^meta-yocto/', lines)
18 if meta_yocto_line:
19 lines[index] = meta_yocto_line.replace('meta-yocto', 'meta-poky')
20 with open(fn, "w") as f:
21 f.write(''.join(lines))
22 bb.note("Your conf/templateconf.cfg file was updated from meta-yocto to meta-poky")
23
24 # add any additional layer checks/changes here
25
26 if success:
27 current_version = latest_version
28 bblayers_fn = bblayers_conf_file(d)
29 lines = sanity_conf_read(bblayers_fn)
30 # sanity_conf_update() will erroneously find a match when the var name
31 # is used in a comment, so do our own here. The code below can be
32 # removed when sanity_conf_update() is fixed in OE-Core.
33 #sanity_conf_update(bblayers_fn, lines, 'POKY_BBLAYERS_CONF_VERSION', current_version)
34 index, line = sanity_conf_find_line(r'^POKY_BBLAYERS_CONF_VERSION', lines)
35 lines[index] = 'POKY_BBLAYERS_CONF_VERSION = "%d"\n' % current_version
36 with open(bblayers_fn, "w") as f:
37 f.write(''.join(lines))
38 bb.note("Your conf/bblayers.conf has been automatically updated.")
39 if success:
40 return
41
42 raise NotImplementedError("You need to update bblayers.conf manually for this version transition")
43}
44
45# ensure our function runs after the OE-Core one
46BBLAYERS_CONF_UPDATE_FUNCS += "conf/bblayers.conf:POKY_BBLAYERS_CONF_VERSION:REQUIRED_POKY_BBLAYERS_CONF_VERSION:poky_update_bblayersconf"