Downstream kernel specific package

Unless a device has been mainlined, we need to package the downstream kernel (also called "vendor kernel"). This is the reference for the files of vendor kernels.

Generate a template
Usually you would generate both a new device specific package and a new vendor kernel package by running  and typing in a new device name. In case you should only have a device package, but not a kernel package, you can regenerate the latter with  (you guessed it, changeme needs to be adjusted).

The template gets improved every now and then to make porting easier, so don't be surprised when you are looking at older ports and their APKBUILDs look a bit more complicated than what gets generated from the latest  version. Essentially they are doing the same thing.

Modernize your aport
To recreate your vendor kernel aport on top of the latest (and therefore most readable) template, do the following steps:

downstreamkernel_prepare
Newly generated downstream kernel packages use the  script. That way we can share code between the APKBUILDs, so it is less redundant. To see what the function does, read the source over here.

It is supposed to be sourced, so the content of the script gets executed in the current shell. This is done with the dot in-front of the script name:

Note that this behavior had changed in. Out of tree device ports may not have been adjusted yet and still pass arguments to the script. This is not supported anymore, adjust them like written above or consider modernizing the whole pmaport as explained earlier in this article.

GCC version
The kernel gets compiled with. Alpine Linux has been shipping version GCC 6 for a long time, but changed the default GCC version to GCC 8 in September 2018. It was discovered that at least one vendor kernel does not boot when compiled with GCC 8, so we ended up packaging GCC 6 side by side with GCC 8. All existing 3.x vendor kernels that were packaged have been adjusted to use GCC 6 at this point in time, just to make sure we don't introduce any breakage there. The default for new packages is using the current GCC version that is packaged in Alpine (at time of writing: GCC 8).

Use GCC 4
Follow the GCC 6 instructions below, but replace 6 with 4 everywhere.

Use GCC 6
If your new kernel port does not boot at all, or it doesn't even compile, please try to compile it with GCC 6 and see if it works then.

To do that, open  and add these lines:

between  and   lines.

Then add  to the kernel's   line.

Technical detail: the  guard around setting the variables is necessary, because the   and   variables extend themselves. will parse the  a second time while running the   step (inside fakeroot). So without the  statement, we will end up with   instead of   which gets problematic if you are calling   to install kernel modules in the package section (as done in   for example). Interestingly, only  and   gets passed through, hence we can't simply check the   variable.

Use the newest GCC from Alpine
Let's say you are using a device that has already been packaged, and you want to figure out if it also boots when compiled with a newer compiler. Just removing HOSTCC vars and references to them should be enough:

Remove these lines:

And remove the mention of  in invocation of.

Then remove the  package from the   line.

Afterwards, remove the  file from the aport dir, and from the   line. Instead you will probably need other patches as linked here. First try compiling without patches, then add one patch at a time to fix a specific problem. As usually, with, you can regenerate the checksums at the bottom of the file, this needs to be done whenever you change.

When you made it boot successfully, please increase the  and make a merge request.

Using a specific kernel image
By default downstreamkernel_package.sh looks for a few kernel image files such as  and , but for various reasons you may want/need to look for something else; in these situations set   similar to the following:

heimdall-isorec
If you have a device that only boots with heimdall-isorec, you will need to adjust your linux APKBUILD as follows:
 * add  to makedepends
 * copy the "init" file from and customize the partition
 * add "init" to  in the APKBUILD
 * adjust your  like it's done in   and adjust the paths in there

You can search for more examples of heimdall-isorec deviecs with grep: