GNU bug report logs -
#37928
Better handle license expressions in 'guix import crate'
Previous Next
Full log
Message #10 received at 37928 <at> debbugs.gnu.org (full text, mbox):
Hi Brice,
Brice Waegeneire <brice <at> 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’.
This bug report was last modified 5 years and 165 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.