You are not logged in.

#1 2017-04-08 17:02:37

EvilRob
Member
Registered: 2016-04-02
Posts: 13

[SOLVED] Applying an incremental patch to a custom kernel

I've been learning the Arch Build System and have successfully built my own kernel from source a couple of times now, although I must admint that I'm still not all that clear about what all of the commands in the PKGBUILD script are actually doing. In spite of that, I was able to modify the PKGBUILD script that I got from ABS to pull down and apply an incremental patch to the existing source that I had from my last build. The issue is that when I run the pkgbuild command, the build system proceeds to recompile EVERYTHING. To avoid hours of recompiling, how do I apply the patch and have the build system only complile the new bits?

Last edited by EvilRob (2017-04-09 20:38:11)

Offline

#2 2017-04-08 17:39:46

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

Re: [SOLVED] Applying an incremental patch to a custom kernel

makepkg -e


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2017-04-08 17:50:54

EvilRob
Member
Registered: 2016-04-02
Posts: 13

Re: [SOLVED] Applying an incremental patch to a custom kernel

@Trilby, so instead of modifying the PKGBUILD file to pull down the incremental patch, I should download and apply the patch manually, and then run makepkg -e?

Offline

#4 2017-04-08 18:13:10

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

Re: [SOLVED] Applying an incremental patch to a custom kernel

Yes, I suppose with -e makepkg will not retrieve any sources newly added to the PKGBUILD.  But that's your goal: use what is already there.  You can't selectively retrieve sources with makepkg.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2017-04-08 18:24:53

EvilRob
Member
Registered: 2016-04-02
Posts: 13

Re: [SOLVED] Applying an incremental patch to a custom kernel

@Trilby Thanks for the advice. That will be the workflow I use for the next patch cycle. Although something I just thought of is that I'll probably still need to modify the pkgver variable for the new package build.

Last edited by EvilRob (2017-04-08 18:28:49)

Offline

#6 2017-04-09 01:04:59

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

Re: [SOLVED] Applying an incremental patch to a custom kernel

If you need to modify the pkgver then you will need to rebuild everything.  I'm not sure I'm following the logic of your question: if you built a package but forgot to apply a patch, you can apply the patch locally and rebuild with `makepkg -e` which will skip downloading the source.  This will keep the previously compiled object files allowing make to only have to recompile whatever source files have changed due to the patch.

If you need to build a new version, then yes you need to build the new version.  In that case, just be sure to apply the patch the first time you build it.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2017-04-09 02:40:39

EvilRob
Member
Registered: 2016-04-02
Posts: 13

Re: [SOLVED] Applying an incremental patch to a custom kernel

@Trilby, It's not that I forgot to apply a patch. It's that there was a new maintainence release for the Linux kernel. This morning, when I checked in at kernel.org, I saw that 4.10.9 was released today. I had already built 4.10.8 a couple of weeks ago. I was hoping to download and apply the 4.10.8-9 incremental patch to the source I still have in my build directory but when makepkg invoked make, it compiled the whole darn thing instead of just the sources that were patched. I'm assuming I lost all the compiled objects from my last build when it re-extracted the 4.10 tar.xz file into my source directory. I'm under the impression that `makepkg -e` will avoid that problem even if I change any of the pkgbuild variables. When makepkg invokes make, it should skip over all the sources that haven't changed since those compiled objects should still exist (unless there's a `make clean` somewhere in the PKGBUILD script). After compiling the newly patched sources, the only thing that make needs to do is link all the old and new compiled objects and then `make install` them into the package directory. Am I wrong?

Offline

#8 2017-04-09 10:18:07

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

Re: [SOLVED] Applying an incremental patch to a custom kernel

Ah, yes.  That sounds correct.  I missed the fact that the patch was an incremental patch for the purpose of going from one version to the other.  I assumed it was some other patch (e.g., some particular driver fix or something).

If you do have an incremental patch from exactly the version you previously compiled to the new one you want to compile, then you could change the pkgver, apply the patch manually, and the use `makepkg -e`.

You could probably also apply the patch in the PKGBUILD if you wanted to automated it a bit, but to do so you'd have to slightly abuse the PKGBUILD structure and put the patch in the build() function rather than a prepare() function where it would normally belong.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#9 2017-04-09 11:39:54

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,868

Re: [SOLVED] Applying an incremental patch to a custom kernel

Evilrob, this sounds look you would benefit from using Ccache .


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

Board footer

Powered by FluxBB