summaryrefslogtreecommitdiff
path: root/gnu/build/linux-modules.scm
diff options
context:
space:
mode:
authorDanny Milosavljevic <dannym@scratchpost.org>2020-02-18 10:42:07 +0100
committerDanny Milosavljevic <dannym@scratchpost.org>2020-03-22 12:51:50 +0100
commit5c79f238634c5adb6657f1b4b1bb4ddb8bb73ef1 (patch)
tree9aa461be2cf3ede11048d3e7c4280b89de4ac73b /gnu/build/linux-modules.scm
parent66a198c8075f02d7075a555b48dd3adde88ebbbf (diff)
downloadguix-patches-5c79f238634c5adb6657f1b4b1bb4ddb8bb73ef1.tar
guix-patches-5c79f238634c5adb6657f1b4b1bb4ddb8bb73ef1.tar.gz
system: Add kernel-loadable-modules to operating-system.
* gnu/system.scm (<operating-system>): Add kernel-loadable-modules. (operating-system-directory-base-entries): Use it. * doc/guix.texi (operating-system Reference): Document KERNEL-LOADABLE-MODULES. * gnu/build/linux-modules.scm (depmod): New procedure. (make-linux-module-directory): New procedure. Export it. * guix/profiles.scm (linux-module-database): New procedure. Export it. * gnu/tests/linux-modules.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. * gnu/packages/linux.scm (make-linux-libre*)[arguments]<#:phases>[install]: Disable depmod. Remove "build" and "source" symlinks. [native-inputs]: Remove kmod.
Diffstat (limited to 'gnu/build/linux-modules.scm')
-rw-r--r--gnu/build/linux-modules.scm46
1 files changed, 44 insertions, 2 deletions
diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index a149eff329..aa1c7cfeae 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -22,12 +22,14 @@
#:use-module (guix elf)
#:use-module (guix glob)
#:use-module (guix build syscalls)
- #:use-module ((guix build utils) #:select (find-files))
+ #:use-module ((guix build utils) #:select (find-files invoke))
+ #:use-module (guix build union)
#:use-module (rnrs io ports)
#:use-module (rnrs bytevectors)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-26)
+ #:use-module (ice-9 ftw)
#:use-module (ice-9 vlist)
#:use-module (ice-9 match)
#:use-module (ice-9 rdelim)
@@ -56,7 +58,9 @@
write-module-name-database
write-module-alias-database
- write-module-device-database))
+ write-module-device-database
+
+ make-linux-module-directory))
;;; Commentary:
;;;
@@ -631,4 +635,42 @@ be loaded on-demand, such as file system modules."
module devname type major minor)))
aliases))))
+(define (depmod version directory)
+ "Given an (existing) DIRECTORY, invoke depmod on it for
+kernel version VERSION."
+ (let ((destination-directory (string-append directory "/lib/modules/"
+ version))
+ ;; Note: "System.map" is an input file.
+ (maps-file (string-append directory "/System.map"))
+ ;; Note: "Module.symvers" is an input file.
+ (symvers-file (string-append directory "/Module.symvers")))
+ ;; These files will be regenerated by depmod below.
+ (for-each (lambda (basename)
+ (when (and (string-prefix? "modules." basename)
+ ;; Note: "modules.builtin" is an input file.
+ (not (string=? "modules.builtin" basename))
+ ;; Note: "modules.order" is an input file.
+ (not (string=? "modules.order" basename)))
+ (delete-file (string-append destination-directory "/"
+ basename))))
+ (scandir destination-directory))
+ (invoke "depmod"
+ "-e" ; Report symbols that aren't supplied
+ ;"-w" ; Warn on duplicates
+ "-b" directory
+ "-F" maps-file
+ ;"-E" symvers-file ; using both "-E" and "-F" is not possible.
+ version)))
+
+(define (make-linux-module-directory inputs version output)
+ "Create a new directory OUTPUT and ensure that the directory
+OUTPUT/lib/modules/VERSION can be used as a source of Linux
+kernel modules for the first kmod in PATH now to eventually
+load. Take modules to put into OUTPUT from INPUTS.
+
+Right now that means it creates @code{modules.*.bin} which
+@command{modprobe} will use to find loadable modules."
+ (union-build output inputs #:create-all-directories? #t)
+ (depmod version output))
+
;;; linux-modules.scm ends here