Bitbake - applying patch to a recipe- No file to patch error
Hello,
I started using yocto project and was trying to play with the recipes.I tried applying a patch to helloworld recipe and got an eror. Here is the command flow. phani@phani-HP-EliteBook-8470p:~/poky/meta-mylayer/recipes-example/example/helloworld-0.1$ diff -Nurp helloworld.c new.c >mypatch.patch So, the source file,modified file and the patch are in the same dir. Now, I added SRC_URI += "file://mypatch.patch" line to the .bb recipe file. After that I tried baking the recipe again. phani@phani-HP-EliteBook-8470p:~/poky/build_dir$ bitbake -c cleansstate helloworld phani@phani-HP-EliteBook-8470p:~/poky/build_dir$ bitbake -c patch helloworld ERROR: Command Error: exit status: 1 Output: Applying patch mypatch.patch can't find file to patch at input line 3 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |--- helloworld.c 2016-01-09 08:33:47.627109864 -0500 |+++ new.c 2016-01-10 23:28:45.554345162 -0500 -------------------------- No file to patch. Skipping patch. 1 out of 1 hunk ignored Patch mypatch.patch does not apply (enforce with -f) ERROR: Function failed: patch_do_patch ERROR: Logfile of failure stored in: /home/phani/poky/build_dir/tmp/work/i586-poky-linux/helloworld/0.1-r0/temp/log.do_patch.10478 ERROR: Task 1 (/home/phani/poky/meta-mylayer/recipes-example/example/helloworld_0.1.bb, do_patch) failed with exit code '1' Can some one please help me fix this.Thanks. |
Are you sure your patch was created correctly?
I looked up the -p option which says it should have a number associated with it but you have none. I did notice that the -p option is also mentioned in the error message. |
I tried giving the number as well.
SRC_URI += "file://mypatch.patch;patch=1" But, I think bitbake does this by default. I tried couple other options too. For ex. diff -u helloworld.c new.c >mypatch.patch But the same error popped. I believe there's a fixed format of the patch file that Bitbake expects and I'm not getting it. |
I've never used yocto, but I have created and used patch files on openembedded, which uses bitbake and looks very similar to what you're doing.
A few thoughts come to mind: 1) Your diff looks very different than mine. This is what I would typically use: Code:
git diff --no-prefix git/board/overo/overo.h-orig git/board/overo/overo.h > pin-mux.patch 2) Your patch file needs to be placed in the right directory for your recipe, not the directory of the file to be patched. In the above example, after creating the patch file I would move it to org.openembedded.dev/recipes/u-boot/u-boot-git/overo/, and modify org.openembedded.dev/recipes/u-boot/u-boot_git.bb: Code:
SRC_URI_overo += "file://pin-mux.patch" |
I tried to use 'git diff --no-prefix'. The patch file created is empty.
Should my source files be under a local git repository(directory) as in your case? |
That's just how the build environment for my device is set up by default.
The biggest issues are that your patch file needs to be in the location that the bitbake recipe expects (see #2), and your patch file needs to have the correct path to the file given the location from which patch will be run, it can't just have the name of the file or patch won't be able to find it (see #1). According to your error: Code:
Applying patch mypatch.patch You can't run your diff from inside helloworld-0.1, you'll need to be in one of the parent directories so the patch file has the proper path to the file being patched. |
By using quilt you can create patch
1)quilt new xxxx.patch 2)quilt add xxxx.c 3)vim xxxx.c # add changes according to your need. 4)quilt refresh Now you can see the directory with name of PATCHES ,in that directory you can see your patch. In .bbappend file code: SRC_URI += " \ file://xxxx.patch \ " |
All times are GMT -5. The time now is 06:27 AM. |