guix package, pull: Use 'with-build-handler'.

* guix/scripts/package.scm (build-and-use-profile): Remove #:dry-run?
and #:use-substitutes?.  Remove call to 'show-what-to-build' and
'dry-run?' special case.
(process-actions): Adjust accordingly.
(guix-package*): Wrap 'parameterize' in 'with-build-handler'.
* guix/scripts/pull.scm (build-and-install): Remove #:use-substitutes?
and #:dry-run? and adjust 'update-profile' call accordingly.  Remove
'dry-run?' conditional.
(guix-pull): Wrap body in 'with-build-handler'.
This commit is contained in:
Ludovic Courtès 2020-03-19 10:42:28 +01:00
parent 5f5e9a5cd6
commit 65ffb9388c
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 71 additions and 76 deletions

View file

@ -132,8 +132,7 @@ (define* (build-and-use-profile store profile manifest
#:key
(hooks %default-profile-hooks)
allow-collisions?
bootstrap? use-substitutes?
dry-run?)
bootstrap?)
"Build a new generation of PROFILE, a file name, using the packages
specified in MANIFEST, a manifest object. When ALLOW-COLLISIONS? is true,
do not treat collisions in MANIFEST as an error. HOOKS is a list of \"profile
@ -144,12 +143,8 @@ (define* (build-and-use-profile store profile manifest
#:hooks (if bootstrap? '() hooks)
#:locales? (not bootstrap?))))
(prof (derivation->output-path prof-drv)))
(show-what-to-build store (list prof-drv)
#:use-substitutes? use-substitutes?
#:dry-run? dry-run?)
(cond
(dry-run? #t)
((and (file-exists? profile)
(and=> (readlink* profile) (cut string=? prof <>)))
(format (current-error-port) (G_ "nothing to be done~%")))
@ -920,9 +915,7 @@ (define (transform-entry entry)
#:dry-run? dry-run?)
(build-and-use-profile store profile new
#:allow-collisions? allow-collisions?
#:bootstrap? bootstrap?
#:use-substitutes? substitutes?
#:dry-run? dry-run?)))))
#:bootstrap? bootstrap?)))))
;;;
@ -951,10 +944,14 @@ (define (guix-package* opts)
(%graft? (assoc-ref opts 'graft?)))
(with-status-verbosity (assoc-ref opts 'verbosity)
(set-build-options-from-command-line (%store) opts)
(with-build-handler (build-notifier #:use-substitutes?
(assoc-ref opts 'substitutes?)
#:dry-run?
(assoc-ref opts 'dry-run?))
(parameterize ((%guile-for-build
(package-derivation
(%store)
(if (assoc-ref opts 'bootstrap?)
%bootstrap-guile
(canonical-package guile-2.2)))))
(process-actions (%store) opts)))))))
(process-actions (%store) opts))))))))

View file

@ -389,8 +389,7 @@ (define (display-news profile)
(display-channel-news profile))
(define* (build-and-install instances profile
#:key use-substitutes? dry-run?)
(define* (build-and-install instances profile)
"Build the tool from SOURCE, and install it in PROFILE. When DRY-RUN? is
true, display what would be built without actually building it."
(define update-profile
@ -403,14 +402,12 @@ (define guix-command
(mlet %store-monad ((manifest (channel-instances->manifest instances)))
(mbegin %store-monad
(update-profile profile manifest
#:use-substitutes? use-substitutes?
#:hooks %channel-profile-hooks
#:dry-run? dry-run?)
(munless dry-run?
(return (newline))
#:hooks %channel-profile-hooks)
(return
(let ((more? (list (display-profile-news profile #:concise? #t)
(display-channel-news-headlines profile))))
(newline)
(when (any ->bool more?)
(display-hint
(G_ "Run @command{guix pull --news} to read all the news.")))))
@ -425,7 +422,7 @@ (define guix-command
@command{hash guix} to make sure your shell refers to @file{~a}.")
(first new))))
(return #f))
(return #f))))))
(return #f)))))
(define (honor-lets-encrypt-certificates! store)
"Tell Guile-Git to use the Let's Encrypt certificates."
@ -762,6 +759,8 @@ (define (guix-pull . args)
(with-git-error-handling
(let* ((opts (parse-command-line args %options
(list %default-options)))
(substitutes? (assoc-ref opts 'substitutes?))
(dry-run? (assoc-ref opts 'dry-run?))
(channels (channel-list opts))
(profile (or (assoc-ref opts 'profile) %current-profile)))
(cond ((assoc-ref opts 'query)
@ -773,6 +772,9 @@ (define (guix-pull . args)
(with-status-verbosity (assoc-ref opts 'verbosity)
(parameterize ((%current-system (assoc-ref opts 'system))
(%graft? (assoc-ref opts 'graft?)))
(with-build-handler (build-notifier #:use-substitutes?
substitutes?
#:dry-run? dry-run?)
(set-build-options-from-command-line store opts)
(ensure-default-profile)
(honor-x509-certificates store)
@ -801,10 +803,6 @@ (define (guix-pull . args)
(canonical-package guile-2.2)))))
(with-profile-lock profile
(run-with-store store
(build-and-install instances profile
#:dry-run?
(assoc-ref opts 'dry-run?)
#:use-substitutes?
(assoc-ref opts 'substitutes?)))))))))))))))
(build-and-install instances profile)))))))))))))))
;;; pull.scm ends here