LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-11-2016, 08:19 AM   #1
phani222
LQ Newbie
 
Registered: Jan 2016
Location: Charlotte
Distribution: Ubuntu 14.04
Posts: 4

Rep: Reputation: Disabled
Cool 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.
 
Old 01-11-2016, 08:27 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
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.
 
1 members found this post helpful.
Old 01-11-2016, 09:10 AM   #3
phani222
LQ Newbie
 
Registered: Jan 2016
Location: Charlotte
Distribution: Ubuntu 14.04
Posts: 4

Original Poster
Rep: Reputation: Disabled
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.
 
Old 01-11-2016, 10:11 AM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
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"
 
Old 01-11-2016, 10:20 AM   #5
phani222
LQ Newbie
 
Registered: Jan 2016
Location: Charlotte
Distribution: Ubuntu 14.04
Posts: 4

Original Poster
Rep: Reputation: Disabled
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?
 
Old 01-11-2016, 01:41 PM   #6
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
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.

Last edited by suicidaleggroll; 01-11-2016 at 01:44 PM.
 
1 members found this post helpful.
Old 01-10-2018, 05:14 AM   #7
sumadhurakalyan
LQ Newbie
 
Registered: Jan 2018
Posts: 1

Rep: Reputation: Disabled
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 \
"

Last edited by sumadhurakalyan; 01-10-2018 at 06:04 AM. Reason: Deleted unwanted commands.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error applying ns2.29 clustering patch on ubuntu 12.04 razachis Linux - Software 3 02-14-2014 03:38 AM
LFS 5.4 error: patch: **** Can't open patch file .. DavidLee1A Linux From Scratch 6 12-28-2012 03:33 PM
PLEASE HELP..Error in applying A new Queue ( OLBP Scheme-user defined) patch to ns mohak.nk Linux - General 11 03-29-2012 01:31 PM
How to make a simple kernel patch with OE Bitbake / Recipe System leiphasw Linux - Distributions 1 11-07-2010 03:25 AM
error while applying patch corbis_demon Programming 1 08-14-2004 11:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration