guix package: Move 'process-actions' out of sight.

* guix/scripts/package.scm (process-actions): New procedure, moved
from...
(guix-package): ... here.  Adjust accordingly.
This commit is contained in:
Ludovic Courtès 2015-11-30 21:18:11 +02:00
parent dfdb15d9c2
commit 6e37017506

View File

@ -786,20 +786,8 @@ processed, #f otherwise."
(delete-generations . ,delete-generations-action) (delete-generations . ,delete-generations-action)
(manifest . ,manifest-action))) (manifest . ,manifest-action)))
(define (process-actions store opts)
;;; "Process any install/remove/upgrade action from OPTS."
;;; Entry point.
;;;
(define (guix-package . args)
(define (handle-argument arg result arg-handler)
;; Process non-option argument ARG by calling back ARG-HANDLER.
(if arg-handler
(arg-handler arg result)
(leave (_ "~A: extraneous argument~%") arg)))
(define (process-actions opts)
;; Process any install/remove/upgrade action from OPTS.
(define dry-run? (assoc-ref opts 'dry-run?)) (define dry-run? (assoc-ref opts 'dry-run?))
(define bootstrap? (assoc-ref opts 'bootstrap?)) (define bootstrap? (assoc-ref opts 'bootstrap?))
@ -811,7 +799,7 @@ processed, #f otherwise."
((key . arg) ((key . arg)
(and=> (assoc-ref %actions key) (and=> (assoc-ref %actions key)
(lambda (proc) (lambda (proc)
(proc (%store) profile arg opts (proc store profile arg opts
#:dry-run? dry-run?))))) #:dry-run? dry-run?)))))
opts) opts)
@ -824,13 +812,25 @@ processed, #f otherwise."
(new (manifest-perform-transaction manifest transaction))) (new (manifest-perform-transaction manifest transaction)))
(unless (and (null? install) (null? remove)) (unless (and (null? install) (null? remove))
(show-manifest-transaction (%store) manifest transaction (show-manifest-transaction store manifest transaction
#:dry-run? dry-run?) #:dry-run? dry-run?)
(build-and-use-profile (%store) profile new (build-and-use-profile store profile new
#:bootstrap? bootstrap? #:bootstrap? bootstrap?
#:use-substitutes? substitutes? #:use-substitutes? substitutes?
#:dry-run? dry-run?)))) #:dry-run? dry-run?))))
;;;
;;; Entry point.
;;;
(define (guix-package . args)
(define (handle-argument arg result arg-handler)
;; Process non-option argument ARG by calling back ARG-HANDLER.
(if arg-handler
(arg-handler arg result)
(leave (_ "~A: extraneous argument~%") arg)))
(let ((opts (parse-command-line args %options (list %default-options #f) (let ((opts (parse-command-line args %options (list %default-options #f)
#:argument-handler handle-argument))) #:argument-handler handle-argument)))
(with-error-handling (with-error-handling
@ -844,4 +844,4 @@ processed, #f otherwise."
(if (assoc-ref opts 'bootstrap?) (if (assoc-ref opts 'bootstrap?)
%bootstrap-guile %bootstrap-guile
(canonical-package guile-2.0))))) (canonical-package guile-2.0)))))
(process-actions opts))))))) (process-actions (%store) opts)))))))