Better handle license expressions in 'guix import crate'

  • Done
  • quality assurance status badge
Details
3 participants
  • Brice Waegeneire
  • Ludovic Courtès
  • Mathieu Othacehe
Owner
unassigned
Submitted by
Brice Waegeneire
Severity
normal
Merged with
B
B
Brice Waegeneire wrote on 25 Oct 2019 22:27
(address . guix-patches@gnu.org)
20191025202713.7739-1-brice@waegenei.re
This patch should allow correctly importing most of the licenses from
crates.io. Before it, importing recursively ripgrep would result in ~140
missing licenses; now none seems missing.
M
M
Mathieu Othacehe wrote on 28 Oct 2019 15:40
(address . control@debbugs.gnu.org)
87sgndj5lr.fsf@gmail.com
merge 37927 37928
quit
L
L
Ludovic Courtès wrote on 4 Nov 2019 23:27
Re: [bug#37928] [PATCH] import: crate: Fix licenses.
(name . Brice Waegeneire)(address . brice@waegenei.re)
87mudb46r7.fsf@gnu.org
Hi Brice,

Brice Waegeneire <brice@waegenei.re> skribis:

Toggle quote (3 lines)
> * guix/import/crate.scm (%dual-license-rx): Removed function.
> (crate->guix-package): Handle most of the multi-licensing cases.

Nice!

Toggle quote (17 lines)
> (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

Let me know if anything is unclear.

Could you send an updated patch?

Thanks,
Ludo’.
L
L
Ludovic Courtès wrote on 4 Nov 2019 23:28
control message for bug #37927
(address . control@debbugs.gnu.org)
87lfsv46q6.fsf@gnu.org
retitle 37927 Better handle license expressions in 'guix import crate'
quit
L
L
Ludovic Courtès wrote on 16 Nov 2019 17:37
Re: [bug#37927] [bug#37928] [PATCH] import: crate: Fix licenses.
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 37927@debbugs.gnu.org)
87bltbwzey.fsf@gnu.org
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’.
L
L
Ludovic Courtès wrote on 11 Dec 2019 12:24
Re: [bug#37928] [PATCH v2] import: crate: Better handle license expressions.
(name . Brice Waegeneire)(address . brice@waegenei.re)
87tv67jeaz.fsf@gnu.org
Hi Brice,

Brice Waegeneire <brice@waegenei.re> skribis:

Toggle quote (4 lines)
> * guix/import/crate.scm (%dual-license-rx): Removed function.
> (crate->guix-package): Handle most of the multi-licensing cases.
> * tests/crate.scm (licenses): Add tests for some licenses.

Thanks for the updated patch!

Toggle quote (9 lines)
> +(define (string->license string)
> + (map
> + spdx-string->license
> + (filter (lambda (license)
> + (and (not (string-null? license))
> + (not (any (lambda (elem) (string=? elem license))
> + '("AND" "OR" "WITH")))))
> + (string-split string (string->char-set " /")))))

I changed that to use ‘filter-map’ instead and pushed as
263a267b75e472cb84428571580dabd99d5dff0c.

Thanks!

Ludo’.
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 37927@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 37927
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch