Hi, On Sun, 05 Nov 2017 11:49:29 +0100 Dominique Dumont <d...@debian.org> wrote: > On Thursday, 2 November 2017 14:28:12 CET you wrote: > > Most ruby gems have the license information in .gemspec file and > > similarly most nodejs modules have this information in package.json file > > (likely for similar files for other languages). It would be good to > > parse it and use that information. > > Yes, good idea. I'm thinking also to parse the content of META.yml to > retrieve > the same kind of information. > > Do you have examples of one ruby and one nodejs package that could be used as > a reference ? > > Then I just need to find time to do this...
Please find attached proof of concept scanner for Rust Cargo.toml files. I’m not fluent in Perl, and I wasn’t sure where exactly to put this piece of code, but this is something you probably can polish up a bit. Thanks for considering this. -- Cheers, Andrej
>From 7ddbb0ac66bd50145a0d6e11d9c574a78e396389 Mon Sep 17 00:00:00 2001 From: Andrej Shadura <andrew.shad...@collabora.co.uk> Date: Fri, 13 Dec 2019 16:07:46 +0100 Subject: [PATCH] WIP: Scan Rust source code getting the defaults from Cargo.toml --- lib/Dpkg/Copyright/Scanner.pm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/Dpkg/Copyright/Scanner.pm b/lib/Dpkg/Copyright/Scanner.pm index 453825a3..3d2bc46f 100644 --- a/lib/Dpkg/Copyright/Scanner.pm +++ b/lib/Dpkg/Copyright/Scanner.pm @@ -9,6 +9,7 @@ use Exporter::Lite; use Array::IntSpan; use Path::Tiny; use Carp; +use TOML; use YAML::Tiny; use feature qw/postderef signatures/; @@ -132,6 +133,7 @@ $default{check} = << 'EOR2' ; |sh |php |py(|x) + |rs # rust |rb |java |js @@ -683,6 +685,27 @@ sub __load_fill_blank_data ($current_dir) { } } + my $cargotoml = $current_dir->child('Cargo.toml'); + if ($cargotoml->is_file) { + my $toml = $cargotoml->slurp_utf8; + my $data = TOML::from_toml($toml); + my $l = $data->{'package'}{'license'}; + my $c = $data->{'package'}{'authors'}; + if (!$fill_blanks{'.*'}) { + if (defined $l) { + # Cargo.toml spells AND and OR in capitals + # and allows / as a synonym to OR + $l =~ s! AND ! and !g; + $l =~ s! OR ! or !g; + $l =~ s!/! or !g; + $fill_blanks{'.*'}->{license} = $l; + } + if (defined $c) { + $fill_blanks{'.*'}->{copyright} = join("\n ", @$c); + } + } + } + return \%fill_blanks; } -- 2.20.1