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
|
@ -45,7 +45,7 @@ exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \
|
|||
#:export (guix-build))
|
||||
|
||||
(define %store
|
||||
(open-connection))
|
||||
(make-parameter #f))
|
||||
|
||||
(define (derivations-from-package-expressions exp system source?)
|
||||
"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))
|
||||
(loc (package-location p)))
|
||||
(if source
|
||||
(package-source-derivation %store source)
|
||||
(package-source-derivation (%store) source)
|
||||
(leave (_ "~a: error: package `~a' has no source~%")
|
||||
(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~%")
|
||||
exp))))
|
||||
|
||||
|
@ -176,12 +176,12 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
|
|||
(match outputs*
|
||||
((output)
|
||||
(symlink output root)
|
||||
(add-indirect-root %store root))
|
||||
(add-indirect-root (%store) root))
|
||||
((outputs ...)
|
||||
(fold (lambda (output count)
|
||||
(let ((root (string-append root "-" (number->string count))))
|
||||
(symlink output root)
|
||||
(add-indirect-root %store root))
|
||||
(add-indirect-root (%store) root))
|
||||
(+ 1 count))
|
||||
0
|
||||
outputs))))
|
||||
|
@ -197,8 +197,9 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
|
|||
(setvbuf (current-error-port) _IOLBF)
|
||||
|
||||
(with-error-handling
|
||||
(let* ((opts (parse-options))
|
||||
(src? (assoc-ref opts 'source?))
|
||||
(let ((opts (parse-options)))
|
||||
(parameterize ((%store (open-connection)))
|
||||
(let* ((src? (assoc-ref opts 'source?))
|
||||
(sys (assoc-ref opts 'system))
|
||||
(drv (filter-map (match-lambda
|
||||
(('expression . exp)
|
||||
|
@ -211,8 +212,8 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
|
|||
((p _ ...)
|
||||
(if src?
|
||||
(let ((s (package-source p)))
|
||||
(package-source-derivation %store s))
|
||||
(package-derivation %store p sys)))
|
||||
(package-source-derivation (%store) s))
|
||||
(package-derivation (%store) p sys)))
|
||||
(_
|
||||
(leave (_ "~A: unknown package~%") x))))
|
||||
(_ #f))
|
||||
|
@ -220,10 +221,10 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
|
|||
(req (append-map (lambda (drv-path)
|
||||
(let ((d (call-with-input-file drv-path
|
||||
read-derivation)))
|
||||
(derivation-prerequisites-to-build %store d)))
|
||||
(derivation-prerequisites-to-build (%store) d)))
|
||||
drv))
|
||||
(req* (delete-duplicates
|
||||
(append (remove (compose (cut valid-path? %store <>)
|
||||
(append (remove (compose (cut valid-path? (%store) <>)
|
||||
derivation-path->output-path)
|
||||
drv)
|
||||
(map derivation-input-path req)))))
|
||||
|
@ -240,7 +241,7 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
|
|||
(null? req*) req*))
|
||||
|
||||
;; TODO: Add more options.
|
||||
(set-build-options %store
|
||||
(set-build-options (%store)
|
||||
#:keep-failed? (assoc-ref opts 'keep-failed?)
|
||||
#:build-cores (or (assoc-ref opts 'cores) 0)
|
||||
#:use-substitutes? (assoc-ref opts 'substitutes?))
|
||||
|
@ -248,7 +249,7 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
|
|||
(if (assoc-ref opts 'derivations-only?)
|
||||
(format #t "~{~a~%~}" drv)
|
||||
(or (assoc-ref opts 'dry-run?)
|
||||
(and (build-derivations %store drv)
|
||||
(and (build-derivations (%store) drv)
|
||||
(for-each (lambda (d)
|
||||
(let ((drv (call-with-input-file d
|
||||
read-derivation)))
|
||||
|
@ -267,7 +268,7 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
|
|||
(when roots
|
||||
(for-each (cut register-root <> <>)
|
||||
drv roots)
|
||||
#t))))))))
|
||||
#t))))))))))
|
||||
|
||||
;; Local Variables:
|
||||
;; eval: (put 'guard 'scheme-indent-function 1)
|
||||
|
|
Loading…
Reference in New Issue