<?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>15266</bug_id>
          
          <creation_ts>2023-10-27 14:59:38 +0000</creation_ts>
          <short_desc>kernel-yocto.bbclass does not handle git am failures when patching kernel-meta</short_desc>
          <delta_ts>2024-01-03 16:58:42 +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>kernel</component>
          <version>unspecified</version>
          <rep_platform>All</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>5.0 M1</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="C. Andy Martin">cam</reporter>
          <assigned_to name="Bruce Ashfield">bruce.ashfield</assigned_to>
          <cc>tom.zanussi</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>97026</commentid>
    <comment_count>0</comment_count>
    <who name="C. Andy Martin">cam</who>
    <bug_when>2023-10-27 14:59:38 +0000</bug_when>
    <thetext>The kernel-yocto.bbclass fails to detect if `git am` fails in the task `do_kernel_metadata()`. This may happen if the patch is malformed, or in a sneakier case if no Signed-off-by is in the patch and no global git config exists for user.email or user.name (since `-s` is used git am needs those set to add the Signed-off-by). The class should handle failure and fail the task instead of allowing it to succeed. Also kernel-meta patching should work without relying on global git config which breaks build reproducibility. This could be done by removing `-s` requiring the patches to already have Signed-off-by or by adding local git config similar to utils.bbclass for the Signed-off-by field.

This was discovered locally in a higher layer which needed to patch a config bug in yocto-kernel-cache. The build worked fine locally where git config was setup outside yocto, but in CI it &quot;succeeded&quot; even though the patch did not apply, leading to inconsistent results for the same yocto workspace.

AFAICT this bug has existed for a long time (at least since Kirkstone which is what we use) and exists in the current master branch of OE-core.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97029</commentid>
    <comment_count>1</comment_count>
    <who name="Bruce Ashfield">bruce.ashfield</who>
    <bug_when>2023-10-27 18:33:13 +0000</bug_when>
    <thetext>The patching of the kernel-meta data was largely an add-on for debug when I introduced it in 2019, hence why the support is sparse for dealing with issues related to the patching.

There are more robust patch application methods in both the kern-tools and the core patch classes (but neither can be used in this context).

The preferred method for overriding configuration is to provide the meta-data in a layer, either via a complete directory (kernel-cache style) or via fragments. If there are errors in that sort of process, they are more significant.

That being said, I can certainly improve things by simply checking the return code and doing an exit. The routine has failure code trapping off by default, as some commands are expected to have failure codes.

Also, the -s is intentional and will stay. We have a routine check_git_config, which was added to ensure that some sort of user is configured and available for the patch application. If that is broken, again, that is a different issue that we need to fix. So it isn&apos;t relying on global config, and has been implemented with that in mind.

There&apos;s another active issue that I&apos;m working on that will enhance our avoidance of system/user git configuration (bad hooks were being called), so when that work is complete, this patching will leverage it.

Summary: I&apos;ll check the return code for now, and the other feature/enhancements that are pending will deal with other parts.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97723</commentid>
    <comment_count>2</comment_count>
    <who name="Bruce Ashfield">bruce.ashfield</who>
    <bug_when>2024-01-03 16:58:42 +0000</bug_when>
    <thetext>commit d6b37f223015baa6ebb809b18420c62204c4d1b0
Author: Bruce Ashfield &lt;bruce.ashfield@gmail.com&gt;
Date:   Wed Nov 8 09:16:26 2023 -0500

    kernel-yocto: improve metadata patching
    
    The ability to patch the kernel-yocto metadata was added to support
    debug and easier test cycles on kernel-cache provided fragments. As
    such, it was very simple and has limited functionality.
    
    That being said, it is an available feature and can be improved to
    handle patches that fail to apply.
    
    The main kernel patching is already handled by the kern-tools, so
    we extend the patching of the meta-data to same tools and inherit
    more functinality from the scripts.
    
    [YOCTO #15266]
    
    (From OE-Core rev: e867addd6c2f508f7a95e72222e750d37f3d19d8)
    
    Signed-off-by: Bruce Ashfield &lt;bruce.ashfield@gmail.com&gt;
    Signed-off-by: Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;

:100644 100644 cb9cd26b09 9a86616dad M  meta/classes-recipe/kernel-yocto.bbclass</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>