]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: generalize mkosi support for other distros
authorLucas De Marchi <lucas.demarchi@intel.com>
Wed, 3 Jan 2018 19:19:02 +0000 (11:19 -0800)
committerLucas De Marchi <lucas.demarchi@intel.com>
Wed, 3 Jan 2018 22:22:05 +0000 (14:22 -0800)
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.

Makefile.am
testsuite/mkosi/.gitignore
testsuite/mkosi/mkosi.arch
testsuite/mkosi/mkosi.build
testsuite/mkosi/mkosi.default [deleted symlink]

index 3ea42747b63ab759a8180a491ebcb42c0151ac57..7b01201f736b5cf07288da17a27b31dece287150 100644 (file)
@@ -503,6 +503,8 @@ tar-sync: kmod-$(VERSION).tar.xz kmod-$(VERSION).tar.sign
 # 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
index 024d05b174bfc4a5f6c3a6497e4aa79a7e93703f..0e0981a1d0353406828ae1328609b55a57dfd569 100644 (file)
@@ -1,4 +1,3 @@
-/image.raw*
+/*-image.raw*
 /.mkosi-*
 /mkosi.cache
-/rootfs
index 308dcdb9e1b3cfaad7df68fbf5b1b777f36bb9f8..5ac0a45370d1cf26f67ac23d442406b77e002637 100644 (file)
@@ -2,6 +2,9 @@
 Distribution=arch
 Release=(rolling)
 
+[Output]
+Output = arch-image.raw
+
 [Packages]
 Packages = valgrind
 BuildPackages =
index a6b325f55e7a626c2d7911299071f4faf3d90b87..53fc797b202035d03f97f6881fb2482cc052a17c 100755 (executable)
@@ -1,5 +1,26 @@
 #!/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
@@ -8,13 +29,7 @@ rm -rf build
 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
diff --git a/testsuite/mkosi/mkosi.default b/testsuite/mkosi/mkosi.default
deleted file mode 120000 (symlink)
index 695b71a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-mkosi.arch
\ No newline at end of file