[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#30604] [PATCH v4 3/7] linux-initrd: Add kmod.
From: |
Danny Milosavljevic |
Subject: |
[bug#30604] [PATCH v4 3/7] linux-initrd: Add kmod. |
Date: |
Tue, 27 Feb 2018 12:26:15 +0100 |
* gnu/system/linux-initrd.scm (raw-initrd): Add kmod.
(base-initrd): Add kmod.
(expression->initrd): Add kmod, linux-module-directory.
(flat-linux-module-directory): Add kmod; invoke depmod.
* gnu/build/linux-initrd.scm (build-initrd): Add kmod, linux-module-directory.
---
gnu/build/linux-initrd.scm | 12 +++++++++++-
gnu/system/linux-initrd.scm | 45 ++++++++++++++++++++++++++++++++++-----------
2 files changed, 45 insertions(+), 12 deletions(-)
diff --git a/gnu/build/linux-initrd.scm b/gnu/build/linux-initrd.scm
index c65b5aacf..6356007df 100644
--- a/gnu/build/linux-initrd.scm
+++ b/gnu/build/linux-initrd.scm
@@ -107,7 +107,7 @@ This is similar to what 'compiled-file-name' in (system
base compile) does."
(define* (build-initrd output
#:key
- guile init
+ guile init kmod linux-module-directory
(references-graphs '())
(gzip "gzip"))
"Write an initial RAM disk (initrd) to OUTPUT. The initrd starts the script
@@ -131,6 +131,16 @@ REFERENCES-GRAPHS."
(symlink (string-append guile "/bin/guile") "proc/self/exe")
(readlink "proc/self/exe")
+ ;; Make modprobe available as /sbin/modprobe so the kernel finds it.
+ (when kmod
+ (mkdir-p "sbin")
+ (symlink (string-append kmod "/bin/modprobe") "sbin/modprobe"))
+
+ ;; Make modules available as /lib/modules so modprobe finds them.
+ (mkdir-p "lib")
+ (symlink (string-append linux-module-directory "/lib/modules")
+ "lib/modules")
+
;; Reset the timestamps of all the files that will make it in the initrd.
(for-each (lambda (file)
(unless (eq? 'symlink (stat:type (lstat file)))
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 7170d1c0e..46ef055f0 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -59,6 +59,8 @@
#:key
(guile %guile-static-stripped)
(gzip gzip)
+ kmod
+ linux-module-directory
(name "guile-initrd")
(system (%current-system)))
"Return a derivation that builds a Linux initrd (a gzipped cpio archive)
@@ -94,6 +96,8 @@ the derivations referenced by EXP are automatically copied to
the initrd."
(build-initrd (string-append #$output "/initrd")
#:guile #$guile
#:init #$init
+ #:kmod #$kmod
+ #:linux-module-directory #$linux-module-directory
;; Copy everything INIT refers to into the initrd.
#:references-graphs '("closure")
#:gzip (string-append #$gzip "/bin/gzip")))))
@@ -101,7 +105,7 @@ the derivations referenced by EXP are automatically copied
to the initrd."
(gexp->derivation name builder
#:references-graphs `(("closure" ,init))))
-(define (flat-linux-module-directory linux modules)
+(define (flat-linux-module-directory linux modules kmod)
"Return a flat directory containing the Linux kernel modules listed in
MODULES and taken from LINUX."
(define build-exp
@@ -109,7 +113,7 @@ MODULES and taken from LINUX."
'((guix build utils)
(gnu build linux-modules)))
#~(begin
- (use-modules (ice-9 match) (ice-9 regex)
+ (use-modules (ice-9 match) (ice-9 regex) (ice-9 ftw)
(srfi srfi-1)
(guix build utils)
(gnu build linux-modules))
@@ -138,13 +142,27 @@ MODULES and taken from LINUX."
(recursive-module-dependencies modules
#:lookup-module lookup))))
- (mkdir #$output)
- (for-each (lambda (module)
- (format #t "copying '~a'...~%" module)
- (copy-file module
- (string-append #$output "/"
- (basename module))))
- (delete-duplicates modules)))))
+ (define version
+ (match
+ (filter
+ (lambda (name)
+ (not (string-prefix? "." name)))
+ (scandir module-dir))
+ ((item) item)))
+
+ (let ((output (string-append #$output "/lib/modules/" version)))
+ (mkdir-p output)
+ (for-each (lambda (module)
+ (format #t "copying '~a'...~%" module)
+ (copy-file module
+ (string-append output "/"
+ (basename module))))
+ (delete-duplicates modules)))
+ (invoke (string-append #$kmod "/bin/depmod") "-a" "-b" #$output
+ "-e"
+ "-F" (string-append #$linux "/System.map")
+ version)
+ #t)))
(computed-file "linux-modules" build-exp))
@@ -152,6 +170,7 @@ MODULES and taken from LINUX."
#:key
(linux linux-libre)
(linux-modules '())
+ (kmod kmod-minimal/static)
(mapped-devices '())
(helper-packages '())
qemu-networking?
@@ -185,7 +204,7 @@ upon error."
mapped-devices))
(define kodir
- (flat-linux-module-directory linux linux-modules))
+ (flat-linux-module-directory linux linux-modules kmod))
(expression->initrd
(with-imported-modules (source-module-closure
@@ -223,6 +242,8 @@ upon error."
#:qemu-guest-networking? #$qemu-networking?
#:volatile-root? '#$volatile-root?
#:on-error '#$on-error)))
+ #:kmod kmod
+ #:linux-module-directory kodir
#:name "raw-initrd"))
(define* (file-system-packages file-systems #:key (volatile-root? #f))
@@ -245,6 +266,7 @@ FILE-SYSTEMS."
(define* (base-initrd file-systems
#:key
(linux linux-libre)
+ (kmod kmod-minimal/static)
(mapped-devices '())
qemu-networking?
volatile-root?
@@ -322,8 +344,9 @@ loaded at boot time in the order in which they appear."
(raw-initrd file-systems
#:linux linux
#:linux-modules linux-modules
+ #:kmod kmod
#:mapped-devices mapped-devices
- #:helper-packages helper-packages
+ #:helper-packages (cons kmod helper-packages)
#:qemu-networking? qemu-networking?
#:volatile-root? volatile-root?
#:on-error on-error))
- [bug#30604] [PATCH v3 3/6] linux-initrd: Add kmod., (continued)
- [bug#30604] [PATCH v3 3/6] linux-initrd: Add kmod., Danny Milosavljevic, 2018/02/25
- [bug#30604] [PATCH v3 5/6] vm: Allow qemu-image builder to load Linux kernel modules., Danny Milosavljevic, 2018/02/25
- [bug#30604] [PATCH v3 2/6] gnu: Add kmod-minimal-static., Danny Milosavljevic, 2018/02/25
- [bug#30604] [PATCH v4 0/7] Load Linux module only when supported hardware is present., Danny Milosavljevic, 2018/02/27
- [bug#30604] [PATCH v4 7/7] linux-boot: Call make-static-device-nodes much earlier., Danny Milosavljevic, 2018/02/27
- [bug#30604] [PATCH v4 5/7] vm: Allow qemu-image builder to load Linux kernel modules., Danny Milosavljevic, 2018/02/27
- [bug#30604] [PATCH v4 2/7] gnu: Add kmod-minimal-static., Danny Milosavljevic, 2018/02/27
- [bug#30604] [PATCH v4 6/7] vm: Make the virtio-blk uniquely identifyable in /sys., Danny Milosavljevic, 2018/02/27
- [bug#30604] [PATCH v4 4/7] linux-boot: Load kernel modules only when the hardware is present., Danny Milosavljevic, 2018/02/27
- [bug#30604] [PATCH v4 1/7] gnu: kmod: Split off kmod-minimal., Danny Milosavljevic, 2018/02/27
- [bug#30604] [PATCH v4 3/7] linux-initrd: Add kmod.,
Danny Milosavljevic <=
- [bug#30604] [PATCH v5 0/7] Load Linux module only when supported hardware is present., Danny Milosavljevic, 2018/02/27
- [bug#30604] [PATCH v5 3/7] linux-initrd: Add kmod., Danny Milosavljevic, 2018/02/27
- [bug#30604] [PATCH v5 1/7] gnu: kmod: Split off kmod-minimal., Danny Milosavljevic, 2018/02/27
- [bug#30604] [PATCH v5 4/7] linux-boot: Load kernel modules only when the hardware is present., Danny Milosavljevic, 2018/02/27
- [bug#30604] [PATCH v5 2/7] gnu: Add kmod-minimal-static., Danny Milosavljevic, 2018/02/27
- [bug#30604] [PATCH v5 7/7] linux-boot: Call make-static-device-nodes much earlier., Danny Milosavljevic, 2018/02/27
- [bug#30604] [PATCH v5 6/7] vm: Make the virtio-blk is uniquely identifyable in /sys., Danny Milosavljevic, 2018/02/27
- [bug#30604] [PATCH v5 5/7] vm: Allow qemu-image builder to load Linux kernel modules., Danny Milosavljevic, 2018/02/27