From d12e9bdc768532d76c680879271e495e4fd93743 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 9 Sep 2022 08:53:37 +0200 Subject: mkosi: Optionally build a kernel image from mkosi.kernel/ If mkosi.kernel/ exists, the mkosi script will try to build a kernel image from it. We use the architecture defconfig as a base and add our own extra configuration on top. We also add some extra tooling to the build image required to build the kernel and include some documentation in HACKING.md on how to use this new feature. To avoid the kernel sources from being copied into the build or final image (which we don't want because it takes a while), we put the mkosi.kernel/ directory in .gitignore and use "SourceFileTransfer=mount" so that the sources are still accessible in the build image. --- mkosi.build | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'mkosi.build') diff --git a/mkosi.build b/mkosi.build index 1154e738f4..7a32673bb4 100755 --- a/mkosi.build +++ b/mkosi.build @@ -259,3 +259,40 @@ fi # Make sure services aren't enabled by default on Debian/Ubuntu. mkdir -p "$DESTDIR/etc/systemd/system-preset" echo "disable *" > "$DESTDIR/etc/systemd/system-preset/99-mkosi.preset" + +if [ -d mkosi.kernel/ ]; then + cd "$SRCDIR/mkosi.kernel" + mkdir -p "$BUILDDIR/mkosi.kernel" + + make O="$BUILDDIR/mkosi.kernel" defconfig + + scripts/config \ + --file $BUILDDIR/mkosi.kernel/.config \ + --enable BPF_SYSCALL \ + --enable BPF_JIT \ + --enable BPF_JIT_ALWAYS_ON \ + --enable BPF_JIT_DEFAULT_ON \ + --enable BPF_UNPRIV_DEFAULT_OFF \ + --enable USERMODE_DRIVER \ + --enable BPF_PRELOAD \ + --enable BPF_PRELOAD_UMD \ + --enable BPF_LSM \ + --enable BTRFS_FS \ + --enable BTRFS_FS_POSIX_ACL \ + --enable PSI \ + --enable CGROUPS \ + --enable CGROUP_BPF \ + --enable MEMCG \ + --enable MEMCG_SWAP \ + --enable MEMCG_KMEM + + # Make sure all unset options are set to their default value. + make O="$BUILDDIR/mkosi.kernel" olddefconfig + + make O="$BUILDDIR/mkosi.kernel" -j "$(nproc)" + + KERNEL_RELEASE="$(make O=$BUILDDIR/mkosi.kernel -s kernelrelease)" + mkdir -p "$DESTDIR/usr/lib/modules/$KERNEL_RELEASE" + make O="$BUILDDIR/mkosi.kernel" INSTALL_MOD_PATH="$DESTDIR/usr" modules_install + make O="$BUILDDIR/mkosi.kernel" INSTALL_PATH="$DESTDIR/usr/lib/modules/$KERNEL_RELEASE" install +fi -- cgit v1.2.1