From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 0LCAISs3cGL84gAAbAwnHQ (envelope-from ) for ; Mon, 02 May 2022 21:55:23 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id EE5yICs3cGJdSgEAG6o9tA (envelope-from ) for ; Mon, 02 May 2022 21:55:23 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id AD260152B1 for ; Mon, 2 May 2022 21:55:22 +0200 (CEST) Received: from localhost ([::1]:44644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nlc8f-0003lp-95 for larch@yhetil.org; Mon, 02 May 2022 15:55:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlc8N-0003kN-Cx for guix-patches@gnu.org; Mon, 02 May 2022 15:55:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:44144) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nlc8M-0004mC-Qk for guix-patches@gnu.org; Mon, 02 May 2022 15:55:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nlc8M-0007Hp-OW for guix-patches@gnu.org; Mon, 02 May 2022 15:55:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55231] [PATCH v1] initrd: Allow extra search paths with =?UTF-8?Q?=E2=80=98initrd-extra-module-paths=E2=80=99?= Resent-From: Brian Cully Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 02 May 2022 19:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55231 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 55231@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.165152125227834 (code B ref -1); Mon, 02 May 2022 19:55:02 +0000 Received: (at submit) by debbugs.gnu.org; 2 May 2022 19:54:12 +0000 Received: from localhost ([127.0.0.1]:38041 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nlc7W-0007Eo-QW for submit@debbugs.gnu.org; Mon, 02 May 2022 15:54:11 -0400 Received: from lists.gnu.org ([209.51.188.17]:53716) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nlc7V-0007EY-Hr for submit@debbugs.gnu.org; Mon, 02 May 2022 15:54:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlc7V-0003im-7Q for guix-patches@gnu.org; Mon, 02 May 2022 15:54:09 -0400 Received: from coleridge.kublai.com ([166.84.7.167]:53283 helo=mail.spork.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlc7T-0004gU-3g for guix-patches@gnu.org; Mon, 02 May 2022 15:54:08 -0400 Received: from ditto (unknown [IPv6:2001:470:1f07:1b9:8650:a942:ec5e:856b]) by mail.spork.org (Postfix) with ESMTPSA id AAD7D5717 for ; Mon, 2 May 2022 15:53:15 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=spork.org; s=dkim; t=1651521195; bh=u+B+QyVD+9RTOMbyzoXzK6TU4GFt79n3l1oU6PKQJI4=; h=From:To:Subject:Date; b=iAiqhE7p1+86cqE/QfFtAmUv/a0C43yTldM18CZz6yFy6+QnFTKlhlySCpUdMcPh3 AqKxzxQWZnl/b02PFZY7Q39Hg6tVgzgFJjXf1RXB9QOOqAEa/UtK+LYmJloxdK/OGY xr64CNKYwjX22yoXj6ArB5EaJJJvnRHc3gb96uWo= User-agent: mu4e 1.6.10; emacs 28.1 Date: Mon, 2 May 2022 15:11:30 -0400 Message-ID: <87wnf3pv87.fsf@ditto.jhoto.spork.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=166.84.7.167; envelope-from=bjc@spork.org; helo=mail.spork.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" Reply-to: Brian Cully X-ACL-Warn: , Brian Cully via Guix-patches From: Brian Cully via Guix-patches via X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1651521323; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=CT3w6hhUDVKX1pwdap+WKfPr2dxYOKS0LVH2hF+QNco=; b=egkhmyIfjbjEHtgS4arqimIaL++dKOL9yDZktjj/x1jMRMViJo9hIOGbThr6xfdS/juplb wGTlR/eBPiVNA9ZG0G9VSTt8xu6s3gM59wwehkDi36xh8G2jV6zrUxH+cryM8yn7zjwT0S 2r0sjYywmycOECSF7FOOehccdjzF7rcVCKcZZZxUMHK/+c6D5ydVOyzw8gsIBOD/1OT1Nh fGYUJ/dwjKb4ihTMbJwir3ddViw8RxlAnxl+OpQ2nlYEPEf8LO4nnx04hOGQJX98wp46Oc htbP5U4AIzQkc6GOpXt1KhaoVa1zDHWGmDiiCEY6C685kv259kzkBhSzDaaWNg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1651521323; a=rsa-sha256; cv=none; b=YwE1gkEN5D8ZWdDLesFBAhyPdfSz2kI7kqVjFMzGA1t7sTqCLbSJ1VBpbrYg8SbQ8Ut7Vd DvwSUCpmGXcgpuLBuLoancY/PBf0upTnfSd6BbQgDafCaFeT5jufOe2StGlBq3wQuGiHfq zDv7JkbphLBl5pVFkb05NuunSjeUWs7Obqxux18Tie/fqvhhnUEIeLJcadoJOoER9EuVAA k1xFQM4ic+Owd1a3paNTIeLpgOGeKsYhvVp5/sQfedi0dgjbcyjk4U8n2pY1I8l5Q3RZVB LKQbWgpR1B1H0ZZM00PWgBp4mPRVz9/F12r5GwHC1PrsmIfqXFHUYhJky83/TA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=spork.org header.s=dkim header.b=iAiqhE7p; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.48 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=spork.org header.s=dkim header.b=iAiqhE7p; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: AD260152B1 X-Spam-Score: -3.48 X-Migadu-Scanner: scn0.migadu.com X-TUID: guxovtpxnmV6 This patch allows copying of out-of-tree kernel modules to the Linux initrd. For out-of-tree modules to found, an extra slot has been added to =E2=80=98operating-system=E2=80=99: =E2=80=98initrd-extra-module-paths=E2= =80=99, which contains a list containing items of either FILE-LIKE or (FILE-LIKE OUTPUT) which will be searched for modules in addition to the standard Linux module path. The required modules can then be added to =E2=80=98initrd-modules=E2=80=99 as n= ormal and all paths will be searched for it, including for any modules depended on. * gnu/build/linux-modules.scm (find-module-file): change DIRECTORY argument= to DIRECTORIES. Now takes a list of directories to search, rather than a single one. * gnu/system.scm : Add INITRD-EXTRA-MODULE-PATHS field and accessor. Takes a list of file-like objects. * gnu/system/linux-initrd.scm (flat-linux-module-directory): change LINUX argument to PACKAGES. Now contains a list of file-likes to search for modul= es. (raw-initrd): Add LINUX-EXTRA-MODULE-PATHS keyword argument. Pass it to (flat-linux-extra-module-paths) along with the selected LINUX package. (base-initrd): Add LINUX-EXTRA-MODULE-PATHS keyword argument. Pass it to (raw-initrd). --- gnu/build/linux-modules.scm | 19 ++++++++------ gnu/system.scm | 5 ++++ gnu/system/linux-initrd.scm | 52 +++++++++++++++++++++++++------------ 3 files changed, 51 insertions(+), 25 deletions(-) diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm index 053720574b..97b7e429ea 100644 --- a/gnu/build/linux-modules.scm +++ b/gnu/build/linux-modules.scm @@ -225,8 +225,8 @@ (define (file-name->module-name file) '.ko[.gz|.xz]' and normalizing it." (normalize-module-name (strip-extension (basename file)))) =20 -(define (find-module-file directory module) - "Lookup module NAME under DIRECTORY, and return its absolute file name. +(define (find-module-file directories module) + "Lookup module NAME under DIRECTORIES, and return its absolute file name. NAME can be a file name with or without '.ko', or it can be a module name. Raise an error if it could not be found. =20 @@ -247,16 +247,19 @@ (define names (else chr))) module)))) =20 - (match (find-files directory - (lambda (file stat) - (member (strip-extension - (basename file)) names))) + (match (append-map (lambda (directory) + (find-files directory + (lambda (file _stat) + (member (strip-extension + (basename file)) + names)))) + directories) ((file) file) (() - (error "kernel module not found" module directory)) + (error "kernel module not found" module directories)) ((_ ...) - (error "several modules by that name" module directory)))) + (error "several modules by that name" module directories)))) =20 (define* (recursive-module-dependencies files #:key (lookup-module dot-ko)) diff --git a/gnu/system.scm b/gnu/system.scm index c3810cbeeb..15ac30c933 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -103,6 +103,7 @@ (define-module (gnu system) operating-system-label operating-system-default-label operating-system-initrd-modules + operating-system-initrd-extra-module-paths operating-system-initrd operating-system-users operating-system-groups @@ -232,6 +233,8 @@ (define-record-type* operating-system (initrd-modules operating-system-initrd-modules ; list of strings (thunked) ; it's system-dependent (default %base-initrd-modules)) + (initrd-extra-module-paths operating-system-initrd-extra-module-paths ; = list of file-likes + (default '())) =20 (firmware operating-system-firmware ; list of packages (default %base-firmware)) @@ -1307,6 +1310,8 @@ (define make-initrd #:linux (operating-system-kernel os) #:linux-modules (operating-system-initrd-modules os) + #:linux-extra-module-paths + (operating-system-initrd-extra-module-paths os) #:mapped-devices mapped-devices #:keyboard-layout (operating-system-keyboard-layout os))) =20 diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm index 4c4c78e444..50a182d7d5 100644 --- a/gnu/system/linux-initrd.scm +++ b/gnu/system/linux-initrd.scm @@ -119,13 +119,23 @@ (define builder `(#:references-graphs (("closure" ,init)))) "/initrd.cpio.gz")) =20 -(define (flat-linux-module-directory linux modules) +(define (flat-linux-module-directory packages modules) "Return a flat directory containing the Linux kernel modules listed in -MODULES and taken from LINUX." +MODULES and taken from PACKAGES." (define imported-modules (source-module-closure '((gnu build linux-modules) (guix build utils)))) =20 + (define (package+out->input package out) + (gexp-input package out)) + + (define package-inputs + (map (lambda (p) + (match p + ((p o) (package+out->input p o)) + (p (package+out->input p "out")))) + packages)) + (define build-exp (with-imported-modules imported-modules (with-extensions (list guile-zlib) @@ -135,11 +145,12 @@ (define build-exp (srfi srfi-1) (srfi srfi-26)) =20 - (define module-dir - (string-append #$linux "/lib/modules")) + (define module-dirs + (map (cut string-append <> "/lib/modules") + '#$package-inputs)) =20 (define modules - (let* ((lookup (cut find-module-file module-dir <>)) + (let* ((lookup (cut find-module-file module-dirs <>)) (modules (map lookup '#$modules))) (append modules (recursive-module-dependencies @@ -172,20 +183,23 @@ (define* (raw-initrd file-systems #:key (linux linux-libre) (linux-modules '()) + (linux-extra-module-paths '()) (mapped-devices '()) (keyboard-layout #f) (helper-packages '()) qemu-networking? volatile-root? (on-error 'debug)) - "Return as a file-like object a raw initrd, with kernel -modules taken from LINUX. FILE-SYSTEMS is a list of file-systems to be -mounted by the initrd, possibly in addition to the root file system specif= ied -on the kernel command line via 'root'. LINUX-MODULES is a list of kernel -modules to be loaded at boot time. MAPPED-DEVICES is a list of device -mappings to realize before FILE-SYSTEMS are mounted. -HELPER-PACKAGES is a list of packages to be copied in the initrd. It may i= nclude -e2fsck/static or other packages needed by the initrd to check root partiti= on. + "Return as a file-like object a raw initrd, with kernel modules taken fr= om +LINUX. FILE-SYSTEMS is a list of file-systems to be mounted by the initrd, +possibly in addition to the root file system specified on the kernel comma= nd +line via 'root'. LINUX-MODULES is a list of kernel modules to be loaded at +boot time. LINUX-EXTRA-MODULE-PATHS is a list of file-like objects which w= ill +be searched for modules in addition to the linux kernel. MAPPED-DEVICES is= a +list of device mappings to realize before FILE-SYSTEMS are mounted. +HELPER-PACKAGES is a list of packages to be copied in the initrd. It may +include e2fsck/static or other packages needed by the initrd to check root +partition. =20 When true, KEYBOARD-LAYOUT is a record denoting the desi= red console keyboard layout. This is done before MAPPED-DEVICES are set up and @@ -221,7 +235,8 @@ (define file-system-scan-commands #~()))) =20 (define kodir - (flat-linux-module-directory linux linux-modules)) + (flat-linux-module-directory (cons linux linux-extra-module-paths) + linux-modules)) =20 (expression->initrd (with-imported-modules (source-module-closure @@ -366,6 +381,7 @@ (define* (base-initrd file-systems #:key (linux linux-libre) (linux-modules '()) + (linux-extra-module-paths '()) (mapped-devices '()) (keyboard-layout #f) qemu-networking? @@ -386,9 +402,10 @@ (define* (base-initrd file-systems QEMU-NETWORKING? and VOLATILE-ROOT? behaves as in raw-initrd. =20 The initrd is automatically populated with all the kernel modules necessary -for FILE-SYSTEMS and for the given options. Additional kernel -modules can be listed in LINUX-MODULES. They will be added to the initrd,= and -loaded at boot time in the order in which they appear." +for FILE-SYSTEMS and for the given options. Additional kernel modules can= be +listed in LINUX-MODULES. Additional search paths for modules can be liste= d in +LINUX-EXTRA-MODULE-PATHS. They will be added to the initrd, and loaded at +boot time in the order in which they appear." (define linux-modules* ;; Modules added to the initrd and loaded from the initrd. `(,@linux-modules @@ -408,6 +425,7 @@ (define helper-packages (raw-initrd file-systems #:linux linux #:linux-modules linux-modules* + #:linux-extra-module-paths linux-extra-module-paths #:mapped-devices mapped-devices #:helper-packages helper-packages #:keyboard-layout keyboard-layout base-commit: 0a64b629ae8512790d532158a72a4a25698e8157 prerequisite-patch-id: 213ce2b9743f11d45836fe0794f117f3bb84063d --=20 2.35.1