summaryrefslogtreecommitdiff
path: root/mkosi.build
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2022-09-09 08:53:37 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2022-09-29 20:15:57 +0200
commitd12e9bdc768532d76c680879271e495e4fd93743 (patch)
tree1cb101f85323544ffb054fdc6693f3561fa1ef8b /mkosi.build
parent3e139a8e64820bf59552073524b21620d344fae7 (diff)
downloadsystemd-d12e9bdc768532d76c680879271e495e4fd93743.tar.gz
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.
Diffstat (limited to 'mkosi.build')
-rwxr-xr-xmkosi.build37
1 files changed, 37 insertions, 0 deletions
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