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.
This commit is contained in:
Danny Milosavljevic 2020-02-18 10:42:07 +01:00
parent 66a198c807
commit 5c79f23863
No known key found for this signature in database
GPG key ID: E71A35542C30BAA5
7 changed files with 235 additions and 11 deletions

View file

@ -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