<?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>11586</bug_id>
          
          <creation_ts>2017-05-27 17:45:23 +0000</creation_ts>
          <short_desc>scripts/yocto-bsp linux-yocto-custom.bb template faulty?</short_desc>
          <delta_ts>2017-07-07 17:24:44 +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>Meta-yocto</product>
          <component>meta-yocto</component>
          <version>2.3</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.4 M2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Robert Berger">pokylinux</reporter>
          <assigned_to name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</assigned_to>
          <cc>bruce.ashfield</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>73540</commentid>
    <comment_count>0</comment_count>
    <who name="Robert Berger">pokylinux</who>
    <bug_when>2017-05-27 17:45:23 +0000</bug_when>
    <thetext>By default if you create a BSP the kernel template looks like this[1]

...
SRC_URI += &quot;file://{{=machine}}.scc \
            file://{{=machine}}.cfg \
            file://{{=machine}}-user-config.cfg \
            file://{{=machine}}-user-patches.scc \
           &quot;
...

The problem IMHO is, that we have double inclusing of e.g. patches, which makes bitbake apply the same patch twize, which does not work.

I suggest something like this:

SRC_URI += &quot;file://{{=machine}}.scc \
             file://{{=machine}}.cfg \
-            file://{{=machine}}-user-config.cfg \
-            file://{{=machine}}-user-patches.scc \
            &quot;
+# {{=machine}}-user-config.cfg and
+# {{=machine}}-user-patches.scc are
+# included by {{=machine}}.scc
+# removed from SRC_URI to avoid double inclusion
+# and like this avoiding applying same patch twice

[1] http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/scripts/lib/bsp/substrate/target/arch/common/recipes-kernel/linux/linux-yocto-custom.bb?h=pyro</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73999</commentid>
    <comment_count>1</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2017-06-12 16:46:36 +0000</bug_when>
    <thetext>Actually a I just sent a patch which may cause trouble for all archs [1]. Adding Bruce, he can provide better directions.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74000</commentid>
    <comment_count>2</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2017-06-12 16:49:17 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; Actually a I just sent a patch which may cause trouble for all archs [1].
&gt; Adding Bruce, he can provide better directions.

Forgot to include the reference:

[1] https://lists.yoctoproject.org/pipermail/poky/2017-June/011020.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74037</commentid>
    <comment_count>3</comment_count>
    <who name="Bruce Ashfield">bruce.ashfield</who>
    <bug_when>2017-06-13 07:19:28 +0000</bug_when>
    <thetext>Let me ask a couple of potentially dumb questions .. and make a couple of obvious statements. Since I&apos;m not 100% clear on the issue.

Whatever is on the SRC_URI will be expanded and processed, whether it is configs or patches.

So if any of the .scc files that we are adding to the bbappend have patches, and then include other .scc files with those same patches, we will have the double application of patches and failure.

If we are creating a new BSP that inherits the configuration of an existing kernel type, then the &quot;include with config only should be used&quot;, otherwise, the .scc files will be expanded, patches found and re-applied.

i.e. &quot;include ktypes/standard/standard.scc nopatch&quot; would be in the bbappend to inherit all of the standard configurations, but not the patches (since all of ktypes standard is already on standard/base, you&apos;ll fail to re-apply the patches).

So I don&apos;t see the recent patch as making things any worse, but we still probably don&apos;t have the optimal set of .scc files in the bbappends. They were initially written when the tools were far more complex and analyzed the entire branch to see if patches were already applied and skipped them if they were .. while that was nice, it was error prone and lead to some surprise failures. We are now &quot;if it is on the SRC_URI, do what it says and add the patches to the patch queue&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74042</commentid>
    <comment_count>4</comment_count>
    <who name="Robert Berger">pokylinux</who>
    <bug_when>2017-06-13 08:26:09 +0000</bug_when>
    <thetext>Just to elaborate a bit more how I came up with the bug:

1) I use the bsp tool and create with it a BSP for a custom (mainline) kernel

2) The bsp tool spits out a kernel recipe based on this template:

...
SRC_URI += &quot;file://{{=machine}}.scc \
            file://{{=machine}}.cfg \
            file://{{=machine}}-user-config.cfg \
            file://{{=machine}}-user-patches.scc \
           &quot;
...

3) I use the yocto-kernel tool to add patches

yocto-kernel patch add &lt;BSP name&gt; &lt;patch&gt;

The yocto-kernel tool adds the patch to {{=machine}}-user-patches.scc.

The problem is, that {{=machine}}-user-config.cfg and {{=machine}}-user-patches.scc are included by {{=machine}}.scc hence we have double inclusion and obviously the second time the patch is being applied it fails.

Apparently doing all this manually without the bsp tool and the yocto-kernel
tool things can be fixed and also one can manually (or with a patch) fix the stuff. 

If you need further info I&apos;m glad to provide it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74066</commentid>
    <comment_count>5</comment_count>
    <who name="Bruce Ashfield">bruce.ashfield</who>
    <bug_when>2017-06-13 12:53:31 +0000</bug_when>
    <thetext>(In reply to comment #4)
&gt; Just to elaborate a bit more how I came up with the bug:
&gt; 
&gt; 1) I use the bsp tool and create with it a BSP for a custom (mainline) kernel
&gt; 
&gt; 2) The bsp tool spits out a kernel recipe based on this template:
&gt; 
&gt; ...
&gt; SRC_URI += &quot;file://{{=machine}}.scc \
&gt;             file://{{=machine}}.cfg \
&gt;             file://{{=machine}}-user-config.cfg \
&gt;             file://{{=machine}}-user-patches.scc \
&gt;            &quot;
&gt; ...
&gt; 
&gt; 3) I use the yocto-kernel tool to add patches
&gt; 
&gt; yocto-kernel patch add &lt;BSP name&gt; &lt;patch&gt;
&gt; 
&gt; The yocto-kernel tool adds the patch to {{=machine}}-user-patches.scc.
&gt; 
&gt; The problem is, that {{=machine}}-user-config.cfg and
&gt; {{=machine}}-user-patches.scc are included by {{=machine}}.scc hence we have
&gt; double inclusion and obviously the second time the patch is being applied it
&gt; fails.
&gt; 
&gt; Apparently doing all this manually without the bsp tool and the yocto-kernel
&gt; tool things can be fixed and also one can manually (or with a patch) fix the
&gt; stuff. 
&gt; 
&gt; If you need further info I&apos;m glad to provide it.

definitely a valid use case, and it maps to what I was explaining. In the previous incantations, the tools jumped through hoops to validate patches and would have known how to skip the double include.

But now, they will simply do as they are told.

So the default machine.scc shouldn&apos;t include user-patches.scc if it is already on the SRC_URI .. it should just leave it up to the file on the SRC_URI. Or vice versa, if it includes the user-patches.scc, we should remove it from the SRC_URI.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74084</commentid>
    <comment_count>6</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2017-06-13 17:35:00 +0000</bug_when>
    <thetext>Confirmed. Do(In reply to comment #5)
&gt; (In reply to comment #4)
&gt; &gt; Just to elaborate a bit more how I came up with the bug:
&gt; &gt; 
&gt; &gt; 1) I use the bsp tool and create with it a BSP for a custom (mainline) kernel
&gt; &gt; 
&gt; &gt; 2) The bsp tool spits out a kernel recipe based on this template:
&gt; &gt; 
&gt; &gt; ...
&gt; &gt; SRC_URI += &quot;file://{{=machine}}.scc \
&gt; &gt;             file://{{=machine}}.cfg \
&gt; &gt;             file://{{=machine}}-user-config.cfg \
&gt; &gt;             file://{{=machine}}-user-patches.scc \
&gt; &gt;            &quot;
&gt; &gt; ...
&gt; &gt; 
&gt; &gt; 3) I use the yocto-kernel tool to add patches
&gt; &gt; 
&gt; &gt; yocto-kernel patch add &lt;BSP name&gt; &lt;patch&gt;
&gt; &gt; 
&gt; &gt; The yocto-kernel tool adds the patch to {{=machine}}-user-patches.scc.
&gt; &gt; 
&gt; &gt; The problem is, that {{=machine}}-user-config.cfg and
&gt; &gt; {{=machine}}-user-patches.scc are included by {{=machine}}.scc hence we have
&gt; &gt; double inclusion and obviously the second time the patch is being applied it
&gt; &gt; fails.
&gt; &gt; 
&gt; &gt; Apparently doing all this manually without the bsp tool and the yocto-kernel
&gt; &gt; tool things can be fixed and also one can manually (or with a patch) fix the
&gt; &gt; stuff. 
&gt; &gt; 
&gt; &gt; If you need further info I&apos;m glad to provide it.
&gt; 
&gt; definitely a valid use case, and it maps to what I was explaining. In the
&gt; previous incantations, the tools jumped through hoops to validate patches
&gt; and would have known how to skip the double include.
&gt; 
&gt; But now, they will simply do as they are told.
&gt; 
&gt; So the default machine.scc shouldn&apos;t include user-patches.scc if it is
&gt; already on the SRC_URI .. it should just leave it up to the file on the
&gt; SRC_URI. Or vice versa, if it includes the user-patches.scc, we should
&gt; remove it from the SRC_URI.

So the series [1], which is now merged at master, will have issues due to the reason posted on this bug. I believe this problem (the double inclusion) applies to patches and cfg scripts, right?

Will send a patch to fix this bug (the custom kernel) and the rest of the architectures.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74114</commentid>
    <comment_count>7</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2017-06-13 19:50:02 +0000</bug_when>
    <thetext>Proposed patch sent to 

https://lists.yoctoproject.org/pipermail/poky/2017-June/011026.html

Thanks Bruce for your info and Robert for noticing it!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74124</commentid>
    <comment_count>8</comment_count>
    <who name="Bruce Ashfield">bruce.ashfield</who>
    <bug_when>2017-06-13 22:17:28 +0000</bug_when>
    <thetext>I&apos;ve acked the patch on the list, it looks good to me!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74876</commentid>
    <comment_count>9</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2017-07-07 17:24:44 +0000</bug_when>
    <thetext>Merged at poky repo:

(From meta-yocto rev: 86ab7ab6688f250bb5777371d2cbc28c770847d4)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>