guix-build: Don't connect to the daemon when run with `--version' or `--help'.
* guix-build.in (%store): Turn into a SRFI-39 parameter. Update users. (guix-build): Set %STORE and call `open-connection' only after `parse-options' has been called.
This commit is contained in:
parent
cd3ded4301
commit
c7bdb1b9d1
149
guix-build.in
149
guix-build.in
|
@ -45,7 +45,7 @@ exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \
|
||||||
#:export (guix-build))
|
#:export (guix-build))
|
||||||
|
|
||||||
(define %store
|
(define %store
|
||||||
(open-connection))
|
(make-parameter #f))
|
||||||
|
|
||||||
(define (derivations-from-package-expressions exp system source?)
|
(define (derivations-from-package-expressions exp system source?)
|
||||||
"Eval EXP and return the corresponding derivation path for SYSTEM.
|
"Eval EXP and return the corresponding derivation path for SYSTEM.
|
||||||
|
@ -56,10 +56,10 @@ When SOURCE? is true, return the derivations of the package sources."
|
||||||
(let ((source (package-source p))
|
(let ((source (package-source p))
|
||||||
(loc (package-location p)))
|
(loc (package-location p)))
|
||||||
(if source
|
(if source
|
||||||
(package-source-derivation %store source)
|
(package-source-derivation (%store) source)
|
||||||
(leave (_ "~a: error: package `~a' has no source~%")
|
(leave (_ "~a: error: package `~a' has no source~%")
|
||||||
(location->string loc) (package-name p))))
|
(location->string loc) (package-name p))))
|
||||||
(package-derivation %store p system))
|
(package-derivation (%store) p system))
|
||||||
(leave (_ "expression `~s' does not evaluate to a package~%")
|
(leave (_ "expression `~s' does not evaluate to a package~%")
|
||||||
exp))))
|
exp))))
|
||||||
|
|
||||||
|
@ -176,12 +176,12 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
|
||||||
(match outputs*
|
(match outputs*
|
||||||
((output)
|
((output)
|
||||||
(symlink output root)
|
(symlink output root)
|
||||||
(add-indirect-root %store root))
|
(add-indirect-root (%store) root))
|
||||||
((outputs ...)
|
((outputs ...)
|
||||||
(fold (lambda (output count)
|
(fold (lambda (output count)
|
||||||
(let ((root (string-append root "-" (number->string count))))
|
(let ((root (string-append root "-" (number->string count))))
|
||||||
(symlink output root)
|
(symlink output root)
|
||||||
(add-indirect-root %store root))
|
(add-indirect-root (%store) root))
|
||||||
(+ 1 count))
|
(+ 1 count))
|
||||||
0
|
0
|
||||||
outputs))))
|
outputs))))
|
||||||
|
@ -197,77 +197,78 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
|
||||||
(setvbuf (current-error-port) _IOLBF)
|
(setvbuf (current-error-port) _IOLBF)
|
||||||
|
|
||||||
(with-error-handling
|
(with-error-handling
|
||||||
(let* ((opts (parse-options))
|
(let ((opts (parse-options)))
|
||||||
(src? (assoc-ref opts 'source?))
|
(parameterize ((%store (open-connection)))
|
||||||
(sys (assoc-ref opts 'system))
|
(let* ((src? (assoc-ref opts 'source?))
|
||||||
(drv (filter-map (match-lambda
|
(sys (assoc-ref opts 'system))
|
||||||
(('expression . exp)
|
(drv (filter-map (match-lambda
|
||||||
(derivations-from-package-expressions exp sys
|
(('expression . exp)
|
||||||
src?))
|
(derivations-from-package-expressions exp sys
|
||||||
(('argument . (? derivation-path? drv))
|
src?))
|
||||||
drv)
|
(('argument . (? derivation-path? drv))
|
||||||
(('argument . (? string? x))
|
drv)
|
||||||
(match (find-packages-by-name x)
|
(('argument . (? string? x))
|
||||||
((p _ ...)
|
(match (find-packages-by-name x)
|
||||||
(if src?
|
((p _ ...)
|
||||||
(let ((s (package-source p)))
|
(if src?
|
||||||
(package-source-derivation %store s))
|
(let ((s (package-source p)))
|
||||||
(package-derivation %store p sys)))
|
(package-source-derivation (%store) s))
|
||||||
(_
|
(package-derivation (%store) p sys)))
|
||||||
(leave (_ "~A: unknown package~%") x))))
|
(_
|
||||||
(_ #f))
|
(leave (_ "~A: unknown package~%") x))))
|
||||||
opts))
|
(_ #f))
|
||||||
(req (append-map (lambda (drv-path)
|
opts))
|
||||||
(let ((d (call-with-input-file drv-path
|
(req (append-map (lambda (drv-path)
|
||||||
read-derivation)))
|
(let ((d (call-with-input-file drv-path
|
||||||
(derivation-prerequisites-to-build %store d)))
|
read-derivation)))
|
||||||
drv))
|
(derivation-prerequisites-to-build (%store) d)))
|
||||||
(req* (delete-duplicates
|
drv))
|
||||||
(append (remove (compose (cut valid-path? %store <>)
|
(req* (delete-duplicates
|
||||||
derivation-path->output-path)
|
(append (remove (compose (cut valid-path? (%store) <>)
|
||||||
drv)
|
derivation-path->output-path)
|
||||||
(map derivation-input-path req)))))
|
drv)
|
||||||
(if (assoc-ref opts 'dry-run?)
|
(map derivation-input-path req)))))
|
||||||
(format (current-error-port)
|
(if (assoc-ref opts 'dry-run?)
|
||||||
(N_ "~:[the following derivation would be built:~%~{ ~a~%~}~;~]"
|
(format (current-error-port)
|
||||||
"~:[the following derivations would be built:~%~{ ~a~%~}~;~]"
|
(N_ "~:[the following derivation would be built:~%~{ ~a~%~}~;~]"
|
||||||
(length req*))
|
"~:[the following derivations would be built:~%~{ ~a~%~}~;~]"
|
||||||
(null? req*) req*)
|
(length req*))
|
||||||
(format (current-error-port)
|
(null? req*) req*)
|
||||||
(N_ "~:[the following derivation will be built:~%~{ ~a~%~}~;~]"
|
(format (current-error-port)
|
||||||
"~:[the following derivations will be built:~%~{ ~a~%~}~;~]"
|
(N_ "~:[the following derivation will be built:~%~{ ~a~%~}~;~]"
|
||||||
(length req*))
|
"~:[the following derivations will be built:~%~{ ~a~%~}~;~]"
|
||||||
(null? req*) req*))
|
(length req*))
|
||||||
|
(null? req*) req*))
|
||||||
|
|
||||||
;; TODO: Add more options.
|
;; TODO: Add more options.
|
||||||
(set-build-options %store
|
(set-build-options (%store)
|
||||||
#:keep-failed? (assoc-ref opts 'keep-failed?)
|
#:keep-failed? (assoc-ref opts 'keep-failed?)
|
||||||
#:build-cores (or (assoc-ref opts 'cores) 0)
|
#:build-cores (or (assoc-ref opts 'cores) 0)
|
||||||
#:use-substitutes? (assoc-ref opts 'substitutes?))
|
#:use-substitutes? (assoc-ref opts 'substitutes?))
|
||||||
|
|
||||||
(if (assoc-ref opts 'derivations-only?)
|
(if (assoc-ref opts 'derivations-only?)
|
||||||
(format #t "~{~a~%~}" drv)
|
(format #t "~{~a~%~}" drv)
|
||||||
(or (assoc-ref opts 'dry-run?)
|
(or (assoc-ref opts 'dry-run?)
|
||||||
(and (build-derivations %store drv)
|
(and (build-derivations (%store) drv)
|
||||||
(for-each (lambda (d)
|
(for-each (lambda (d)
|
||||||
(let ((drv (call-with-input-file d
|
(let ((drv (call-with-input-file d
|
||||||
read-derivation)))
|
read-derivation)))
|
||||||
(format #t "~{~a~%~}"
|
(format #t "~{~a~%~}"
|
||||||
(map (match-lambda
|
(map (match-lambda
|
||||||
((out-name . out)
|
((out-name . out)
|
||||||
(derivation-path->output-path
|
(derivation-path->output-path
|
||||||
d out-name)))
|
d out-name)))
|
||||||
(derivation-outputs drv)))))
|
(derivation-outputs drv)))))
|
||||||
drv)
|
drv)
|
||||||
(let ((roots (filter-map (match-lambda
|
(let ((roots (filter-map (match-lambda
|
||||||
(('gc-root . root)
|
(('gc-root . root)
|
||||||
root)
|
root)
|
||||||
(_ #f))
|
(_ #f))
|
||||||
opts)))
|
opts)))
|
||||||
(when roots
|
(when roots
|
||||||
(for-each (cut register-root <> <>)
|
(for-each (cut register-root <> <>)
|
||||||
drv roots)
|
drv roots)
|
||||||
#t))))))))
|
#t))))))))))
|
||||||
|
|
||||||
;; Local Variables:
|
;; Local Variables:
|
||||||
;; eval: (put 'guard 'scheme-indent-function 1)
|
;; eval: (put 'guard 'scheme-indent-function 1)
|
||||||
|
|
Loading…
Reference in New Issue