guix-package: Use more (guix ui) features.

* guix-package.in (leave): Remove.
  (guix-package): Wrap body in `with-error-handling'.
This commit is contained in:
Ludovic Courtès 2012-11-03 21:23:16 +01:00
parent cdd5d6f95f
commit 1275baeba7

View file

@ -187,12 +187,6 @@ all of PACKAGES, a list of name/version/output/path tuples."
;; Alist of default option values.
`((profile . ,%current-profile)))
(define-syntax-rule (leave fmt args ...)
"Format FMT and ARGS to the error port and exit."
(begin
(format (current-error-port) fmt args ...)
(exit 1)))
(define (show-help)
(display (_ "Usage: guix-package [OPTION]... PACKAGES...
Install, remove, or upgrade PACKAGES in a single transaction.\n"))
@ -322,6 +316,7 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
(setvbuf (current-error-port) _IOLBF)
(let ((opts (parse-options)))
(with-error-handling
(parameterize ((%guile-for-build
(package-derivation %store
(if (assoc-ref opts 'bootstrap?)
@ -338,7 +333,8 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
(_ #f))
opts))
(drv (filter-map (match-lambda
((name version sub-drv (? package? package))
((name version sub-drv
(? package? package))
(package-derivation %store package))
(_ #f))
install))
@ -353,8 +349,8 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
(match tuple
((name version sub-drv _)
(let ((output-path
(derivation-path->output-path drv
sub-drv)))
(derivation-path->output-path
drv sub-drv)))
`(,name ,version ,sub-drv ,output-path)))))
install drv)))
(remove (filter-map (match-lambda
@ -364,7 +360,8 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
opts))
(packages (append install*
(fold alist-delete
(manifest-packages (profile-manifest profile))
(manifest-packages
(profile-manifest profile))
remove))))
(show-what-to-build drv dry-run?)
@ -382,7 +379,7 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
(symlink prof name)
(when (file-exists? profile)
(delete-file profile))
(symlink name profile))))))))))
(symlink name profile)))))))))))
;; Local Variables:
;; eval: (put 'guard 'scheme-indent-function 1)