import: stackage: Avoid using (guix ui) in importer code.

* guix/import/stackage.scm (stackage->guix-package, stackage-lts-info-fetch):
  Raise 'message' condition instead of using 'leave' from (guix ui).
* guix/scripts/import/stackage.scm (guix-import-stackage): Handle conditions.
This commit is contained in:
Federico Beffa 2017-02-11 18:18:45 +01:00
parent 4fc282b32a
commit 57075ade97
No known key found for this signature in database
GPG Key ID: 58936E0E2F1B5A4C
2 changed files with 17 additions and 12 deletions

View File

@ -21,12 +21,13 @@
#:use-module (ice-9 regex)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-34)
#:use-module (srfi srfi-35)
#:use-module (guix import json)
#:use-module (guix import hackage)
#:use-module (guix memoization)
#:use-module (guix packages)
#:use-module (guix upstream)
#:use-module (guix ui)
#:export (stackage->guix-package
%stackage-updater))
@ -49,6 +50,9 @@
((_ ("packages" pkg ...)) pkg)
(_ '())))
(define (leave-with-message fmt . args)
(raise (condition (&message (message (apply format #f fmt args))))))
(define stackage-lts-info-fetch
;; "Retrieve the information about the LTS Stackage release VERSION."
(memoize
@ -59,7 +63,7 @@
(lts-info (json-fetch url)))
(if lts-info
(reverse lts-info)
(leave (_ "LTS release version not found: ~A~%") version))))))
(leave-with-message "LTS release version not found: ~a" version))))))
(define (stackage-package-name pkg-info)
(assoc-ref pkg-info "name"))
@ -99,7 +103,7 @@ included in the Stackage LTS release."
(hackage->guix-package name-version
#:include-test-dependencies?
include-test-dependencies?)
(leave (_ "package not found: ~A~%") package-name))))
(leave-with-message "~a: Stackage package not found" package-name))))
;;;

View File

@ -98,15 +98,16 @@ Import and convert the LTS Stackage package for PACKAGE-NAME.\n"))
(reverse opts))))
(match args
((package-name)
(let ((sexp (stackage->guix-package
package-name
#:include-test-dependencies?
(assoc-ref opts 'include-test-dependencies?)
#:lts-version (assoc-ref opts 'lts-version))))
(unless sexp
(leave (_ "failed to download cabal file for package '~a'~%")
package-name))
sexp))
(with-error-handling
(let ((sexp (stackage->guix-package
package-name
#:include-test-dependencies?
(assoc-ref opts 'include-test-dependencies?)
#:lts-version (assoc-ref opts 'lts-version))))
(unless sexp
(leave (_ "failed to download cabal file for package '~a'~%")
package-name))
sexp)))
(()
(leave (_ "too few arguments~%")))
((many ...)