Subject: [PATCH] linux-initrd: Avoid looking up builtin modules.

From: Hilton Chain <[email-masked]>
Date: Mon, 26 Feb 2024 14:06:23 +0800

* gnu/system/linux-initrd.scm (flat-linux-module-directory)
[build-exp]<builtin-modules,modules-to-lookup>: New variables.
<modules>: Use ‘modules-to-lookup’ to avoid looking up builtin modules.

Change-Id: I60fdae0211bb6632508b1c63582e013e78186cd1
---
 gnu/system/linux-initrd.scm | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 5847f52a37..25563b703f 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -132,15 +132,27 @@ (define (flat-linux-module-directory linux modules)
         #~(begin
             (use-modules (gnu build linux-modules)
                          (guix build utils)
+                         (rnrs io ports)
                          (srfi srfi-1)
                          (srfi srfi-26))

             (define module-dir
               (string-append #$linux "/lib/modules"))

+            (define builtin-modules
+              (call-with-input-file
+                  (first (find-files module-dir "modules.builtin$"))
+                (lambda (port)
+                  (map file-name->module-name
+                       (string-tokenize
+                        (get-string-all port))))))
+
+            (define modules-to-lookup
+              (lset-difference string=? '#$modules builtin-modules))
+
             (define modules
               (let* ((lookup  (cut find-module-file module-dir <>))
-                     (modules (map lookup '#$modules)))
+                     (modules (map lookup modules-to-lookup)))
                 (append modules
                         (recursive-module-dependencies
                          modules

base-commit: b25b94335a3ee8d68d2145da8e5ea0325ecea451
prerequisite-patch-id: c615f2b08070db6cbe847a2bdd5b7c0aae79789b
prerequisite-patch-id: fd7da036342f36a8c698f5c8975f9e48d3ade435
prerequisite-patch-id: a2c81c14423bb9858f33d7d26976e8eea61982b7
prerequisite-patch-id: e30fd25b1dc4aaaff76474153836cd48e8565eb9
prerequisite-patch-id: 1d070b26dc64ee2ec95f14c4f5fc23419f766810
prerequisite-patch-id: 03de992f0312d5f0ee3368ebc3c1fad7c955d095
prerequisite-patch-id: b330efe2b0713e30b766c3b84643df67eb1eae5d
prerequisite-patch-id: a233d53e8895d3f82af872fffb2e3858f44ceb23
prerequisite-patch-id: a2b6bd60bc05d7b5a75f15a06b1b614afd6a7033
prerequisite-patch-id: f2a0189de95456f15ec6a92526c72fbedb74f359
--
2.41.0