[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/16: guix build: Use 'with-build-handler'.
From: |
guix-commits |
Subject: |
04/16: guix build: Use 'with-build-handler'. |
Date: |
Sun, 22 Mar 2020 07:43:11 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 62195b9a8fd6846117c5d7698842748300d13e31
Author: Ludovic Courtès <address@hidden>
AuthorDate: Wed Mar 18 22:46:39 2020 +0100
guix build: Use 'with-build-handler'.
Fixes <https://bugs.gnu.org/28310>.
Reported by Andreas Enge <address@hidden>.
* guix/scripts/build.scm (guix-build): Wrap 'parameterize' in
'with-build-handler'. Remove explicit call to 'show-what-to-build'.
Call 'build-derivations' regardless of whether OPTS contains 'dry-run?'.
---
guix/scripts/build.scm | 118 ++++++++++++++++++++++++-------------------------
1 file changed, 57 insertions(+), 61 deletions(-)
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index da2a675..af18d8b 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -952,64 +952,60 @@ needed."
;; Set the build options before we do anything else.
(set-build-options-from-command-line store opts)
- (parameterize ((current-terminal-columns (terminal-columns))
-
- ;; Set grafting upfront in case the user's input
- ;; depends on it (e.g., a manifest or code snippet that
- ;; calls 'gexp->derivation').
- (%graft? graft?))
- (let* ((mode (assoc-ref opts 'build-mode))
- (drv (options->derivations store opts))
- (urls (map (cut string-append <> "/log")
- (if (assoc-ref opts 'substitutes?)
- (or (assoc-ref opts 'substitute-urls)
- ;; XXX: This does not necessarily match
the
- ;; daemon's substitute URLs.
- %default-substitute-urls)
- '())))
- (items (filter-map (match-lambda
- (('argument . (? store-path? file))
- ;; If FILE is a .drv that's not in
- ;; store, keep it so that it can be
- ;; substituted.
- (and (or (not (derivation-path? file))
- (not (file-exists? file)))
- file))
- (_ #f))
- opts))
- (roots (filter-map (match-lambda
- (('gc-root . root) root)
- (_ #f))
- opts)))
-
- (unless (or (assoc-ref opts 'log-file?)
- (assoc-ref opts 'derivations-only?))
- (show-what-to-build store drv
- #:use-substitutes?
- (assoc-ref opts 'substitutes?)
- #:dry-run? (assoc-ref opts 'dry-run?)
- #:mode mode))
-
- (cond ((assoc-ref opts 'log-file?)
- ;; Pass 'show-build-log' the output file names, not the
- ;; derivation file names, because there can be several
- ;; derivations leading to the same output.
- (for-each (cut show-build-log store <> urls)
- (delete-duplicates
- (append (map derivation->output-path drv)
- items))))
- ((assoc-ref opts 'derivations-only?)
- (format #t "~{~a~%~}" (map derivation-file-name drv))
- (for-each (cut register-root store <> <>)
- (map (compose list derivation-file-name) drv)
- roots))
- ((not (assoc-ref opts 'dry-run?))
- (and (build-derivations store (append drv items)
- mode)
- (for-each show-derivation-outputs drv)
- (for-each (cut register-root store <> <>)
- (map (lambda (drv)
- (map cdr
- (derivation->output-paths drv)))
- drv)
- roots))))))))))
+ (with-build-handler (build-notifier #:use-substitutes?
+ (assoc-ref opts 'substitutes?)
+ #:dry-run?
+ (assoc-ref opts 'dry-run?))
+ (parameterize ((current-terminal-columns (terminal-columns))
+
+ ;; Set grafting upfront in case the user's input
+ ;; depends on it (e.g., a manifest or code snippet
that
+ ;; calls 'gexp->derivation').
+ (%graft? graft?))
+ (let* ((mode (assoc-ref opts 'build-mode))
+ (drv (options->derivations store opts))
+ (urls (map (cut string-append <> "/log")
+ (if (assoc-ref opts 'substitutes?)
+ (or (assoc-ref opts 'substitute-urls)
+ ;; XXX: This does not necessarily match
the
+ ;; daemon's substitute URLs.
+ %default-substitute-urls)
+ '())))
+ (items (filter-map (match-lambda
+ (('argument . (? store-path? file))
+ ;; If FILE is a .drv that's not in
+ ;; store, keep it so that it can be
+ ;; substituted.
+ (and (or (not (derivation-path? file))
+ (not (file-exists? file)))
+ file))
+ (_ #f))
+ opts))
+ (roots (filter-map (match-lambda
+ (('gc-root . root) root)
+ (_ #f))
+ opts)))
+
+ (cond ((assoc-ref opts 'log-file?)
+ ;; Pass 'show-build-log' the output file names, not the
+ ;; derivation file names, because there can be several
+ ;; derivations leading to the same output.
+ (for-each (cut show-build-log store <> urls)
+ (delete-duplicates
+ (append (map derivation->output-path drv)
+ items))))
+ ((assoc-ref opts 'derivations-only?)
+ (format #t "~{~a~%~}" (map derivation-file-name drv))
+ (for-each (cut register-root store <> <>)
+ (map (compose list derivation-file-name) drv)
+ roots))
+ (else
+ (and (build-derivations store (append drv items)
+ mode)
+ (for-each show-derivation-outputs drv)
+ (for-each (cut register-root store <> <>)
+ (map (lambda (drv)
+ (map cdr
+ (derivation->output-paths
drv)))
+ drv)
+ roots)))))))))))
- branch master updated (1550db6 -> 66a198c), guix-commits, 2020/03/22
- 02/16: store: Add 'with-build-handler'., guix-commits, 2020/03/22
- 05/16: deploy: Use 'with-build-handler'., guix-commits, 2020/03/22
- 01/16: syscalls: 'with-file-lock' re-grabs lock when reentering its dynamic extent., guix-commits, 2020/03/22
- 03/16: ui: Add a notification build handler., guix-commits, 2020/03/22
- 04/16: guix build: Use 'with-build-handler'.,
guix-commits <=
- 08/16: guix system: Use 'with-build-handler'., guix-commits, 2020/03/22
- 10/16: ui: 'show-what-to-build' returns two values, for builds and downloads., guix-commits, 2020/03/22
- 12/16: copy: Factorize 'with-store' & co., guix-commits, 2020/03/22
- 15/16: packages: 'package-field-location' handles missing source properties., guix-commits, 2020/03/22
- 13/16: copy: Actually implement '--dry-run'., guix-commits, 2020/03/22
- 07/16: guix package, pull: Use 'with-build-handler'., guix-commits, 2020/03/22
- 06/16: pack: Use 'with-build-handler'., guix-commits, 2020/03/22
- 09/16: ui: 'show-what-to-build' returns true when there are grafts to build., guix-commits, 2020/03/22
- 11/16: ui: 'build-notifier' invokes continuation when there's nothing to do., guix-commits, 2020/03/22
- 14/16: copy: Use 'with-build-handler'., guix-commits, 2020/03/22