* [PATCH] linux-initrd: Make platform-specific linux modules optional
@ 2015-08-23 18:14 Mark H Weaver
2015-08-27 21:16 ` Ludovic Courtès
0 siblings, 1 reply; 2+ messages in thread
From: Mark H Weaver @ 2015-08-23 18:14 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 794 bytes --]
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
[-- Attachment #2: [PATCH] linux-initrd: Make platform-specific linux modules optional --]
[-- Type: text/x-patch, Size: 5094 bytes --]
From 6201794d7a1aa36b5596048b890d65c0635e0d14 Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw@netris.org>
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 <ludo@gnu.org>
+;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
;;;
;;; 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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] linux-initrd: Make platform-specific linux modules optional
2015-08-23 18:14 [PATCH] linux-initrd: Make platform-specific linux modules optional Mark H Weaver
@ 2015-08-27 21:16 ` Ludovic Courtès
0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2015-08-27 21:16 UTC (permalink / raw)
To: Mark H Weaver; +Cc: guix-devel
Mark H Weaver <mhw@netris.org> skribis:
> 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.
Yaay, awesome!
> 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.
What about using (%current-system) in the definition of the
‘linux-modules’ variable? (At that point, it should have the correct
value.) This would probably be simpler.
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-27 21:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-23 18:14 [PATCH] linux-initrd: Make platform-specific linux modules optional Mark H Weaver
2015-08-27 21:16 ` Ludovic Courtès
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).