import: hackage: Filter upper/mixed case dependencies too.

* guix/import/hackage.scm (filter-dependencies): Convert OWN-NAMES
to lowercase before filtering.
(hackage-module->sexp): Remove #f from OWN-NAMES, which is used for
unnamed (default) libraries.
* tests/hackage.scm (test-cabal-internal-library-ignored): Add mismatched
uppercase letters.
This commit is contained in:
Lars-Dominik Braun 2022-06-02 13:52:08 +02:00
parent dedfcaa8e2
commit 143141726e
No known key found for this signature in database
GPG key ID: F663943E08D8092A
2 changed files with 9 additions and 6 deletions

View file

@ -227,9 +227,10 @@ (define (filter-dependencies dependencies own-names)
list with the names of dependencies. OWN-NAMES is the name of the Cabal list with the names of dependencies. OWN-NAMES is the name of the Cabal
package being processed and its internal libaries and is used to filter package being processed and its internal libaries and is used to filter
references to itself." references to itself."
(filter (lambda (d) (not (member (string-downcase d) (let ((ignored-dependencies (map string-downcase
(append own-names ghc-standard-libraries)))) (append own-names ghc-standard-libraries))))
dependencies)) (filter (lambda (d) (not (member (string-downcase d) ignored-dependencies)))
dependencies)))
(define* (hackage-module->sexp cabal cabal-hash (define* (hackage-module->sexp cabal cabal-hash
#:key (include-test-dependencies? #t)) #:key (include-test-dependencies? #t))
@ -250,7 +251,8 @@ (define source-url
(hackage-source-url name version)) (hackage-source-url name version))
(define own-names (cons (cabal-package-name cabal) (define own-names (cons (cabal-package-name cabal)
(map cabal-library-name (cabal-package-library cabal)))) (filter (lambda (x) (not (eqv? x #f)))
(map cabal-library-name (cabal-package-library cabal)))))
(define hackage-dependencies (define hackage-dependencies
(filter-dependencies (cabal-dependencies->names cabal) own-names)) (filter-dependencies (cabal-dependencies->names cabal) own-names))

View file

@ -368,7 +368,8 @@ (define test-cabal-no-final-newline
(test-assert "hackage->guix-package test without final newline" (test-assert "hackage->guix-package test without final newline"
(eval-test-with-cabal test-cabal-no-final-newline match-ghc-foo)) (eval-test-with-cabal test-cabal-no-final-newline match-ghc-foo))
;; Make sure internal libraries will not be part of the dependencies. ;; Make sure internal libraries will not be part of the dependencies,
;; ignore case.
(define test-cabal-internal-library-ignored (define test-cabal-internal-library-ignored
"name: foo "name: foo
version: 1.0.0 version: 1.0.0
@ -379,8 +380,8 @@ (define test-cabal-internal-library-ignored
executable cabal executable cabal
build-depends: build-depends:
HTTP >= 4000.2.5 && < 4000.3, HTTP >= 4000.2.5 && < 4000.3,
internal internAl
library internal library internaL
build-depends: mtl >= 2.0 && < 3 build-depends: mtl >= 2.0 && < 3
") ")