Bug 9318 - sanity_conf_update() will erroneously find a var name match in comments
Summary: sanity_conf_update() will erroneously find a var name match in comments
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: Scripts and Tools (show other bugs)
Version: 2.1
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 2.1 M4
Assignee: Bill Randle
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2016-03-21 20:04 UTC by Bill Randle
Modified: 2016-04-01 17:14 UTC (History)
1 user (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bill Randle 2016-03-21 20:04:52 UTC
In sanity_conf_update(), in file meta/classes/sanity.bbclass, a call is made to sanity_conf_find_line(version_var_name, lines) with the intent to find a line like 'CONF_VERSION = "1"' and update the version number. However, the search is not anchored to the beginning of a line, so the search will find the var name in a comment and replace the comment with the new string. E.g., in the poky bblayers.conf file, the first three lines look like:

# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "1"

If sanity_conf_update() is called to change the version to "2", the result will be:

POKY_BBLAYERS_CONF_VERSION = "2"
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "1"

which is certainly not the expected result.

A simple fix is to anchor the search to the beginning of a line:

--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -20,7 +20,7 @@ def sanity_conf_find_line(pattern, lines): 
         if re.search(pattern, line)), (None, None))
 
 def sanity_conf_update(fn, lines, version_var_name, new_version):
-    index, line = sanity_conf_find_line(version_var_name, lines)
+    index, line = sanity_conf_find_line(r"^%s" % version_var_name, lines)
     lines[index] = '%s = "%d"\n' % (version_var_name, new_version)
     with open(fn, "w") as f:
         f.write(''.join(lines))
Comment 1 Bill Randle 2016-03-21 20:26:13 UTC
Submitted patch as outlined in the bug description to the oe-core mailing list. Also included some other minor cleanups in the same patch.