#!/usr/bin/perl -w use strict; die if @ARGV; our %ok_always; our %ok_crate; open OK, "maint/licences-ok" or die $!; while () { chomp; s/\#.*//; next unless m/\S/; my @f = split /\s+/; if (@f == 1) { $ok_always{$f[0]} = 1; } elsif (@f == 2) { my ($licence, $crate) = @f; $ok_crate{$licence, $crate} = 1; } else { die "bad ok line"; } } OK->error and die $!; open GOT, '${CARGO:-cargo} license -t |' or die $!; our $report; our $crate; sub is_ok ($); sub is_ok ($) { local ($_) = @_; $report .= "evaluating $_\n"; while (s{\(([^()]+)\)}{ is_ok($1) ? '+' : '!' }ge) {} if (m{[()]}) { $report .= "unbalanced paranetheses! in $_\n"; return 0; } foreach my $alt (split m{ OR }) { $report .= " alternative $alt\n"; my $all = 1; foreach my $req (split m{ AND }, $alt) { $report .= " requirement $alt\n"; next if $req eq '+'; next if $ok_always{$req}; #printf STDERR "X %s %s\n", "$req/$crate", $ok_crate{$req, $crate}; next if $ok_crate{$req, $crate}; $report .= " requirement $alt failed\n"; $all = 0; } return 1 if $all; } $report .= "dissatisfied $_\n"; 0; } $_ = ; die unless m{^name\s}; our $bad_count = 0; while () { chomp or die; my ($version, $author, $homepage, $licence); ($crate, $version, $author, $homepage, $licence) = split /\t/; $licence = '!' unless $licence =~ m/\S/; $report = ''; next if is_ok($licence); print STDERR <