简体   繁体   English

如何在 yotco 中修补 Linux 内核源代码

[英]How to patch Linux kernel source code in yotco

The part I'm working on is kernel-devsrc , which is in the recipe recipes-kernel .我正在处理的部分是kernel-devsrc ,它位于配方recipes-kernel中。

I want to change one of the source .c files in drivers/usb/serial in kernal-devsrc .我想更改kernal-devsrcdrivers/usb/serial中的源 .c 文件之一。 From some of the online materials, I need to:从一些在线材料中,我需要:

  • Have my own layer有我自己的图层
  • In the layer, need a recipe with the same name as recipes-kernel (and further more, recipes-kernel/linux )在该层中,需要一个与recipes-kernel同名的配方(还有recipes-kernel/linux
  • Add the .bbappend file and patch file.添加 .bbappend 文件和补丁文件。

The problem is : to create a patch file I need to know the 2 git SHAs of before and after the change, but I don't have access to the third party recipes-kernel , how do I get the SHA??问题是:要创建补丁文件,我需要知道更改前后的 2 个 git SHA,但我无权访问第三方recipes-kernel ,如何获取 SHA? OR, if that is the wrong way to do this, could you point out the right way to do it?或者,如果这是错误的方法,你能指出正确的方法吗? Thanks!谢谢!

NOTE: This is problem is not like this one: How patching works in yocto , which the author has access to the source code (.c and .h files).注意:这不是这样的问题: 如何在 yocto 中进行修补工作,作者可以访问源代码(.c 和 .h 文件)。 I DON"T have access to the source code, the yotco kernel I'm working on is from a public git repo, and I am not able to git commit to get the SHA, which is necessary to create the patch file.我无法访问源代码,我正在处理的 yotco 内核来自公共 git 存储库,并且我无法通过git commit获取 SHA,这是创建补丁文件所必需的。

So, the way I do it is to use Quilt , follow the steps there then good to go: https://www.yoctoproject.org/docs/1.8/dev-manual/dev-manual.html#using-a-quilt-workflow所以,我这样做的方式是使用Quilt ,然后按照那里的步骤进行操作:https: //www.yoctoproject.org/docs/1.8/dev-manual/dev-manual.html#using-a-quilt -工作流程

I don't need to know the SHA (though I still don't know why others in my organization end up writing SHAs in the patch files and how did they know the SHAs).我不需要知道 SHA(尽管我仍然不知道为什么我的组织中的其他人最终会在补丁文件中编写 SHA,以及他们是如何知道 SHA 的)。

The power of Yocto is precisely that it makes it relatively straightforward to patch any existing recipes, without requiring write access to the upstream project source code or Yocto layer. Yocto 的强大之处在于它可以相对简单地修补任何现有的配方,而不需要对上游项目源代码或 Yocto 层的写入权限。

As a pre-requisite, the project needs to have its own layer to track the patches.作为先决条件,项目需要有自己的层来跟踪补丁。 Then, the easiest way it to use devtool .然后,使用devtool的最简单方法。 The general idea is to:总体思路是:

  1. Create a local sandbox to patch the project: devtool modify RECIPE_NAME (use the name of the target recipe here).创建一个本地沙箱来修补项目: devtool modify RECIPE_NAME (在此处使用目标配方的名称)。 This command will create a temporary workspace and print the path to this workspace.此命令将创建一个临时工作区并打印该工作区的路径。
  2. Move to the temporary workspace, apply the needed patches and commit them one by one.移动到临时工作区,应用所需的补丁并一一提交。
  3. Once all the desired patches have been applied, use devtool finish RECIPE_NAME CUSTOM_LAYER_NAME to save the chances as clean patch files in a bbappend in the custom layer.一旦应用了所有所需的补丁,使用devtool finish RECIPE_NAME CUSTOM_LAYER_NAME将机会保存为自定义层的 bbappend 中的干净补丁文件。

Under the hood, devtool modify initializes a (writable) git repository in the sandbox.在后台, devtool modify在沙箱中初始化一个(可写的)git 存储库。 When devtool finish is invoked, devtool checks the list of extra-commits and saves them as patch files in a .bbappend in the target layer.当调用devtool finish时,devtool 检查额外提交列表并将它们作为补丁文件保存在目标层的.bbappend中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM