system: Allow Linux-libre to find our 'modprobe' command.

Fixes <http://bugs.gnu.org/18525>.
Reported by Mark H Weaver <mhw@netris.org>.

* gnu/build/activation.scm (activate-modprobe): New procedure.
* gnu/system.scm (modprobe-wrapper): New procedure.
  (operating-system-activation-script): Use both.
This commit is contained in:
Ludovic Courtès 2014-11-02 23:06:17 +01:00
parent ac67e20582
commit d460204f2e
2 changed files with 25 additions and 0 deletions

View File

@ -27,6 +27,7 @@
activate-etc activate-etc
activate-setuid-programs activate-setuid-programs
activate-/bin/sh activate-/bin/sh
activate-modprobe
activate-current-system)) activate-current-system))
;;; Commentary: ;;; Commentary:
@ -252,6 +253,12 @@ copy SOURCE to TARGET."
(symlink shell "/bin/sh.new") (symlink shell "/bin/sh.new")
(rename-file "/bin/sh.new" "/bin/sh")) (rename-file "/bin/sh.new" "/bin/sh"))
(define (activate-modprobe modprobe)
"Tell the kernel to use MODPROBE to load modules."
(call-with-output-file "/proc/sys/kernel/modprobe"
(lambda (port)
(display modprobe port))))
(define %current-system (define %current-system
;; The system that is current (a symlink.) This is not necessarily the same ;; The system that is current (a symlink.) This is not necessarily the same
;; as the system we booted (aka. /run/booted-system) because we can re-build ;; as the system we booted (aka. /run/booted-system) because we can re-build

View File

@ -477,6 +477,20 @@ alias ll='ls -l'
#$(user-account-password account) #$(user-account-password account)
#$(user-account-system? account))) #$(user-account-system? account)))
(define (modprobe-wrapper)
"Return a wrapper for the 'modprobe' command that knows where modules live.
This wrapper is typically invoked by the Linux kernel ('call_modprobe', in
kernel/kmod.c), a situation where the 'LINUX_MODULE_DIRECTORY' environment
variable is not set---hence the need for this wrapper."
(let ((modprobe "/run/current-system/profile/bin/modprobe"))
(gexp->script "modprobe"
#~(begin
(setenv "LINUX_MODULE_DIRECTORY"
"/run/booted-system/kernel/lib/modules")
(apply execl #$modprobe
(cons #$modprobe (cdr (command-line))))))))
(define (operating-system-activation-script os) (define (operating-system-activation-script os)
"Return the activation script for OS---i.e., the code that \"activates\" the "Return the activation script for OS---i.e., the code that \"activates\" the
stateful part of OS, including user accounts and groups, special directories, stateful part of OS, including user accounts and groups, special directories,
@ -498,6 +512,7 @@ etc."
(etc (operating-system-etc-directory os)) (etc (operating-system-etc-directory os))
(modules (imported-modules %modules)) (modules (imported-modules %modules))
(compiled (compiled-modules %modules)) (compiled (compiled-modules %modules))
(modprobe (modprobe-wrapper))
(accounts (operating-system-accounts os))) (accounts (operating-system-accounts os)))
(define setuid-progs (define setuid-progs
(operating-system-setuid-programs os)) (operating-system-setuid-programs os))
@ -540,6 +555,9 @@ etc."
;; Activate setuid programs. ;; Activate setuid programs.
(activate-setuid-programs (list #$@setuid-progs)) (activate-setuid-programs (list #$@setuid-progs))
;; Tell the kernel to use our 'modprobe' command.
(activate-modprobe #$modprobe)
;; Run the services' activation snippets. ;; Run the services' activation snippets.
;; TODO: Use 'load-compiled'. ;; TODO: Use 'load-compiled'.
(for-each primitive-load '#$actions) (for-each primitive-load '#$actions)