Subject: [bug#41924] [PATCH] profiles: Make linux-module-database skip inappropriate inputs

From: Danny Milosavljevic <[email-masked]>
Date: Thu, 18 Jun 2020 20:16:47 +0200

Hi Ivan,

thanks for the patch, and for persevering on this.

Could you also add a system test to gnu/tests/linux-modules.scm ?

That would also mean that you'd create a variant of linux-libre that has
CONFIG_MODULES=n.

>                   (directory-entries
>                    (lambda (directory)
> -                    (scandir directory (lambda (basename)
> -                                         (not
> -                                           (string-prefix? "." basename))))))
> +                    (if (file-exists? directory)
> +                        (scandir directory (lambda (basename)
> +                                             (not
> +                                              (string-prefix? "." basename))))
> +                        '())))

That would silently skip packages that don't contain kernel modules (but for
example supertux or something), too, right?
(so misconfigured guix wouldn't be detected)

Also, if you tried to use a kernel without module support and then added modules
(for the wrong kernel, one with CONFIG_MODULES=y) via extra guix packages,
this would erroneously succeed, right?
(I guess depmod would have something against it, though.  Still, I'd like a test
for that)

Usually I'd be fine with these unsupported constellations, but misconfigured
kernel vs module ABI makes me reconsider my life choices, so probably not here :->

What I would do is try to find a file that's only in the kernel when there's
module support (/lib/modules doesn't count since there could be a kernel with
module support but no modules compiled), and then try to ascertain whether
CONFIG_MODULES=y that way, so
(define config-modules? (any (append-map directory-entries with marker-file)))
or something.

Then succeed either with config-modules? and at least one file per entry, or
with (not config-modules?) and no files anywhere.

Alternatively, we could at least make it only possible for the FIRST entry
in the list of module packages (which is the Linux kernel) to have no
/lib/modules, and not care about any of the other entries in that way.

> +               ;; Do nothing when there is nothing to do
> +               (() (mkdir #$output))

Good idea.