Instead of using the mkosi.default symlink, use an env var passed from
the build system. We would need to pass the --default switch nonetheless
or change the symlink, making the git tree dirty.
Also, search for installed kernel headers in a way that's compatible
with more distros. On Fedora, for example, the
/usr/lib/modules/<kver>/build symlink is only available if there's a
kernel installed. We don't care about a kernel installed since we don't
need to boot it on a real machine: the only thing we need is the
kernel-devel package.
# mkosi
# ------------------------------------------------------------------------------
+DISTRO ?= "arch"
+
mkosi:
-$(MKDIR_P) $(top_srcdir)/testsuite/mkosi/mkosi.cache
- $(MKOSI) -C $(top_srcdir)/testsuite/mkosi --build-sources ../../ -fi
+ $(MKOSI) -C $(top_srcdir)/testsuite/mkosi --build-sources ../../ --default mkosi.${DISTRO} -fi
-/image.raw*
+/*-image.raw*
/.mkosi-*
/mkosi.cache
-/rootfs
Distribution=arch
Release=(rolling)
+[Output]
+Output = arch-image.raw
+
[Packages]
Packages = valgrind
BuildPackages =
#!/bin/bash -ex
+function find_kdir() {
+ local kdirs=(/usr/lib/modules/*/build/Makefile /usr/src/kernels/*/Makefile)
+ local kdir=""
+
+ for f in "${kdirs[@]}"; do
+ if [ -f "$f" ]; then
+ kdir=$f
+ break
+ fi
+ done
+
+ if [ -z "$kdir" ]; then
+ printf '==> Unable to find kernel headers to build modules for tests\n' >&2
+ exit 1
+ fi
+
+ kdir=${kdir%/Makefile}
+
+ echo $kdir
+}
+
if [ -f configure ]; then
make distclean
fi
mkdir build
cd build
-kdirs=(/usr/lib/modules/*/build/Makefile)
-if [[ ! -f ${kdirs[0]} ]]; then
- printf '==> Unable to find kernel headers to build modules for tests\n' >&2
- return 1
-fi
-
-kdir=${kdirs[0]%/Makefile}
+kdir=$(find_kdir)
IFS=/ read _ _ _ kver _ <<<"$kdir"
../autogen.sh c
+++ /dev/null
-mkosi.arch
\ No newline at end of file