Custom kernel build

Turns out that building a custom kernel for ArchLinux isn’t as easy as it seems. Just changing $pkgver in the official PKGBUILD doesn’t work, because it doesn’t fetch the sources from the official git tree, but from a clone on github. Here’s how to do it as of 2021-07-31:

  1. Change pkgbase to e.g. linux-ryzen
  2. Change pkgver to the version you want to compile

Then change the sources array to:

"$_srcname::git+https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git#tag=v${pkgver}"

This will clone the stable source tree HEAD. To checkout a specific version, add the following to prepare() after cd $_srcname:

echo "Checking out $_srctag"
git checkout "v${pkgver}"

If you want to save some time, remove make htmldocs from build() and the equivalent from pkgname() at the bottom.

Share and enjoy!