|
Lines 24-39
Link Here
|
| 24 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
24 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 25 |
|
25 |
|
| 26 |
use Modern::Perl; |
26 |
use Modern::Perl; |
| 27 |
use Test::More; |
27 |
use Test::More tests => 1; |
| 28 |
|
28 |
|
| 29 |
use File::Spec; |
29 |
use File::Spec; |
| 30 |
use File::Find; |
30 |
use File::Find; |
| 31 |
|
31 |
|
| 32 |
my @files; |
32 |
my @files; |
|
|
33 |
|
| 33 |
sub wanted { |
34 |
sub wanted { |
| 34 |
my $name = $File::Find::name; |
35 |
my $name = $File::Find::name; |
| 35 |
push @files, $name |
36 |
push @files, $name |
| 36 |
unless $name =~ /\/(\.git|koha-tmpl|node_modules|swagger-ui)(\/.*)?$/ || |
37 |
unless $name =~ /\/(\.git|installer\/data\/mysql\/db_revs|koha-tmpl|node_modules|swagger-ui)(\/.*)?$/ || |
| 37 |
$name =~ /\.(gif|jpg|odt|ogg|pdf|png|po|psd|svg|swf|zip|patch)$/ || |
38 |
$name =~ /\.(gif|jpg|odt|ogg|pdf|png|po|psd|svg|swf|zip|patch)$/ || |
| 38 |
$name =~ m[(xt/find-license-problems|xt/fix-old-fsf-address|misc/translator/po2json)] || |
39 |
$name =~ m[(xt/find-license-problems|xt/fix-old-fsf-address|misc/translator/po2json)] || |
| 39 |
! -f $name; |
40 |
! -f $name; |
|
Lines 41-46
sub wanted {
Link Here
|
| 41 |
|
42 |
|
| 42 |
find({ wanted => \&wanted, no_chdir => 1 }, File::Spec->curdir()); |
43 |
find({ wanted => \&wanted, no_chdir => 1 }, File::Spec->curdir()); |
| 43 |
|
44 |
|
|
|
45 |
my @fails; |
| 44 |
foreach my $name (@files) { |
46 |
foreach my $name (@files) { |
| 45 |
open( my $fh, '<', $name ) || die "cannot open file $name $!"; |
47 |
open( my $fh, '<', $name ) || die "cannot open file $name $!"; |
| 46 |
my ( $hascopyright, $hasgpl, $hasv3, $hasorlater, $haslinktolicense, |
48 |
my ( $hascopyright, $hasgpl, $hasv3, $hasorlater, $haslinktolicense, |
|
Lines 58-70
foreach my $name (@files) {
Link Here
|
| 58 |
$needs_copyright = 1 if $line =~ m|This file is part of Koha| || $name =~ /(.*).pl/ || $name =~ /(.*).pm/; |
60 |
$needs_copyright = 1 if $line =~ m|This file is part of Koha| || $name =~ /(.*).pl/ || $name =~ /(.*).pm/; |
| 59 |
} |
61 |
} |
| 60 |
close $fh; |
62 |
close $fh; |
| 61 |
next unless $hascopyright || $needs_copyright; |
63 |
next unless $needs_copyright &&!$hascopyright; |
| 62 |
next if $is_not_us; |
64 |
next if $is_not_us; |
| 63 |
is( $hascopyright |
65 |
my $diagnostics = license_info( $hascopyright, $hasgpl, $hasv3, $hasorlater, $haslinktolicense, $hasfranklinst ); |
| 64 |
&& $hasgpl |
66 |
push @fails, [ $name, $diagnostics ] if $diagnostics; |
| 65 |
&& $hasv3 |
67 |
} |
| 66 |
&& $hasorlater |
68 |
is( scalar @fails, 0, 'No files without license problems anymore!' ); |
| 67 |
&& $haslinktolicense |
69 |
|
| 68 |
&& !$hasfranklinst, 1 ) or diag(sprintf "File %s has wrong copyright: hascopyright=%s, hasgpl=%s, hasv3=%s, hasorlater=%s, haslinktolicense=%s, hasfranklinst=%s", $name, $hascopyright, $hasgpl, $hasv3, $hasorlater, $haslinktolicense, $hasfranklinst); |
70 |
if( grep { $_ eq '-v' } @ARGV ) { |
|
|
71 |
map { print "File ". $_->[0]. ": ". $_->[1]. "\n"; } @fails; |
| 72 |
} |
| 73 |
|
| 74 |
sub license_info { |
| 75 |
my ( $hascopyright, $hasgpl, $hasv3, $hasorlater, $haslinktolicense, $hasfranklinst ) = @_; |
| 76 |
return sprintf( "hascopyright=%s, hasgpl=%s, hasv3=%s, hasorlater=%s, haslinktolicense=%s, hasfranklinst=%s", $hascopyright, $hasgpl, $hasv3, $hasorlater, $haslinktolicense, $hasfranklinst ) unless $hascopyright && $hasgpl && $hasv3 && $hasorlater && $haslinktolicense && !$hasfranklinst; |
| 77 |
return; |
| 69 |
} |
78 |
} |
| 70 |
done_testing; |
|
|
| 71 |
- |