Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Where do you add a custom kernel patch
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
noelpaz
n00b
n00b


Joined: 22 Dec 2005
Posts: 2

PostPosted: Thu Dec 22, 2005 12:33 am    Post subject: Where do you add a custom kernel patch Reply with quote

Hi,

I am new to this forum and just started using gentoo about 2 months ago and have not really gotten well versed in the ebuild process but I like the concept a lot.

I have a kernel patch that I want to apply to the kernel using the "Portage Way". I am not so sure how I add it

I have a local mirror that is locked down -- means it is not updating anymore.

I see that under distfiles there is a genpatches-{kernel version}extras.tar.bz2 archive. My patch has a number suffix that is high to ensure it gets added last.

Do I:

untar the genpatches-file add my patch and then tar it up again?

Or do I add it in ..portage/sys-kernel/gentoosources/files -- the reason I am asking this is that there are 2 patch files there as well. What do I have to do or edit in the ebuild files ..portage/sys-kernel/gentoosources?

I am building some boxes in an automated fashion and I'd rather apply the patch through the "Portage/Ebuild" system instead of the patch command

I did a search and still searching but I am not getting a satisfactory answer. Thanks in advance

Noel
Back to top
View user's profile Send private message
asiobob
Veteran
Veteran


Joined: 29 Oct 2003
Posts: 1375
Location: Bamboo Creek

PostPosted: Thu Dec 22, 2005 4:53 am    Post subject: Reply with quote

The kernel is a small exception here if you want it to be. When you emerge a kernel all thats's happening is the kernel is downloaded and extracted for you. Nothing is configured, compiled, or installed -- that's something you do. This is opposed to any other package where portage downaloads, extracts, applies patches (if any), configures, compiles and installs.

So the easiest way to apply a kernel patch would be to..

1. Save the patch somewhere
2. cd into your sources directory, eg
/usr/src/linux
3. patch -p1 --dry-run < /path/to/patch

4. The --dry-run option never applies the patch but shows what would happen if you were to really apply it, it says if it worked or not. If it complains about what patch file to use try the -p0 option rather than -p1

5. If you are happy with the above result, run it again without the --dry-run option and the patch will get applied.

And that's it. Then you configure and make the kernel as normal. I guess this is how most people do it *at least* when it comes to the kernel
Back to top
View user's profile Send private message
noelpaz
n00b
n00b


Joined: 22 Dec 2005
Posts: 2

PostPosted: Thu Dec 22, 2005 8:46 am    Post subject: Reply with quote

Thanks ASIO_BOB!

It looks like the epatch function does not apply the patch (works for other packages). I do know the patch method but I think it is easier to maintain my build if I use the portage way. Unless there is a way to do it through portage by editing the gentoo-sources{version}.ebuild file -- the way that I find this to work is to add the patches to the genpatches(version}.base.tar.bz2 genpatches(version}.extras.tar.bz2. The README in these archives tell of the numbering scheme to use for your patch filename prefix. As long as you've tested the kernel patch before hand, adding it to these .bz2 files seems to be the only way and ebuild figures automatically the patching parameter -- one of the reasons I like it done just using portage. I'd really like to do it through ebuild rather than mucking with .bz2 files

Thanks
Back to top
View user's profile Send private message
twb1270
n00b
n00b


Joined: 20 Jan 2006
Posts: 6

PostPosted: Fri Jan 20, 2006 7:20 pm    Post subject: Reply with quote

Quote:
I'd really like to do it through ebuild rather than mucking with .bz2 files


I totally agree. I have several kernel patches that I need to apply to the kernel. I would be nice if I could copy the standard kernel ebuild to my local overlay, modify a variable, and not have to worry about it.

I would be really great if I could edit the ebuild to contain something like this:

K_LOCAL_PATCHURL="http://my.server.com/mypatchfile.tgz"

and have the eclass download, unpack, and patch with kernel with the contents of the downloaded file. I'm not an expert on the kernel-2 eclass, but it would seem like this would be an easy addition. I'd even be open to having to adhere to some kind of rules (imposed by the eclass) for creating/name/building the tgz file.

It seems like this is much closer to the Gentoo way than the suggested alternative (download, patch by hand).

I expect the package management system to assist me in this task. I understand that for each new kernel update there will be a bunch of manual work to make sure the patches still work or to fix them if they don't. But once I do that once, I can use portage to make installation on all my systems much easier and more reliable by taking out a lot of manual processing.
Back to top
View user's profile Send private message
dsd
Developer
Developer


Joined: 30 Mar 2003
Posts: 2162
Location: nr London

PostPosted: Sun Jan 22, 2006 12:01 pm    Post subject: Reply with quote

you could even do it on the command line, without need for overlay: UNIPATCH_LIST_USER="/path/to/patchfile" emerge gentoo-sources
its a nice idea, and a bug report with a patch to kernel-2.eclass would probably be accepted.

the function that would have to be modified is "kernel-2_src_unpack" and you'll probably find its an easy change to make. one request though, if the variable you choose (my suggestion is UNIPATCH_LIST_USER) is set, a warning message should be printed, saying something along the lines that if you modify your kernel yourself then you must say so on all Gentoo bug reports that you file, and you may be expected to drop that patch when working through bug reports.
_________________
http://dev.gentoo.org/~dsd
Back to top
View user's profile Send private message
twb1270
n00b
n00b


Joined: 20 Jan 2006
Posts: 6

PostPosted: Thu Jan 26, 2006 1:31 am    Post subject: Reply with quote

dsd wrote:
you could even do it on the command line, without need for overlay: UNIPATCH_LIST_USER="/path/to/patchfile" emerge gentoo-sources
its a nice idea, and a bug report with a patch to kernel-2.eclass would probably be accepted.


A bug report with patch for this has been filed.

https://bugs.gentoo.org/show_bug.cgi?id=120357
Back to top
View user's profile Send private message
mikenerone
n00b
n00b


Joined: 11 Feb 2004
Posts: 22
Location: San Antonio, TX

PostPosted: Mon Jan 30, 2006 11:38 pm    Post subject: Reply with quote

Please take a look at my parent-kernel.eclass. It provides a way to make a custom-patched version of another kernel package, that automatically handles fetching of packages, provides a cleaner way of handling version tracking for the patch files (for patches that are release on a per-version basis), and automatically evolves and stabilizes with the parent package upon which your overlay ebuild is based. And without a kludgy environment variable you have to remember to pass in each time you merge.

Mike Nerone
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