Hi Brice,
Did you have a chance to look into this?
Thanks in advance. :-)
Ludo’.
Ludovic Courtès <ludo@gnu.org> skribis:
Toggle quote (47 lines)
> Hi Brice,
>
> Brice Waegeneire <brice@waegenei.re> skribis:
>
>> * guix/import/crate.scm (%dual-license-rx): Removed function.
>> (crate->guix-package): Handle most of the multi-licensing cases.
>
> Nice!
>
>> (define* (crate->guix-package crate-name #:optional version)
>> "Fetch the metadata for CRATE-NAME from crates.io, and return the
>> `package' s-expression corresponding to that package, or #f on failure.
>> When VERSION is specified, attempt to fetch that version; otherwise fetch the
>> latest version of CRATE-NAME."
>> (define (string->license string)
>> - (match (regexp-exec %dual-license-rx string)
>> - (#f (list (spdx-string->license string)))
>> - (m (list (spdx-string->license (match:substring m 1))
>> - (spdx-string->license (match:substring m 2))))))
>> + (filter
>> + (lambda (word)
>> + (and (not (string-null? word))
>> + (not (any (lambda (elem) (string=? elem word))
>> + '("AND" "OR" "WITH"))) ))
>> + (string-split string (string->char-set " /"))))
>
> It would be great to have tests for that in tests/crate.scm. To that
> end, I think you could lift ‘string->license’ to the top level (that is,
> outside ‘crate->guix-package’), and then have a few tests along these
> lines:
>
> (define string->license
> (@@ (guix import crate) string->license))
>
> (test-equal "GPL OR LGPL"
> (list license:gpl3+ license:lgpl3+)
> (string->license "GPL OR LGPL"))
>
> (See
> <https://guix.gnu.org/manual/en/html_node/Running-the-Test-Suite.html>.)
>
> Let me know if anything is unclear.
>
> Could you send an updated patch?
>
> Thanks,
> Ludo’.