linux-initrd: Factorize kernel command-line option parsing.
* guix/build/linux-initrd.scm (find-long-option): New procedure. (boot-system): Use it instead of the local 'option'.master
parent
d216323f0a
commit
87a52da7d0
|
@ -28,6 +28,7 @@
|
||||||
#:use-module (guix build utils)
|
#:use-module (guix build utils)
|
||||||
#:export (mount-essential-file-systems
|
#:export (mount-essential-file-systems
|
||||||
linux-command-line
|
linux-command-line
|
||||||
|
find-long-option
|
||||||
make-essential-device-nodes
|
make-essential-device-nodes
|
||||||
configure-qemu-networking
|
configure-qemu-networking
|
||||||
check-file-system
|
check-file-system
|
||||||
|
@ -78,6 +79,15 @@
|
||||||
(call-with-input-file "/proc/cmdline"
|
(call-with-input-file "/proc/cmdline"
|
||||||
get-string-all)))
|
get-string-all)))
|
||||||
|
|
||||||
|
(define (find-long-option option arguments)
|
||||||
|
"Find OPTION among ARGUMENTS, where OPTION is something like \"--load\".
|
||||||
|
Return the value associated with OPTION, or #f on failure."
|
||||||
|
(let ((opt (string-append option "=")))
|
||||||
|
(and=> (find (cut string-prefix? opt <>)
|
||||||
|
arguments)
|
||||||
|
(lambda (arg)
|
||||||
|
(substring arg (+ 1 (string-index arg #\=)))))))
|
||||||
|
|
||||||
(define* (make-essential-device-nodes #:key (root "/"))
|
(define* (make-essential-device-nodes #:key (root "/"))
|
||||||
"Make essential device nodes under ROOT/dev."
|
"Make essential device nodes under ROOT/dev."
|
||||||
;; The hand-made udev!
|
;; The hand-made udev!
|
||||||
|
@ -411,14 +421,8 @@ to it are lost."
|
||||||
|
|
||||||
(mount-essential-file-systems)
|
(mount-essential-file-systems)
|
||||||
(let* ((args (linux-command-line))
|
(let* ((args (linux-command-line))
|
||||||
(option (lambda (opt)
|
(to-load (find-long-option "--load" args))
|
||||||
(let ((opt (string-append opt "=")))
|
(root (find-long-option "--root" args)))
|
||||||
(and=> (find (cut string-prefix? opt <>)
|
|
||||||
args)
|
|
||||||
(lambda (arg)
|
|
||||||
(substring arg (+ 1 (string-index arg #\=))))))))
|
|
||||||
(to-load (option "--load"))
|
|
||||||
(root (option "--root")))
|
|
||||||
|
|
||||||
(when (member "--repl" args)
|
(when (member "--repl" args)
|
||||||
(start-repl))
|
(start-repl))
|
||||||
|
|
Loading…
Reference in New Issue