Builds the Linux kernel into OCI images.
This repo is a series of helper scripts and Github Actions that
- Use config.yaml and various scripts in
hack/buildto generate a matrix of kernel upstream versions, variants, and flavors to be built. - Fetches
kernel.orgtarballs, applies custom config flags, and patches, depending on version, flavor and variant. - Builds those kernels for x86_64/arm64.
See the configs directory for more info.
See the patches directory for the current set of patches Edera carries against upstream kernels.
Note that not all the patches will be applied to all kernel versions, this is driven by version constraints in config.yaml.
- Fork this repo into your Github org/account.
- Inspect the Github Action file .github/workflows/build.yaml:
- This will use the default
GITHUB_TOKENgranted to all Github Action workflows by default to push OCI images toghcr.ioin your fork's context. Refer to Github's documentation for details on access permissions and howGITHUB_TOKENworks. - You should not need to make changes to this file, but it is best practice to understand what an Action does and what permissions it expects before you run it.
- This will use the default
- Edit config.yaml in the root of your fork:
- Edit the line
imageNameFormat: "ghcr.io/edera-dev/[image]:[tag]"and change it toimageNameFormat: "ghcr.io/<your GH org>/[image]:[tag]" - Add or remove any
Kconfigoptions you want to theflavorandvariantKconfig fragments in configs, as outlined by the README in that folder. - Commit those changes to
mainin your fork.
- Edit the line
- From your forked repository's
Actionstab, run theBuild Kernelsjob with a Build Specification like:stable:flavor=zone,host. This will buildzoneandhostkernel flavors usingstablekernel.org releases for all current LTS kernels.
For most of the kernels in this registry, debugging symbols and features are disabled, to keep the kernel artifacts small.
You may want or need to build your own debugging kernel with custom patches/options locally, and publish it to a transient OCI registry (like ttl.sh) for testing purposes.
To do this, you will need docker installed and configured correctly to support cross-builds (docker buildx) in your local environment.
The simplest way to do that is to
-
Clone this repo locally:
git clone [email protected]:edera-dev/linux-kernel-oci.git -
Manually edit config.yaml on-disk:
-
to change the
imageNameFormatkey to push to an OCI registry you have access to. -
to change the
architecturesYAML key to only include the architectures you care about (x86_64, arm64, or both -docker buildxis used so you can build arm64 on x86_64 and vice-versa). -
to change the
flavorsYAML key to only include the flavors you care about (host, or zone, or both). -
to change the
versionsYAML key to only include thekernel.orgversions you care about. For instance, to only build the latest5.4kernel.org upstream release, use:versions: - series: '5.4'
-
For example, if I wanted to only build the
zonekernel flavor, only forx86_64, only the latest6.15point release, and tag the result for a customttl.sh/hackbenregistry, the final result would look something like this:imageNameFormat: "ttl.sh/hackben/[image]:[tag]" architectures: - x86_64 flavors: - name: zone-debu constraints: series: - '6.15' versions: - current: true
-
-
Add or remove any
Kconfigoptions you want to theflavorandvariantKconfig fragments in configs, as outlined by the README in that folder. -
Run hack/build/docker-build.sh
- It is important you follow the previous step, and edit the config.yaml locally to reduce the number of kernels the script will try to build, or you may end up building 15+ different kernels in parallel on your local box, which will take a very, very long time.
- When this command runs, it will generate a build matrix and print out what it will build.
-
When the above command finishes, you can see the local OCI images that were built by running
docker image list. The images will be tagged with the repo you specified inimageNameFormatin the config.yaml. -
From this point, you may push those images to an OCI registry with standard commands like
docker image push <image tag>, and consume them how you wish. -
If you wish to unpack and inspect the final image (for instance, to make sure certain modules or firmware exist in the correct paths, or that the final
config.gzhas the options you expect), you can do the following to fetch and extract the image artifact you just pushed to your local disk withcrane:crane export ttl.sh/hackben/zone-kernel:6.15.6 - --platform=linux/amd64 | tar --keep-directory-symlink -xf - -C . cd `kernel` zcat config.gz unsquashfs addons.squashfs ...
