mirror of
https://codeberg.org/guix/guix.git
synced 2025-10-02 02:15:12 +00:00
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:
parent
4fc282b32a
commit
57075ade97
2 changed files with 17 additions and 12 deletions
|
@ -21,12 +21,13 @@
|
||||||
#:use-module (ice-9 regex)
|
#:use-module (ice-9 regex)
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
#:use-module (srfi srfi-26)
|
#:use-module (srfi srfi-26)
|
||||||
|
#:use-module (srfi srfi-34)
|
||||||
|
#:use-module (srfi srfi-35)
|
||||||
#:use-module (guix import json)
|
#:use-module (guix import json)
|
||||||
#:use-module (guix import hackage)
|
#:use-module (guix import hackage)
|
||||||
#:use-module (guix memoization)
|
#:use-module (guix memoization)
|
||||||
#:use-module (guix packages)
|
#:use-module (guix packages)
|
||||||
#:use-module (guix upstream)
|
#:use-module (guix upstream)
|
||||||
#:use-module (guix ui)
|
|
||||||
#:export (stackage->guix-package
|
#:export (stackage->guix-package
|
||||||
%stackage-updater))
|
%stackage-updater))
|
||||||
|
|
||||||
|
@ -49,6 +50,9 @@
|
||||||
((_ ("packages" pkg ...)) pkg)
|
((_ ("packages" pkg ...)) pkg)
|
||||||
(_ '())))
|
(_ '())))
|
||||||
|
|
||||||
|
(define (leave-with-message fmt . args)
|
||||||
|
(raise (condition (&message (message (apply format #f fmt args))))))
|
||||||
|
|
||||||
(define stackage-lts-info-fetch
|
(define stackage-lts-info-fetch
|
||||||
;; "Retrieve the information about the LTS Stackage release VERSION."
|
;; "Retrieve the information about the LTS Stackage release VERSION."
|
||||||
(memoize
|
(memoize
|
||||||
|
@ -59,7 +63,7 @@
|
||||||
(lts-info (json-fetch url)))
|
(lts-info (json-fetch url)))
|
||||||
(if lts-info
|
(if lts-info
|
||||||
(reverse 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)
|
(define (stackage-package-name pkg-info)
|
||||||
(assoc-ref pkg-info "name"))
|
(assoc-ref pkg-info "name"))
|
||||||
|
@ -99,7 +103,7 @@ included in the Stackage LTS release."
|
||||||
(hackage->guix-package name-version
|
(hackage->guix-package name-version
|
||||||
#:include-test-dependencies?
|
#:include-test-dependencies?
|
||||||
include-test-dependencies?)
|
include-test-dependencies?)
|
||||||
(leave (_ "package not found: ~A~%") package-name))))
|
(leave-with-message "~a: Stackage package not found" package-name))))
|
||||||
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
|
|
|
@ -98,6 +98,7 @@ Import and convert the LTS Stackage package for PACKAGE-NAME.\n"))
|
||||||
(reverse opts))))
|
(reverse opts))))
|
||||||
(match args
|
(match args
|
||||||
((package-name)
|
((package-name)
|
||||||
|
(with-error-handling
|
||||||
(let ((sexp (stackage->guix-package
|
(let ((sexp (stackage->guix-package
|
||||||
package-name
|
package-name
|
||||||
#:include-test-dependencies?
|
#:include-test-dependencies?
|
||||||
|
@ -106,7 +107,7 @@ Import and convert the LTS Stackage package for PACKAGE-NAME.\n"))
|
||||||
(unless sexp
|
(unless sexp
|
||||||
(leave (_ "failed to download cabal file for package '~a'~%")
|
(leave (_ "failed to download cabal file for package '~a'~%")
|
||||||
package-name))
|
package-name))
|
||||||
sexp))
|
sexp)))
|
||||||
(()
|
(()
|
||||||
(leave (_ "too few arguments~%")))
|
(leave (_ "too few arguments~%")))
|
||||||
((many ...)
|
((many ...)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue