GNU bug report logs - #67599
[PATCH] guix: import: Fix parsing Cabal files that import many stanzas

Previous Next

Package: guix-patches;

Reported by: Saku Laesvuori <saku <at> laesvuori.fi>

Date: Sun, 3 Dec 2023 09:47:01 UTC

Severity: normal

Tags: patch

Done: Lars-Dominik Braun <lars <at> 6xq.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 67599 in the body.
You can then email your comments to 67599 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to lars <at> 6xq.net, guix-patches <at> gnu.org:
bug#67599; Package guix-patches. (Sun, 03 Dec 2023 09:47:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Saku Laesvuori <saku <at> laesvuori.fi>:
New bug report received and forwarded. Copy sent to lars <at> 6xq.net, guix-patches <at> gnu.org. (Sun, 03 Dec 2023 09:47:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Saku Laesvuori <saku <at> laesvuori.fi>
To: guix-patches <at> gnu.org
Cc: Saku Laesvuori <saku <at> laesvuori.fi>
Subject: [PATCH] guix: import: Fix parsing Cabal files that import many stanzas
Date: Sun,  3 Dec 2023 11:45:07 +0200
* 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





Reply sent to Lars-Dominik Braun <lars <at> 6xq.net>:
You have taken responsibility. (Sun, 03 Dec 2023 15:18:01 GMT) Full text and rfc822 format available.

Notification sent to Saku Laesvuori <saku <at> laesvuori.fi>:
bug acknowledged by developer. (Sun, 03 Dec 2023 15:18:02 GMT) Full text and rfc822 format available.

Message #10 received at 67599-done <at> debbugs.gnu.org (full text, mbox):

From: Lars-Dominik Braun <lars <at> 6xq.net>
To: Saku Laesvuori <saku <at> laesvuori.fi>
Cc: 67599-done <at> debbugs.gnu.org
Subject: Re: [bug#67599] [PATCH] guix: import: Fix parsing Cabal files that
 import many stanzas
Date: Sun, 3 Dec 2023 16:16:51 +0100
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





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 01 Jan 2024 12:24:13 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 129 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.