summaryrefslogtreecommitdiff
path: root/gnu/system/linux-initrd.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/system/linux-initrd.scm')
-rw-r--r--gnu/system/linux-initrd.scm72
1 files changed, 45 insertions, 27 deletions
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 0971ec29e21..b8a30c0abc6 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -77,6 +77,9 @@ the derivations referenced by EXP are automatically copied to the initrd."
77 (program-file "init" exp #:guile guile)) 77 (program-file "init" exp #:guile guile))
78 78
79 (define builder 79 (define builder
80 ;; Do not use "guile-zlib" extension here, otherwise it would drag the
81 ;; non-static "zlib" package to the initrd closure. It is not needed
82 ;; anyway because the modules are stored uncompressed within the initrd.
80 (with-imported-modules (source-module-closure 83 (with-imported-modules (source-module-closure
81 '((gnu build linux-initrd))) 84 '((gnu build linux-initrd)))
82 #~(begin 85 #~(begin
@@ -111,34 +114,49 @@ the derivations referenced by EXP are automatically copied to the initrd."
111(define (flat-linux-module-directory linux modules) 114(define (flat-linux-module-directory linux modules)
112 "Return a flat directory containing the Linux kernel modules listed in 115 "Return a flat directory containing the Linux kernel modules listed in
113MODULES and taken from LINUX." 116MODULES and taken from LINUX."
114 (define build-exp 117 (define imported-modules
115 (with-imported-modules (source-module-closure 118 (source-module-closure '((gnu build linux-modules)
116 '((gnu build linux-modules))) 119 (guix build utils))))
117 #~(begin
118 (use-modules (gnu build linux-modules)
119 (srfi srfi-1)
120 (srfi srfi-26))
121
122 (define module-dir
123 (string-append #$linux "/lib/modules"))
124 120
125 (define modules 121 (define build-exp
126 (let* ((lookup (cut find-module-file module-dir <>)) 122 (with-imported-modules imported-modules
127 (modules (map lookup '#$modules))) 123 (with-extensions (list guile-zlib)
128 (append modules 124 #~(begin
129 (recursive-module-dependencies modules 125 (use-modules (gnu build linux-modules)
130 #:lookup-module lookup)))) 126 (guix build utils)
131 127 (srfi srfi-1)
132 (mkdir #$output) 128 (srfi srfi-26))
133 (for-each (lambda (module) 129
134 (format #t "copying '~a'...~%" module) 130 (define module-dir
135 (copy-file module 131 (string-append #$linux "/lib/modules"))
136 (string-append #$output "/" 132
137 (basename module)))) 133 (define modules
138 (delete-duplicates modules)) 134 (let* ((lookup (cut find-module-file module-dir <>))
139 135 (modules (map lookup '#$modules)))
140 ;; Hyphen or underscore? This database tells us. 136 (append modules
141 (write-module-name-database #$output)))) 137 (recursive-module-dependencies
138 modules
139 #:lookup-module lookup))))
140
141 (define (maybe-uncompress file)
142 ;; If FILE is a compressed module, uncompress it, as the initrd
143 ;; is already gzipped as a whole.
144 (cond
145 ((string-contains file ".ko.gz")
146 (invoke #+(file-append gzip "/bin/gunzip") file))))
147
148 (mkdir #$output)
149 (for-each (lambda (module)
150 (let ((out-module
151 (string-append #$output "/"
152 (basename module))))
153 (format #t "copying '~a'...~%" module)
154 (copy-file module out-module)
155 (maybe-uncompress out-module)))
156 (delete-duplicates modules))
157
158 ;; Hyphen or underscore? This database tells us.
159 (write-module-name-database #$output)))))
142 160
143 (computed-file "linux-modules" build-exp)) 161 (computed-file "linux-modules" build-exp))
144 162