From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark H Weaver Subject: [PATCH] linux-initrd: Make platform-specific linux modules optional Date: Sun, 23 Aug 2015 14:14:13 -0400 Message-ID: <87io85x47e.fsf@netris.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTZn4-0004Qo-8p for guix-devel@gnu.org; Sun, 23 Aug 2015 14:14:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZTZn0-0003kw-79 for guix-devel@gnu.org; Sun, 23 Aug 2015 14:14:46 -0400 Received: from world.peace.net ([50.252.239.5]:47877) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTZn0-0003kp-2d for guix-devel@gnu.org; Sun, 23 Aug 2015 14:14:42 -0400 List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-linux-initrd-Make-platform-specific-linux-modules-op.patch Content-Transfer-Encoding: quoted-printable Content-Description: [PATCH] linux-initrd: Make platform-specific linux modules optional >From 6201794d7a1aa36b5596048b890d65c0635e0d14 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Sun, 9 Aug 2015 03:40:25 -0400 Subject: [PATCH] linux-initrd: Make platform-specific linux modules optiona= l. * gnu/system/linux-initrd.scm (flat-linux-module-directory): Add 'optional-modules' argument. Add 'required?' argument to internal 'looku= p' 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 =C2=A9 2013, 2014, 2015 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2015 Mark H Weaver ;;; ;;; 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))))) =20 -(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)) =20 @@ -102,22 +104,29 @@ MODULES and taken from LINUX." (define module-dir (string-append #$linux "/lib/modules")) =20 - (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))))) =20 (define modules - (let ((modules (map lookup '#$modules))) + (let ((modules + (append (map (cut lookup <> #t) '#$modules) + (filter-map (cut lookup <> #f) '#$optional-module= s)))) (append modules (recursive-module-dependencies modules - #:lookup-module lookup)= ))) + #:lookup-module + (cut lookup <> #t))))) =20 (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)) =20 + (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)) =20 - (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) --=20 2.5.0 --=-=-=--