gentoo / cargo-ebuild

[MIRROR] cargo extension that can generate ebuilds using the in-tree eclasses
https://gitweb.gentoo.org/proj/cargo-ebuild.git
Apache License 2.0
33 stars 10 forks source link

Ignore SPDX parentheses and add crate name to the license error message #28

Closed leonardohn closed 1 year ago

leonardohn commented 1 year ago

This fixes issue #27.

mgorny commented 1 year ago

I don't think this is the right approach. With the patch, I get:

$ cargo-ebuild ebuild
WARNING: unknown license "" at package "unicode-ident", please correct manually
WARNING: unknown license "" at package "unicode-ident", please correct manually
WARNING: unknown license "Unicode-DFS-2016" at package "unicode-ident", please correct manually
Wrote: cryptography-rust-0.1.0.ebuild

So I guess the parentheses now create additional empty tokens.

leonardohn commented 1 year ago

I forgot that the split function would actually give an empty string for the left and right side of the left and right parentheses, respectively. Please test again.

leonardohn commented 1 year ago

About the approach, I know it is not as clean as using an actual parser, but I guess writing a parser for that would be overkill and as not as simple to understand. What do you think?

mgorny commented 1 year ago

Yeah, this one seems to work.

I don't know about Rust but it took me 5 minutes to find a SPDX parsing library in Python.

leonardohn commented 1 year ago

In fact there is the spdx library in Rust, but I think it introduces complexity for the sole purpose of obtaining the set of license names from the SPDX string. If the current implementation show not to be reliable, I might reimplement using it, though.

mgorny commented 1 year ago

Yeah, I suppose there's not much point in bothering with that, given that pycargoebuild is superior to cargo-ebuild in every way I can think of.