Out-of-tree kernel modules
The information on this page is obsolete. Alpine has akms now. |
Introduction
Wireguard found its way into the official kernel tree. But this is just an example, there is more kernel code that gets developed as out of tree module before it finds its way upstream. |
Drivers in the Linux kernel can either be built into the kernel, or built as modules that stay on disk and get loaded as needed. The modules that can be generated while building the kernel package are called in-tree (because the source code lives in the kernel source tree). There are also out-of-tree modules, for which the source code is located elsewhere. One popular example is wireguard, which is as time of writing, an out-of-tree kernel module.
These out-of-tree modules must be built against the specific kernel source code, that your target device is using, and this is a challenge on its own. Because there are many different Linux kernel packages that the user could install, especially in postmarketOS where we package a downstream kernel for every non-mainlined device. (But even in Alpine, there are various kernel packages to choose from.)
Alpine doesn't use DKMS
Many Linux distributions use DKMS, they install gcc and build the out-of-tree modules on the user's computer for the user's specific kernel just after that kernel has been installed or updated. Alpine does not use DKMS, it goes the route of compiling all out-of-tree modules for all available kernels and offering them as binary packages (e.g. wireguard-vanilla). This is acceptable in Alpine, as there's a low amount of available kernels and out-of-tree modules.
Alpine developers have expressed several times that they have no interest in adding DKMS to Alpine, because it requires installing the compiler and sources, and that goes against the minimal philosophy of Alpine.
How we had it in postmarketOS
For a short time, we also had the out-of-tree kernel module for wireguard working in postmarketOS. Eventually, this became too much maintenance effort and it was dropped. But for the record, here is how it was done:
- a wireguard-postmarketos-stable package (which worked only with linux-postmarketos-stable)
- a kernel-scripts package, which provides the "kernel scripts" for the right architecture, which are necessary to build the out-of-tree module (note that the
[ "$type" != "application/x-sharedlib" ]
bit from the patch had to be updated a few times afterwards, but the PR description explains in detail why the package is needed, that's why there's a link to the original PR.)
Related
- pmaports!538 Proposal for wireguard support without DKMS or the fragile out-of-tree build method from before
- pmaports!1851 DKMS for postmarketOS