Skip to contentSkip to conversation

sanity.bbclass: expand error messages for version checks

PATCH New Patrick Ohly 1 participant 3 messages Mar 17, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 sanity.bbclass: expand error messages for version checks

The ${WORKDIR} variable was not getting expanded (anymore?), leading to less helpful error messages like:

Exception: NotImplementedError: Your version of bblayers.conf has the wrong LCONF_VERSION (has 7, expecting 8). Please compare your file against bblayers.conf.sample and merge any changes before continuing. "meld conf/bblayers.conf ${COREBASE}/meta*/conf/bblayers.conf.sample"

is a good way to visualise the changes.

ERROR: Execution of event handler 'check_sanity_eventhandler' failed

After adding expansion, embedding ${LCONF_VERSION} and ${LAYER_CONF_VERSION} in the error message seems a bit more readable and consistent.

---
 meta/classes/sanity.bbclass | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
meta/classes/sanity.bbclass +5 -2
index 4873e64..334e362 100644
@@ -48,6 +48,7 @@ Matching the version numbers will remove this message.
 \"meld conf/local.conf ${COREBASE}/meta*/conf/local.conf.sample\" 
 
 is a good way to visualise the changes."
+    failmsg = d.expand(failmsg)
 
     raise NotImplementedError(failmsg)
 }
@@ -66,6 +67,7 @@ Matching the version numbers will remove this message.
 \"meld conf/site.conf ${COREBASE}/meta*/conf/site.conf.sample\" 
 
 is a good way to visualise the changes."
+    failmsg = d.expand(failmsg)
 
     raise NotImplementedError(failmsg)
 }
@@ -76,11 +78,12 @@ python oecore_update_bblayers() {
     current_lconf = int(d.getVar('LCONF_VERSION', True))
     lconf_version = int(d.getVar('LAYER_CONF_VERSION', True))
 
-    failmsg = """Your version of bblayers.conf has the wrong LCONF_VERSION (has %s, expecting %s).
+    failmsg = """Your version of bblayers.conf has the wrong LCONF_VERSION (has ${LCONF_VERSION}, expecting ${LAYER_CONF_VERSION}).
 Please compare your file against bblayers.conf.sample and merge any changes before continuing.
 "meld conf/bblayers.conf ${COREBASE}/meta*/conf/bblayers.conf.sample" 
 
-is a good way to visualise the changes.""" % (current_lconf, lconf_version)
+is a good way to visualise the changes."""
+    failmsg = d.expand(failmsg)
 
     if not current_lconf:
         raise NotImplementedError(failmsg)
Signature · 1 line
2.1.4
#1 lore raw

PATCH 2/3 sanity.bbclass: fix success message when config file was updated

The code now iterates over different config files, but always printed a message about conf/bblayers.conf for each file.

---
 meta/classes/sanity.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/sanity.bbclass +1 -1
index 334e362..2539bd8 100644
@@ -559,7 +559,7 @@ def sanity_check_conffiles(status, d):
                 success = False
                 status.addresult(e.msg)
             if success:
-                bb.note("Your conf/bblayers.conf has been automatically updated.")
+                bb.note("Your %s file has been automatically updated." % conffile)
                 status.reparse = True
 
 def sanity_handle_abichanges(status, d):
Signature · 1 line
2.1.4
#2 lore raw

PATCH 3/3 sanity.bbclass: allow customizing config file update error messages

In reply to Patrick Ohly

The default file pattern may be amiguous and "meld" might not always be the preferred tool, so allow distros to override those parts of the error messages.

---
 meta/classes/sanity.bbclass | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
meta/classes/sanity.bbclass +8 -3
index 2539bd8..e72a007 100644
@@ -34,6 +34,9 @@ BBLAYERS_CONF_UPDATE_FUNCS += " \
     conf/site.conf:SCONF_VERSION:SITE_CONF_VERSION:oecore_update_siteconf \
 "
 
+SANITY_DIFF_TOOL ?= "meld"
+
+SANITY_LOCALCONF_SAMPLE ?= "${COREBASE}/meta*/conf/local.conf.sample"
 python oecore_update_localconf() {
     # Check we are using a valid local.conf
     current_conf  = d.getVar('CONF_VERSION', True)
@@ -45,7 +48,7 @@ files and merge any changes before continuing.
 
 Matching the version numbers will remove this message.
 
-\"meld conf/local.conf ${COREBASE}/meta*/conf/local.conf.sample\" 
+\"${SANITY_DIFF_TOOL} conf/local.conf ${SANITY_LOCALCONF_SAMPLE}\" 
 
 is a good way to visualise the changes."
     failmsg = d.expand(failmsg)
@@ -53,6 +56,7 @@ is a good way to visualise the changes."
     raise NotImplementedError(failmsg)
 }
 
+SANITY_SITECONF_SAMPLE ?= "${COREBASE}/meta*/conf/site.conf.sample"
 python oecore_update_siteconf() {
     # If we have a site.conf, check it's valid
     current_sconf = d.getVar('SCONF_VERSION', True)
@@ -64,7 +68,7 @@ files and merge any changes before continuing.
 
 Matching the version numbers will remove this message.
 
-\"meld conf/site.conf ${COREBASE}/meta*/conf/site.conf.sample\" 
+\"${SANITY_DIFF_TOOL} conf/site.conf ${SANITY_SITECONF_SAMPLE}\" 
 
 is a good way to visualise the changes."
     failmsg = d.expand(failmsg)
@@ -72,6 +76,7 @@ is a good way to visualise the changes."
     raise NotImplementedError(failmsg)
 }
 
+SANITY_BBLAYERCONF_SAMPLE ?= "${COREBASE}/meta*/conf/bblayers.conf.sample"
 python oecore_update_bblayers() {
     # bblayers.conf is out of date, so see if we can resolve that
 
@@ -80,7 +85,7 @@ python oecore_update_bblayers() {
 
     failmsg = """Your version of bblayers.conf has the wrong LCONF_VERSION (has ${LCONF_VERSION}, expecting ${LAYER_CONF_VERSION}).
 Please compare your file against bblayers.conf.sample and merge any changes before continuing.
-"meld conf/bblayers.conf ${COREBASE}/meta*/conf/bblayers.conf.sample" 
+"${SANITY_DIFF_TOOL} conf/bblayers.conf ${SANITY_BBLAYERCONF_SAMPLE}" 
 
 is a good way to visualise the changes."""
     failmsg = d.expand(failmsg)
Signature · 1 line
2.1.4