guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] linux-initrd: Make platform-specific linux modules optional


From: Mark H Weaver
Subject: [PATCH] linux-initrd: Make platform-specific linux modules optional
Date: Sun, 23 Aug 2015 14:14:13 -0400

I now have GuixSD running well on my MIPS-based Lemote Yeeloong 8101B
with XFCE, and many of the patches are now ready for submission
upstream.  Here's the first.

Our 'base-initrd' has a hard-coded set of modules to include, some of
which are only available on Intel platforms.  It does not accept a
'system' argument, so it's not clear to me how to parameterize the set
of modules based on the system.  Since 'base-initrd' is used within OS
configuration files and thus a part of our API, I was reluctant to add
'system' to its argument list.

So, the approach I took here is to allow some of the modules to be
optional, such that if they are not available, a warning is issued but
not an error.  I'm not wedded to this approach, and am open to
suggestions.

What do you think?

      Mark


>From 6201794d7a1aa36b5596048b890d65c0635e0d14 Mon Sep 17 00:00:00 2001
From: Mark H Weaver <address@hidden>
Date: Sun, 9 Aug 2015 03:40:25 -0400
Subject: [PATCH] linux-initrd: Make platform-specific linux modules optional.

* gnu/system/linux-initrd.scm (flat-linux-module-directory): Add
  'optional-modules' argument.  Add 'required?' argument to internal 'lookup'
  procedure.  Use it when producing the list of modules to copy.
  (base-initrd): Add 'optional-linux-modules' internal variable.  Pass it to
  'flat-linux-module-directory'.  Move 'pata_acpi', 'pata_atiixp' and 'isci'
  from 'linux-modules' to 'optional-linux-modules'.
---
 gnu/system/linux-initrd.scm | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 48b855b..b2d961b 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <address@hidden>
+;;; Copyright © 2015 Mark H Weaver <address@hidden>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -85,13 +86,14 @@ MODULES is a list of Guile module names to be embedded in 
the initrd."
                                  (gnu build linux-initrd))
                      #:references-graphs `(("closure" ,init)))))
 
-(define (flat-linux-module-directory linux modules)
+(define (flat-linux-module-directory linux modules optional-modules)
   "Return a flat directory containing the Linux kernel modules listed in
 MODULES and taken from LINUX."
   (define build-exp
     #~(begin
         (use-modules (ice-9 match) (ice-9 regex)
                      (srfi srfi-1)
+                     (srfi srfi-26)
                      (guix build utils)
                      (gnu build linux-modules))
 
@@ -102,22 +104,29 @@ MODULES and taken from LINUX."
         (define module-dir
           (string-append #$linux "/lib/modules"))
 
-        (define (lookup module)
+        (define (lookup module required?)
           (let ((name (ensure-dot-ko module)))
             (match (find-files module-dir (string->regexp name))
               ((file)
                file)
               (()
-               (error "module not found" name module-dir))
+               (if required?
+                   (error "module not found" name module-dir)
+                   (begin
+                     (format #t "warning: module not found: ~a~%" name)
+                     #f)))
               ((_ ...)
                (error "several modules by that name"
                       name module-dir)))))
 
         (define modules
-          (let ((modules (map lookup '#$modules)))
+          (let ((modules
+                 (append (map        (cut lookup <> #t) '#$modules)
+                         (filter-map (cut lookup <> #f) '#$optional-modules))))
             (append modules
                     (recursive-module-dependencies modules
-                                                   #:lookup-module lookup))))
+                                                   #:lookup-module
+                                                   (cut lookup <> #t)))))
 
         (mkdir #$output)
         (for-each (lambda (module)
@@ -178,8 +187,6 @@ loaded at boot time in the order in which they appear."
   (define linux-modules
     ;; Modules added to the initrd and loaded from the initrd.
     `("ahci"                                  ;for SATA controllers
-      "pata_acpi" "pata_atiixp"               ;for ATA controllers
-      "isci"                              ;for SAS controllers like Intel C602
       "usb-storage" "uas"                     ;for the installation image etc.
       "usbkbd" "usbhid"                       ;USB keyboards, for debugging
       ,@(if (or virtio? qemu-networking?)
@@ -196,6 +203,12 @@ loaded at boot time in the order in which they appear."
             '())
       ,@extra-modules))
 
+  (define optional-linux-modules
+    ;; Like linux-modules (above), but if these modules are not available, a
+    ;; warning is issued instead of an error.
+    `("pata_acpi" "pata_atiixp"           ;for ATA controllers
+      "isci"))                            ;for SAS controllers like Intel C602
+
   (define helper-packages
     ;; Packages to be copied on the initrd.
     `(,@(if (find (lambda (fs)
@@ -217,8 +230,10 @@ loaded at boot time in the order in which they appear."
              (open source target)))
          mapped-devices))
 
-  (mlet %store-monad ((kodir (flat-linux-module-directory linux
-                                                          linux-modules)))
+  (mlet %store-monad ((kodir (flat-linux-module-directory
+                              linux
+                              linux-modules
+                              optional-linux-modules)))
     (expression->initrd
      #~(begin
          (use-modules (gnu build linux-boot)
-- 
2.5.0


reply via email to

[Prev in Thread] Current Thread [Next in Thread]