* [bug#67599] [PATCH] guix: import: Fix parsing Cabal files that import many stanzas
@ 2023-12-03 9:45 Saku Laesvuori via Guix-patches via
2023-12-03 15:16 ` bug#67599: " Lars-Dominik Braun
0 siblings, 1 reply; 2+ messages in thread
From: Saku Laesvuori via Guix-patches via @ 2023-12-03 9:45 UTC (permalink / raw)
To: 67599; +Cc: Saku Laesvuori, Lars-Dominik Braun
* guix/import/cabal.scm (eval-cabal)[eval]: Split imports to a
normalized list before mapping over it.
* tests/hackage.scm: Test it.
Change-Id: I39ece019251b6a23a937c8562d2d4a545a6bc7df
---
This fixes at least `guix import hackage --recursive haskell-language-server`
guix/import/cabal.scm | 11 ++++++++++-
tests/hackage.scm | 45 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/guix/import/cabal.scm b/guix/import/cabal.scm
index b969197455..d32c1c15fe 100644
--- a/guix/import/cabal.scm
+++ b/guix/import/cabal.scm
@@ -865,7 +865,16 @@ (define (eval-cabal cabal-sexp env)
(((? string? name) values)
(list name values))
((("import" imports) rest ...)
- (eval (append (append-map (cut assoc-ref common-stanzas <>) imports)
+ (eval (append (append-map
+ ;; The imports are (at least sometimes) a list with one string
+ ;; containing all the names separeted by commas. This splits
+ ;; those strings to a list of strings in the same format that is
+ ;; used in common-stanzas.
+ (cut assoc-ref common-stanzas <>)
+ (append-map (lambda (imports-string)
+ (map (compose string-downcase string-trim-both)
+ (string-split imports-string #\,)))
+ imports))
rest)))
((element rest ...)
(cons (eval element) (eval rest)))
diff --git a/tests/hackage.scm b/tests/hackage.scm
index 32e5f39329..403f587c41 100644
--- a/tests/hackage.scm
+++ b/tests/hackage.scm
@@ -622,4 +622,49 @@ (define-package-matcher match-ghc-foo-import
(test-assert "hackage->guix-package test cabal import"
(eval-test-with-cabal test-cabal-import match-ghc-foo-import))
+(define test-cabal-multiple-imports
+ "name: foo
+version: 1.0.0
+homepage: http://test.org
+synopsis: synopsis
+description: description
+license: BSD3
+common commons
+ build-depends:
+ HTTP >= 4000.2.5 && < 4000.3,
+ mtl >= 2.0 && < 3
+
+common others
+ build-depends:
+ base == 4.16.*,
+ stm-chans == 3.0.*
+
+executable cabal
+ import:
+ commons
+ , others
+")
+
+(define-package-matcher match-ghc-foo-multiple-imports
+ ('package
+ ('name "ghc-foo")
+ ('version "1.0.0")
+ ('source
+ ('origin
+ ('method 'url-fetch)
+ ('uri ('hackage-uri "foo" 'version))
+ ('sha256
+ ('base32
+ (? string? hash)))))
+ ('build-system 'haskell-build-system)
+ ('properties '(quote ((upstream-name . "foo"))))
+ ('inputs ('list 'ghc-http 'ghc-stm-chans))
+ ('home-page "http://test.org")
+ ('synopsis (? string?))
+ ('description (? string?))
+ ('license 'license:bsd-3)))
+
+(test-assert "hackage->guix-package test cabal multiple imports"
+ (eval-test-with-cabal test-cabal-multiple-imports match-ghc-foo-multiple-imports))
+
(test-end "hackage")
base-commit: 5bd00bb54235856dddd11e9f0d03481c5469ca63
--
2.41.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#67599: [PATCH] guix: import: Fix parsing Cabal files that import many stanzas
2023-12-03 9:45 [bug#67599] [PATCH] guix: import: Fix parsing Cabal files that import many stanzas Saku Laesvuori via Guix-patches via
@ 2023-12-03 15:16 ` Lars-Dominik Braun
0 siblings, 0 replies; 2+ messages in thread
From: Lars-Dominik Braun @ 2023-12-03 15:16 UTC (permalink / raw)
To: Saku Laesvuori; +Cc: 67599-done
Hi,
> * guix/import/cabal.scm (eval-cabal)[eval]: Split imports to a
> normalized list before mapping over it.
> * tests/hackage.scm: Test it.
>
> Change-Id: I39ece019251b6a23a937c8562d2d4a545a6bc7df
> ---
> This fixes at least `guix import hackage --recursive haskell-language-server`
looks good to me. Pushed as
ab8612d99eca5c25ecbefe026b04ed9f00e3f8b5 guix: import: Fix parsing Cabal files that import many stanzas
Thanks!
Lars
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-12-03 15:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-03 9:45 [bug#67599] [PATCH] guix: import: Fix parsing Cabal files that import many stanzas Saku Laesvuori via Guix-patches via
2023-12-03 15:16 ` bug#67599: " Lars-Dominik Braun
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).