guix package: Report packages to be removed/installed.

* guix/scripts/package.scm (guix-package)[process-actions](show-what-to-remove/install):
  New procedure.
  Call it before `show-what-to-build'.
This commit is contained in:
Ludovic Courtès 2013-03-18 23:04:07 +01:00
parent 71f4b81aa5
commit a4f08f9258

View file

@ -552,6 +552,44 @@ (define (package->tuple p)
,path
,(canonicalize-deps deps))))
(define (show-what-to-remove/install remove install dry-run?)
;; Tell the user what's going to happen in high-level terms.
;; TODO: Report upgrades more clearly.
(match remove
(((name version _ path _) ..1)
(let ((len (length name))
(remove (map (cut format #f " ~a-~a\t~a" <> <> <>)
name version path)))
(if dry-run?
(format (current-error-port)
(N_ "The following package would be removed:~% ~{~a~%~}~%"
"The following packages would be removed:~% ~{~a~%~}~%"
len)
remove)
(format (current-error-port)
(N_ "The following package will be removed:~% ~{~a~%~}~%"
"The following packages will be removed:~% ~{~a~%~}~%"
len)
remove))))
(_ #f))
(match install
(((name version _ path _) ..1)
(let ((len (length name))
(install (map (cut format #f " ~a-~a\t~a" <> <> <>)
name version path)))
(if dry-run?
(format (current-error-port)
(N_ "The following package would be installed:~% ~{~a~%~}~%"
"The following packages would be installed:~% ~{~a~%~}~%"
len)
install)
(format (current-error-port)
(N_ "The following package will be installed:~% ~{~a~%~}~%"
"The following packages will be installed:~% ~{~a~%~}~%"
len)
install))))
(_ #f)))
;; First roll back if asked to.
(if (and (assoc-ref opts 'roll-back?) (not dry-run?))
(begin
@ -619,6 +657,7 @@ (define (package->tuple p)
package)
(_ #f))
opts))
(remove* (filter-map (cut assoc <> installed) remove))
(packages (append install*
(fold (lambda (package result)
(match package
@ -630,6 +669,7 @@ (define (package->tuple p)
(when (equal? profile %current-profile)
(ensure-default-profile))
(show-what-to-remove/install remove* install* dry-run?)
(show-what-to-build (%store) drv dry-run?)
(or dry-run?