unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Ivan Kozlov <kanichos@yandex.ru>
To: Danny Milosavljevic <dannym@scratchpost.org>
Cc: "41924@debbugs.gnu.org" <41924@debbugs.gnu.org>
Subject: [bug#41924] [PATCH] profiles: Make linux-module-database skip inappropriate inputs
Date: Fri, 19 Jun 2020 11:20:36 +0300	[thread overview]
Message-ID: <3181592520939@mail.yandex.ru> (raw)
In-Reply-To: <20200618201647.73f8b0d5@scratchpost.org>

Hi,

> 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.

The only way to do this sort of thing is to have the config. Otherwise the kernel will always sort of exist in a separate world. You can always compile it in a way that breaks the rest of the Guix system’s assumptions, e.g. by disabling the necessary system calls or cgroups controllers, and get no warnings/build failures. This applies to any extra kernel modules, too. I don’t think LKM support stands out. I actually don’t think it is a big problem that using an unofficial Linux package puts some burden on the maintainer, I merely want such setups to be possible.

The problem in question really applies to all cases when there aren’t any modules to deal with, as you correctly point out, not necessary having to do with CONFIG_MODULES; e.g. building a system with CONFIG_MODULES=y and no loadable modules, and no extra modules, is perfectly legitimate.

> 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)

It is possible to rely on the way operating-system-directory-base-entries builds the manifest to avoid this specific issue: (car #$(manifest-inputs manifest)) should be the kernel.

I haven’t really looked into the test suite, here is my guess:

diff --git a/gnu/tests/linux-modules.scm b/gnu/tests/linux-modules.scm
index 953b132ef7..2fc8f52b90 100644
--- a/gnu/tests/linux-modules.scm
+++ b/gnu/tests/linux-modules.scm
@@ -25,6 +25,7 @@
   #:use-module (gnu system)
   #:use-module (gnu system vm)
   #:use-module (gnu tests)
+  #:use-module (gnu tests base)
   #:use-module (guix derivations)
   #:use-module (guix gexp)
   #:use-module (guix modules)
@@ -129,3 +130,37 @@ with two extra modules.")
                                                  (package-arguments
                                                   ddcci-driver-linux))))))
            '("acpi_call" "ddcci")))))
+
+(define %test-no-loadable-kernel-modules
+  (let* ((kernel (package
+                   (inherit linux-libre)
+                   (arguments
+                    (substitute-keyword-arguments (package-arguments linux-libre)
+                      ((#:phases phases)
+                       `(modify-phases ,phases
+                          (add-before 'build 'no-lkm-config
+                            (lambda _
+                              (substitute* ".config"
+                                (("=m") "=y"))
+                              (let ((port (open-file ".config" "a")))
+                                (display "CONFIG_MODULES=n" port)
+                                (close-port port))))
+                          (replace 'install
+                            (lambda* (#:key outputs #:allow-other-keys)
+                              (for-each
+                               (let ((out (assoc-ref outputs "out")))
+                                 (lambda (file) (install-file file out)))
+                               (find-files "." "^(\\.config|bzImage|zImage|Image|vmlinuz|System\\.map|Module\\.symvers)$"))))))))))
+         (os (marionette-operating-system
+              (operating-system
+                (inherit (simple-operating-system))
+                (kernel kernel)
+                (initrd-modules '()))
+              #:imported-modules '((gnu services herd)
+                                   (guix combinators))))
+         (vm (virtual-machine os)))
+    (system-test
+     (name "no-loadable-kernel-modules")
+     (description "Build and run a basic system without loadable kernel module support")
+     (value (run-basic-test (virtualized-operating-system os '())
+                            #~(list #$vm))))))
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 25ff146bdf..abf0cf7f27 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1201,6 +1201,8 @@ for both major versions of GTK+."
   "Return a derivation that unites all the kernel modules of the manifest
 and creates the dependency graph of all these kernel modules.

+The first entry in the manifest must be a Linux kernel package.
+
 This is meant to be used as a profile hook."
   (define kmod  ; lazy reference
     (module-ref (resolve-interface '(gnu packages linux)) 'kmod))
@@ -1226,14 +1228,22 @@ This is meant to be used as a profile hook."
                  ;; Note: Should usually result in one entry.
                  (versions (delete-duplicates
                             (append-map directory-entries
-                                        module-directories))))
-              (match versions
-               ((version)
-                (let ((old-path (getenv "PATH")))
-                  (setenv "PATH" #+(file-append kmod "/bin"))
-                  (make-linux-module-directory inputs version #$output)
-                  (setenv "PATH" old-path)))
-               (_ (error "Specified Linux kernel and Linux kernel modules
+                                        (if (file-exists? (car module-directories))
+                                            module-directories
+                                            (cdr module-directories))))))
+            (match versions
+              ((version)
+               (let ((old-path (getenv "PATH")))
+                 (setenv "PATH" #+(file-append kmod "/bin"))
+                 (make-linux-module-directory inputs version #$output)
+                 (setenv "PATH" old-path)))
+              ;; Do nothing when there is nothing to do
+              (() (mkdir #$output))
+              ;; This might not catch a version incompatibility
+              ;; if all kernel modules reside in extra packages
+              ;; Would checking the kernel package version have
+              ;; undesirable effects?
+              (_ (error "Specified Linux kernel and Linux kernel modules
 are not all of the same version")))))))
   (gexp->derivation "linux-module-database" build
                     #:local-build? #t





      parent reply	other threads:[~2020-06-19  8:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-17 18:44 [bug#41924] [PATCH] profiles: Make linux-module-database skip inappropriate inputs Ivan Kozlov
2020-06-17 21:18 ` Ivan Kozlov
2020-06-18 18:16 ` Danny Milosavljevic
2020-06-19  7:47   ` Ludovic Courtès
2020-06-19 14:23     ` Ivan Kozlov
2020-06-19 20:27       ` bug#41924: " Ludovic Courtès
2020-06-19  8:20   ` Ivan Kozlov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3181592520939@mail.yandex.ru \
    --to=kanichos@yandex.ru \
    --cc=41924@debbugs.gnu.org \
    --cc=dannym@scratchpost.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).