Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED]howto create a patch file?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
littletux
n00b
n00b


Joined: 08 Dec 2003
Posts: 66

PostPosted: Wed Jun 20, 2018 12:44 pm    Post subject: [SOLVED]howto create a patch file? Reply with quote

Aaargh I had done this longer time before without any problems and now I can't figure it out what I am doing wrong now.
I have done some changes in a source code, and now i want to create a patchfile. This are my steps

if I unpack it, the original source code reside in
Quote:
squashfs4.3/squashfs-tools/

then i rename it to
Quote:
squashfs4.3.old/squashfs-tools/

and unpack it again.
then I made my changes in
Quote:
squashfs4.3/squashfs-tools/


now I create the patchfile with
Code:
diff -crB squashfs4.3.old squashfs4.3 squashtoolszenityprogress.patch

have also tried with
Code:
diff -ruN squashfs4.3.old squashfs4.3 squashtoolszenityprogress.patch

in both cases I can add the patch manually if i go into the directory
Quote:
squashfs4.3.old/squashfs-tools/
where after first unpack the unchanged code
resides in. I apply it by
Code:
patch -Np1 -i /path/to/my/patchfile

and all works fine

Now the Problem:
I have an overlay with ebuilds on github, and in one I want to apply this patch, but the patchfile can not be applied and emerge stops.

I know that the ebuild works fine if I remove the line where I add my patch. So I only need to know what I have to do in another way so the patchfile works for portage


Last edited by littletux on Thu Jun 21, 2018 8:24 am; edited 1 time in total
Back to top
View user's profile Send private message
fedeliallalinea
Bodhisattva
Bodhisattva


Joined: 08 Mar 2003
Posts: 19441
Location: here

PostPosted: Wed Jun 20, 2018 12:56 pm    Post subject: Reply with quote

Usually I use these steps:
Code:
# ebuild /usr/portage/category/package/package-version.ebuild unpack
# cd /var/tmp/portage/category/package-version/work
# cp -r package-version package-version.orig
# cd package-version
... now modify all files you want ...
# cd /var/tmp/portage/category/package-version/work
# diff -Naru package-version.orig package-version > /etc/portage/patches/category/package-version/patch-name.patch

_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6075
Location: Room 101

PostPosted: Wed Jun 20, 2018 1:07 pm    Post subject: Re: howto create a patch file? Reply with quote

littletux wrote:
Code:
diff -ruN squashfs4.3.old squashfs4.3 squashtoolszenityprogress.patch

littletux ... that (and the other diff) is incorrect, you'll get a "extra operand" error and no patch will be generated ... you need to redirect the output:

Code:
% diff -rupN input.orig input > output.patch
% cat output.patch
diff -rupN input.orig/input input/input
--- input.orig/input   2018-06-20 14:56:19.301265897 +0200
+++ input/input   2018-06-20 14:59:41.479791288 +0200
@@ -1,4 +1,4 @@
 hello hello hello
 hello hello hello
 hello hello hello
-hello hello hello
+hello hello goodbye

... but show us the patch, ebuild, and build.log.

best ... khay
Back to top
View user's profile Send private message
littletux
n00b
n00b


Joined: 08 Dec 2003
Posts: 66

PostPosted: Wed Jun 20, 2018 1:38 pm    Post subject: Reply with quote

@khayyam
no I not recieve a error, and a patchfile will be created, because i create not a patch for 2 files. I create it for 2 folders, and so the basicly syntax is correct. problem is not the patch will not createt, but it not works if I use emerge and my ebuild to patch. only thing you thought it would be wrong, i have forgotten the > in my description

@fedeliallalinea

yeah you have saved my day
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6075
Location: Room 101

PostPosted: Wed Jun 20, 2018 2:55 pm    Post subject: Reply with quote

littletux wrote:
@khayyam no I not recieve a error, and a patchfile will be created, because i create not a patch for 2 files. I create it for 2 folders, and so the basicly syntax is correct. problem is not the patch will not createt, but it not works if I use emerge and my ebuild to patch. only thing you thought it would be wrong, i have forgotten the > in my description

littletux ... look closer, I also created the patch for "two folders" (umm ... "directories"), and as I said "you need to redirect the output", so if you "have forgotten the >", then you're not redirecting the output.

littletux wrote:
@fedeliallalinea yeah you have saved my day

If this is part of your overlay then this patch isn't distrubuted with the overlay, /etc/portage/patches/ is outside of ::repo ... you may, or may not, want this, but by your first post it reads as though that is what you were aiming for:

littletux wrote:
I have an overlay with ebuilds on github, and in one I want to apply this patch, but the patchfile can not be applied and emerge stops.

There is no reason why the patch would fail for epatch but succeed for epatch_user.

best ... khay
Back to top
View user's profile Send private message
littletux
n00b
n00b


Joined: 08 Dec 2003
Posts: 66

PostPosted: Wed Jun 20, 2018 3:06 pm    Post subject: Reply with quote

@khayyam
we speek in different directions
I have not forgotten the > for doing my command, I only have forgotten in the previous description about my problem so all
My Problem was only becauso of wrong parameters and wrong places to apply in the directoriy hirarchy, and the description of fedeliallalinea was really straight forward step by step with the correct parameters so the patch now works as it should
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6188

PostPosted: Thu Jun 21, 2018 6:28 am    Post subject: Reply with quote

khayyam wrote:
There is no reason why the patch would fail for epatch but succeed for epatch_user.

(epatch, epatch_user) != (eapply, eapply_user)
In the latter case, the format must be patch -p1 for safety reasons.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6075
Location: Room 101

PostPosted: Thu Jun 21, 2018 7:08 am    Post subject: Reply with quote

khayyam wrote:
There is no reason why the patch would fail for epatch but succeed for epatch_user.

mv wrote:
(epatch, epatch_user) != (eapply, eapply_user)

mv ... that maybe the case, but it doesn't matter in the context in which that was written, the point was if patch succeeds when in /etc/portage/patches it should similarly if applied via the ebuild.

best ... khay
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6188

PostPosted: Thu Jun 21, 2018 1:02 pm    Post subject: Reply with quote

khayyam wrote:
the point was if patch succeeds when in /etc/portage/patches it should similarly if applied via the ebuild.

I understood it was applied in the own ebuild by epatch while /etc/portage/patches is usually handled with eapply_user.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum