0

The part I'm working on is kernel-devsrc, which is in the recipe recipes-kernel.

I want to change one of the source .c files in drivers/usb/serial in kernal-devsrc. 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)
  • Add the .bbappend file and patch file.

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?? 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). 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.

Henry
  • 2,819
  • 3
  • 18
  • 33
  • Does this answer your question? [How patching works in yocto](https://stackoverflow.com/questions/45584131/how-patching-works-in-yocto) – Oleksandr Kravchuk Oct 22 '20 at 12:47
  • @OleksandrKravchuk No, in that question, the author has access to the source code while I don't have access to the source code. That is a fundamental difference. – Henry Oct 22 '20 at 13:39
  • 1
    You DO have access to the source code, by cloning the public git repo. You CAN commit. You just can't PUSH to the public git repo, but that's unnecessary to create a patch since you can use `git format-patch` on the commit you did locally (no need to push). – qschulz Oct 22 '20 at 18:35
  • @qschulz but how do I make this change available to others if I don't do any kind of PUSH? Every time I build the image, the build system goes to the public repo to download code and compile. I have a team to share my changes. It cannot be local. – Henry Oct 22 '20 at 18:55
  • 1
    You create `bbappend` as it's described in the question. – Oleksandr Kravchuk Oct 23 '20 at 14:54
  • @OleksandrKravchuk I did create `.bbappend` file. Like I said, to apply a patch I also need a `.patch` file, which consists the SHA of `git commit` of my desired change. Where do I get the SHA? I need to `git commit` (and `git push`) first; Where do I git commit? I **have no way** to `git commit`, because I don't have access to the git repo of `recipes-kernel`. That is what blocks me. – Henry Oct 23 '20 at 17:43

2 Answers2

0

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

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).

Henry
  • 2,819
  • 3
  • 18
  • 33
0

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.

As a pre-requisite, the project needs to have its own layer to track the patches. Then, the easiest way it to use 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). 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.

Under the hood, devtool modify initializes a (writable) git repository in the sandbox. 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.

yadutaf
  • 6,840
  • 1
  • 37
  • 48