You are not logged in.

#1 2021-10-29 16:28:03

boomshalek
Member
Registered: 2007-10-12
Posts: 113

Patching kernel xxx.h file from PKGBUILD

Hi
I would like to patch a /usr/include/linux/xxx.h kernel file as part of my PKGBUILD before starting the compilation of my custom module.
Clearly i need to be root for this.
how can this be done (in a better way)?
TIA

Offline

#2 2021-10-29 17:29:43

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: Patching kernel xxx.h file from PKGBUILD

You want to patch a file on the host system, or in your package's source tree?  The former absolutely cannot be done - and if you ever tried to do it, you should catch no end of crap for doing so.

The latter is trivial ... to the point that I'm not sure what the question really is: read `man patch`.  If you need more than that, don't obscure what the file is: post your PKGBUILD and your actual goal.

EDIT: also if you are thinking of the former, this is almost certainly an X-Y question.  The headers on the host system are matched to the kernel code.  If there is an actual error in one of them, it should be reported upstream to be fixed.  If it is not an error, then there is absolutely nothing that you could patch into a header file that would change functionality in any way that wouldn't be easier to add to your own code or your own projects local header file(s).  So what are you really trying to do?

Last edited by Trilby (2021-10-29 20:31:21)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2021-10-29 20:23:01

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,637

Re: Patching kernel xxx.h file from PKGBUILD

If it's the former, you would really need to make your own kernel package for that.

Online

#4 2021-10-29 20:30:39

loqs
Member
Registered: 2014-03-06
Posts: 18,822

Re: Patching kernel xxx.h file from PKGBUILD

/usr/include/linux/* are the sanitized headers for userspace from the linux-api-headers package.  You need to point your module to the source tree of the kernel you are building for,  commonly using the -C option e.g.

make -C /usr/lib/modules/5.14.15-arch1-1/build/ M=$PWD

See also https://www.kernel.org/doc/html/latest/ … dules.html

Last edited by loqs (2021-10-29 20:31:34)

Offline

#5 2021-11-03 16:31:14

boomshalek
Member
Registered: 2007-10-12
Posts: 113

Re: Patching kernel xxx.h file from PKGBUILD

Trilby wrote:

So what are you really trying to do?

I am trying to include this patch in my system.
Apparently the two files to be modified are part of the linux-lts-headers package on my system.

I would like to patch this file as a part of a PKBUILD file.

Offline

#6 2021-11-03 19:40:09

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: Patching kernel xxx.h file from PKGBUILD

If you are patching files in the linux-lts-headers package, you'd do that in the linux-lts-headers PKGBUILD.

But I still don't see *why* you want to patch the linux-lts-headers files to build your module.  The linux-lts-headers are shared, and you are including code in them that is only used by your module, right?  So just include those structs, defines, and typedefs in your own project's code.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB