Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] auto-patching through /etc/portage/patches
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
Atom2
Apprentice
Apprentice


Joined: 01 Aug 2011
Posts: 185

PostPosted: Sun Mar 30, 2014 7:46 pm    Post subject: [SOLVED] auto-patching through /etc/portage/patches Reply with quote

Hi guys,
I need to apply a few patches to my kernel and would like to do that automatically through /etc/portage/patches. I think I understand the general idea and also have this working for a few other packages; the idea is absolutely great IMHO.

The only issue I face, and I don't know how to deal with this, is that two of the patches I have to apply to the kernel are actually reversals. Is there a way to specify that those two patch files should be applied by providing the -R option to patch command (i.e. through the filename?). If I run the patch command manually with -R it clearly works, but it would be nice if all were done automatically by just emerging the source ...

BTW the third patch, which does not require the -R option is applied without any issues, but the overall emerge fails due to the other two patches being reversals.

Thanks and regards,

Atom2


Last edited by Atom2 on Mon Mar 31, 2014 3:44 pm; edited 1 time in total
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21631

PostPosted: Sun Mar 30, 2014 8:29 pm    Post subject: Reply with quote

Where did you get these backward patches? Can you regenerate them to be forward patches instead?
Back to top
View user's profile Send private message
Atom2
Apprentice
Apprentice


Joined: 01 Aug 2011
Posts: 185

PostPosted: Sun Mar 30, 2014 8:53 pm    Post subject: Reply with quote

Hi Hu,
thanks for your quick answer. I received these patches from the XEN-devel mailing list due to powerdown problems on my dom0 - the system always reboots on "shutdown -h now" instead of powering off.

The full thread is available here and the specific three patches are listed here. I had to apply those patches starting from 3.9.5 over 3.11.2, 3.11.7 and now also on 3.13.2 (gentoo-hardende in all cases). As this seems to be an on-going issue (also confirmed here) it asks for some better automation ...

If creating a forward patch solves the issue, that's fine as well. I however would need a bit of help on how to convert the two relevant ones of my three pactches to forward patches ...

Thanks Atom2
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21631

PostPosted: Sun Mar 30, 2014 11:08 pm    Post subject: Reply with quote

The post you linked says to revert some particular Linux commits. Were they reverted upstream and you are now trying to unrevert them? If so, then you can just cherry-pick the originally cited commit.

A reverse (or "backward") patch is generated when someone passes the old and new files to diff in the wrong order. The easiest way to deal with this is to teach the offending individual to pass the files in the proper order. In the meantime, you could manually patch the files with -R to get the correct new file, then use that new file and a backup of the old file to privately generate a correct forward patch.
Code:
cd work
mkdir a b
cp file-to-patch.c a/
cp file-to-patch.c b/
(cd b && patch -p1 -R backward-patch-file.patch)
diff -ru a b > forward-patch-file.patch
Back to top
View user's profile Send private message
Atom2
Apprentice
Apprentice


Joined: 01 Aug 2011
Posts: 185

PostPosted: Mon Mar 31, 2014 3:43 pm    Post subject: Reply with quote

As far as I understood the discussion in xen-devel the commits (which I need to revert) were not reverted upstream but rather applied upstream - so I am not trying to unrevert (i.e. apply) them but rather really revert the applied patches. I guess your first option would not work then as there is nothing to cherry-pick

But the good news is that I was able to build upon and apply the procedure you proposed in your second idea: In the end I have simply created a single patch file that includes all three patches - that is the two that are to be reverted plus the third one that needs to be applied.

The resulting single patch file is now filed into the /etc/portage/patches/sys-kernel/hardened-sources directory and everything works (at least) for 3.13.2.

Apart from that I would think it were a nice idea if portage had the ability to automatically revert (instead of apply) a patch in a file. In my view that should easily be possible by using a file name extension rule - e.g. extension ".patch" for applying patches and ".rpatch" or ".revert.patch" for a patch to be reverted. But that's just an idea - my current problem is solved.

In any case many thanks and regards,

Atom2
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