diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-16 21:51:12 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-28 11:31:17 +0000 |
commit | c1c6a9d64e5f54386a811aa01fa1f7d99c2b08f7 (patch) | |
tree | 77b2da5b0a9eb55bf57f6343d2ac321d8e89d8c1 | |
parent | 25871016e01c54ab4e1d8c00f9242437f736c843 (diff) | |
download | poky-c1c6a9d64e5f54386a811aa01fa1f7d99c2b08f7.tar.gz |
sanity: Improve configuration upgrade capabilities (support meta-yocto -> poky transition)
Right now, only one configuration file can be processed (conf/bblayers.conf)
and it can only have one version number. This is a cause of immense friction
between OE-Core and Poky since if one needs a version change, it shouldn't
be forced on the other.
We'd like to rename the meta-yocto layer (within the meta-yocto repository)
to meta-poky. To do this, we need to correct the bblayers.conf file and that
means changing the sanity version. After the pain this caused the last time,
Paul made me promise never to have them out of sync between OE-Core and Poky,
equally, having every distro changing config update OE-Core isn't scalable
either.
This patch changes the sanity upgrade method to list a more generic format:
<config file>:<current version variable name>:<required version variable name>:<upgrade function>
This in theory allows us to support upgrades to any of the core
configuration files, and allow layers to extend them as needed. Files
with the same name can be handled in different layers by setting a unique
version name variable in the file itself. The upgrade code is only called
if the version variable is set.
To allow us to make the poky name change and use a new configuration file
name, one last version bump is included for poky to handle the transition.
(From OE-Core rev: 10fd24271e771ed12e36edcff0007caa1a4e67e4)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/sanity.bbclass | 124 | ||||
-rw-r--r-- | meta/conf/sanity.conf | 2 |
2 files changed, 92 insertions, 34 deletions
diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass index 466eb49121..31f01ca9ba 100644 --- a/meta/classes/sanity.bbclass +++ b/meta/classes/sanity.bbclass | |||
@@ -25,21 +25,70 @@ def sanity_conf_update(fn, lines, version_var_name, new_version): | |||
25 | with open(fn, "w") as f: | 25 | with open(fn, "w") as f: |
26 | f.write(''.join(lines)) | 26 | f.write(''.join(lines)) |
27 | 27 | ||
28 | # Functions added to this variable MUST throw an exception (or sys.exit()) unless they | 28 | # Functions added to this variable MUST throw a NotImplementedError exception unless |
29 | # successfully changed LCONF_VERSION in bblayers.conf | 29 | # they successfully changed the config version in the config file. Exceptions |
30 | BBLAYERS_CONF_UPDATE_FUNCS += "oecore_update_bblayers" | 30 | # are used since exec_func doesn't handle return values. |
31 | BBLAYERS_CONF_UPDATE_FUNCS += " \ | ||
32 | conf/bblayers.conf:LCONF_VERSION:LAYER_CONF_VERSION:oecore_update_bblayers \ | ||
33 | conf/local.conf:CONF_VERSION:LOCALCONF_VERSION:oecore_update_localconf \ | ||
34 | conf/site.conf:SCONF_VERSION:SITE_CONF_VERSION:oecore_update_siteconf \ | ||
35 | " | ||
36 | |||
37 | python oecore_update_localconf() { | ||
38 | # Check we are using a valid local.conf | ||
39 | current_conf = d.getVar('CONF_VERSION', True) | ||
40 | conf_version = d.getVar('LOCALCONF_VERSION', True) | ||
41 | |||
42 | failmsg = "Your version of local.conf was generated from an older/newer version of | ||
43 | local.conf.sample and there have been updates made to this file. Please compare the two | ||
44 | files and merge any changes before continuing. | ||
45 | |||
46 | Matching the version numbers will remove this message. | ||
47 | |||
48 | \"meld conf/local.conf ${COREBASE}/meta*/conf/local.conf.sample\" | ||
49 | |||
50 | is a good way to visualise the changes." | ||
51 | |||
52 | raise NotImplementedError(failmsg) | ||
53 | } | ||
54 | |||
55 | python oecore_update_siteconf() { | ||
56 | # If we have a site.conf, check it's valid | ||
57 | current_sconf = d.getVar('SCONF_VERSION', True) | ||
58 | sconf_version = d.getVar('SITE_CONF_VERSION', True) | ||
59 | |||
60 | failmsg = "Your version of site.conf was generated from an older version of | ||
61 | site.conf.sample and there have been updates made to this file. Please compare the two | ||
62 | files and merge any changes before continuing. | ||
63 | |||
64 | Matching the version numbers will remove this message. | ||
65 | |||
66 | \"meld conf/site.conf ${COREBASE}/meta*/conf/site.conf.sample\" | ||
67 | |||
68 | is a good way to visualise the changes." | ||
69 | |||
70 | raise NotImplementedError(failmsg) | ||
71 | } | ||
31 | 72 | ||
32 | python oecore_update_bblayers() { | 73 | python oecore_update_bblayers() { |
33 | # bblayers.conf is out of date, so see if we can resolve that | 74 | # bblayers.conf is out of date, so see if we can resolve that |
34 | 75 | ||
35 | current_lconf = int(d.getVar('LCONF_VERSION', True)) | 76 | current_lconf = int(d.getVar('LCONF_VERSION', True)) |
36 | if not current_lconf: | ||
37 | sys.exit() | ||
38 | lconf_version = int(d.getVar('LAYER_CONF_VERSION', True)) | 77 | lconf_version = int(d.getVar('LAYER_CONF_VERSION', True)) |
78 | |||
79 | failmsg = """Your version of bblayers.conf has the wrong LCONF_VERSION (has %s, expecting %s). | ||
80 | Please compare the your file against bblayers.conf.sample and merge any changes before continuing. | ||
81 | "meld conf/bblayers.conf ${COREBASE}/meta*/conf/bblayers.conf.sample" | ||
82 | |||
83 | is a good way to visualise the changes.""" % (current_lconf, lconf_version) | ||
84 | |||
85 | if not current_lconf: | ||
86 | raise NotImplementedError(failmsg) | ||
87 | |||
39 | lines = [] | 88 | lines = [] |
40 | 89 | ||
41 | if current_lconf < 4: | 90 | if current_lconf < 4: |
42 | sys.exit() | 91 | raise NotImplementedError(failmsg) |
43 | 92 | ||
44 | bblayers_fn = bblayers_conf_file(d) | 93 | bblayers_fn = bblayers_conf_file(d) |
45 | lines = sanity_conf_read(bblayers_fn) | 94 | lines = sanity_conf_read(bblayers_fn) |
@@ -58,13 +107,13 @@ python oecore_update_bblayers() { | |||
58 | lines[index] = (bbpath_line[:start + 1] + | 107 | lines[index] = (bbpath_line[:start + 1] + |
59 | topdir_var + ':' + bbpath_line[start + 1:]) | 108 | topdir_var + ':' + bbpath_line[start + 1:]) |
60 | else: | 109 | else: |
61 | sys.exit() | 110 | raise NotImplementedError(failmsg) |
62 | else: | 111 | else: |
63 | index, bbfiles_line = sanity_conf_find_line('BBFILES', lines) | 112 | index, bbfiles_line = sanity_conf_find_line('BBFILES', lines) |
64 | if bbfiles_line: | 113 | if bbfiles_line: |
65 | lines.insert(index, 'BBPATH = "' + topdir_var + '"\n') | 114 | lines.insert(index, 'BBPATH = "' + topdir_var + '"\n') |
66 | else: | 115 | else: |
67 | sys.exit() | 116 | raise NotImplementedError(failmsg) |
68 | 117 | ||
69 | current_lconf += 1 | 118 | current_lconf += 1 |
70 | sanity_conf_update(bblayers_fn, lines, 'LCONF_VERSION', current_lconf) | 119 | sanity_conf_update(bblayers_fn, lines, 'LCONF_VERSION', current_lconf) |
@@ -76,7 +125,33 @@ python oecore_update_bblayers() { | |||
76 | sanity_conf_update(bblayers_fn, lines, 'LCONF_VERSION', current_lconf) | 125 | sanity_conf_update(bblayers_fn, lines, 'LCONF_VERSION', current_lconf) |
77 | return | 126 | return |
78 | 127 | ||
79 | sys.exit() | 128 | if not status.reparse: |
129 | status.addresult() | ||
130 | |||
131 | elif current_lconf == 6 and lconf_version > 6: | ||
132 | # Handle rename of meta-yocto -> meta-poky | ||
133 | # This marks the start of separate version numbers but code is needed in OE-Core | ||
134 | # for the migration, one last time. | ||
135 | layers = d.getVar('BBLAYERS', True) | ||
136 | if 'meta-yocto' in layers: | ||
137 | index, meta_yocto_line = sanity_conf_find_line('.*meta-yocto.*\n', lines) | ||
138 | if meta_yocto_line: | ||
139 | lines[index] = meta_yocto_line.replace('meta-yocto', 'meta-poky') | ||
140 | else: | ||
141 | raise NotImplementedError(failmsg) | ||
142 | index, meta_yocto_line = sanity_conf_find_line('LCONF_VERSION.*\n', lines) | ||
143 | if meta_yocto_line: | ||
144 | lines[index] = 'POKY_BBLAYERS_CONF_VERSION = "1"\n' | ||
145 | else: | ||
146 | raise NotImplementedError(failmsg) | ||
147 | with open(bblayers_fn, "w") as f: | ||
148 | f.write(''.join(lines)) | ||
149 | return | ||
150 | |||
151 | sanity_conf_update(bblayers_fn, lines, 'LCONF_VERSION', "7") | ||
152 | return | ||
153 | |||
154 | raise NotImplementedError(failmsg) | ||
80 | } | 155 | } |
81 | 156 | ||
82 | def raise_sanity_error(msg, d, network_error=False): | 157 | def raise_sanity_error(msg, d, network_error=False): |
@@ -463,37 +538,20 @@ def check_perl_modules(sanity_data): | |||
463 | return None | 538 | return None |
464 | 539 | ||
465 | def sanity_check_conffiles(status, d): | 540 | def sanity_check_conffiles(status, d): |
466 | # Check we are using a valid local.conf | 541 | funcs = d.getVar('BBLAYERS_CONF_UPDATE_FUNCS', True).split() |
467 | current_conf = d.getVar('CONF_VERSION', True) | 542 | for func in funcs: |
468 | conf_version = d.getVar('LOCALCONF_VERSION', True) | 543 | conffile, current_version, required_version, func = func.split(":") |
469 | 544 | if check_conf_exists(conffile, d) and d.getVar(current_version, True) is not None and \ | |
470 | if current_conf != conf_version: | 545 | d.getVar(current_version, True) != d.getVar(required_version, True): |
471 | 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") | ||
472 | |||
473 | # Check bblayers.conf is valid | ||
474 | current_lconf = d.getVar('LCONF_VERSION', True) | ||
475 | lconf_version = d.getVar('LAYER_CONF_VERSION', True) | ||
476 | if current_lconf != lconf_version: | ||
477 | funcs = d.getVar('BBLAYERS_CONF_UPDATE_FUNCS', True).split() | ||
478 | for func in funcs: | ||
479 | success = True | 546 | success = True |
480 | try: | 547 | try: |
481 | bb.build.exec_func(func, d) | 548 | bb.build.exec_func(func, d) |
482 | except Exception: | 549 | except NotImplementedError as e: |
483 | success = False | 550 | success = False |
551 | status.addresult(e.msg) | ||
484 | if success: | 552 | if success: |
485 | bb.note("Your conf/bblayers.conf has been automatically updated.") | 553 | bb.note("Your conf/bblayers.conf has been automatically updated.") |
486 | status.reparse = True | 554 | status.reparse = True |
487 | if not status.reparse: | ||
488 | 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)) | ||
489 | |||
490 | # If we have a site.conf, check it's valid | ||
491 | if check_conf_exists("conf/site.conf", d): | ||
492 | current_sconf = d.getVar('SCONF_VERSION', True) | ||
493 | sconf_version = d.getVar('SITE_CONF_VERSION', True) | ||
494 | if current_sconf != sconf_version: | ||
495 | 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") | ||
496 | |||
497 | 555 | ||
498 | def sanity_handle_abichanges(status, d): | 556 | def sanity_handle_abichanges(status, d): |
499 | # | 557 | # |
diff --git a/meta/conf/sanity.conf b/meta/conf/sanity.conf index 0f852d140c..0d20c9908e 100644 --- a/meta/conf/sanity.conf +++ b/meta/conf/sanity.conf | |||
@@ -9,7 +9,7 @@ SANITY_ABIFILE = "${TMPDIR}/abi_version" | |||
9 | 9 | ||
10 | SANITY_VERSION ?= "1" | 10 | SANITY_VERSION ?= "1" |
11 | LOCALCONF_VERSION ?= "1" | 11 | LOCALCONF_VERSION ?= "1" |
12 | LAYER_CONF_VERSION ?= "6" | 12 | LAYER_CONF_VERSION ?= "7" |
13 | SITE_CONF_VERSION ?= "1" | 13 | SITE_CONF_VERSION ?= "1" |
14 | 14 | ||
15 | INHERIT += "sanity" | 15 | INHERIT += "sanity" |