sys-kernel/coreos-kernel: Decompress the minimal initrd kernel modules

The initrd itself is already compressed with xz, so compressing the
modules within with xz as well just makes the image bigger and slower.

Not compressing all the kernel modules in the first place is not such a
clear win because it is zlib and zstd compression that is applied
elsewhere.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
This commit is contained in:
James Le Cuirot 2025-10-28 14:38:25 +00:00
parent 2874a9898a
commit 6de93722c2
No known key found for this signature in database
GPG Key ID: 1226415D00DD3137

View File

@ -108,15 +108,16 @@ src_compile() {
ln -s usr/lib64 lib || die ln -s usr/lib64 lib || die
ln -s usr/lib64 lib64 || die ln -s usr/lib64 lib64 || die
ln -s lib64 usr/lib || die ln -s lib64 usr/lib || die
mkdir -p lib/modules/"${KV_FULL}"/ || die
# Instead from ESYSROOT we can also copy kernel modules from the dracut pre-selection # Instead from ESYSROOT we can also copy kernel modules from the dracut pre-selection
cp "${S}"/build/bootengine/usr/lib/modules/"${KV_FULL}"/modules.* lib/modules/"${KV_FULL}"/ || die
mkdir -p lib/modprobe.d/ || die mkdir -p lib/modprobe.d/ || die
cp "${S}"/build/bootengine/lib/modprobe.d/* lib/modprobe.d/ || die cp "${S}"/build/bootengine/lib/modprobe.d/* lib/modprobe.d/ || die
# Only include modules related to mounting /usr and for interacting with the emergency console # Only include modules related to mounting /usr and for interacting with the emergency console
pushd "${S}/build/bootengine/usr/lib/modules/${KV_FULL}" || die pushd "${S}/build/bootengine/usr/lib/modules/${KV_FULL}" || die
find kernel/drivers/{ata,block,hid,hv,input/serio,mmc,nvme,pci,scsi,usb} kernel/fs/{btrfs,overlayfs,squashfs} kernel/security/keys -name "*.ko.*" -printf "%f\0" | DRACUT_NO_XATTR=1 xargs --null "${BROOT}"/usr/lib/dracut/dracut-install --destrootdir "${S}"/build/minimal --kerneldir . --sysrootdir "${S}"/build/bootengine/ --firmwaredirs "${S}"/build/bootengine/usr/lib/firmware --module dm-verity dm-mod virtio_console || die find kernel/drivers/{ata,block,hid,hv,input/serio,mmc,nvme,pci,scsi,usb} kernel/fs/{btrfs,overlayfs,squashfs} kernel/security/keys -name "*.ko.*" -printf "%f\0" | DRACUT_NO_XATTR=1 xargs --null "${BROOT}"/usr/lib/dracut/dracut-install --destrootdir "${S}"/build/minimal --kerneldir . --sysrootdir "${S}"/build/bootengine/ --firmwaredirs "${S}"/build/bootengine/usr/lib/firmware --module dm-verity dm-mod virtio_console || die
popd || die popd || die
# Double compression only makes the image bigger and slower
find . -name "*.ko.xz" -exec unxz {} + || die
depmod -a -b . "${KV_FULL}" || die
echo '$MODALIAS=.* 0:0 660 @/sbin/modprobe "$MODALIAS"' > ./etc/mdev.conf || die echo '$MODALIAS=.* 0:0 660 @/sbin/modprobe "$MODALIAS"' > ./etc/mdev.conf || die
# We can't use busybox's modprobe because it doesn't support the globs in module.alias, breaking module loading # We can't use busybox's modprobe because it doesn't support the globs in module.alias, breaking module loading
DRACUT_NO_XATTR=1 "${BROOT}"/usr/lib/dracut/dracut-install --destrootdir . --sysrootdir "${ESYSROOT}" --ldd /bin/veritysetup /bin/dmsetup /bin/busybox /sbin/modprobe || die DRACUT_NO_XATTR=1 "${BROOT}"/usr/lib/dracut/dracut-install --destrootdir . --sysrootdir "${ESYSROOT}" --ldd /bin/veritysetup /bin/dmsetup /bin/busybox /sbin/modprobe || die