# Is there a guide for applying a patch to kernel?

## pd1986

I've been looking for the guide for a while. But I didn't find it. I would like to know if there is a guide or some special operation to apply a patch to kernel. Thanks

----------

## charles17

Not sure if https://wiki.gentoo.org/wiki//etc/portage/patches also applies to kernel ebuilds.

----------

## toralf

 *charles17 wrote:*   

> Not sure if https://wiki.gentoo.org/wiki//etc/portage/patches also applies to kernel ebuilds.

 IIRC it does.

----------

## pd1986

Thank you all. I will try.

----------

## Nicias

I've used /etc/portage/patches for kernels, it works.

----------

## charles17

 *Nicias wrote:*   

> I've used /etc/portage/patches for kernels, it works.

 

Did you have to add the /etc/portage/bashrc stuff or does the kernel (which?) support epatch_user?

----------

## khayyam

 *charles17 wrote:*   

>  *Nicias wrote:*   I've used /etc/portage/patches for kernels, it works. 
> 
> Did you have to add the /etc/portage/bashrc stuff or does the kernel (which?) support epatch_user?

 

charles ... if the package in question is using the kernel-2.eclass (as gentoo-sources does) then it supports epatch_user:

```
# awk '!/(^#|^$)/&&/epatch_user/' ~portdir/eclass/kernel-2.eclass

   debug-print "Doing epatch_user"

   epatch_user
```

@pd1986 ... if this is a oneoff patch then you can simply use 'patch' rather than epatch_user ...

```
# patch -p1 --dry-run -d /usr/src/linux <mypatch.patch
```

... remove '--dry-run' for the patch to be applied, and note that '-p1' may need to be altered dependent on the patch. I do this with the tuxonice patch as it tracks KVERSION and its easier to apply the patch subsequent to merging than using epatch_user.

HTH & best ... khay

----------

## pd1986

 *khayyam wrote:*   

>  *charles17 wrote:*    *Nicias wrote:*   I've used /etc/portage/patches for kernels, it works. 
> 
> Did you have to add the /etc/portage/bashrc stuff or does the kernel (which?) support epatch_user? 
> 
> charles ... if the package in question is using the kernel-2.eclass (as gentoo-sources does) then it supports epatch_user:
> ...

 

Hi Khayyam, you are right. I use the command "patch". and it works. I think it much easier. Just need to be careful about the directory level in the patch, it will be OK. Thanks.

----------

