<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>9318</bug_id>
          
          <creation_ts>2016-03-21 20:04:52 +0000</creation_ts>
          <short_desc>sanity_conf_update() will erroneously find a var name match in comments</short_desc>
          <delta_ts>2016-04-01 17:14:28 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>Scripts and Tools</component>
          <version>2.1</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.1 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Bill Randle">bill.randle</reporter>
          <assigned_to name="Bill Randle">bill.randle</assigned_to>
          <cc>ross.burton</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>60221</commentid>
    <comment_count>0</comment_count>
    <who name="Bill Randle">bill.randle</who>
    <bug_when>2016-03-21 20:04:52 +0000</bug_when>
    <thetext>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 &apos;CONF_VERSION = &quot;1&quot;&apos; 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 = &quot;1&quot;

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

POKY_BBLAYERS_CONF_VERSION = &quot;2&quot;
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = &quot;1&quot;

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&quot;^%s&quot; % version_var_name, lines)
     lines[index] = &apos;%s = &quot;%d&quot;\n&apos; % (version_var_name, new_version)
     with open(fn, &quot;w&quot;) as f:
         f.write(&apos;&apos;.join(lines))</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60222</commentid>
    <comment_count>1</comment_count>
    <who name="Bill Randle">bill.randle</who>
    <bug_when>2016-03-21 20:26:13 +0000</bug_when>
    <thetext>Submitted patch as outlined in the bug description to the oe-core mailing list. Also included some other minor cleanups in the same patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60695</commentid>
    <comment_count>2</comment_count>
    <who name="Bill Randle">bill.randle</who>
    <bug_when>2016-04-01 17:14:28 +0000</bug_when>
    <thetext>Merged to master and verified.

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/meta/classes/sanity.bbclass?id=421289cbcc422d8a45018f69660a1ed3b1018cb3</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>