guix-commits
[Top][All Lists]
Advanced

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

07/15: linux-initrd: Make platform-specific linux modules optional.


From: Mark H. Weaver
Subject: 07/15: linux-initrd: Make platform-specific linux modules optional.
Date: Mon, 24 Aug 2015 03:16:32 +0000

mhw pushed a commit to branch wip-loongson2f
in repository guix.

commit d05a9d8a1d993f5445657142e52124509850edf7
Author: Mark H Weaver <address@hidden>
Date:   Sun Aug 9 03:40:25 2015 -0400

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



reply via email to

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