LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Bitbake - applying patch to a recipe- No file to patch error (https://www.linuxquestions.org/questions/linux-newbie-8/bitbake-applying-patch-to-a-recipe-no-file-to-patch-error-4175563629/)

phani222 01-11-2016 08:19 AM

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.

grail 01-11-2016 08:27 AM

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.

phani222 01-11-2016 09:10 AM

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.

suicidaleggroll 01-11-2016 10:11 AM

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
Notice the "git diff --no-prefix" instead of "diff -Nurp". Also notice that I am NOT in the directory that contains the code to be diff'd. You need to be in the right directory, because the path in your patch file needs to be referenced from where the patch command will be run. In the above example, the patch file header uses the full "git/board/overo/overo.h", rather than just "overo.h". If it just said "overo.h", then patch wouldn't know where to find the file, since that's not where the patch command is run from.

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"

phani222 01-11-2016 10:20 AM

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?

suicidaleggroll 01-11-2016 01:41 PM

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
can't find file to patch at input line 3

Your problem is #1. Bitbake is trying to use your patch file, but it can't find the file being referenced. It doesn't know what "helloworld.c" is, your patch file needs the proper path to the file so patch can find it.

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.

sumadhurakalyan 01-10-2018 05:14 AM

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.