guix system: Type-check the file or expression.
Previously, users would get a wrong-type-arg exception down the road with an intimidating backtrace. * guix/scripts/system.scm (process-action)[ensure-operating-system]: New procedure. Use it.
This commit is contained in:
parent
6e633a510c
commit
ce10e6053b
|
@ -1143,22 +1143,30 @@ Some ACTIONS support additional ARGS.\n"))
|
||||||
ACTION must be one of the sub-commands that takes an operating system
|
ACTION must be one of the sub-commands that takes an operating system
|
||||||
declaration as an argument (a file name.) OPTS is the raw alist of options
|
declaration as an argument (a file name.) OPTS is the raw alist of options
|
||||||
resulting from command-line parsing."
|
resulting from command-line parsing."
|
||||||
|
(define (ensure-operating-system file-or-exp obj)
|
||||||
|
(unless (operating-system? obj)
|
||||||
|
(leave (G_ "'~a' does not return an operating system~%")
|
||||||
|
file-or-exp))
|
||||||
|
obj)
|
||||||
|
|
||||||
(let* ((file (match args
|
(let* ((file (match args
|
||||||
(() #f)
|
(() #f)
|
||||||
((x . _) x)))
|
((x . _) x)))
|
||||||
(expr (assoc-ref opts 'expression))
|
(expr (assoc-ref opts 'expression))
|
||||||
(system (assoc-ref opts 'system))
|
(system (assoc-ref opts 'system))
|
||||||
(os (cond
|
(os (ensure-operating-system
|
||||||
((and expr file)
|
(or file expr)
|
||||||
(leave
|
(cond
|
||||||
(G_ "both file and expression cannot be specified~%")))
|
((and expr file)
|
||||||
(expr
|
(leave
|
||||||
(read/eval expr))
|
(G_ "both file and expression cannot be specified~%")))
|
||||||
(file
|
(expr
|
||||||
(load* file %user-module
|
(read/eval expr))
|
||||||
#:on-error (assoc-ref opts 'on-error)))
|
(file
|
||||||
(else
|
(load* file %user-module
|
||||||
(leave (G_ "no configuration specified~%")))))
|
#:on-error (assoc-ref opts 'on-error)))
|
||||||
|
(else
|
||||||
|
(leave (G_ "no configuration specified~%"))))))
|
||||||
|
|
||||||
(dry? (assoc-ref opts 'dry-run?))
|
(dry? (assoc-ref opts 'dry-run?))
|
||||||
(bootloader? (assoc-ref opts 'install-bootloader?))
|
(bootloader? (assoc-ref opts 'install-bootloader?))
|
||||||
|
|
Loading…
Reference in New Issue