blue-build / modules

BlueBuild standard modules used for building your Atomic Images
Apache License 2.0
21 stars 27 forks source link

feat: `initramfs` module #241

Open fiftydinar opened 1 month ago

fiftydinar commented 1 month ago

Intro

This type of module would be unique in 1 way.

In my proposal, module would be automatically enabled for all BlueBuild images & it would always run last in the pipeline.

Reason

It makes it possible for the users to include stuff like modprobe or module configs in files, without need to manually fiddle with the initramfs regeneration script.

Linux distributions also do this for their own modifications.

I don't ever see the scenario of users needing to manually disable this, except to gain a little bit faster image-builds, which is not worth it imo.

It makes the 1 consistent script available for everyone to use, instead of it being scattered everywhere. This also makes it possible for the users to report issues or PR improvements to it in 1 consistent place, which is great.

For Fedora Atomic/Universal Blue, this is the script:

#!/usr/bin/env bash

set -euo pipefail

rpm-ostree cliwrap install-to-root /
QUALIFIED_KERNEL="$(rpm -qa | grep -P 'kernel-(\d+\.\d+\.\d+)' | sed -E 's/kernel-//')"
/usr/libexec/rpm-ostree/wrapped/dracut --no-hostonly --kver "${QUALIFIED_KERNEL}" --reproducible -v --add ostree -f "/lib/modules/${QUALIFIED_KERNEL}/initramfs.img"
chmod 0600 "/lib/modules/${QUALIFIED_KERNEL}/initramfs.img"

In the future, VanillaOS could be also easily supported here. They seem to use their custom update-initramfs. https://github.com/Vanilla-OS/ABRoot/blob/f818e46888642053900eccfd0a16758eb60bce15/cmd/update-initramfs.go

Additional options

Maybe we would add option to specify type: initramfs just for making initramfs options available to customize. Like compression method for example.

Defaults would be optimized for the best operation (like Fedora defaults are).

Potential blockers

Usage of custom kernel in the image. QUALIFIED_KERNEL logic should be improved to be more universally compatible.

xynydev commented 1 month ago

Great! If it works and is that simple, that's amazing.

In my proposal, module would be automatically enabled for all BlueBuild images & it would always run last in the pipeline.

I would rather tuck it down with the signing module in the template, making it just a normal module that one can remove if they wish. Of course, existing users would have to be informed about this, and they could just add the module if they want or need to.